From b5c647fbe0c9e2d525afd05b841245498b36192c Mon Sep 17 00:00:00 2001 From: Jae Hoon Seo Date: Wed, 14 Oct 2026 17:32:14 +0900 Subject: [PATCH 01/31] fix: exclude OpenBLAS 0.3.34 from the development environment (#7) The modal and stack_modal tests stopped with an access violation inside openblas.dll on some hosted CI runners, and on every run on an AMD Zen 4 workstation. The fault is in OpenBLAS 0.3.34, not in CableDyn: a plain DGEMM with an inner dimension above 128 reproduces it with no CableDyn code loaded, and 0.3.33 runs the same calls cleanly. OpenBLAS 0.3.34 enlarges the GEMM blocking on AMD Zen 4/5 CPUs that expose AVX-512, and its Zen and Haswell DGEMM kernels then overrun their stack buffer. It is reached in builds without the AVX-512 kernels, such as the conda-forge Windows package, and with a forced OPENBLAS_CORETYPE (OpenMathLib/OpenBLAS#6013, #6021, fixed upstream after 0.3.34). The dense DSYGV reference of test_modal reached it; the solver's banded LAPACK calls never pass DGEMM an inner dimension above 128, and the release executables use reference LAPACK, so results are unchanged. The CI failures were intermittent because only some runners expose AVX-512. Exclude 0.3.34 in environment.yml, which CI also uses, so that the next OpenBLAS release is admitted, and record the cause in the changelog and the troubleshooting table of DEVELOPMENT.md. Signed-off-by: Jae Hoon Seo --- CHANGELOG.md | 15 +++++++++++++++ DEVELOPMENT.md | 1 + environment.yml | 9 ++++++++- 3 files changed, 24 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 06114682..efd8f9d7 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -8,6 +8,21 @@ All notable changes to CableDyn are recorded in this file. The format follows ## [Unreleased] +### Fixed + +- The development environment (`environment.yml`) excludes OpenBLAS 0.3.34, which caused the + access violation in the modal analysis tests listed under Known issues for 0.1.1. On AMD + Zen 4 and Zen 5 CPUs that expose AVX-512, OpenBLAS 0.3.34 enlarges the GEMM blocking, + and its Zen and Haswell DGEMM kernels then overrun their stack buffer for an inner + dimension above 128. This happens in builds without the AVX-512 kernels, such as the + conda-forge Windows package, and in any build when `OPENBLAS_CORETYPE` forces one of these + kernels (OpenMathLib/OpenBLAS#6013 and #6021). The dense reference eigensolve + (`DSYGV`) of the modal tests reached it. On hosted CI runners the fault appeared only on + those runners whose AMD CPU exposed AVX-512. The solver itself calls only banded LAPACK + routines and a 4 × 4 eigensolve, none of which passes DGEMM an inner dimension above 128, + and the released Windows executables use reference LAPACK, so results are unchanged. An existing environment takes the exclusion with + `conda env update -f environment.yml`, followed by a fresh build directory. + ## [0.1.1] - 2026-10-09 ### Added diff --git a/DEVELOPMENT.md b/DEVELOPMENT.md index 5d3d7f13..bad3ba8e 100644 --- a/DEVELOPMENT.md +++ b/DEVELOPMENT.md @@ -189,3 +189,4 @@ for details. | `find_package(LAPACK)` fails | no system LAPACK | install `liblapack-dev`, or build inside the conda environment | | Python exits while importing NumPy on Windows | runtime DLL directories on `PATH` | remove them from `PATH`; set `CABLEDYN_LIBRARY` instead | | Windows checkout differs from CI | CRLF line endings | `.gitattributes` enforces LF; run `git add --renormalize .` | +| `modal` test stops with an access violation in `openblas.dll` (AMD Zen 4/5) | OpenBLAS 0.3.34 DGEMM stack overrun (OpenMathLib/OpenBLAS#6013) | `conda env update -f environment.yml`, which excludes 0.3.34, then configure a fresh build directory: the build keeps a staged `openblas.dll` that is newer than the package's | diff --git a/environment.yml b/environment.yml index 2ef5cb06..2aec7fb0 100644 --- a/environment.yml +++ b/environment.yml @@ -45,7 +45,14 @@ dependencies: # BLAS / LAPACK — linked by the Fortran core (banded DGBSV/DGBTRF/DGBTRS and # DPBTRF/DPBTRS; DSBGVX, DSYGV and DSYEV for modal analysis). - - openblas + # + # OpenBLAS 0.3.34 is excluded: on AMD Zen 4/5 CPUs that expose AVX-512, its Zen and + # Haswell DGEMM kernels overrun their stack buffer for an inner dimension above 128 + # in builds without the AVX-512 kernels (the win-64 package), or with a forced + # OPENBLAS_CORETYPE (OpenMathLib/OpenBLAS#6013, #6021; fixed after 0.3.34). The dense + # modal reference (DSYGV) of test_modal faulted there. + - openblas !=0.3.34 + - libopenblas !=0.3.34 - liblapack # Formatting / local commit hooks for Fortran development. From 69cbe6af198772eb502259a90d09c3df89462e6a Mon Sep 17 00:00:00 2001 From: Jae Hoon Seo Date: Wed, 14 Oct 2026 20:37:33 +0900 Subject: [PATCH 02/31] perf: evaluate each directional-sea phase and depth profile once (#9) Profiling the release build showed the directional-sea kinematics(CD_Sea_Kinematics, the deck's wavetrain rows and spectral seas) taking80 % of a chain run in a two-train sea. For every node, step andcomponent it computed the phase cosine twice (for the elevation andagain for the kinematics) and two exponentials for the depth profile.The cosines of the elevation pass are now kept for the kinematics pass(up to 4096 components; any further ones are recomputed), and thedepth profile uses EXP(-k (z + 2h)) = e2kd / EXP(k z) with the table'se2kd = EXP(-2 k h), as the JONSWAP component path does. A componentwhose EXP(k z) or e2kd underflows, or a call at another depth than thesynthesis, takes the second exponential instead; the sea now recordsthe depth of its synthesis for that test. With the release build thetwo-train chain example runs in 1.57 s instead of 1.89 s (-17 %).The formulas are unchanged. With gfortran the outputs of the twodirectional-sea examples are bit-identical; with IFX the reuse removesa fused sin/cos evaluation of the second pass, and one channel ofchain_torsethaugen_spread.dat differs by one unit in its eighth printeddigit at isolated rows. A new unit test checks the kinematics against adirect per-component sum, with all cosines kept, with cosines past thekept length, with underflowing exponentials, and at another depth.Signed-off-by: Jae Hoon Seo --- CHANGELOG.md | 10 +++++ src/CableDyn_WaveSpectra.f90 | 53 +++++++++++++++++----- tests/test_wave_spectra.f90 | 86 +++++++++++++++++++++++++++++++++++- 3 files changed, 137 insertions(+), 12 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index efd8f9d7..b67c7204 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -8,6 +8,16 @@ All notable changes to CableDyn are recorded in this file. The format follows ## [Unreleased] +### Changed + +- Faster wave kinematics of directional and multi-train seas (`wavetrain` rows, spectral + `waves` rows, `WaveSpreading`). Each component's phase cosine is now computed once for the + surface elevation and the kinematics, and its depth profile with one exponential instead of + two. `examples/chain_two_train_sea.dat` runs 17 % faster with the release build. The formulas + are unchanged. With gfortran the results are bit-identical. With the Intel compiler of the + release, which had computed the second cosine through a fused sine/cosine evaluation, they + can differ in the last printed digit. + ### Fixed - The development environment (`environment.yml`) excludes OpenBLAS 0.3.34, which caused the diff --git a/src/CableDyn_WaveSpectra.f90 b/src/CableDyn_WaveSpectra.f90 index befe8b0f..2b617f1e 100644 --- a/src/CableDyn_WaveSpectra.f90 +++ b/src/CableDyn_WaveSpectra.f90 @@ -64,6 +64,7 @@ MODULE CableDyn_WaveSpectra ! the synthesised component table (all trains) INTEGER :: n_comp = 0 REAL(wp), ALLOCATABLE :: omega(:), k(:), amplitude(:), phase(:), cosb(:), sinb(:), e2kd(:) + REAL(wp) :: depth = CD_ZERO ! the water depth of the synthesis: k and e2kd = EXP(-2 k depth) LOGICAL :: ready = .FALSE. END TYPE CD_SeaType @@ -569,6 +570,7 @@ SUBROUTINE CD_Sea_Synthesise(sea, depth, gravity, seed, ErrStat, ErrMsg) sea%e2kd(i) = EXP(-2.0_wp*sea%k(i)*depth) END DO sea%n_comp = n_total + sea%depth = depth sea%ready = .TRUE. END SUBROUTINE CD_Sea_Synthesise @@ -626,8 +628,12 @@ SUBROUTINE CD_Sea_Kinematics(sea, x, y, z, t, depth, scale, eta, velocity, accel CHARACTER(*), INTENT(OUT) :: ErrMsg REAL(wp), INTENT(OUT), OPTIONAL :: pdyn INTEGER, PARAMETER :: NB = 256 - REAL(wp) :: cth(NB), sth(NB), ch(NB), sh(NB) - INTEGER :: i0, i1, i, m + ! The phase cosines of the elevation pass, kept for the kinematics pass (whose chunk loop + ! would compute the same values again), for the first NKEEP components; the rest are + ! recomputed there. A multiple of NB, so each chunk is either kept whole or recomputed. + INTEGER, PARAMETER :: NKEEP = 16*NB + REAL(wp) :: cth(NB), sth(NB), ch(NB), sh(NB), ckeep(NKEEP) + INTEGER :: i0, i1, i, m, n_small REAL(wp) :: z_eval, a, e1, e2, den, uh eta = CD_ZERO @@ -648,6 +654,7 @@ SUBROUTINE CD_Sea_Kinematics(sea, x, y, z, t, depth, scale, eta, velocity, accel DO i = i0, i1 eta = eta + (scale*sea%amplitude(i))*cth(i - i0 + 1) END DO + IF (i1 <= NKEEP) ckeep(i0:i1) = cth(1:i1 - i0 + 1) END DO IF (z > eta) RETURN IF (.NOT. (depth + eta > EPSILON(depth)*depth)) THEN @@ -659,20 +666,44 @@ SUBROUTINE CD_Sea_Kinematics(sea, x, y, z, t, depth, scale, eta, velocity, accel DO i0 = 1, sea%n_comp, NB i1 = MIN(sea%n_comp, i0 + NB - 1) m = i1 - i0 + 1 - DO i = i0, i1 - cth(i - i0 + 1) = COS(sea%k(i)*(x*sea%cosb(i) + y*sea%sinb(i)) - sea%omega(i)*t + sea%phase(i)) - END DO + IF (i1 <= NKEEP) THEN + cth(1:m) = ckeep(i0:i1) + ELSE + DO i = i0, i1 + cth(i - i0 + 1) = COS(sea%k(i)*(x*sea%cosb(i) + y*sea%sinb(i)) - sea%omega(i)*t + sea%phase(i)) + END DO + END IF DO i = i0, i1 sth(i - i0 + 1) = SIN(sea%k(i)*(x*sea%cosb(i) + y*sea%sinb(i)) - sea%omega(i)*t + sea%phase(i)) END DO + ! cosh(k(z+h))/sinh(kh) and sinh(k(z+h))/sinh(kh) without overflow, from e1 = EXP(k z) + ! and e2 = EXP(-k (z + 2h)) = e2kd/e1 at the synthesis depth: one exponential per + ! component. A component whose e1 or e2kd underflows, or a call at another depth than the + ! synthesis, takes the second exponential instead. DO i = i0, i1 - ! cosh(k(z+h))/sinh(kh) and sinh(k(z+h))/sinh(kh) without overflow - e1 = EXP(sea%k(i)*z_eval) - e2 = EXP(-sea%k(i)*(z_eval + 2.0_wp*depth)) - den = CD_ONE - sea%e2kd(i) - ch(i - i0 + 1) = (e1 + e2)/den - sh(i - i0 + 1) = (e1 - e2)/den + ch(i - i0 + 1) = EXP(sea%k(i)*z_eval) END DO + n_small = 0 + IF (ABS(depth - sea%depth) <= CD_ZERO) THEN + n_small = COUNT(ch(1:m) <= TINY(CD_ONE) .OR. sea%e2kd(i0:i1) <= TINY(CD_ONE)) + DO i = i0, i1 + e1 = ch(i - i0 + 1) + e2 = sea%e2kd(i)/MAX(e1, TINY(CD_ONE)) + den = CD_ONE - sea%e2kd(i) + ch(i - i0 + 1) = (e1 + e2)/den + sh(i - i0 + 1) = (e1 - e2)/den + END DO + END IF + IF (n_small > 0 .OR. ABS(depth - sea%depth) > CD_ZERO) THEN + DO i = i0, i1 + e1 = EXP(sea%k(i)*z_eval) + IF (ABS(depth - sea%depth) <= CD_ZERO .AND. e1 > TINY(CD_ONE) .AND. sea%e2kd(i) > TINY(CD_ONE)) CYCLE + e2 = EXP(-sea%k(i)*(z_eval + 2.0_wp*depth)) + den = CD_ONE - sea%e2kd(i) + ch(i - i0 + 1) = (e1 + e2)/den + sh(i - i0 + 1) = (e1 - e2)/den + END DO + END IF DO i = 1, m a = scale*sea%amplitude(i0 + i - 1)*sea%omega(i0 + i - 1) uh = a*ch(i)*cth(i) diff --git a/tests/test_wave_spectra.f90 b/tests/test_wave_spectra.f90 index 5b4f1bcc..c1a33731 100644 --- a/tests/test_wave_spectra.f90 +++ b/tests/test_wave_spectra.f90 @@ -12,7 +12,9 @@ PROGRAM test_wave_spectra !! band-averaged periodogram matches S(omega); two trains add in energy; a spread !! sea gives the lateral/longitudinal velocity-variance ratio 1/(2s + 1). !! 4. A long-crested JONSWAP train reproduces the original JONSWAP synthesis and its - !! kinematics (same seed, same components, same Wheeler convention). + !! kinematics (same seed, same components, same Wheeler convention); the kinematics + !! of spread seas below and above the kept-phase length of CD_Sea_Kinematics equal a + !! direct per-component sum. !! 5. Deck rows: spectral waves rows, WaveSpreading, wavetrain rows run end to end, and !! malformed or conflicting rows are rejected. USE CableDyn_Precision, ONLY: wp @@ -36,6 +38,7 @@ PROGRAM test_wave_spectra CALL case_two_trains() CALL case_spread_velocity_ratio() CALL case_legacy_jonswap_identity() + CALL case_kinematics_reference() CALL case_parse_rows() CALL case_deck_runs() IF (nfail > 0) THEN @@ -493,6 +496,87 @@ SUBROUTINE case_legacy_jonswap_identity() END DO END SUBROUTINE case_legacy_jonswap_identity + SUBROUTINE case_kinematics_reference() + !! CD_Sea_Kinematics against a direct per-component sum of the same linear kinematics with + !! Wheeler stretching, at points below the surface (one near the seabed) and one above it: + !! 1. 9 x 200 components: every phase cosine kept between the two passes; + !! 2. 31 x 200 components: the components past the kept length recomputed; + !! 3. a short sea in 1000 m: EXP(-2 k h), and near the seabed EXP(k z), underflow for the + !! short components, which take the two-exponential form; + !! 4. kinematics asked at another depth than the synthesis: the two-exponential form. + ! allocatable: a default-initialised local with allocatable components draws spurious + ! -Wuninitialized warnings from gfortran 16 (DEVELOPMENT.md) + TYPE(CD_SeaType), ALLOCATABLE :: sea + TYPE(CD_WaveTrainType) :: tr + REAL(wp), PARAMETER :: SCL = 0.85_wp + REAL(wp), PARAMETER :: PX(4) = [0.0_wp, 37.5_wp, -210.0_wp, 4.0_wp] + REAL(wp), PARAMETER :: PY(4) = [0.0_wp, -12.0_wp, 95.0_wp, 1.0_wp] + REAL(wp), PARAMETER :: PT(4) = [0.0_wp, 13.7_wp, 401.25_wp, 7.0_wp] + INTEGER, PARAMETER :: NDIR(4) = [9, 31, 9, 9] + REAL(wp), PARAMETER :: SYNTH_DEPTH(4) = [120.0_wp, 120.0_wp, 1000.0_wp, 120.0_wp] + REAL(wp), PARAMETER :: CALL_DEPTH(4) = [120.0_wp, 120.0_wp, 1000.0_wp, 150.0_wp] + REAL(wp), PARAMETER :: PERIOD(4) = [10.0_wp, 10.0_wp, 4.0_wp, 10.0_wp] + REAL(wp) :: eta, v(3), a(3), p, eta_r, v_r(3), a_r(3), p_r, th, z_e, e1, e2, ch, sh, amp, depth, pz(4) + INTEGER :: es, js, ip, i + CHARACTER(256) :: em + CHARACTER(48) :: tag + ALLOCATE (sea) + DO js = 1, SIZE(NDIR) + CALL CD_Sea_Reset(sea) + tr%kind = CD_TRAIN_JONSWAP + tr%height = MERGE(1.0_wp, 6.0_wp, PERIOD(js) < 5.0_wp) + tr%period = PERIOD(js) + tr%gamma = 3.3_wp + tr%direction = 20.0_wp + tr%spreading = 4.0_wp + sea%n_dir = NDIR(js) + CALL CD_Sea_Add_Train(sea, tr, es, em) + CALL CD_Sea_Synthesise(sea, SYNTH_DEPTH(js), G, 3, es, em) + WRITE (tag, '(A,I0,A,I0)') 'sea-reference:case ', js, ', n_comp=', sea%n_comp + CALL require(es == CD_SEA_OK .AND. sea%n_comp == 200*NDIR(js), TRIM(tag)//':synth') + IF (es /= CD_SEA_OK) CYCLE + depth = CALL_DEPTH(js) + pz = [-1.5_wp, -20.0_wp, -0.95_wp*depth, 30.0_wp] + DO ip = 1, SIZE(PX) + CALL CD_Sea_Kinematics(sea, PX(ip), PY(ip), pz(ip), PT(ip), depth, SCL, eta, v, a, es, em, pdyn=p) + CALL require(es == CD_SEA_OK, TRIM(tag)//':kinematics: '//TRIM(em)) + eta_r = 0.0_wp + DO i = 1, sea%n_comp + th = sea%k(i)*(PX(ip)*sea%cosb(i) + PY(ip)*sea%sinb(i)) - sea%omega(i)*PT(ip) + sea%phase(i) + eta_r = eta_r + SCL*sea%amplitude(i)*COS(th) + END DO + v_r = 0.0_wp + a_r = 0.0_wp + p_r = 0.0_wp + IF (pz(ip) <= eta_r) THEN + z_e = MIN(0.0_wp, (pz(ip) - eta_r)*depth/(depth + eta_r)) + DO i = 1, sea%n_comp + th = sea%k(i)*(PX(ip)*sea%cosb(i) + PY(ip)*sea%sinb(i)) - sea%omega(i)*PT(ip) + sea%phase(i) + e1 = EXP(sea%k(i)*z_e) + e2 = EXP(-sea%k(i)*(z_e + 2.0_wp*depth)) + ch = (e1 + e2)/(1.0_wp - sea%e2kd(i)) + sh = (e1 - e2)/(1.0_wp - sea%e2kd(i)) + amp = SCL*sea%amplitude(i)*sea%omega(i) + v_r = v_r + amp*[ch*COS(th)*sea%cosb(i), ch*COS(th)*sea%sinb(i), sh*SIN(th)] + amp = amp*sea%omega(i) + a_r = a_r + amp*[ch*SIN(th)*sea%cosb(i), ch*SIN(th)*sea%sinb(i), -sh*COS(th)] + p_r = p_r + amp/sea%k(i)*ch*COS(th) + END DO + END IF + CALL require(ABS(eta - eta_r) <= 1.0e-11_wp*MAX(1.0_wp, ABS(eta_r)), TRIM(tag)//':eta') + CALL require(nan_max_abs(v - v_r) <= 1.0e-11_wp*MAX(1.0_wp, MAXVAL(ABS(v_r))), TRIM(tag)//':velocity') + CALL require(nan_max_abs(a - a_r) <= 1.0e-11_wp*MAX(1.0_wp, MAXVAL(ABS(a_r))), TRIM(tag)//':acceleration') + CALL require(ABS(p - p_r) <= 1.0e-11_wp*MAX(1.0_wp, ABS(p_r)), TRIM(tag)//':pressure') + END DO + ! the last point lies above the surface: the elevation only, no kinematics + CALL require(pz(SIZE(pz)) > eta_r .AND. MAXVAL(ABS(v)) <= 0.0_wp .AND. MAXVAL(ABS(a)) <= 0.0_wp, & + TRIM(tag)//':above-surface') + ! case 3 reaches both underflows that the two-exponential form handles + IF (js == 3) CALL require(ANY(sea%e2kd <= TINY(1.0_wp)) .AND. & + ANY(EXP(sea%k*(-0.95_wp*depth)) <= TINY(1.0_wp)), TRIM(tag)//':underflow-reached') + END DO + END SUBROUTINE case_kinematics_reference + SUBROUTINE case_parse_rows() TYPE(CD_WaveTrainType) :: tr CHARACTER(16) :: kw From 02132900846aacc4ecb3290705aa21fd2bed3ac3 Mon Sep 17 00:00:00 2001 From: Jae Hoon Seo Date: Wed, 14 Oct 2026 21:30:03 +0900 Subject: [PATCH 03/31] feat: add a run-time profile to the standalone driver (#8) Speed work on CableDyn needs to know where a run spends its time, on any build and any deck. Until now the only breakdown was the profile of the OpenFAST module and the finite-EI step counters, which no standalone run could switch on. With CABLEDYN_PROFILE set (the variable the OpenFAST module already reads), the driver prints, before the success line, the wall time of input parsing, initialisation and statics, and the dynamic march, split into the fluid sampled by the driver, the line, cable and object steps, the checks, the outputs and the progress report, with the time per step. It also prints the EI = 0 line steps and their Newton iterations, and the finite-EI cable step counters and times on the routes that step their cables in turn. The profile tracks the running phase: CD_Profile_Enter charges the time since the previous mark to it and starts the next one, so the phases add up to the total, and a run that stops with an error keeps its time in the phase it stopped in. Every march marks where its fluid update, step, checks, outputs and progress report begin, and counts a step once it has passed its checks. The EI = 0 counts are taken in CD_Step_Model with atomic updates, because lines step in parallel. Unarmed, each mark is one test of a flag. The profile only reads the clock: every output file of the eight example decks tried, one per route, is byte-identical with and without it, with one OpenMP thread and with the default. A unit test checks the partition, a failed run's phase and the OpenMP counts; driver tests check the report on the EI = 0, finite-EI and failing routes. Signed-off-by: Jae Hoon Seo --- ARCHITECTURE.md | 7 ++ CHANGELOG.md | 12 ++ CMakeLists.txt | 38 +++++++ app/cabledyn.f90 | 137 ++++++++++++++++++++--- doc/cli.rst | 68 ++++++++++- doc/faq.rst | 3 +- src/CableDyn_DeckDriver.f90 | 92 ++++++++++++--- src/CableDyn_Model.f90 | 2 + src/CableDyn_Profile.f90 | 129 +++++++++++++++++++++ tests/check_driver_profile.cmake | 89 +++++++++++++++ tests/check_driver_profile_failure.cmake | 31 +++++ tests/test_profile.f90 | 126 +++++++++++++++++++++ 12 files changed, 700 insertions(+), 34 deletions(-) create mode 100644 src/CableDyn_Profile.f90 create mode 100644 tests/check_driver_profile.cmake create mode 100644 tests/check_driver_profile_failure.cmake create mode 100644 tests/test_profile.f90 diff --git a/ARCHITECTURE.md b/ARCHITECTURE.md index 8af4f8b5..71582bd4 100644 --- a/ARCHITECTURE.md +++ b/ARCHITECTURE.md @@ -376,6 +376,12 @@ the exchange buildable and testable without OpenFAST. carry `app/utf8_code_page.manifest`, which makes UTF-8 the process code page, so the Fortran runtime opens any name as written; a GNU build falls back to 8.3 short names for characters outside the system ANSI code page. +- **Run-time profile** (`CableDyn_Profile`): with `CABLEDYN_PROFILE` set, the standalone + driver charges its wall time to the phase that is running. Every time march marks where its + fluid update, step, checks, output and progress report begin, so a run that stops with an + error keeps its time in the phase it stopped in. The driver counts the `EI = 0` line steps and + Newton iterations in `CD_Step_Model`, and reports them with the finite-EI step counters of + `CableDyn_HermiteCableDynamic`. Unarmed, each mark is one test of a flag. - **C-ABI handles** (`cabledyn_mutex.c`): the handle registry is guarded by a spin-yield lock and deck initialisation by an input lock; operating on a handle while closing it from another thread is outside the API contract. @@ -395,6 +401,7 @@ src/ cabledyn_mutex.c C-ABI registry and initialisation locks cabledyn_crt_locale.c MinGW-w64 guard for libgfortran's locale restore CableDyn_FatalReport.f90 abnormal-end report of the driver (time reached) + CableDyn_Profile.f90 opt-in run-time profile of the driver (CABLEDYN_PROFILE) cabledyn_fatal.c interrupt, fault and stack-overflow handlers of the driver EI = 0 cable path: diff --git a/CHANGELOG.md b/CHANGELOG.md index b67c7204..4bba0978 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -8,6 +8,18 @@ All notable changes to CableDyn are recorded in this file. The format follows ## [Unreleased] +### Added + +- Run-time profile of the standalone driver. With the environment variable + `CABLEDYN_PROFILE=1`, the driver prints at the end of the run how its wall time divides + between input parsing, initialisation and statics, and the dynamic march. The march is split + into the fluid sampled by the driver, the line, cable and object steps, the checks, the + outputs, and the progress report. The profile also gives the committed steps and the time per + step, the tension-only line steps and their Newton iterations, and (outside the mixed + `EI = 0` + finite-EI route) the finite-EI cable steps with their residual, tangent and solve + counts and times. Every output file is the same with and without it. See the manual's + command-line page (Run-time profile). + ### Changed - Faster wave kinematics of directional and multi-train seas (`wavetrain` rows, spectral diff --git a/CMakeLists.txt b/CMakeLists.txt index 14bdab4e..83eb7c1f 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -332,6 +332,7 @@ add_library(cabledyn_obj OBJECT src/cabledyn_fatal.c src/CableDyn_Precision.f90 src/CableDyn_FatalReport.f90 + src/CableDyn_Profile.f90 src/CableDyn_PathIO.f90 src/CableDyn_Banner.f90 src/CableDyn_Linalg.f90 @@ -1899,6 +1900,43 @@ add_test( set_tests_properties(driver_repeat_exit PROPERTIES LABELS "fortran;driver;integration;static") +# Run-time profile module: phase partition, a failed run's time kept in its phase, and exact +# line-step counts under OpenMP. +add_executable(test_profile tests/test_profile.f90) +target_link_libraries(test_profile PRIVATE cabledyn_core) +add_test(NAME profile COMMAND test_profile) +set_tests_properties(profile PROPERTIES LABELS "fortran;unit;driver" + ENVIRONMENT "OMP_NUM_THREADS=4") + +# Run-time profile (CABLEDYN_PROFILE): printed only when requested, before the success line, +# with its phase rows and counts, and without changing any output file. One EI = 0 deck with +# waves (fluid, steps and line counts) and one finite-EI deck on the cubic-Hermite route. +add_test( + NAME driver_profile_ei0 + COMMAND ${CMAKE_COMMAND} + -DDRIVER=$ + -DDECK=${CMAKE_CURRENT_SOURCE_DIR}/examples/dynamic_chain_waves.dat + -DOUTPUT_ROOT=${CMAKE_CURRENT_BINARY_DIR}/driver_profile_ei0 + "-DEXPECT=\n EI = 0 line steps: [1-9][0-9]* \\(substeps and retries included\\), Newton iterations: [1-9]" + -P ${CMAKE_CURRENT_SOURCE_DIR}/tests/check_driver_profile.cmake) +add_test( + NAME driver_profile_finite_ei + COMMAND ${CMAKE_COMMAND} + -DDRIVER=$ + -DDECK=${CMAKE_CURRENT_SOURCE_DIR}/tests/data/held_start_gomex80_power_cable.dat + -DOUTPUT_ROOT=${CMAKE_CURRENT_BINARY_DIR}/driver_profile_finite_ei + "-DEXPECT=\n Finite-EI cable steps: [1-9][0-9]*, residual evaluations: [1-9]" + -P ${CMAKE_CURRENT_SOURCE_DIR}/tests/check_driver_profile.cmake) +add_test( + NAME driver_profile_failure + COMMAND ${CMAKE_COMMAND} + -DDRIVER=$ + -DDECK=${CMAKE_CURRENT_SOURCE_DIR}/tests/data/nonconvergent_motion.dat + -DOUTPUT_ROOT=${CMAKE_CURRENT_BINARY_DIR}/driver_profile_failure + -P ${CMAKE_CURRENT_SOURCE_DIR}/tests/check_driver_profile_failure.cmake) +set_tests_properties(driver_profile_ei0 driver_profile_finite_ei driver_profile_failure PROPERTIES + LABELS "fortran;driver;integration;dynamic") + # Command-line contract: unknown options, an output root whose .out would overwrite # the deck, and an unwritable output directory all fail before any solve. configure_file(${CMAKE_CURRENT_SOURCE_DIR}/tests/data/nonconvergent_motion.dat diff --git a/app/cabledyn.f90 b/app/cabledyn.f90 index 5da8af12..1f20b569 100644 --- a/app/cabledyn.f90 +++ b/app/cabledyn.f90 @@ -34,6 +34,12 @@ PROGRAM cabledyn USE CableDyn_Banner, ONLY: CD_Print_Banner USE CableDyn_Linalg, ONLY: CD_Blas_Runtime_Check, CD_LINALG_OK USE CableDyn_FatalReport, ONLY: CD_Fatal_Report_Install, CD_Fatal_Report_Time + USE CableDyn_Profile, ONLY: CD_Profile_Requested, CD_Profile_Arm, CD_Profile_Armed, CD_Profile_Enter, & + CD_Profile_Flush, CD_Profile_Step, CD_Profile_Seconds, CD_Profile_Counts, & + CD_PROF_INPUT, CD_PROF_INIT, CD_PROF_FLUID, CD_PROF_SOLVE, CD_PROF_CHECK, & + CD_PROF_OUTPUT, CD_PROF_PROGRESS, CD_PROF_FINAL, CD_PROF_NPHASE + USE CableDyn_HermiteCableDynamic, ONLY: CD_HermiteCable_Dyn_Reset_Profile, CD_HermiteCable_Dyn_Get_Profile, & + CD_HermiteCable_Dyn_Recovery_Reset, CD_HermiteCable_Dyn_Recovery_Count USE, INTRINSIC :: ISO_FORTRAN_ENV, ONLY: error_unit, output_unit, int64 IMPLICIT NONE TYPE :: StandaloneProgress @@ -56,6 +62,8 @@ PROGRAM cabledyn INTEGER :: nargs, ErrStat, n_ei0, n_finite_ei, iarg REAL(wp) :: dtM, tmax LOGICAL :: converged, has_dtm, has_tmax, has_motion_file, has_line_outputs, has_objects + ! the run-time profile includes the finite-EI cable step counters (not on the mixed route) + LOGICAL :: profile_cable_detail = .FALSE. ! Sized for the aggregate and deck-driver messages it relays (512-character buffers ! plus deck-line context), so no diagnostic is cut short. CHARACTER(1024) :: ErrMsg @@ -117,10 +125,24 @@ PROGRAM cabledyn ! without a word. Installed after the LAPACK runtime has loaded, so its handlers are the ! process's own. CALL CD_Fatal_Report_Install() + ! Opt-in run-time profile (environment variable CABLEDYN_PROFILE), printed before the last + ! stdout line. + IF (CD_Profile_Requested()) THEN + CALL CD_Profile_Arm() + CALL CD_HermiteCable_Dyn_Recovery_Reset() + WRITE (output_unit, '(A)') ' Run-time profile armed by CABLEDYN_PROFILE.' + END IF CALL CD_Deck_Query_dtM(TRIM(deck_path), dtM, has_dtm, ErrStat, ErrMsg, tmax=tmax, & has_tmax=has_tmax, n_ei0=n_ei0, n_finite_ei=n_finite_ei, & has_motion_file=has_motion_file, standalone_scan=.TRUE., & has_line_outputs=has_line_outputs, input_files=input_files, has_objects=has_objects) + IF (ErrStat == CD_DECKDRV_OK .AND. CD_Profile_Armed()) THEN + ! The finite-EI step counters are process-global, so the aggregate of the mixed route steps + ! its cables one after another while they are armed. That route keeps its cables concurrent + ! and reports no finite-EI step detail; every other route steps its cables in turn anyway. + profile_cable_detail = .NOT. (n_ei0 > 0 .AND. n_finite_ei > 0 .AND. .NOT. has_objects) + IF (profile_cable_detail) CALL CD_HermiteCable_Dyn_Reset_Profile() + END IF IF (ErrStat == CD_DECKDRV_OK) THEN DO iarg = 1, SIZE(input_files) CALL check_input_not_output(TRIM(input_files(iarg)), TRIM(out_root), root_native, 'input file') @@ -154,6 +176,7 @@ PROGRAM cabledyn END IF CALL stop_run(2) END IF + CALL print_profile() WRITE (output_unit, '(A,A,A)') PROG//': converged run written to ', TRIM(out_root), '.out' CONTAINS @@ -164,6 +187,7 @@ SUBROUTINE stop_run(code) !! a caller can tell such an exit from a process ended from outside (Task Manager, !! `taskkill /F`, `kill -9`), which runs no code of the driver and leaves no closing line. INTEGER, INTENT(IN) :: code + CALL print_profile() WRITE (error_unit, '(A,I0)') PROG//': ended with exit code ', code FLUSH (error_unit) STOP code, QUIET = .TRUE. @@ -472,6 +496,8 @@ SUBROUTINE run_mixed_held_deck(deck, root, dt, has_dt, run_time, has_run_time, h END IF mixed_run: BLOCK + ! the aggregate parses the deck again with its models: initialisation from here + CALL CD_Profile_Enter(CD_PROF_INIT) ALLOCATE (aggregate, STAT=ios) IF (ios /= 0) THEN run_stat = CD_DECKDRV_SOLVEFAIL @@ -555,11 +581,14 @@ SUBROUTINE run_mixed_held_deck(deck, root, dt, has_dt, run_time, has_run_time, h max_consecutive_miss = 0 first_miss_time = CD_ZERO last_miss_time = CD_ZERO + ! the march (no fluid sampled by the driver on this route) or, without one, finalisation + CALL CD_Profile_Enter(MERGE(CD_PROF_SOLVE, CD_PROF_FINAL, nstep > 0)) IF (nstep > 0) CALL start_standalone_progress(progress, nstep, step_dt) DO step = 1, nstep time = REAL(step, wp)*step_dt CALL CD_AGG_Step_Moving(aggregate, step_dt, position, velocity, acceleration, step_converged, stalled, & n_iter, es, em, t_committed=time) + CALL CD_Profile_Enter(CD_PROF_CHECK) IF (es /= CD_AGG_OK) THEN CALL set_aggregate_error(es, em, run_stat, run_msg) EXIT mixed_run @@ -577,6 +606,9 @@ SUBROUTINE run_mixed_held_deck(deck, root, dt, has_dt, run_time, has_run_time, h ELSE consecutive_miss = 0 END IF + ! a committed step: count it, then its outputs + CALL CD_Profile_Step() + CALL CD_Profile_Enter(CD_PROF_OUTPUT) CALL CD_AGG_CalcOutput(aggregate, es, em) IF (es /= CD_AGG_OK) THEN CALL set_aggregate_error(es, em, run_stat, run_msg) @@ -588,6 +620,7 @@ SUBROUTINE run_mixed_held_deck(deck, root, dt, has_dt, run_time, has_run_time, h CALL set_aggregate_error(es, em, run_stat, run_msg) EXIT mixed_run END IF + CALL CD_Profile_Enter(CD_PROF_PROGRESS) CALL update_standalone_progress(progress, step, time) END DO @@ -800,22 +833,98 @@ SUBROUTINE update_standalone_progress(progress, step, simulated_time) CHARACTER(16) :: elapsed_text, remaining_text ! Every committed step: the time an abnormal end of the process reports. CALL CD_Fatal_Report_Time(simulated_time) - IF (step < progress%nstep .AND. MOD(step, progress%stride) /= 0) RETURN - CALL SYSTEM_CLOCK(now) - elapsed = CD_ZERO - IF (progress%count_rate > 0_int64 .AND. now >= progress%start_count) & - elapsed = REAL(now - progress%start_count, wp)/REAL(progress%count_rate, wp) - remaining = CD_ZERO - IF (step < progress%nstep .AND. elapsed > CD_ZERO) & - remaining = elapsed*REAL(progress%nstep - step, wp)/REAL(step, wp) - percent = 100.0_wp*REAL(step, wp)/REAL(progress%nstep, wp) - elapsed_text = format_wall_time(elapsed) - remaining_text = format_wall_time(remaining) - WRITE (output_unit, '(A,F6.1,A,F12.3,A,A,A,A)') ' Progress: ', percent, '% | t = ', & - simulated_time, ' s | elapsed ', TRIM(elapsed_text), ' | ETA ', TRIM(remaining_text) - FLUSH (output_unit) + IF (step >= progress%nstep .OR. MOD(step, progress%stride) == 0) THEN + CALL SYSTEM_CLOCK(now) + elapsed = CD_ZERO + IF (progress%count_rate > 0_int64 .AND. now >= progress%start_count) & + elapsed = REAL(now - progress%start_count, wp)/REAL(progress%count_rate, wp) + remaining = CD_ZERO + IF (step < progress%nstep .AND. elapsed > CD_ZERO) & + remaining = elapsed*REAL(progress%nstep - step, wp)/REAL(step, wp) + percent = 100.0_wp*REAL(step, wp)/REAL(progress%nstep, wp) + elapsed_text = format_wall_time(elapsed) + remaining_text = format_wall_time(remaining) + WRITE (output_unit, '(A,F6.1,A,F12.3,A,A,A,A)') ' Progress: ', percent, '% | t = ', & + simulated_time, ' s | elapsed ', TRIM(elapsed_text), ' | ETA ', TRIM(remaining_text) + FLUSH (output_unit) + END IF + ! the next step, or after the last step the finalisation + CALL CD_Profile_Enter(MERGE(CD_PROF_FINAL, CD_PROF_SOLVE, step >= progress%nstep)) END SUBROUTINE update_standalone_progress + SUBROUTINE print_profile() + !! The run-time profile requested with CABLEDYN_PROFILE (CableDyn_Profile): the wall time + !! of each phase of the run, the step counts and the Newton iterations, and the interior of + !! the finite-EI cable steps. Printed once, on stdout, at the end of the run. + LOGICAL, SAVE :: printed = .FALSE. + REAL(wp) :: seconds(CD_PROF_NPHASE), total, march, t_step, t_resid, t_eff, t_solve, t_am, t_tan + INTEGER(int64) :: march_steps, line_steps, line_iterations + INTEGER :: line_max_iterations, n_step, n_resid, n_solve, n_am, n_alloc, n_tan, k + IF (printed .OR. .NOT. CD_Profile_Armed()) RETURN + printed = .TRUE. + ! the running phase up to now: the finalisation of a completed run, or the phase in which a + ! failed run stopped + CALL CD_Profile_Flush() + DO k = 1, CD_PROF_NPHASE + seconds(k) = CD_Profile_Seconds(k) + END DO + total = SUM(seconds) + march = SUM(seconds(CD_PROF_FLUID:CD_PROF_PROGRESS)) + CALL CD_Profile_Counts(march_steps, line_steps, line_iterations, line_max_iterations) + WRITE (output_unit, '(A)') ' Run-time profile (CABLEDYN_PROFILE), wall-clock time:' + CALL profile_row('input parsing', seconds(CD_PROF_INPUT), total) + CALL profile_row('initialisation and statics', seconds(CD_PROF_INIT), total) + CALL profile_row('dynamic march', march, total) + CALL profile_row(' fluid sampled by the driver', seconds(CD_PROF_FLUID), total) + CALL profile_row(' line, cable and object steps', seconds(CD_PROF_SOLVE), total) + CALL profile_row(' checks and line failures', seconds(CD_PROF_CHECK), total) + CALL profile_row(' outputs', seconds(CD_PROF_OUTPUT), total) + CALL profile_row(' progress and bookkeeping', seconds(CD_PROF_PROGRESS), total) + CALL profile_row('finalisation', seconds(CD_PROF_FINAL), total) + CALL profile_row('total', total, total) + IF (march_steps > 0_int64) WRITE (output_unit, '(A,I0,A,A,A)') ' March: ', march_steps, & + ' committed step(s), ', fixed(1.0e3_wp*march/REAL(march_steps, wp), 4), ' ms per step.' + IF (line_steps > 0_int64) WRITE (output_unit, '(A,I0,A,I0,A,A,A,I0,A)') ' EI = 0 line steps: ', & + line_steps, ' (substeps and retries included), Newton iterations: ', line_iterations, ' (', & + fixed(REAL(line_iterations, wp)/REAL(line_steps, wp), 3), ' per line step, at most ', line_max_iterations, ').' + CALL CD_HermiteCable_Dyn_Get_Profile(n_step, n_resid, n_solve, n_am, n_alloc, t_step, t_resid, t_eff, & + t_solve, t_am, n_tan, t_tan) + IF (n_step > 0) THEN + WRITE (output_unit, '(A,I0,A,I0,A,I0,A,I0,A,I0,A)') ' Finite-EI cable steps: ', n_step, & + ', residual evaluations: ', n_resid, ', tangent assemblies: ', n_tan, ', linear solves: ', n_solve, & + ', intervals recovered by substeps: ', CD_HermiteCable_Dyn_Recovery_Count(), '.' + WRITE (output_unit, '(13A)') ' Finite-EI cable step time (s): residual ', fixed(t_resid, 3), & + ', tangent ', fixed(t_tan, 3), ', effective matrix ', fixed(t_eff, 3), ', linear solve ', & + fixed(t_solve, 3), ', added mass ', fixed(t_am, 3), ', other ', & + fixed(MAX(0.0_wp, t_step - (t_resid + t_tan + t_eff + t_solve + t_am)), 3), '.' + ELSE IF (.NOT. profile_cable_detail .AND. n_finite_ei > 0) THEN + WRITE (output_unit, '(A)') ' Finite-EI cable steps: not counted on the mixed EI = 0 + finite-EI route, '// & + 'whose cables step concurrently.' + END IF + FLUSH (output_unit) + END SUBROUTINE print_profile + + FUNCTION fixed(value, digits) RESULT(text) + !! value in fixed-point notation with the given decimals and a leading zero below one. + REAL(wp), INTENT(IN) :: value + INTEGER, INTENT(IN) :: digits + CHARACTER(:), ALLOCATABLE :: text + CHARACTER(32) :: buffer + CHARACTER(16) :: form + WRITE (form, '(A,I0,A)') '(F32.', digits, ')' + WRITE (buffer, form) value + text = TRIM(ADJUSTL(buffer)) + END FUNCTION fixed + + SUBROUTINE profile_row(label, seconds, total) + CHARACTER(*), INTENT(IN) :: label + REAL(wp), INTENT(IN) :: seconds, total + REAL(wp) :: share + share = 0.0_wp + IF (total > 0.0_wp) share = 100.0_wp*seconds/total + WRITE (output_unit, '(4X,A,T40,F12.3,A,F7.1,A)') label, seconds, ' s', share, ' %' + END SUBROUTINE profile_row + PURE FUNCTION format_wall_time(seconds) RESULT(text) REAL(wp), INTENT(IN) :: seconds CHARACTER(16) :: text diff --git a/doc/cli.rst b/doc/cli.rst index 1dd9f598..d9f0ec02 100644 --- a/doc/cli.rst +++ b/doc/cli.rst @@ -132,7 +132,8 @@ Standard streams - the initialisation report on mixed ``EI = 0`` + finite-EI decks; dynamic progress (``Dynamic simulation: …`` and ``Progress: …% | t = … s | elapsed … | ETA …``, at 5 % intervals); ``Recovery audit: …`` and ``Tensile monitor: …`` summaries; - ``CableDyn: FAILURE …`` event lines; and, last, the success line + ``CableDyn: FAILURE …`` event lines; the run-time profile when ``CABLEDYN_PROFILE`` is + set (:ref:`cli-profile`); and, last, the success line The formats of the report and progress records are shown in :doc:`outputs`. On success the final stdout line is exactly:: @@ -143,6 +144,71 @@ stdout is a human-readable log, not a machine-parseable stream: its records vary and the route. Automation should rely on the **exit status** and read results from the output files. To keep only the stdout records, discard stderr (``2>/dev/null`` or ``2>$null``). +.. _cli-profile: + +Run-time profile +~~~~~~~~~~~~~~~~ + +Set the environment variable ``CABLEDYN_PROFILE`` to ``1`` to see where the wall time of a run +goes. The driver then prints ``Run-time profile armed by CABLEDYN_PROFILE.`` at the start and, +at the end of the run (before the success line, or before the closing line of a failed run), a +breakdown such as: + +.. code-block:: text + + Run-time profile (CABLEDYN_PROFILE), wall-clock time: + input parsing 0.002 s 0.0 % + initialisation and statics 0.233 s 3.1 % + dynamic march 7.232 s 96.8 % + fluid sampled by the driver 0.050 s 0.7 % + line, cable and object steps 7.168 s 96.0 % + checks and line failures 0.001 s 0.0 % + outputs 0.013 s 0.2 % + progress and bookkeeping 0.000 s 0.0 % + finalisation 0.000 s 0.0 % + total 7.467 s 100.0 % + March: 600 committed step(s), 12.0528 ms per step. + EI = 0 line steps: 3621 (substeps and retries included), Newton iterations: 4661 (1.287 per line step, at most 2). + Finite-EI cable steps: 4849, residual evaluations: 21255, tangent assemblies: 10391, linear solves: 10391, intervals recovered by substeps: 0. + Finite-EI cable step time (s): residual 1.416, tangent 2.674, effective matrix 0.136, linear solve 0.943, added mass 0.167, other 0.457. + +The phases add up to the total, which runs from the start of the deck parse to the report. If the +run stops with an error, the time up to the stop counts to the phase in which it stopped, and +finalisation stays at zero. + +* **Input parsing** covers reading the deck and its auxiliary files. +* **Initialisation and statics** covers the synthesis of the deck's waves, building the models, + the static equilibrium, any modal analysis, and the initial output rows. For a static deck it + also covers writing the output + files. On the mixed ``EI = 0`` + finite-EI route it includes the deck parse that builds the + models. +* **Fluid sampled by the driver** is the deck wave and current field that the driver samples at + the nodes before each step. A finite-EI cable evaluates the wave kinematics inside its + element loads, and a ``motionFile`` Rigid6 or rod march samples the fluid within its step. On + those routes, that work counts as **line, cable and object steps**. +* **Outputs** covers the output channels, the per-line files, and the range-graph samples. + +The counts follow the march: + +* **EI = 0 line steps** counts every step of every tension-only line, including recovery + substeps, retries and, on the body marches, each re-step of a line within the body + iterations. **Newton iterations** is their total. +* **Finite-EI cable steps** counts the same for the cubic-Hermite cables. A cable clamped to a + body is re-stepped in every body iteration, so the count can exceed the number of march + steps. + +An unset or empty variable, or ``0``, leaves the profile off. The driver reads the variable once, +when it starts. + +The profile only reads the clock and never changes a result: every output file is identical +with and without it. Its cost is a few clock reads per step. + +On the mixed ``EI = 0`` + finite-EI route the cables step concurrently, so the profile does not +count the finite-EI cable steps there. It says so in their place, and leaves that route's +execution exactly as in an unprofiled run. + +``openfast.exe`` reads the same variable for its own module profile (see :doc:`faq`). + Exit codes ~~~~~~~~~~ diff --git a/doc/faq.rst b/doc/faq.rst index b83b517a..226b305f 100644 --- a/doc/faq.rst +++ b/doc/faq.rst @@ -104,7 +104,8 @@ OpenFAST coupling benchmark does **not** imply a fast coupled run: OpenFAST may call ``CalcOutput`` several times per physical step with different trial kinematics. Set the environment variable ``CABLEDYN_PROFILE=1`` before running ``openfast.exe`` to separate CableDyn solve, SeaState - sampling, output-probe, and native-I/O time. Keep ``ModCoupling`` fixed while + sampling, output-probe, and native-I/O time; the standalone driver reads the same variable + and prints its own breakdown (:ref:`cli-profile`). Keep ``ModCoupling`` fixed while comparing configurations. Do not switch to loose coupling merely to meet a wall-clock target; on the IEA-15MW reference model it materially changed platform and tension responses. Test ``OMP_NUM_THREADS=1`` as well as the intended threaded setting: three short lines can be too diff --git a/src/CableDyn_DeckDriver.f90 b/src/CableDyn_DeckDriver.f90 index 38b28db7..fb5d855e 100644 --- a/src/CableDyn_DeckDriver.f90 +++ b/src/CableDyn_DeckDriver.f90 @@ -142,6 +142,8 @@ MODULE CableDyn_DeckDriver CD_RIGID_NEWMARK_BETA USE CableDyn_SO3, ONLY: CD_Log_SO3, CD_Exp_SO3 USE CableDyn_PathIO, ONLY: CD_Open_Input, CD_Native_Path, CD_Strip_BOM + USE CableDyn_Profile, ONLY: CD_Profile_Enter, CD_Profile_Step, CD_PROF_INPUT, CD_PROF_INIT, CD_PROF_FLUID, & + CD_PROF_SOLVE, CD_PROF_CHECK, CD_PROF_OUTPUT, CD_PROF_PROGRESS, CD_PROF_FINAL USE, INTRINSIC :: IEEE_ARITHMETIC, ONLY: IEEE_IS_FINITE USE, INTRINSIC :: ISO_FORTRAN_ENV, ONLY: error_unit, output_unit, int64 IMPLICIT NONE @@ -6168,12 +6170,16 @@ SUBROUTINE run_deck_driver(deck_path, out_root, converged, ErrStat, ErrMsg) CALL fail(ErrStat, ErrMsg, 'FAILURE deck does not support seabed friction (the dynamic-point rule)'); RETURN END IF END IF + ! the wave synthesis or stream-function solve is initialisation; the bathymetry file read input + CALL CD_Profile_Enter(CD_PROF_INIT) CALL precompute_deck_wave(opts, ErrStat, ErrMsg) IF (ErrStat /= 0) RETURN IF (opts%has_bathymetry_file) THEN + CALL CD_Profile_Enter(CD_PROF_INPUT) CALL load_bathymetry_file(path_join(deck_dir(deck_path), opts%bathymetry_file), bathymetry, ErrStat, ErrMsg, & points=points) IF (ErrStat /= 0) RETURN + CALL CD_Profile_Enter(CD_PROF_INIT) END IF CALL print_static_input_warnings(types, points, lines, sections, opts) ! free Rigid6 bodies and rods (jointly with Free/Connect points) start at their static @@ -6503,6 +6509,8 @@ SUBROUTINE run_deck_driver(deck_path, out_root, converged, ErrStat, ErrMsg) CALL write_out(out_root, channels, lines, points, ne, q_all, q_off, ten_all, ten_off, converged, ErrStat, ErrMsg, & end_ten=end_all, end_force=end_vec, opts=opts, bathymetry=bathymetry) + ! a failed static run stays in initialisation, where it stopped + IF (ErrStat == CD_DECKDRV_OK .AND. converged) CALL CD_Profile_Enter(CD_PROF_FINAL) IF (opts%has_bathymetry_file) CALL CD_End_Bathymetry(bathymetry) IF (ErrStat /= 0) RETURN IF (.NOT. converged) THEN @@ -14336,6 +14344,7 @@ SUBROUTINE write_dynamic_out(out_root, channels, lines, points, opts, models, co RETURN END IF END IF + CALL CD_Profile_Enter(CD_PROF_SOLVE) IF (opts%has_motion_file) THEN CALL step_motion_models(models, lines, points, motion, step + 1, opts%dtM, & opts%recovery_max_substeps, step_converged, stalled, n_iter, step_substeps, & @@ -14344,6 +14353,7 @@ SUBROUTINE write_dynamic_out(out_root, channels, lines, points, opts, models, co CALL step_held_models(models, opts%dtM, opts%recovery_max_substeps, step_converged, stalled, & n_iter, step_substeps, es, em, step_work) END IF + CALL CD_Profile_Enter(CD_PROF_CHECK) IF (step_substeps > 1) THEN recovery_event_count = recovery_event_count + 1 recovery_max_substeps_used = MAX(recovery_max_substeps_used, step_substeps) @@ -14373,6 +14383,8 @@ SUBROUTINE write_dynamic_out(out_root, channels, lines, points, opts, models, co ErrMsg = TRIM(ErrMsg)//INSPECTION_NOTE RETURN END IF + CALL CD_Profile_Step() + CALL CD_Profile_Enter(CD_PROF_OUTPUT) IF (opts%has_motion_file) THEN CALL write_model_row(unit, t, channels, lines, points, models, output_work, ErrStat, ErrMsg, motion, step + 1) ELSE @@ -14389,6 +14401,7 @@ SUBROUTINE write_dynamic_out(out_root, channels, lines, points, opts, models, co CALL close_dynamic_line_outputs(pos_units, ten_units) RETURN END IF + CALL CD_Profile_Enter(CD_PROF_PROGRESS) CALL update_driver_progress(progress, step, t) END DO CLOSE (unit) @@ -14498,7 +14511,9 @@ SUBROUTINE write_system_dynamic_out(out_root, channels, lines, points, opts, sys ErrMsg = em RETURN END IF + CALL CD_Profile_Enter(CD_PROF_SOLVE) CALL CD_Step_System_DynamicPoints(system, opts%dtM, step_converged, stalled, n_iter, es, em) + CALL CD_Profile_Enter(CD_PROF_CHECK) IF (es /= CD_SYSTEM_OK) THEN CLOSE (unit) CALL close_dynamic_line_outputs(pos_units, ten_units) @@ -14534,6 +14549,8 @@ SUBROUTINE write_system_dynamic_out(out_root, channels, lines, points, opts, sys RETURN END IF END IF + CALL CD_Profile_Step() + CALL CD_Profile_Enter(CD_PROF_OUTPUT) CALL write_system_model_row(unit, t, channels, lines, points, system, output_work, ErrStat, ErrMsg) IF (ErrStat /= CD_DECKDRV_OK) THEN CLOSE (unit) @@ -14546,6 +14563,7 @@ SUBROUTINE write_system_dynamic_out(out_root, channels, lines, points, opts, sys CALL close_dynamic_line_outputs(pos_units, ten_units) RETURN END IF + CALL CD_Profile_Enter(CD_PROF_PROGRESS) CALL update_driver_progress(progress, step, t) END DO CLOSE (unit) @@ -14858,6 +14876,7 @@ SUBROUTINE write_rigid6_dynamic_out(out_root, channels, bodies, lines, points, o DO step = 1, nstep t = REAL(step, wp)*opts%dtM IF (use_prescribed_rigid6) THEN + CALL CD_Profile_Enter(CD_PROF_SOLVE) CALL step_prescribed_rigid6_system(system, points, opts, motion, rigid, step + 1, t, opts%dtM, & step_converged, stalled, n_iter, es, em, step_work, hydro_work) ELSE @@ -14869,9 +14888,11 @@ SUBROUTINE write_rigid6_dynamic_out(out_root, channels, bodies, lines, points, o ErrMsg = em RETURN END IF + CALL CD_Profile_Enter(CD_PROF_SOLVE) CALL step_rigid6_system(system, points, opts, rigid, t, opts%dtM, step_converged, stalled, n_iter, & es, em, step_work, bathymetry) END IF + CALL CD_Profile_Enter(CD_PROF_CHECK) IF (es /= CD_DECKDRV_OK) THEN CLOSE (unit) CALL close_dynamic_line_outputs(pos_units, ten_units) @@ -14906,6 +14927,8 @@ SUBROUTINE write_rigid6_dynamic_out(out_root, channels, bodies, lines, points, o RETURN END IF END IF + CALL CD_Profile_Step() + CALL CD_Profile_Enter(CD_PROF_OUTPUT) CALL write_system_model_row(unit, t, channels, lines, points, system, output_work, ErrStat, ErrMsg, & rigid=rigid, opts=opts, bathymetry=bathymetry) IF (ErrStat /= CD_DECKDRV_OK) THEN @@ -14919,6 +14942,7 @@ SUBROUTINE write_rigid6_dynamic_out(out_root, channels, bodies, lines, points, o CALL close_dynamic_line_outputs(pos_units, ten_units) RETURN END IF + CALL CD_Profile_Enter(CD_PROF_PROGRESS) CALL update_driver_progress(progress, step, t) END DO CLOSE (unit) @@ -15038,6 +15062,7 @@ SUBROUTINE write_rod_dynamic_out(out_root, channels, rod_types, rods, lines, poi DO step = 1, nstep t = REAL(step, wp)*opts%dtM IF (use_prescribed_rods) THEN + CALL CD_Profile_Enter(CD_PROF_SOLVE) CALL step_prescribed_rod_system(system, points, opts, motion, rod_state, step + 1, t, opts%dtM, & step_converged, stalled, n_iter, es, em, step_work, hydro_work, bathymetry) ELSE @@ -15050,9 +15075,11 @@ SUBROUTINE write_rod_dynamic_out(out_root, channels, rod_types, rods, lines, poi ErrMsg = em RETURN END IF + CALL CD_Profile_Enter(CD_PROF_SOLVE) CALL step_rod_system(system, points, opts, rod_state, t, opts%dtM, step_converged, stalled, n_iter, & es, em, step_work, bathymetry) END IF + CALL CD_Profile_Enter(CD_PROF_CHECK) IF (es /= CD_DECKDRV_OK) THEN CLOSE (unit) CALL close_dynamic_line_outputs(pos_units, ten_units) @@ -15080,6 +15107,8 @@ SUBROUTINE write_rod_dynamic_out(out_root, channels, rod_types, rods, lines, poi converged = .FALSE. RETURN END IF + CALL CD_Profile_Step() + CALL CD_Profile_Enter(CD_PROF_OUTPUT) CALL write_system_model_row(unit, t, channels, lines, points, system, output_work, ErrStat, ErrMsg, & rods=rod_state, opts=opts, bathymetry=bathymetry) IF (ErrStat /= CD_DECKDRV_OK) THEN @@ -15102,6 +15131,7 @@ SUBROUTINE write_rod_dynamic_out(out_root, channels, rod_types, rods, lines, poi CALL close_dynamic_rod_outputs(rod_pos_units) RETURN END IF + CALL CD_Profile_Enter(CD_PROF_PROGRESS) CALL update_driver_progress(progress, step, t) END DO CLOSE (unit) @@ -16063,6 +16093,7 @@ SUBROUTINE write_objects_dynamic_out(out_root, channels, bodies, rod_types, rods nstep = NINT(opts%tmax/opts%dtM) CALL start_driver_progress(progress, nstep, opts%dtM) DO step = 1, nstep + CALL CD_Profile_Enter(CD_PROF_SOLVE) t = REAL(step, wp)*opts%dtM old_rigid = rigid old_rst = rst @@ -16111,12 +16142,17 @@ SUBROUTINE write_objects_dynamic_out(out_root, channels, bodies, rod_types, rods CALL pin_rod(rst(k)) END DO END IF - IF (ErrStat == CD_DECKDRV_OK) CALL write_row(t) + IF (ErrStat == CD_DECKDRV_OK) THEN + CALL CD_Profile_Step() + CALL CD_Profile_Enter(CD_PROF_OUTPUT) + CALL write_row(t) + END IF IF (ErrStat /= CD_DECKDRV_OK) THEN converged = .FALSE. CLOSE (unit) RETURN END IF + CALL CD_Profile_Enter(CD_PROF_PROGRESS) CALL update_driver_progress(progress, step, t) END DO CLOSE (unit) @@ -16549,7 +16585,9 @@ SUBROUTINE write_multibody_dynamic_out(deck_path, out_root, channels, types, bod t = REAL(step, wp)*opts%dtM CALL mb_hydro(t, .FALSE.) IF (ErrStat /= CD_DECKDRV_OK) GOTO 800 + CALL CD_Profile_Enter(CD_PROF_SOLVE) CALL mb_step(mb, points, opts, t, opts%dtM, step_converged, stalled, n_iter, es, em, bathymetry) + CALL CD_Profile_Enter(CD_PROF_CHECK) IF (es /= CD_DECKDRV_OK) THEN ErrStat = es ErrMsg = em @@ -16569,9 +16607,12 @@ SUBROUTINE write_multibody_dynamic_out(deck_path, out_root, channels, types, bod GOTO 800 END IF END IF + CALL CD_Profile_Step() + CALL CD_Profile_Enter(CD_PROF_OUTPUT) CALL mb_outputs(t) IF (ErrStat /= CD_DECKDRV_OK) GOTO 800 IF (ALLOCATED(probe_rec) .AND. probe_armed) CALL probe_record(step, t) + CALL CD_Profile_Enter(CD_PROF_PROGRESS) CALL update_driver_progress(progress, step, t) END DO IF (mb%implicit .AND. mb%n_steps_imp > 0) THEN @@ -23697,6 +23738,7 @@ SUBROUTINE write_hermite_dynamic_out(out_root, channels, lines, points, opts, ca t = REAL(step, wp)*opts%dtM CALL update_hermite_deck_fluid(cables, opts, t, ErrStat, ErrMsg) IF (ErrStat /= CD_DECKDRV_OK) EXIT + CALL CD_Profile_Enter(CD_PROF_SOLVE) DO i = 1, SIZE(cables) IF (opts%has_motion_file) THEN pidx = find_point(points, lines(i)%nodeA) @@ -23732,12 +23774,15 @@ SUBROUTINE write_hermite_dynamic_out(out_root, channels, lines, points, opts, ca END IF END DO IF (ErrStat /= CD_DECKDRV_OK) EXIT + CALL CD_Profile_Step() + CALL CD_Profile_Enter(CD_PROF_OUTPUT) CALL write_hermite_model_row(unit, t, channels, lines, points, cables, ErrStat, ErrMsg, & motion=motion, motion_time_index=MERGE(step + 1, 0, opts%has_motion_file), & has_motion=opts%has_motion_file, ranges=ranges) IF (ErrStat == CD_DECKDRV_OK) & CALL write_dynamic_hermite_line_outputs(t, lines, cables, pos_units, ten_units, ErrStat, ErrMsg) IF (ErrStat /= CD_DECKDRV_OK) EXIT + CALL CD_Profile_Enter(CD_PROF_PROGRESS) CALL update_driver_progress(progress, step, t) END DO CLOSE (unit) @@ -24332,6 +24377,7 @@ SUBROUTINE write_finite_dynamic_out(out_root, channels, lines, points, opts, mod END IF CALL start_driver_progress(progress, nstep, opts%dtM) DO step = 1, nstep + CALL CD_Profile_Enter(CD_PROF_SOLVE) t = REAL(step, wp)*opts%dtM IF (opts%has_motion_file) THEN ! Moving-support march: the prescribed endpoint translations follow the motionFile @@ -24342,6 +24388,7 @@ SUBROUTINE write_finite_dynamic_out(out_root, channels, lines, points, opts, mod ELSE CALL step_finite_held_models(models, opts, t, opts%dtM, step_converged, stalled, n_iter, es, em) END IF + CALL CD_Profile_Enter(CD_PROF_CHECK) IF (es /= CD_DECKDRV_OK) THEN CLOSE (unit) CALL close_dynamic_line_outputs(pos_units, ten_units) @@ -24359,6 +24406,8 @@ SUBROUTINE write_finite_dynamic_out(out_root, channels, lines, points, opts, mod converged, ErrStat, ErrMsg) RETURN END IF + CALL CD_Profile_Step() + CALL CD_Profile_Enter(CD_PROF_OUTPUT) IF (opts%has_motion_file) THEN CALL write_finite_model_row(unit, t, channels, lines, points, models, output_work, ErrStat, ErrMsg, & motion, step + 1) @@ -24376,6 +24425,7 @@ SUBROUTINE write_finite_dynamic_out(out_root, channels, lines, points, opts, mod CALL close_dynamic_line_outputs(pos_units, ten_units) RETURN END IF + CALL CD_Profile_Enter(CD_PROF_PROGRESS) CALL update_driver_progress(progress, step, t) END DO CLOSE (unit) @@ -25790,6 +25840,9 @@ SUBROUTINE start_driver_progress(progress, nstep, dt) INTEGER, INTENT(IN) :: nstep REAL(wp), INTENT(IN) :: dt + ! the run so far (model build, statics, initial outputs) was the initialisation phase; the + ! march starts with the fluid update of its first step + CALL CD_Profile_Enter(MERGE(CD_PROF_FINAL, CD_PROF_FLUID, nstep <= 0)) progress%nstep = nstep progress%report_stride = MAX(1, (nstep + 19)/20) IF (nstep <= 0) RETURN @@ -25814,23 +25867,26 @@ SUBROUTINE update_driver_progress(progress, step, simulated_time) ! Every committed step: the time an abnormal end of the process reports. CALL CD_Fatal_Report_Time(simulated_time) - IF (progress%nstep <= 0 .OR. step <= 0) RETURN - IF (step < progress%nstep .AND. MOD(step, progress%report_stride) /= 0) RETURN - CALL SYSTEM_CLOCK(now) - IF (progress%count_rate > 0_int64 .AND. now >= progress%start_count) THEN - elapsed = REAL(now - progress%start_count, wp)/REAL(progress%count_rate, wp) - ELSE - elapsed = CD_ZERO - END IF - remaining = CD_ZERO - IF (step < progress%nstep .AND. elapsed > CD_ZERO) & - remaining = elapsed*REAL(progress%nstep - step, wp)/REAL(step, wp) - percent = 100.0_wp*REAL(step, wp)/REAL(progress%nstep, wp) - elapsed_text = wall_time_text(elapsed) - remaining_text = wall_time_text(remaining) - WRITE (output_unit, '(A,F6.1,A,F12.3,A,A,A,A)') ' Progress: ', percent, '% | t = ', & - simulated_time, ' s | elapsed ', TRIM(elapsed_text), ' | ETA ', TRIM(remaining_text) - FLUSH (output_unit) + IF (progress%nstep > 0 .AND. step > 0 .AND. & + (step >= progress%nstep .OR. MOD(step, progress%report_stride) == 0)) THEN + CALL SYSTEM_CLOCK(now) + IF (progress%count_rate > 0_int64 .AND. now >= progress%start_count) THEN + elapsed = REAL(now - progress%start_count, wp)/REAL(progress%count_rate, wp) + ELSE + elapsed = CD_ZERO + END IF + remaining = CD_ZERO + IF (step < progress%nstep .AND. elapsed > CD_ZERO) & + remaining = elapsed*REAL(progress%nstep - step, wp)/REAL(step, wp) + percent = 100.0_wp*REAL(step, wp)/REAL(progress%nstep, wp) + elapsed_text = wall_time_text(elapsed) + remaining_text = wall_time_text(remaining) + WRITE (output_unit, '(A,F6.1,A,F12.3,A,A,A,A)') ' Progress: ', percent, '% | t = ', & + simulated_time, ' s | elapsed ', TRIM(elapsed_text), ' | ETA ', TRIM(remaining_text) + FLUSH (output_unit) + END IF + ! the next step starts with its fluid update; after the last step the run finalises + CALL CD_Profile_Enter(MERGE(CD_PROF_FINAL, CD_PROF_FLUID, step >= progress%nstep)) END SUBROUTINE update_driver_progress PURE FUNCTION wall_time_text(seconds) RESULT(text) diff --git a/src/CableDyn_Model.f90 b/src/CableDyn_Model.f90 index c39010ce..b2eb699f 100644 --- a/src/CableDyn_Model.f90 +++ b/src/CableDyn_Model.f90 @@ -58,6 +58,7 @@ MODULE CableDyn_Model USE CableDyn_Mesh, ONLY: CD_Partition_Free_Dofs, CD_Validate_Connectivity USE CableDyn_Linalg, ONLY: CD_Solve_Dense_As_Banded, CD_Solve_Dense_As_Banded_Multiple, CD_Factor_Banded, & CD_Solve_Factored_Banded_Multiple + USE CableDyn_Profile, ONLY: CD_Profile_Count_Line_Step IMPLICIT NONE PRIVATE @@ -1815,6 +1816,7 @@ SUBROUTINE CD_Step_Model(model, dt, converged, stalled, n_iter, ErrStat, ErrMsg, n_iter, es, em, workspace=model%dynamic_workspace) END IF model%ve_dt = CD_ZERO + CALL CD_Profile_Count_Line_Step(n_iter) IF (es /= CD_DYN_OK) THEN ErrStat = model_status_from_dyn(es) ErrMsg = 'CableDyn_Model: step failed: '//TRIM(em) diff --git a/src/CableDyn_Profile.f90 b/src/CableDyn_Profile.f90 new file mode 100644 index 00000000..c40fcb92 --- /dev/null +++ b/src/CableDyn_Profile.f90 @@ -0,0 +1,129 @@ +! File: src/CableDyn_Profile.f90 +! SPDX-License-Identifier: Apache-2.0 +! Copyright (c) 2026 Jae Hoon Seo, SMI Lab, Inha University +MODULE CableDyn_Profile + !! Opt-in wall-clock profile of a standalone driver run, requested with the environment + !! variable CABLEDYN_PROFILE (as for the OpenFAST module). + !! + !! The driver arms it once at start, in the input phase. The run then marks where each phase + !! begins: CD_Profile_Enter(phase) adds the time since the previous mark to the phase that + !! was running and makes phase the running one, so the phases partition the run exactly and + !! a run that stops with an error has its time up to the stop in the phase it stopped in. + !! Each time march enters its fluid update, its step, its checks, its output and its + !! progress report in turn; CD_Profile_Step counts the committed steps. CD_Step_Model counts + !! the EI = 0 line steps and their Newton iterations. Unarmed, every entry point returns after + !! one test, so a run that does not ask for the profile, and a host that loads the library, + !! are not affected. The state is process-global and serves one run: the phase marks are + !! taken on the driver's thread, and the line-step counters are updated atomically because + !! lines step concurrently. + USE, INTRINSIC :: ISO_FORTRAN_ENV, ONLY: int64 + USE CableDyn_Precision, ONLY: wp + IMPLICIT NONE + PRIVATE + PUBLIC :: CD_Profile_Requested, CD_Profile_Arm, CD_Profile_Armed, CD_Profile_Enter, CD_Profile_Flush, & + CD_Profile_Step, CD_Profile_Count_Line_Step, CD_Profile_Seconds, CD_Profile_Counts + + INTEGER, PARAMETER, PUBLIC :: CD_PROF_INPUT = 1 ! deck parsing and auxiliary input files + INTEGER, PARAMETER, PUBLIC :: CD_PROF_INIT = 2 ! model build, static equilibrium, initial outputs + INTEGER, PARAMETER, PUBLIC :: CD_PROF_FLUID = 3 ! march: deck waves and current sampled by the driver + INTEGER, PARAMETER, PUBLIC :: CD_PROF_SOLVE = 4 ! march: line, cable and object steps + INTEGER, PARAMETER, PUBLIC :: CD_PROF_CHECK = 5 ! march: plausibility checks and line failures + INTEGER, PARAMETER, PUBLIC :: CD_PROF_OUTPUT = 6 ! march: output channels, line files, range graphs + INTEGER, PARAMETER, PUBLIC :: CD_PROF_PROGRESS = 7 ! march: progress report and bookkeeping + INTEGER, PARAMETER, PUBLIC :: CD_PROF_FINAL = 8 ! after the march: closing files, range files + INTEGER, PARAMETER, PUBLIC :: CD_PROF_NPHASE = 8 + + LOGICAL, SAVE :: armed = .FALSE. + INTEGER, SAVE :: current = CD_PROF_INPUT + INTEGER(int64), SAVE :: rate = 0_int64, last = 0_int64 + INTEGER(int64), SAVE :: ticks(CD_PROF_NPHASE) = 0_int64 + INTEGER(int64), SAVE :: n_march_steps = 0_int64, n_line_steps = 0_int64, n_line_iter = 0_int64 + INTEGER, SAVE :: max_line_iter = 0 + +CONTAINS + + LOGICAL FUNCTION CD_Profile_Requested() RESULT(requested) + !! TRUE when CABLEDYN_PROFILE is set to a non-empty value other than 0. + CHARACTER(32) :: value + INTEGER :: stat + value = '' + CALL GET_ENVIRONMENT_VARIABLE('CABLEDYN_PROFILE', value, STATUS=stat) + requested = stat == 0 .AND. LEN_TRIM(value) > 0 .AND. TRIM(value) /= '0' + END FUNCTION CD_Profile_Requested + + SUBROUTINE CD_Profile_Arm() + !! Zero the phases and counters and start the clock in the input phase. + ticks = 0_int64 + n_march_steps = 0_int64 + n_line_steps = 0_int64 + n_line_iter = 0_int64 + max_line_iter = 0 + current = CD_PROF_INPUT + CALL SYSTEM_CLOCK(last, rate) + armed = rate > 0_int64 + END SUBROUTINE CD_Profile_Arm + + LOGICAL FUNCTION CD_Profile_Armed() RESULT(is_armed) + is_armed = armed + END FUNCTION CD_Profile_Armed + + SUBROUTINE CD_Profile_Enter(phase) + !! Add the wall time since the previous mark to the running phase, and run phase (a + !! CD_PROF_* value) from here. + INTEGER, INTENT(IN) :: phase + IF (.NOT. armed) RETURN + IF (phase < 1 .OR. phase > CD_PROF_NPHASE) RETURN + CALL CD_Profile_Flush() + current = phase + END SUBROUTINE CD_Profile_Enter + + SUBROUTINE CD_Profile_Flush() + !! Add the wall time since the previous mark to the running phase, which keeps running. + INTEGER(int64) :: now + IF (.NOT. armed) RETURN + CALL SYSTEM_CLOCK(now) + ticks(current) = ticks(current) + (now - last) + last = now + END SUBROUTINE CD_Profile_Flush + + SUBROUTINE CD_Profile_Step() + !! Count a committed step of the march. + IF (.NOT. armed) RETURN + n_march_steps = n_march_steps + 1_int64 + END SUBROUTINE CD_Profile_Step + + SUBROUTINE CD_Profile_Count_Line_Step(n_iter) + !! Count one EI = 0 line step (a nominal step, a recovery substep or a retry) and its + !! Newton iterations. Lines of a system step in an OpenMP team, so the updates are atomic. + INTEGER, INTENT(IN) :: n_iter + INTEGER(int64) :: iterations + IF (.NOT. armed) RETURN + iterations = INT(MAX(0, n_iter), int64) + !$OMP ATOMIC UPDATE + n_line_steps = n_line_steps + 1_int64 + !$OMP ATOMIC UPDATE + n_line_iter = n_line_iter + iterations + !$OMP ATOMIC UPDATE + max_line_iter = MAX(max_line_iter, n_iter) + END SUBROUTINE CD_Profile_Count_Line_Step + + REAL(wp) FUNCTION CD_Profile_Seconds(phase) RESULT(seconds) + !! Wall time attributed to phase so far [s]; zero when the profile is not armed. + INTEGER, INTENT(IN) :: phase + seconds = 0.0_wp + IF (.NOT. armed) RETURN + IF (phase < 1 .OR. phase > CD_PROF_NPHASE) RETURN + seconds = REAL(ticks(phase), wp)/REAL(rate, wp) + END FUNCTION CD_Profile_Seconds + + SUBROUTINE CD_Profile_Counts(march_steps, line_steps, line_iterations, line_max_iterations) + !! Committed march steps, EI = 0 line steps, their Newton iterations and the most in one step. + INTEGER(int64), INTENT(OUT) :: march_steps, line_steps, line_iterations + INTEGER, INTENT(OUT) :: line_max_iterations + march_steps = n_march_steps + line_steps = n_line_steps + line_iterations = n_line_iter + line_max_iterations = max_line_iter + END SUBROUTINE CD_Profile_Counts + +END MODULE CableDyn_Profile diff --git a/tests/check_driver_profile.cmake b/tests/check_driver_profile.cmake new file mode 100644 index 00000000..56aee54d --- /dev/null +++ b/tests/check_driver_profile.cmake @@ -0,0 +1,89 @@ +# SPDX-License-Identifier: Apache-2.0 +# The run-time profile of the standalone driver (CABLEDYN_PROFILE). The same deck runs +# without the variable, with CABLEDYN_PROFILE=0 and with CABLEDYN_PROFILE=1. Only the last +# run prints the profile, before the success line, which stays the last stdout line; its +# phase rows and step counts are present; and every output file of the three runs is +# byte-identical, so the profile never changes a result. +# Optional: EXPECT (a regular expression the profiled stdout must also match). +if(NOT DEFINED DRIVER OR NOT DEFINED DECK OR NOT DEFINED OUTPUT_ROOT) + message(FATAL_ERROR "DRIVER, DECK, and OUTPUT_ROOT are required") +endif() + +function(run_driver label profile_value) + if(profile_value STREQUAL "") + unset(ENV{CABLEDYN_PROFILE}) + else() + set(ENV{CABLEDYN_PROFILE} "${profile_value}") + endif() + execute_process( + COMMAND "${DRIVER}" "${DECK}" "${OUTPUT_ROOT}_${label}" + RESULT_VARIABLE result + OUTPUT_VARIABLE out + ERROR_VARIABLE err) + if(NOT result EQUAL 0) + message(FATAL_ERROR "${label} run returned ${result}, expected 0\nstdout:\n${out}\nstderr:\n${err}") + endif() + set(stdout_${label} "${out}" PARENT_SCOPE) +endfunction() + +run_driver(unset "") +run_driver(zero "0") +run_driver(profiled "1") + +foreach(label unset zero) + if(stdout_${label} MATCHES "Run-time profile") + message(FATAL_ERROR "the ${label} run printed a profile:\n${stdout_${label}}") + endif() +endforeach() + +set(profiled "${stdout_profiled}") +foreach(row + "Run-time profile armed by CABLEDYN_PROFILE\\." + "Run-time profile \\(CABLEDYN_PROFILE\\), wall-clock time:" + "\n input parsing +[0-9]+\\.[0-9]+ s +[0-9]+\\.[0-9] %" + "\n initialisation and statics +[0-9]+\\.[0-9]+ s" + "\n dynamic march +[0-9]+\\.[0-9]+ s" + "\n fluid sampled by the driver +[0-9]+\\.[0-9]+ s" + "\n line, cable and object steps +[0-9]+\\.[0-9]+ s" + "\n checks and line failures +[0-9]+\\.[0-9]+ s" + "\n outputs +[0-9]+\\.[0-9]+ s" + "\n progress and bookkeeping +[0-9]+\\.[0-9]+ s" + "\n finalisation +[0-9]+\\.[0-9]+ s" + "\n total +[0-9]+\\.[0-9]+ s +100\\.0 %" + "\n March: [1-9][0-9]* committed step\\(s\\), [0-9]+\\.[0-9]+ ms per step\\.") + if(NOT profiled MATCHES "${row}") + message(FATAL_ERROR "the profiled stdout lacks \"${row}\":\n${profiled}") + endif() +endforeach() +if(DEFINED EXPECT AND NOT profiled MATCHES "${EXPECT}") + message(FATAL_ERROR "the profiled stdout lacks \"${EXPECT}\":\n${profiled}") +endif() +# the profile comes before the success line, which stays the last stdout line +string(STRIP "${profiled}" profiled_stripped) +if(NOT profiled_stripped MATCHES "\n total [^\n]*\n.*CableDyn_driver: converged run written to [^\n]*$") + message(FATAL_ERROR "the success line is not the last stdout line after the profile:\n${profiled}") +endif() + +# every output file of the reference run, byte-identical in the other two runs +get_filename_component(out_dir "${OUTPUT_ROOT}" DIRECTORY) +get_filename_component(out_name "${OUTPUT_ROOT}" NAME) +file(GLOB reference_files "${out_dir}/${out_name}_unset*") +list(FILTER reference_files EXCLUDE REGEX "\\.lock$") +list(LENGTH reference_files n_files) +if(n_files EQUAL 0) + message(FATAL_ERROR "the reference run wrote no output files under ${OUTPUT_ROOT}_unset") +endif() +foreach(reference IN LISTS reference_files) + file(SHA256 "${reference}" reference_hash) + foreach(label zero profiled) + string(REPLACE "${out_name}_unset" "${out_name}_${label}" other "${reference}") + if(NOT EXISTS "${other}") + message(FATAL_ERROR "the ${label} run did not write ${other}") + endif() + file(SHA256 "${other}" other_hash) + if(NOT other_hash STREQUAL reference_hash) + message(FATAL_ERROR "${other} differs from ${reference}: the profile changed a result") + endif() + endforeach() +endforeach() +message(STATUS "driver profile: ${n_files} output file(s) identical with and without the profile") diff --git a/tests/check_driver_profile_failure.cmake b/tests/check_driver_profile_failure.cmake new file mode 100644 index 00000000..ff924c4c --- /dev/null +++ b/tests/check_driver_profile_failure.cmake @@ -0,0 +1,31 @@ +# SPDX-License-Identifier: Apache-2.0 +# The run-time profile of a run that stops with an error (CABLEDYN_PROFILE): the deck's march +# fails to converge, the driver exits with code 2, and the profile it prints before the closing +# line charges the time up to the stop to the phase that was running, not to the finalisation +# the run never reached (which stays exactly zero). +if(NOT DEFINED DRIVER OR NOT DEFINED DECK OR NOT DEFINED OUTPUT_ROOT) + message(FATAL_ERROR "DRIVER, DECK, and OUTPUT_ROOT are required") +endif() + +set(ENV{CABLEDYN_PROFILE} "1") +execute_process( + COMMAND "${DRIVER}" "${DECK}" "${OUTPUT_ROOT}" + RESULT_VARIABLE result + OUTPUT_VARIABLE out + ERROR_VARIABLE err) +if(NOT result EQUAL 2) + message(FATAL_ERROR "the run returned ${result}, expected 2\nstdout:\n${out}\nstderr:\n${err}") +endif() +foreach(row + "Run-time profile \\(CABLEDYN_PROFILE\\), wall-clock time:" + "\n dynamic march +[0-9]+\\.[0-9]+ s" + "\n finalisation +0\\.000 s +0\\.0 %" + "\n total +[0-9]+\\.[0-9]+ s +100\\.0 %") + if(NOT out MATCHES "${row}") + message(FATAL_ERROR "the stdout of the failed run lacks \"${row}\":\n${out}") + endif() +endforeach() +if(NOT err MATCHES "CableDyn_driver: ended with exit code 2") + message(FATAL_ERROR "the stderr of the failed run lacks the closing line:\n${err}") +endif() +message(STATUS "driver profile of a failed run: no time charged to finalisation") diff --git a/tests/test_profile.f90 b/tests/test_profile.f90 new file mode 100644 index 00000000..ed1244a2 --- /dev/null +++ b/tests/test_profile.f90 @@ -0,0 +1,126 @@ +! File: tests/test_profile.f90 +! SPDX-License-Identifier: Apache-2.0 +! Copyright (c) 2026 Jae Hoon Seo, SMI Lab, Inha University +PROGRAM test_profile + !! The run-time profile of the driver (CableDyn_Profile): + !! 1. Unarmed, it records nothing. + !! 2. Armed, the phases partition the elapsed time: each mark charges the time since the + !! previous one to the phase that was running, so their sum is the time from arming to + !! the last flush. + !! 3. Time spent in a phase that never hands over (a run that stops with an error) stays + !! in that phase when the report flushes it, and a phase never entered (the + !! finalisation of such a run) stays exactly zero. + !! 4. The EI = 0 line-step counters are exact when the lines of an OpenMP team update them + !! at once. + USE CableDyn_Precision, ONLY: wp + USE CableDyn_Profile + USE CableDyn_FatalReport, ONLY: CD_Fatal_Thread_Init + USE, INTRINSIC :: ISO_FORTRAN_ENV, ONLY: int64 + IMPLICIT NONE + INTEGER :: nfail + + nfail = 0 + CALL case_unarmed() + CALL case_partition_and_failure() + CALL case_concurrent_counts() + IF (nfail > 0) THEN + WRITE (*, '(A,I0,A)') 'test_profile: ', nfail, ' failure(s)' + ERROR STOP 1 + END IF + WRITE (*, '(A)') 'test_profile: all checks passed' + +CONTAINS + + SUBROUTINE require(cond, label) + LOGICAL, INTENT(IN) :: cond + CHARACTER(*), INTENT(IN) :: label + IF (.NOT. cond) THEN + WRITE (*, '(A)') 'MISMATCH ['//label//']' + nfail = nfail + 1 + END IF + END SUBROUTINE require + + SUBROUTINE busy(seconds) + !! Spin for at least the given wall time. + REAL(wp), INTENT(IN) :: seconds + INTEGER(int64) :: c0, c, rate + CALL SYSTEM_CLOCK(c0, rate) + DO + CALL SYSTEM_CLOCK(c) + IF (REAL(c - c0, wp) >= seconds*REAL(rate, wp)) EXIT + END DO + END SUBROUTINE busy + + REAL(wp) FUNCTION total_seconds() RESULT(s) + INTEGER :: k + s = 0.0_wp + DO k = 1, CD_PROF_NPHASE + s = s + CD_Profile_Seconds(k) + END DO + END FUNCTION total_seconds + + SUBROUTINE case_unarmed() + INTEGER(int64) :: march, steps, iterations + INTEGER :: max_iterations + CALL require(.NOT. CD_Profile_Armed(), 'unarmed:not-armed-at-start') + CALL CD_Profile_Enter(CD_PROF_SOLVE) + CALL busy(0.002_wp) + CALL CD_Profile_Flush() + CALL CD_Profile_Step() + CALL CD_Profile_Count_Line_Step(4) + CALL CD_Profile_Counts(march, steps, iterations, max_iterations) + CALL require(total_seconds() <= 0.0_wp, 'unarmed:no-time') + CALL require(march == 0 .AND. steps == 0 .AND. iterations == 0 .AND. max_iterations == 0, 'unarmed:no-counts') + END SUBROUTINE case_unarmed + + SUBROUTINE case_partition_and_failure() + INTEGER(int64) :: c0, c1, rate + REAL(wp) :: elapsed + CALL SYSTEM_CLOCK(c0, rate) + CALL CD_Profile_Arm() + CALL require(CD_Profile_Armed(), 'phases:armed') + CALL busy(0.010_wp) ! input + CALL CD_Profile_Enter(CD_PROF_INIT) + CALL busy(0.020_wp) ! initialisation + CALL CD_Profile_Enter(CD_PROF_SOLVE) + CALL busy(0.030_wp) ! a step that stops with an error: no further mark + CALL CD_Profile_Flush() ! the report of the failed run + CALL SYSTEM_CLOCK(c1) + elapsed = REAL(c1 - c0, wp)/REAL(rate, wp) + CALL require(CD_Profile_Seconds(CD_PROF_INPUT) >= 0.010_wp, 'phases:input') + CALL require(CD_Profile_Seconds(CD_PROF_INIT) >= 0.020_wp, 'phases:initialisation') + CALL require(CD_Profile_Seconds(CD_PROF_SOLVE) >= 0.030_wp, 'phases:failed-step-stays-in-its-phase') + CALL require(CD_Profile_Seconds(CD_PROF_FINAL) <= 0.0_wp, 'phases:finalisation-never-entered-is-zero') + CALL require(total_seconds() >= 0.060_wp .AND. total_seconds() <= elapsed, 'phases:sum-is-the-elapsed-time') + ! a second flush adds the new time to the same running phase + CALL busy(0.005_wp) + CALL CD_Profile_Flush() + CALL require(CD_Profile_Seconds(CD_PROF_SOLVE) >= 0.035_wp .AND. CD_Profile_Seconds(CD_PROF_FINAL) <= 0.0_wp, & + 'phases:flush-keeps-the-running-phase') + ! re-arming starts a new profile + CALL CD_Profile_Arm() + CALL require(total_seconds() <= 0.0_wp, 'phases:re-armed-from-zero') + END SUBROUTINE case_partition_and_failure + + SUBROUTINE case_concurrent_counts() + INTEGER, PARAMETER :: N = 20000 + INTEGER(int64) :: march, steps, iterations + INTEGER :: max_iterations, i + CALL CD_Profile_Arm() + !$OMP PARALLEL NUM_THREADS(4) DEFAULT(SHARED) PRIVATE(i) + CALL CD_Fatal_Thread_Init() + !$OMP DO SCHEDULE(STATIC) + DO i = 1, N + CALL CD_Profile_Count_Line_Step(MOD(i, 7)) + END DO + !$OMP END DO + !$OMP END PARALLEL + CALL CD_Profile_Step() + CALL CD_Profile_Counts(march, steps, iterations, max_iterations) + CALL require(march == 1, 'counts:march-steps') + CALL require(steps == N, 'counts:line-steps-exact') + CALL require(iterations == SUM([(INT(MOD(i, 7), int64), i=1, N)]), 'counts:newton-iterations-exact') + CALL require(max_iterations == 6, 'counts:most-iterations') + END SUBROUTINE case_concurrent_counts + +END PROGRAM test_profile From 4d706a99c6424cb4e389ae74bf3ac9e54ab2e2fe Mon Sep 17 00:00:00 2001 From: Jae Hoon Seo Date: Wed, 14 Oct 2026 22:55:23 +0900 Subject: [PATCH 04/31] perf: reuse the clamped-cable Jacobian columns across body steps (#10) Profiling a buoy with a clamped power cable showed 77 % of the run in cable steps: 4849 of them for 600 march steps. Each monolithic step took one outer iteration, then rebuilt the junction Jacobian, whose clamped- cable part is six finite-difference columns, each re-stepping the whole cable from the step entry, and converged at the second iteration: eight cable steps per step. The cable columns are now kept per cable and reused across steps, with the refresh rules of the mooring lines' condensed tangent: rebuilt on a step's first Jacobian when they are 20 steps old, when the previous step needed more than two outer iterations, or when the step size changed (step halving), and on every Jacobian from the third outer iteration on; a failed step discards them. A fresh build adds the same values as before. The cache spans the largest junction group, a body's six coordinates plus three for each rod pinned to it. examples/buoy_clamped_cable.dat runs in 2.25 s instead of 6.60 s with the release build, with the same mean outer iterations (2.01). The junction still converges to its tolerance, so results change within it: tensions by about 2e-6 relative, the body position by under 1 um, the body pitch moment by 2 N m on a 11 kN m channel. Against a run converged to 1e-10, the previous code already differed by 1.7 N m on that channel; at that tolerance both versions agree to 7e-8. Decks without a clamped cable are unchanged. A new test deck runs a clamped cable on a body that also holds a pinned rod. Signed-off-by: Jae Hoon Seo --- CHANGELOG.md | 9 +++ CMakeLists.txt | 10 +++ src/CableDyn_DeckDriver.f90 | 57 ++++++++++++-- tests/data/buoy_clamped_cable_pinned_rod.dat | 83 ++++++++++++++++++++ 4 files changed, 152 insertions(+), 7 deletions(-) create mode 100644 tests/data/buoy_clamped_cable_pinned_rod.dat diff --git a/CHANGELOG.md b/CHANGELOG.md index 4bba0978..d449f5b8 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -29,6 +29,15 @@ All notable changes to CableDyn are recorded in this file. The format follows are unchanged. With gfortran the results are bit-identical. With the Intel compiler of the release, which had computed the second cosine through a fused sine/cosine evaluation, they can differ in the last printed digit. +- Faster monolithic body steps with a finite-EI cable clamped or elastically connected to a + body or rod. The cable's finite-difference columns of the junction Jacobian, each of which + re-steps the whole cable, are now kept and reused across steps like the mooring lines' + condensed tangent. They are rebuilt when 20 steps old, after a step that needed more than two + outer iterations, when the step size changes, and from the third outer iteration of a step. + `examples/buoy_clamped_cable.dat` runs 66 % faster with the release build, with the same + outer iterations per step. The junction converges to the same tolerance, so results differ + only within it, and by no more than the tolerance already allowed against a tightly converged + run: tensions by about 2e-6 relative and the body position by under 1 µm. ### Fixed diff --git a/CMakeLists.txt b/CMakeLists.txt index 83eb7c1f..0f05fc1b 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -1999,6 +1999,16 @@ add_test(NAME driver_clamped_buoyant_held -DWORKDIR=${CMAKE_CURRENT_BINARY_DIR}/driver_clamped_buoyant_held -P ${CMAKE_CURRENT_SOURCE_DIR}/tests/check_driver_output.cmake) set_tests_properties(driver_clamped_buoyant_held PROPERTIES LABELS "fortran;driver;integration;static") +# A clamped finite-EI cable on a Rigid6 body that also holds a pinned rod: the body's junction +# group has nine coordinates, which the cable's kept Jacobian columns must span (the Debug +# build's bounds checks catch a cache sized for six). +add_test(NAME driver_clamped_cable_pinned_rod + COMMAND ${CMAKE_COMMAND} -DDRIVER=$ -DEXPECT_RC=0 + "-DARGS=${CMAKE_CURRENT_SOURCE_DIR}/tests/data/buoy_clamped_cable_pinned_rod.dat|pinned" + "-DONCE=converged run written" + -DWORKDIR=${CMAKE_CURRENT_BINARY_DIR}/driver_clamped_cable_pinned_rod + -P ${CMAKE_CURRENT_SOURCE_DIR}/tests/check_driver_output.cmake) +set_tests_properties(driver_clamped_cable_pinned_rod PROPERTIES LABELS "fortran;driver;integration") if(WIN32 AND CABLEDYN_RUNTIME_DLLS) add_test( diff --git a/src/CableDyn_DeckDriver.f90 b/src/CableDyn_DeckDriver.f90 index fb5d855e..3fe730e6 100644 --- a/src/CableDyn_DeckDriver.f90 +++ b/src/CableDyn_DeckDriver.f90 @@ -805,6 +805,12 @@ MODULE CableDyn_DeckDriver INTEGER :: n_outer = 0, max_outer = 0, n_steps_imp = 0, n_subdiv = 0 ! condensed line tangent reuse: steps since the last refresh and the last step's outer count INTEGER :: tan_age = HUGE(1), last_outer = 0, n_refresh = 0 + ! clamped-cable Jacobian reuse: each clamped cable's finite-difference contribution to the + ! junction Jacobian over its object's group (cab_jac(1:n, 1:n, c), rows and columns from the + ! group's first coordinate), the steps since it was built and the step size it was built for + REAL(wp), ALLOCATABLE :: cab_jac(:, :, :) + INTEGER :: cab_age = HUGE(1) + REAL(wp) :: cab_dt = CD_ZERO INTEGER, ALLOCATABLE :: jb_off(:), jr_off(:), jp_off(:), g_kind(:), g_idx(:), g_lo(:), g_hi(:) LOGICAL, ALLOCATABLE :: jactive(:), is_rot(:) ! jobj: coupled DOFs driven by a body or rod (the objects' trapezoidal levels at the line @@ -16427,6 +16433,7 @@ SUBROUTINE write_multibody_dynamic_out(deck_path, out_root, channels, types, bod mb%cab_off(3, SIZE(cab_lines)), mb%cab_force(3, SIZE(cab_lines)), & mb%cab_clamp(SIZE(cab_lines)), mb%cab_moment(3, SIZE(cab_lines)), mb%cab_fend(3, SIZE(cab_lines)), & mb%cab_mend(3, SIZE(cab_lines)), mb%cab_f0(3, SIZE(cab_lines)), mb%cab_m0(3, SIZE(cab_lines))) + mb%cab_age = HUGE(1) mb%cab_kind = 0 mb%cab_obj = 0 mb%cab_off = CD_ZERO @@ -17672,6 +17679,16 @@ SUBROUTINE mb_junction_layout(mb, points) mb%is_rot(mb%jr_off(ir) + 4:mb%jr_off(ir) + 6) = .TRUE. END IF END DO + ! the clamped cables' kept Jacobian columns span a whole group: a body's six coordinates + ! and three for each rod pinned to it + IF (ALLOCATED(mb%cables)) THEN + IF (ALLOCATED(mb%cab_jac)) DEALLOCATE (mb%cab_jac) + k = 1 + IF (mb%ng > 0) k = MAX(k, MAXVAL(mb%g_hi(1:mb%ng) - mb%g_lo(1:mb%ng) + 1)) + ALLOCATE (mb%cab_jac(k, k, SIZE(mb%cables))) + mb%cab_jac = CD_ZERO + mb%cab_age = HUGE(1) + END IF CONTAINS SUBROUTINE add_group(kind, idx) INTEGER, INTENT(IN) :: kind, idx @@ -18112,8 +18129,8 @@ RECURSIVE SUBROUTINE mb_step_implicit(mb, points, opts, time, dt, converged, sta ! times the object length scale); the line reactions carry the inner tolerance REAL(wp), PARAMETER :: JUNCTION_TOL = 1.0e-6_wp, PREDICTOR_TOL = 1.0e-9_wp CHARACTER(24) :: tstr - INTEGER :: dep, it, g, c, ib, ir, p, o, es, lit, nj, gworst, it2 - LOGICAL :: lconv, lstall, first, ok, conv2, stall2, refresh, lines_stepped, tors_turn, lim + INTEGER :: dep, it, g, c, ib, ir, p, o, es, lit, nj, gworst, it2, gsz + LOGICAL :: lconv, lstall, first, ok, conv2, stall2, refresh, lines_stepped, tors_turn, lim, cab_refresh INTEGER, PARAMETER :: TAN_MAX_AGE = 20 REAL(wp) :: rho, am, af, beta_na, gam_na, t_af, h, fac, dth, worst, tol_it, am_p, gam_p, beta_p REAL(wp), ALLOCATABLE :: x(:), xp(:), r(:), rp(:), jac(:, :), dx(:), kg(:, :), ga(:, :), rscale(:) @@ -18194,6 +18211,7 @@ RECURSIVE SUBROUTINE mb_step_implicit(mb, points, opts, time, dt, converged, sta lines_stepped = .FALSE. ok = .FALSE. tors_turn = .FALSE. + cab_refresh = .FALSE. gworst = 0 DO it = 1, MAX_OUTER ! a body holding a line restrained in torsion turns by less than pi/2 per step: the line @@ -18284,6 +18302,7 @@ RECURSIVE SUBROUTINE mb_step_implicit(mb, points, opts, time, dt, converged, sta mb%max_outer = MAX(mb%max_outer, it) mb%last_outer = it IF (mb%tan_age < HUGE(1)) mb%tan_age = mb%tan_age + 1 + IF (mb%cab_age < HUGE(1)) mb%cab_age = mb%cab_age + 1 EXIT END IF IF (it == MAX_OUTER) EXIT @@ -18316,15 +18335,36 @@ RECURSIVE SUBROUTINE mb_step_implicit(mb, points, opts, time, dt, converged, sta ! clamped cables: their end force and moment follow the object motion within the step; the ! condensed dynamic end tangent (translations and rotations of the attachment) enters by ! finite differences of the cable step over the columns of the object's group, each - ! perturbing the end-of-step pose by CABLE_FD rad or m + ! perturbing the end-of-step pose by CABLE_FD rad or m. Each column re-steps the whole + ! cable, so the columns are kept and reused like the lines' condensed tangent: rebuilt on + ! the first Jacobian of a step when they are TAN_MAX_AGE steps old, the previous step + ! needed more than two outer iterations or the step size changed, and on every Jacobian + ! from the third outer iteration on. A Newton with reused columns converges to the same + ! junction tolerance. + IF (it == 1) THEN + cab_refresh = mb%cab_age >= TAN_MAX_AGE .OR. mb%last_outer > 2 .OR. ABS(dt - mb%cab_dt) > CD_ZERO + ELSE + cab_refresh = cab_refresh .OR. it >= 3 + END IF DO c = 1, SIZE(mb%cables) IF (.NOT. mb%cab_clamp(c)) CYCLE g = mb_cable_group(mb, c) IF (g == 0) CYCLE - CALL cable_columns(c, g) - IF (ErrStat /= CD_DECKDRV_OK) EXIT + IF (cab_refresh) THEN + CALL cable_columns(c, g) + IF (ErrStat /= CD_DECKDRV_OK) EXIT + ELSE + gsz = mb%g_hi(g) - mb%g_lo(g) + 1 + jac(mb%g_lo(g):mb%g_hi(g), mb%g_lo(g):mb%g_hi(g)) = & + jac(mb%g_lo(g):mb%g_hi(g), mb%g_lo(g):mb%g_hi(g)) + mb%cab_jac(1:gsz, 1:gsz, c) + END IF END DO IF (ErrStat /= CD_DECKDRV_OK) EXIT + IF (cab_refresh) THEN + mb%cab_age = 0 + mb%cab_dt = dt + cab_refresh = .FALSE. + END IF dx = -r CALL CD_Solve_Dense_As_Banded(jac, dx, es, em) IF (es /= CD_LINALG_OK .OR. .NOT. ALL(IEEE_IS_FINITE(dx))) EXIT @@ -18360,6 +18400,7 @@ RECURSIVE SUBROUTINE mb_step_implicit(mb, points, opts, time, dt, converged, sta CALL CD_HFMF_Restore(mb%cables(c), es, em) END DO mb%tan_age = HUGE(1) + mb%cab_age = HUGE(1) IF (dep >= MAX_DEPTH) THEN IF (ErrStat == CD_DECKDRV_OK .AND. tors_turn) THEN WRITE (tstr, '(ES12.5)') time @@ -18402,7 +18443,8 @@ RECURSIVE SUBROUTINE mb_step_implicit(mb, points, opts, time, dt, converged, sta SUBROUTINE cable_columns(cc, gg) !! Add clamped cable cc's end-load derivative to the Jacobian columns of its group gg: !! the cable re-stepped from the step entry with each column perturbed, the group residual - !! re-evaluated at the unperturbed objects with the perturbed cable loads. + !! re-evaluated at the unperturbed objects with the perturbed cable loads. The columns are + !! also kept in mb%cab_jac for reuse. INTEGER, INTENT(IN) :: cc, gg REAL(wp), PARAMETER :: CABLE_FD = 1.0e-5_wp INTEGER :: col, lo, hi @@ -18432,7 +18474,8 @@ SUBROUTINE cable_columns(cc, gg) mb%cab_force(:, cc) = fsave mb%cab_moment(:, cc) = msave IF (ErrStat /= CD_DECKDRV_OK) RETURN - jac(lo:hi, col) = jac(lo:hi, col) + (rp(lo:hi) - r(lo:hi))/hc + mb%cab_jac(1:hi - lo + 1, col - lo + 1, cc) = (rp(lo:hi) - r(lo:hi))/hc + jac(lo:hi, col) = jac(lo:hi, col) + mb%cab_jac(1:hi - lo + 1, col - lo + 1, cc) END DO END SUBROUTINE cable_columns END SUBROUTINE mb_step_implicit diff --git a/tests/data/buoy_clamped_cable_pinned_rod.dat b/tests/data/buoy_clamped_cable_pinned_rod.dat new file mode 100644 index 00000000..20976ff4 --- /dev/null +++ b/tests/data/buoy_clamped_cable_pinned_rod.dat @@ -0,0 +1,83 @@ +--------------------- CableDyn Input File ------------------------------------ +Rigid6 buoy with a clamped finite-EI cable and a rod pinned to the buoy (test deck) +-- examples/buoy_clamped_cable.dat with a 7.8 m arm rod pinned to Body1 (Body1Pinned) and a 6 s +-- run. The body's junction group then has nine coordinates (six of the body, three of the pin), +-- and the clamped cable's finite-difference Jacobian columns, kept across steps, span all nine. +--------------------- 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) (-) (-) (-) (-) +poly 0.12 15.0 5.0e7 -1.0 0.0 1.2 0.2 1.0 0.0 +cable 0.20 60.0 5.0e8 -1.0 2.0e4 1.2 0.0 1.0 0.0 +--------------------- ROD TYPES ---------------------------------------- +Name Diam Mass Cd Ca CdEnd CaEnd +(-) (m) (kg/m) (-) (-) (-) (-) +arm 0.3 150.0 1.0 1.0 0.0 0.0 +--------------------- BODIES ------------------------------------------------- +ID Type X Y Z Roll Pitch Yaw Mass Vol C33 C44 C55 CdA Ca Ixx Iyy Izz +(-) (-) (m) (m) (m) (deg) (deg) (deg) (kg) (m3) (N/m) (Nm/rad) (Nm/rad) (m2) (-) (kgm2) (kgm2) (kgm2) +1 Rigid6 0.0 0.0 0.0 0.0 0.0 0.0 8.0e4 113.1 2.84e5 2.0e6 2.0e6 24.0 1.0 4.0e5 4.0e5 3.6e5 +--------------------- RODS --------------------------------------------- +ID RodType Attachment XA YA ZA XB YB ZB NumSegs Outputs +(-) (-) (-) (m) (m) (m) (m) (m) (m) (-) (-) +1 arm Body1Pinned 0.0 2.0 -4.0 0.0 8.0 -9.0 4 - +--------------------- POINTS ------------------------------------------------- +ID Type X Y Z Mass Vol CdA Ca +(-) (-) (m) (m) (m) (kg) (m^3) (m^2) (-) +1 Body1 3.0 0.0 -4.0 0 0 0 0 +2 Body1 -1.5 2.598 -4.0 0 0 0 0 +3 Body1 -1.5 -2.598 -4.0 0 0 0 0 +4 Body1 0.0 0.0 -4.0 0 0 0 0 +5 Fixed 60.0 0.0 -100.0 0 0 0 0 +6 Fixed -30.0 51.962 -100.0 0 0 0 0 +7 Fixed -30.0 -51.962 -100.0 0 0 0 0 +8 Fixed -60.0 0.0 -100.0 0 0 0 0 +--------------------- LINES -------------------------------------------------- +ID NodeA NodeB Outputs +(-) (-) (-) (-) +1 1 5 - +2 2 6 - +3 3 7 - +4 4 8 - +--------------------- SECTIONS ----------------------------------------------- +LineID LineType Length NumSegs +(-) (-) (m) (-) +1 poly 111.4 20 +2 poly 111.4 20 +3 poly 111.4 20 +4 cable 10.0 40 +4 cable 120.0 60 +--------------------- END CONNECTIONS ---------------------------------------- +LineID End Stiffness EzX EzY EzZ +(-) (-) (N-m/rad) (-) (-) (-) +4 A Rigid -0.5 0.0 -0.86603 +--------------------- OPTIONS ------------------------------------------------ +9.80665 g - Gravitational acceleration (m/s^2) [default: 9.80665] +1025.0 rhoW - Water density (kg/m^3) [default: 1025] +100.0 WtrDpth - Water depth (m) [default: absent standalone; host-owned OpenFAST] +1.0e5 kBot - Seabed penalty stiffness base (Pa/m) [default: 1.0e5] +1.0e4 cBot - Seabed normal damping base (Pa-s/m) [default: 1.0e4] +0.05 dtM - CableDyn internal time step (s) [default: omitted standalone; 0.1 s target OpenFAST] +6.0 TMax - Standalone simulation duration (s) [default: omitted standalone; host-owned OpenFAST] +static bodyIC - Free Rigid6 body / rod start {static=equilibrium; deck=deck pose} [default: static] +monolithic bodyScheme - Body time integration {monolithic; staggered}; a clamped End A needs monolithic [default: monolithic] +0.4 rhoInf - Generalised-alpha spectral radius {0<=rhoInf<=1} [default: 0.4] +False modified_newton - Tangent-reuse mode {False=full Newton; True=guarded reuse} [default: False] +False adaptive_mesh - Automatic finite-EI refinement {False; True} [default: False] +dynamic_solver 1.0e-8 1.0e-14 30 12 - Relative tolerance, absolute tolerance, max iterations, backtracks [defaults shown] +none frictionMu - Seabed friction coefficient {none; value>=0} [default: none] +none current - Current model and X/Y/Z velocity (m/s) {none; uniform; profile} [default: none] +airy 1.0 14.0 0.0 waves - Wave model, height, period, and direction (m, s, deg) {none; airy; jonswap} [default: none] +8.0 rampTime - Half-cosine start-up ramp of the wave amplitudes (s) [default: 0] +0 WaterKin - Water-kinematics source {0/none; file; SEASTATE coupled only} [default: no policy] +-- Complete option/default reference: cabledyn_options_reference.dat and doc/options.rst. +--------------------- OUTPUTS ------------------------------------------------ +"FairTen1" +"FairTen4" +"AnchTen4" +"Body1Px" +"Body1Pz" +"Body1Ry" +"Body1My" +"BendMom4N1" +"Curv4N1" +--------------------- need this line ----------------------------------------- From 13452d0507ac9e068c0ef6acb59c33f537d33d8e Mon Sep 17 00:00:00 2001 From: Jae Hoon Seo Date: Thu, 15 Oct 2026 00:28:06 +0900 Subject: [PATCH 05/31] feat: run lines restrained in torsion in coupled OpenFAST runs (#11) Torsion of finite-EI lines was the main feature of 0.1.1 but ran in the standalone driver only: the coupled entries refused any torsion column. Most of what the coupled route needs was already in place. The cable module turns a parent-attached End A frame with the host orientation, returns the torque moment with the connection moment, substeps a large turn within a step, and carries the unwrapped twist in its snapshot and checkpoint mirror. The OpenFAST and FAST.Farm shells pass the platform orientation every update. The aggregate and the single-cable entry now take a host_orientation flag, which the shells set: with it a deck with torsion columns builds, without it (the C API, the standalone mixed route, which move line ends by translation only) the deck is refused by name instead of running with a frozen fairlead frame. A coupled run is always dynamic, so the configuration blend is refused at initialisation as on the standalone route. Three shell changes complete it. The checkpoint rebuild moved the fairlead to the restart pose before it reloaded the cable mirror, so the preflight bounded the twist change against the static twist and a restart after more than 90 deg of turn failed; the rebuild now restores the torsion cables' mirror first. Linearisation now refuses a line restrained in torsion also at a bending-pinned end, whose torque stiffness the translation-only reduction would drop. The state registration subtracted the friction and force-blend slots but not the 14 torsion slots, so the velocity and position blocks were mislabelled. A new test, coupled_torsion, drives the aggregate: a rolled fairlead gives Twist1 = -roll and GJ(-roll)/L, a 60 deg/s roll the quasi-static torque at every step (bit-identical to the single coupled cable), 1.5 turns no 2 pi slip; rewind, refusal of a 100 deg non-stepping turn, PtfmInit, a FAST.Farm turbine yaw, and the checkpoint recipe after 150 deg (the previous order is refused) are checked. In an OpenFAST build, the IEA-15 MW mixed deck with its power cable restrained in torsion runs 60 s in waves and restarts from a checkpoint bit-identically. Signed-off-by: Jae Hoon Seo --- CHANGELOG.md | 8 + CMakeLists.txt | 5 + VALIDATION.md | 26 +- doc/capabilities.rst | 16 +- doc/driver_format.md | 20 +- doc/openfast.rst | 19 + doc/troubleshooting.rst | 17 +- python/cabledyn/deck_file.py | 29 +- python/tests/test_deck_native_parity.py | 17 +- src/CableDyn_DeckDriver.f90 | 50 ++- src/CableDyn_OpenFAST_Aggregate.f90 | 7 +- src/CableDyn_OpenFAST_HermiteFMF.f90 | 8 +- src/openfast/CableDyn_OF.f90 | 113 ++++-- tests/test_coupled_torsion.f90 | 509 ++++++++++++++++++++++++ tests/test_torsion_deck.f90 | 34 +- 15 files changed, 788 insertions(+), 90 deletions(-) create mode 100644 tests/test_coupled_torsion.f90 diff --git a/CHANGELOG.md b/CHANGELOG.md index d449f5b8..4c95d454 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -19,6 +19,14 @@ All notable changes to CableDyn are recorded in this file. The format follows `EI = 0` + finite-EI route) the finite-EI cable steps with their residual, tangent and solve counts and times. Every output file is the same with and without it. See the manual's command-line page (Run-time profile). +- Torsion of finite-EI lines in coupled OpenFAST (`CompMooring = 5`) and FAST.Farm runs. The + End A frame of a line restrained in torsion turns with the platform orientation, the torque + moment is returned to the platform, `PtfmInit` twists the line in the static initialisation, + the `Torq`/`Twist` channels are written, and the unwrapped twist is restored on a checkpoint + restart. The C API and the standalone deck that mixes `EI = 0` and finite-EI lines without a + body, which move the line ends by translation only, still refuse torsion columns by name, and + so does OpenFAST linearisation of a line restrained in torsion. See the manual's OpenFAST page + (Line torsion). ### Changed diff --git a/CMakeLists.txt b/CMakeLists.txt index 0f05fc1b..b3d6db2d 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -1785,6 +1785,11 @@ target_link_libraries(test_torsion_deck PRIVATE cabledyn_core) add_test(NAME torsion_deck COMMAND test_torsion_deck) set_tests_properties(torsion_deck PROPERTIES LABELS "fortran;driver;integration;static;dynamic") +add_executable(test_coupled_torsion tests/test_coupled_torsion.f90) +target_link_libraries(test_coupled_torsion PRIVATE cabledyn_core) +add_test(NAME coupled_torsion COMMAND test_coupled_torsion WORKING_DIRECTORY ${CMAKE_BINARY_DIR}) +set_tests_properties(coupled_torsion PROPERTIES LABELS "fortran;unit;static;dynamic;openfast") + add_executable(test_torsion_orcaflex tests/test_torsion_orcaflex.f90) target_link_libraries(test_torsion_orcaflex PRIVATE cabledyn_core) add_test(NAME torsion_orcaflex diff --git a/VALIDATION.md b/VALIDATION.md index 8087502e..c93346d7 100644 --- a/VALIDATION.md +++ b/VALIDATION.md @@ -98,6 +98,7 @@ article's methods, are compared in | **T-8** | Cross-check with the Cosserat rod path | Cosserat path | shape 4.2e-4 L, torque 5.2e-5 | <1% | Pass | | **T-9** | Bordered Newton step on post-buckled states | predicted linear rate without the rank-one term | 3 iterations; rate 0.055 / 0.217 vs 0.055 / 0.218 | ≤4; within 25% | Pass | | **T-10** | Torsion dynamics, restart and body torque | quasi-static torque, energy, uninterrupted run, pendulum | torque 2.2e-16; energy band 4.9e-4; restart bit-identical; pendulum 6.4e-5 | see [Torsion](#torsion) | Pass | +| **T-11** | Torsion on the coupled OpenFAST / FAST.Farm route | `GJ (−roll)/L`; single coupled cable; uninterrupted run | twist ≤1.8e-15°, torque ≤1.7e-13 N·m; aggregate = single cable bit for bit; restart bit-identical (aggregate and `openfast -restart`) | see [Torsion](#torsion) | Pass | **Pass** meets the stated acceptance value. **Pass measured** records a measured comparison without an acceptance value. **Informative** is reported but not used for @@ -875,13 +876,32 @@ in parentheses). form of the march's trapezoidal body integrator at every step (≤9.7e-8°), so the body–twist coupling is stable at any step. The `motionFile` roll column and a rolling vessel give `Twist = −roll` and the quasi-static torque at every step. +- **T-11 coupled route** (`coupled_torsion`, `torsion_deck`; OpenFAST runs). On the aggregate + surface the OpenFAST and FAST.Farm shells drive, the straight neutral line of T-2 with its End A + on the platform fairlead twists by `−roll` when the platform rolls about the line axis: a + non-stepping update gives `Twist1 = −20°` and `GJ(−roll)/L` at both ends, with the fairlead + moment equal to that torque about the line axis and resisting the roll; a 60 °/s roll gives the + quasi-static torque at every step (twist error 1.8e-15°, torque 1.7e-13 N·m), and the aggregate + column equals the single coupled cable driven with the same calls bit for bit. 1.5 turns of roll + in 18° steps carry no `2π` slip, a snapshot–step–restore–step is bit-identical, and a + non-stepping turn of 100° stops by name without changing the state. `PtfmInit` yaw over a + vertical line and a FAST.Farm `Turbine2` yaw give the static twist `+yaw` (15° and 10°, 1e-5). + The shell's checkpoint recipe, which restores the committed twist before it moves the fairlead + to the restart pose, continues bit-identically after 150° of roll, where the previous order is + refused by the 90° bound. In OpenFAST (IEA-15 MW VolturnUS-S with three chains and a lazy-wave + power cable restrained in torsion, 60 s of irregular SeaState waves, no wind) the run + completes with `Torq4N1 = GJ·Twist4/L`, the twist follows the platform yaw (±0.14° against + ±0.12°), and + `openfast -restart` from 30 s reproduces all 1200 later rows of the OpenFAST and CableDyn + outputs bit for bit. No full FAST.Farm run is part of this record. - **Backward compatibility and refusals** (`torsion_deck`, full suite). Without torsion columns, with `Free` columns (whatever their normal), or with one restrained end, every output is byte-identical to the 6-column deck, and `Rigid`, `Infinity`, `Inf` and a quoted `"Rigid"` give the same run. Malformed rows, a missing `GJ`, an `EI = 0` line, a rod end, a `Point3` body, - `ATTACHMENTS`, modal analysis, the configuration blend, misuse of the roll column, channels on - an unrestrained line, the coupled entries and a mixed `EI = 0` + finite-EI deck without a body - stop with named errors. + `ATTACHMENTS`, modal analysis, the configuration blend (also on the coupled entries), misuse of + the roll column, channels on an unrestrained line, a coupled caller that passes no orientation + (the C API) and a standalone mixed `EI = 0` + finite-EI deck without a body stop with named + errors. Limits. The torsion model is quasi-static (no torsional inertia), takes no seabed friction against twist and no torque–tension coupling, and does not resolve self-contact. Dynamic loop diff --git a/doc/capabilities.rst b/doc/capabilities.rst index 4032d823..398383c7 100644 --- a/doc/capabilities.rst +++ b/doc/capabilities.rst @@ -80,17 +80,19 @@ Line and constitutive capability - single-section taut dynamic line with OWC and two history states; composite, hydro, finite-EI, current, and wave combinations fail closed by name * - Torsion of finite-EI lines - - Standalone only, with limits + - Supported with limits - condensed isotropic torsion (uniform torque, quasi-static: no torsional inertia) of a finite-EI line restrained in torsion at both ends (``END CONNECTIONS`` torsion columns, explicit ``GJ``), in statics with a stability check and buckling descent, and in dynamics with turning Rigid6 bodies, ``vesselMotion``/``vesselRAO`` and the ``motionFile`` roll - column; ``Torq``/``Twist`` channels and range graphs. Stopped by name: coupled OpenFAST - and FAST.Farm, the mixed ``EI = 0`` + finite-EI aggregate, rod ends, bodies other than - Rigid6, lines with ``ATTACHMENTS``, modal analysis, ``False alpha_force_blend``, and C API - object queries (which take ``EI = 0`` decks only). Not modelled: seabed friction against - twist, torque–tension coupling, anisotropic sections, self-contact of a loop (see - :ref:`theory-torsion`) + column standalone, and with the platform orientation in coupled OpenFAST and FAST.Farm + runs (torque returned to the platform, ``PtfmInit``, checkpoints; see + :doc:`openfast`); ``Torq``/``Twist`` channels and standalone range graphs. Stopped by + name: the standalone mixed ``EI = 0`` + finite-EI aggregate and the C API (which move the + line ends by translation only), OpenFAST linearisation of a line restrained in torsion, + rod ends, bodies other than Rigid6, lines with ``ATTACHMENTS``, modal analysis, and + ``False alpha_force_blend``. Not modelled: seabed friction against twist, torque–tension + coupling, anisotropic sections, self-contact of a loop (see :ref:`theory-torsion`) * - Hockling loops, nonlinear cross-section laws - Not provided - the buckling onset and the post-buckled shape are computed, but a loop that closes on diff --git a/doc/driver_format.md b/doc/driver_format.md index 97dfd75a..cb048610 100644 --- a/doc/driver_format.md +++ b/doc/driver_format.md @@ -815,15 +815,17 @@ Behaviour: Scope. A torsionally restrained line needs a finite-EI line with a `Fixed` End B, an explicit `GJ` on every section, and, at End A, a `Fixed`, `Coupled`/`Vessel` point or a Rigid6 -`Body` point. Each of the following stops with a named error: torsion on an `EI = 0` line, -on a rod end or on a `Point3` body, a line with `ATTACHMENTS`, modal analysis (`nModes`), a -dynamic run with `False alpha_force_blend`, any restrained end (one end included) in a coupled -OpenFAST or FAST.Farm run or in a deck mixing `EI = 0` and finite-EI lines without a body -(`torsion is not yet supported in a deck that mixes ...`; with a body such a deck runs on the -multibody route, which supports torsion), and a `Torq`/`Twist` channel on a line that is not -restrained at both ends. Seabed -friction does not resist twist (the laid part of a line twists freely), and there is no -torque–tension coupling. +`Body` point; in a coupled OpenFAST or FAST.Farm run the End A frame turns with the platform +(see the manual's OpenFAST page, Line torsion). Each of the following stops with a named error: +torsion on an `EI = 0` line, on a rod end or on a `Point3` body, a line with `ATTACHMENTS`, +modal analysis (`nModes`), a dynamic or coupled run with `False alpha_force_blend`, any +restrained end (one end included) in a standalone deck mixing `EI = 0` and finite-EI lines +without a body or through the C API, which move the line ends by translation only (`a line +restrained in torsion needs a host that turns its fairlead frame ...`; with a body such a deck +runs on the multibody route, which supports torsion), OpenFAST linearisation of a line +restrained in torsion, and a `Torq`/`Twist` channel on a line that is not restrained at both +ends. Seabed friction does not resist twist (the laid part of a line twists freely), and there +is no torque–tension coupling. ### EQUIVALENT BUOYANCY (optional) diff --git a/doc/openfast.rst b/doc/openfast.rst index 346aad04..3791536a 100644 --- a/doc/openfast.rst +++ b/doc/openfast.rst @@ -219,6 +219,25 @@ direction reversal of exactly 180° in one host update is rejected, because the is not unique. Formal linearisation (``Linearize = True``) with a platform-relative end connection fails during initialisation. Row grammar: :doc:`driver_format`. +Line torsion +------------ + +A finite-EI line restrained in torsion at both ends (``END CONNECTIONS`` torsion columns, see +:ref:`theory-torsion`) runs coupled as it does standalone. Its End A frame is given in platform +axes and turns with the OpenFAST point-mesh orientation, whatever the bending connection, so a +platform roll, pitch or yaw about the line's end direction twists the line. The torque moment is +returned to OpenFAST with the connection moment, the ``TorqN`` and ``Twist`` +channels are available, ``PtfmInit`` twists the line in the static initialisation, and the +unwrapped twist is part of the checkpoint state. End B must be a ``Fixed`` point. Within one +step the line may turn by more than 90° about its end direction, because the step is cut into +substeps; an output probe moves the frame without a step, is limited to 90° from the +committed twist, and stops by name beyond it (a restart first restores the checkpoint's twist, +so it is not limited this way). Formal +linearisation of a line restrained in torsion fails during initialisation: the torque's +rotational stiffness has no column in the translation-only quasi-static reduction. The C API +and the standalone deck that mixes ``EI = 0`` and finite-EI lines without a body move the line +ends by translation only and refuse torsion columns. + Lifecycle features ------------------ diff --git a/doc/troubleshooting.rst b/doc/troubleshooting.rst index 40d5a8f1..46468820 100644 --- a/doc/troubleshooting.rst +++ b/doc/troubleshooting.rst @@ -342,11 +342,18 @@ Torsion - outside the torsion scope (:doc:`capabilities`). Move End A to a ``Fixed``, ``Coupled``/``Vessel`` point or a Rigid6 body, or represent the modules as a smeared buoyancy section. - * - ``torsion is not yet supported in coupled OpenFAST runs`` / ``torsion is not yet supported - in a deck that mixes EI = 0 and finite-EI lines without a BODY, nor in coupled OpenFAST or - FAST.Farm runs`` - - run the torsional line standalone (a mixed deck with a body runs on the multibody route, - which supports torsion), or set ``TorsStiffness Free`` in every ``END CONNECTIONS`` row. + * - ``a line restrained in torsion needs a host that turns its fairlead frame`` + - the standalone deck that mixes ``EI = 0`` and finite-EI lines without a body, and the C + API, move the line ends by translation only. Run the line in a coupled OpenFAST or + FAST.Farm run, add a body (such a deck runs on the multibody route, which supports + torsion), or set ``TorsStiffness Free`` in every ``END CONNECTIONS`` row. + * - ``formal OpenFAST linearization of a line restrained in torsion is not supported`` + - linearise the model with ``TorsStiffness Free``; the torque's rotational stiffness is not + part of the quasi-static reduction. + * - ``torsion: the twist would move more than pi/2 from its committed value`` + - the host turned a fairlead by more than 90° about the line's end direction without a + step (an output probe or a non-stepping input update). Keep the platform turn per + coupling step well below 90°. * - ``a body holding a line restrained in torsion turns by more than 90 deg in one step even after 6 step halvings`` - the body turns faster than one step can follow the twist; reduce ``dtM``. diff --git a/python/cabledyn/deck_file.py b/python/cabledyn/deck_file.py index 0a621b57..66341c0f 100644 --- a/python/cabledyn/deck_file.py +++ b/python/cabledyn/deck_file.py @@ -3805,9 +3805,11 @@ def _check_torsion_lines( solved as without the columns. Restrained at both ends, torsion is solved: End B must be Fixed, every section type needs an explicit GJ > 0, no ATTACHMENTS, End A neither a rod end nor on a body other than Rigid6. A deck with torsion runs dynamics only with - the force-blended generalised-alpha and takes no modal analysis. The coupled routes - and a standalone mixed EI = 0 + finite-EI deck without bodies (``aggregate_route``, - run on the aggregate) refuse any torsion column, one restrained end included. + the force-blended generalised-alpha (a coupled run is always dynamic) and takes no + modal analysis. A standalone mixed EI = 0 + finite-EI deck without bodies + (``aggregate_route``, run on the aggregate, which moves the line ends by translation + only) refuses any torsion column, one restrained end included; the coupled OpenFAST + and FAST.Farm routes turn the fairlead frame with the platform and accept it. """ # _check_attachments has already accepted every LineID as an integer attachment_lines = {str(_native_int(row.tokens[0])) for row in self._rows("ATTACHMENTS")} @@ -3861,19 +3863,24 @@ def _check_torsion_lines( "a Rigid6 body" ) torsion_lines.add(line_id) - # native CD_Init_Deck_Aggregate (deck_has_torsion_columns): the coupled routes and a - # standalone mixed EI = 0 + finite-EI deck without bodies refuse any restrained end - if has_torsion_column and (self.caller_driven or aggregate_route): + # native CD_Init_Deck_Aggregate (deck_has_torsion_columns): a standalone mixed EI = 0 + + # finite-EI deck without bodies moves its line ends by translation only and refuses any + # restrained end; the OpenFAST and FAST.Farm hosts turn the fairlead frame + if has_torsion_column and aggregate_route and not self.caller_driven: raise DeckFormatError( - f"{self._label}: torsion is not yet supported in a deck that mixes EI = 0 and " - "finite-EI lines without a BODY, nor in coupled OpenFAST or FAST.Farm runs (with a " - "BODY such a deck runs on the multibody route, which supports torsion); set " - "TorsStiffness Free in every END CONNECTIONS row" + f"{self._label}: a line restrained in torsion needs a host that turns its fairlead " + "frame: coupled OpenFAST and FAST.Farm runs do, while the C API and a standalone " + "deck that mixes EI = 0 and finite-EI lines without a BODY move the line ends by " + "translation only (with a BODY such a deck runs on the multibody route, which " + "supports torsion); set TorsStiffness Free in every END CONNECTIONS row" ) if not torsion_lines: return torsion_lines tmax_row = option_by_key.get("tmax") - dynamic = has_tmax and tmax_row is not None and _native_float(tmax_row.values[0]) > 0.0 + # a coupled run is always dynamic (the host owns TMax) + dynamic = self.caller_driven or ( + has_tmax and tmax_row is not None and _native_float(tmax_row.values[0]) > 0.0 + ) blend_row = option_by_key.get("alpha_force_blend") force_blend = blend_row is None or blend_row.values[0].lower() in { "true", diff --git a/python/tests/test_deck_native_parity.py b/python/tests/test_deck_native_parity.py index 9a84c1c2..e10149e8 100644 --- a/python/tests/test_deck_native_parity.py +++ b/python/tests/test_deck_native_parity.py @@ -886,16 +886,25 @@ def test_torsion_line_rules_follow_the_native_checks(): one_end = _edit(_TORSION, (_TORSION_ROW_A, "1 A Rigid 1 0 0 Free 0 0 1 0\n")) _rejects(one_end, "is not torsionally restrained at both ends") DeckFile.from_text(_edit(one_end, ("Torq1N1\nTwist1N41\nTwist1\n", "FairTen1\n"))) - # the dynamic run needs the force blend; modal analysis and the coupled routes refuse torsion + # the dynamic run needs the force blend; modal analysis refuses torsion dynamic = _edit(_TORSION, ("0.0 TMax\n", "10.0 TMax\n")) DeckFile.from_text(dynamic) _rejects( _options(dynamic, "False alpha_force_blend"), "needs the force-blended generalised-alpha" ) _rejects(_options(_TORSION, "3 nModes"), "modal analysis .* with torsion is not yet supported") - _rejects(_TORSION, "nor in coupled OpenFAST or FAST.Farm runs", caller_driven=True) - # the coupled routes refuse one restrained end too (any torsion column), after the line rules - _rejects(one_end, "nor in coupled OpenFAST or FAST.Farm runs", caller_driven=True) + # the coupled OpenFAST and FAST.Farm routes turn the fairlead frame with the platform and + # accept torsion, one restrained end included; a coupled run is always dynamic, so it + # needs the force blend whatever the deck's TMax + DeckFile.from_text(_TORSION, caller_driven=True) + DeckFile.from_text( + _edit(one_end, ("Torq1N1\nTwist1N41\nTwist1\n", "FairTen1\n")), caller_driven=True + ) + _rejects( + _options(_TORSION, "False alpha_force_blend"), + "needs the force-blended generalised-alpha", + caller_driven=True, + ) _rejects(ei0, "require a finite-EI line; line 1 has EI = 0", caller_driven=True) diff --git a/src/CableDyn_DeckDriver.f90 b/src/CableDyn_DeckDriver.f90 index 3fe730e6..6872c545 100644 --- a/src/CableDyn_DeckDriver.f90 +++ b/src/CableDyn_DeckDriver.f90 @@ -231,6 +231,14 @@ MODULE CableDyn_DeckDriver INTEGER, PARAMETER :: NAMELEN = CD_DECK_NAMELEN ! appended to a failed standalone march's message: the .out file keeps the committed rows CHARACTER(*), PARAMETER :: INSPECTION_NOTE = ' Output contains only committed states and is for inspection only.' + ! a line restrained in torsion on an entry whose caller does not turn the fairlead frame + CHARACTER(*), PARAMETER :: TORSION_NEEDS_ORIENTATION = 'a line restrained in torsion needs a host that '// & + 'turns its fairlead frame: coupled OpenFAST and FAST.Farm runs do, while the C API '// & + 'and a standalone deck that mixes EI = 0 and finite-EI lines without a BODY move '// & + 'the line ends by translation only (with a BODY such a deck runs on the multibody '// & + 'route, which supports torsion); set TorsStiffness Free in every END CONNECTIONS row' + CHARACTER(*), PARAMETER :: TORSION_NEEDS_FORCE_BLEND = 'torsion in a dynamic run needs the force-blended '// & + 'generalised-alpha (OPTION alpha_force_blend True)' REAL(wp), PARAMETER :: QUARTER_PI = 0.785398163397448309616_wp ! pi/4 (displaced-area factor) REAL(wp), PARAMETER :: CD_RAD2DEG = 57.29577951308232087680_wp ! 180/pi (declination/azimuth output) INTEGER, PARAMETER :: WAVE_NONE = 0, WAVE_AIRY = 1, WAVE_JONSWAP = 2, WAVE_COMPONENTS = 3 @@ -4883,16 +4891,20 @@ PURE FUNCTION short_message(msg, max_len) RESULT(out) END IF END FUNCTION short_message - SUBROUTINE CD_Init_Deck_HermiteCable(deck_path, dt, cable, coupled_node, ErrStat, ErrMsg) + SUBROUTINE CD_Init_Deck_HermiteCable(deck_path, dt, cable, coupled_node, ErrStat, ErrMsg, host_orientation) !! Parse a single-cable deck (exactly one finite-EI LINE) and build it as a COUPLED !! cubic-Hermite lazy-wave cable driven at the fairlead. Fails closed on an EI=0 deck (use !! CD_Init_Deck_System) or a deck with more than one line (use the aggregate facade). + !! host_orientation: the caller passes the fairlead orientation with every update + !! (CD_HFMF_UpdateStates u_orientation), which a line restrained in torsion needs to turn + !! its End A frame; without it a torsion deck fails closed. CHARACTER(*), INTENT(IN) :: deck_path REAL(wp), INTENT(IN) :: dt TYPE(CD_HFMF_ModuleType), INTENT(INOUT) :: cable INTEGER, INTENT(OUT) :: coupled_node INTEGER, INTENT(OUT) :: ErrStat CHARACTER(*), INTENT(OUT) :: ErrMsg + LOGICAL, INTENT(IN), OPTIONAL :: host_orientation TYPE(DeckLineType), ALLOCATABLE :: types(:) TYPE(DeckBody), ALLOCATABLE :: bodies(:) @@ -4904,6 +4916,7 @@ SUBROUTINE CD_Init_Deck_HermiteCable(deck_path, dt, cable, coupled_node, ErrStat TYPE(DeckOptions) :: opts CHARACTER(NAMELEN), ALLOCATABLE :: channels(:) TYPE(CD_BathymetryType) :: bathymetry + LOGICAL :: host_turns ErrStat = CD_DECKDRV_OK ErrMsg = '' @@ -4911,9 +4924,15 @@ SUBROUTINE CD_Init_Deck_HermiteCable(deck_path, dt, cable, coupled_node, ErrStat CALL parse_deck(deck_path, types, bodies, rod_types, rods, points, lines, sections, opts, channels, & ErrStat, ErrMsg, caller_driven=.TRUE.) IF (ErrStat /= CD_DECKDRV_OK) RETURN - IF (deck_has_torsion_columns(lines)) THEN - CALL fail(ErrStat, ErrMsg, 'torsion is not yet supported in coupled OpenFAST runs; set TorsStiffness '// & - 'Free in every END CONNECTIONS row'); RETURN + host_turns = .FALSE. + IF (PRESENT(host_orientation)) host_turns = host_orientation + IF (deck_has_torsion_columns(lines) .AND. .NOT. host_turns) THEN + CALL fail(ErrStat, ErrMsg, TORSION_NEEDS_ORIENTATION); RETURN + END IF + IF (SIZE(lines) == 1) THEN + IF (line_torsion_active(lines(1)) .AND. .NOT. opts%alpha_force_blend) THEN + CALL fail(ErrStat, ErrMsg, TORSION_NEEDS_FORCE_BLEND); RETURN + END IF END IF IF (.NOT. deck_has_finite_ei(types, sections)) THEN CALL fail(ErrStat, ErrMsg, 'CD_Init_Deck_HermiteCable: deck has no finite-EI (EI>0) line; '// & @@ -4966,7 +4985,7 @@ END SUBROUTINE CD_Init_Deck_HermiteCable SUBROUTINE CD_Init_Deck_Aggregate(deck_path, dt, agg, ErrStat, ErrMsg, env_gravity, env_rho_water, env_wtrdpth, & ptfm_init, external_fluid, coupled_positions, & n_turbines, turbine_ref_pos, farm_ptfm_init, forbid_deck_ambient, run_tmax, & - range_files) + range_files, host_orientation) !! Parse a MIXED deck ONCE and partition its lines into {EI=0 mooring} and !! {finite-EI cable}, returning the raw parts the OpenFAST aggregate facade wraps: !! the EI=0 mooring SYSTEM built from the mooring subset (over ALL deck points, the @@ -5032,8 +5051,14 @@ SUBROUTINE CD_Init_Deck_Aggregate(deck_path, dt, agg, ErrStat, ErrMsg, env_gravi ! range_files: the caller writes the range graphs of the LINES flag r (the standalone ! mixed route); a coupled host does not, so the flag fails closed there. LOGICAL, INTENT(IN), OPTIONAL :: range_files + ! host_orientation: the caller passes each moving point's orientation with every update + ! (the OpenFAST and FAST.Farm shells), which turns the fairlead frame of a finite-EI line + ! restrained in torsion. Without it (the C API, the standalone mixed route) a deck with + ! torsion columns fails closed rather than holding that frame fixed. + LOGICAL, INTENT(IN), OPTIONAL :: host_orientation INTEGER :: nturb + LOGICAL :: host_turns TYPE(DeckLineType), ALLOCATABLE :: types(:) TYPE(DeckBody), ALLOCATABLE :: bodies(:) TYPE(DeckRodType), ALLOCATABLE :: rod_types(:) @@ -5066,11 +5091,13 @@ SUBROUTINE CD_Init_Deck_Aggregate(deck_path, dt, agg, ErrStat, ErrMsg, env_gravi env_rho_water=env_rho_water, env_wtrdpth=env_wtrdpth, allow_turbine=.TRUE., & failures=fails, controls=ctrls, run_tmax=run_tmax, host_coupled_objects=.TRUE.) IF (ErrStat == CD_DECKDRV_OK) THEN - IF (deck_has_torsion_columns(lines)) THEN - CALL fail(ErrStat, ErrMsg, 'torsion is not yet supported in a deck that mixes EI = 0 and finite-EI '// & - 'lines without a BODY, nor in coupled OpenFAST or FAST.Farm runs (with a BODY such a deck '// & - 'runs on the multibody route, which supports torsion); set TorsStiffness Free in every END '// & - 'CONNECTIONS row'); RETURN + host_turns = .FALSE. + IF (PRESENT(host_orientation)) host_turns = host_orientation + IF (deck_has_torsion_columns(lines) .AND. .NOT. host_turns) THEN + CALL fail(ErrStat, ErrMsg, TORSION_NEEDS_ORIENTATION); RETURN + END IF + IF (ANY([(line_torsion_active(lines(i)), i=1, SIZE(lines))]) .AND. .NOT. opts%alpha_force_blend) THEN + CALL fail(ErrStat, ErrMsg, TORSION_NEEDS_FORCE_BLEND); RETURN END IF END IF IF (ErrStat /= CD_DECKDRV_OK) RETURN @@ -6139,8 +6166,7 @@ SUBROUTINE run_deck_driver(deck_path, out_root, converged, ErrStat, ErrMsg) END DO IF (ANY([(line_torsion_active(lines(li)), li=1, SIZE(lines))])) THEN IF (opts%has_tmax .AND. opts%tmax > CD_ZERO .AND. .NOT. opts%alpha_force_blend) THEN - CALL fail(ErrStat, ErrMsg, 'torsion in a dynamic run needs the force-blended generalised-alpha (OPTION '// & - 'alpha_force_blend True)'); RETURN + CALL fail(ErrStat, ErrMsg, TORSION_NEEDS_FORCE_BLEND); RETURN END IF IF (opts%n_modes > 0) THEN CALL fail(ErrStat, ErrMsg, 'modal analysis (OPTION nModes) of a line with torsion is not yet supported'); RETURN diff --git a/src/CableDyn_OpenFAST_Aggregate.f90 b/src/CableDyn_OpenFAST_Aggregate.f90 index 33c24088..bf713e6b 100644 --- a/src/CableDyn_OpenFAST_Aggregate.f90 +++ b/src/CableDyn_OpenFAST_Aggregate.f90 @@ -221,7 +221,7 @@ MODULE CableDyn_OpenFAST_Aggregate SUBROUTINE CD_AGG_Init_From_Deck(self, deck_path, dt, ErrStat, ErrMsg, env_gravity, env_rho_water, env_wtrdpth, & ptfm_init, external_fluid, coupled_positions, & n_turbines, turbine_ref_pos, farm_ptfm_init, forbid_deck_ambient, run_tmax, & - range_files) + range_files, host_orientation) !! Build the aggregate from ONE mixed deck: partition its lines into {EI=0 mooring} !! and {finite-EI cable}, wrap the mooring subset into a CD_FMF, and own one CD_HFMF !! per cable. Same signature philosophy as CD_FMF_Init_From_Deck (host environment @@ -257,6 +257,9 @@ SUBROUTINE CD_AGG_Init_From_Deck(self, deck_path, dt, ErrStat, ErrMsg, env_gravi LOGICAL, INTENT(IN), OPTIONAL :: forbid_deck_ambient ! range_files: the caller writes the range graphs of the LINES flag r (CD_AGG_Range_*) LOGICAL, INTENT(IN), OPTIONAL :: range_files + ! host_orientation: the caller passes the moving-point orientations with every update, + ! which a finite-EI line restrained in torsion requires (see CD_Init_Deck_Aggregate) + LOGICAL, INTENT(IN), OPTIONAL :: host_orientation ! Both bundles (about 70 KB together) are built on the heap: initialisation runs on the ! thread of the calling host, whose stack size CableDyn does not choose. @@ -295,7 +298,7 @@ SUBROUTINE CD_AGG_Init_From_Deck(self, deck_path, dt, ErrStat, ErrMsg, env_gravi coupled_positions=coupled_positions, n_turbines=n_turbines, & turbine_ref_pos=turbine_ref_pos, farm_ptfm_init=farm_ptfm_init, & forbid_deck_ambient=forbid_deck_ambient, run_tmax=run_tmax, & - range_files=range_files) + range_files=range_files, host_orientation=host_orientation) IF (PRESENT(external_fluid)) THEN candidate%built_extfluid = external_fluid END IF diff --git a/src/CableDyn_OpenFAST_HermiteFMF.f90 b/src/CableDyn_OpenFAST_HermiteFMF.f90 index 4e38dd70..fe28b36f 100644 --- a/src/CableDyn_OpenFAST_HermiteFMF.f90 +++ b/src/CableDyn_OpenFAST_HermiteFMF.f90 @@ -83,6 +83,7 @@ MODULE CableDyn_OpenFAST_HermiteFMF PUBLIC :: CD_HFMF_MirrorSize PUBLIC :: CD_HFMF_FrictionMirrorSize PUBLIC :: CD_HFMF_ForceMirrorSize + PUBLIC :: CD_HFMF_TorsionMirrorSize PUBLIC :: CD_HFMF_PackMirror PUBLIC :: CD_HFMF_UnpackMirror PUBLIC :: CD_HFMF_End @@ -1482,17 +1483,18 @@ INTEGER FUNCTION CD_HFMF_MirrorSize(self) RESULT(n) n = 0 IF (.NOT. self%initialized) RETURN IF (ALLOCATED(self%line%freemask)) n = 3*COUNT(self%line%freemask) - n = n + CD_HFMF_FrictionMirrorSize(self) + CD_HFMF_ForceMirrorSize(self) + torsion_mirror_size(self) + n = n + CD_HFMF_FrictionMirrorSize(self) + CD_HFMF_ForceMirrorSize(self) + & + CD_HFMF_TorsionMirrorSize(self) END FUNCTION CD_HFMF_MirrorSize - INTEGER FUNCTION torsion_mirror_size(self) RESULT(n) + INTEGER FUNCTION CD_HFMF_TorsionMirrorSize(self) RESULT(n) !! Mirror slots of the condensed torsion, last: the accepted (unwrapped) Theta, Phi and the !! four end-frame vectors (14 values); zero without torsion. TYPE(CD_HFMF_ModuleType), INTENT(IN) :: self n = 0 IF (.NOT. self%initialized) RETURN IF (self%line%torsion%active) n = 14 - END FUNCTION torsion_mirror_size + END FUNCTION CD_HFMF_TorsionMirrorSize INTEGER FUNCTION CD_HFMF_ForceMirrorSize(self) RESULT(n) !! Mirror slots of the force-blended generalised-alpha integrator state beyond [v; q; a] of diff --git a/src/openfast/CableDyn_OF.f90 b/src/openfast/CableDyn_OF.f90 index 3acb5aba..432f98f9 100644 --- a/src/openfast/CableDyn_OF.f90 +++ b/src/openfast/CableDyn_OF.f90 @@ -90,7 +90,7 @@ MODULE CableDyn CD_AGG_WriteStaticProfile USE CableDyn_OpenFAST_HermiteFMF, ONLY: CD_HFMF_MirrorSize, CD_HFMF_PackMirror, CD_HFMF_UnpackMirror, & CD_HFMF_FrictionMirrorSize, CD_HFMF_ForceMirrorSize, & - CD_HFMF_OK + CD_HFMF_TorsionMirrorSize, CD_HFMF_OK USE CableDyn_HermiteCableDynamic, ONLY: CD_HermiteCable_Dyn_Reset_Profile, & CD_HermiteCable_Dyn_Disable_Profile, & CD_HermiteCable_Dyn_Get_Profile, & @@ -698,20 +698,23 @@ SUBROUTINE CD_Init(InitInp, u, p, x, xd, z, other, y, m, DTcoupling, InitOut, Er n_turbines=nT, & turbine_ref_pos=REAL(InitInp%TurbineRefPos, wp), & farm_ptfm_init=REAL(InitInp%PtfmInit(1:6, 1:nT), wp), & - forbid_deck_ambient=.TRUE., run_tmax=REAL(InitInp%Tmax, wp) ) + forbid_deck_ambient=.TRUE., run_tmax=REAL(InitInp%Tmax, wp), & + host_orientation=.TRUE. ) ELSE CALL CD_AGG_Init_From_Deck( Inst(id)%agg, TRIM(InitInp%FileName), dt_moor, es, em, & env_gravity=REAL(InitInp%g, wp), env_rho_water=REAL(InitInp%rhoW, wp), & env_wtrdpth=REAL(InitInp%WtrDepth, wp), external_fluid=use_extf, & n_turbines=nT, & turbine_ref_pos=REAL(InitInp%TurbineRefPos, wp), & - forbid_deck_ambient=.TRUE., run_tmax=REAL(InitInp%Tmax, wp) ) + forbid_deck_ambient=.TRUE., run_tmax=REAL(InitInp%Tmax, wp), & + host_orientation=.TRUE. ) END IF ELSE CALL CD_AGG_Init_From_Deck( Inst(id)%agg, TRIM(InitInp%FileName), dt_moor, es, em, & env_gravity=REAL(InitInp%g, wp), env_rho_water=REAL(InitInp%rhoW, wp), & env_wtrdpth=REAL(InitInp%WtrDepth, wp), ptfm_init=REAL(ptfm6, wp), & - external_fluid=use_extf, run_tmax=REAL(InitInp%Tmax, wp) ) + external_fluid=use_extf, run_tmax=REAL(InitInp%Tmax, wp), & + host_orientation=.TRUE. ) END IF IF (es /= CD_AGG_OK) THEN ! The slot stays inactive (it is activated only after full success, below), so this and @@ -733,6 +736,17 @@ SUBROUTINE CD_Init(InitInp, u, p, x, xd, z, other, y, m, DTcoupling, InitOut, Er END IF IF (InitInp%Linearize .AND. Inst(id)%agg%ncable > 0) THEN DO ic = 1, Inst(id)%agg%ncable + ! a line restrained in torsion returns a torque moment that turns with the platform + ! even at a bending-pinned end: its rotational stiffness a a^T / C has no column in + ! the translation-only reduction either + IF (Inst(id)%agg%cables(ic)%line%torsion%active) THEN + CALL SetErrStat( ErrID_Fatal, 'CableDyn mooring module: formal OpenFAST linearization '// & + 'of a line restrained in torsion is not supported; the torque''s '// & + 'orientation and moment Jacobian columns are not part of the current '// & + 'quasi-static reduction (set TorsStiffness Free to linearize).', & + ErrStat, ErrMsg, RoutineName ) + RETURN + END IF IF (.NOT. Inst(id)%agg%cables(ic)%has_parent_endconn) CYCLE CALL SetErrStat( ErrID_Fatal, 'CableDyn mooring module: formal OpenFAST linearization '// & 'with a platform-relative cable end connection is not supported; '// & @@ -1308,7 +1322,8 @@ SUBROUTINE rebuild_from_checkpoint( t, u1, p, x, other, m, ErrStat, ErrMsg ) CALL CD_AGG_Init_From_Deck( Inst(id)%agg, TRIM(rst_deck), REAL(p%dtM0, wp), es, em, & env_gravity=REAL(p%g, wp), env_rho_water=REAL(p%rhoW, wp), & env_wtrdpth=REAL(p%WtrDpth, wp), external_fluid=use_extf, & - ptfm_init=REAL(p%PtfmInit, wp), run_tmax=REAL(p%Tmax, wp) ) + ptfm_init=REAL(p%PtfmInit, wp), run_tmax=REAL(p%Tmax, wp), & + host_orientation=.TRUE. ) CALL delete_file( rst_deck ) IF (es /= CD_AGG_OK) THEN CALL SetErrStat( ErrID_Fatal, 'CableDyn mooring module: checkpoint rebuild: '//TRIM(em), & @@ -1383,6 +1398,12 @@ SUBROUTINE rebuild_from_checkpoint( t, u1, p, x, other, m, ErrStat, ErrMsg ) ErrStat2, ErrMsg2 ) CALL SetErrStat( ErrStat2, ErrMsg2, ErrStat, ErrMsg, RoutineName ) IF (ErrStat >= AbortErrLev) RETURN + ! a cable restrained in torsion first takes its committed state: moving its fairlead + ! frame from the static pose to the restart pose is bounded (pi/2) against the twist + ! it had at the checkpoint, not at t = 0 + CALL reload_cable_mirrors( Inst(id), m, x%states, REAL(t, wp), .TRUE., koff, ErrStat2, ErrMsg2 ) + CALL SetErrStat( ErrStat2, ErrMsg2, ErrStat, ErrMsg, RoutineName ) + IF (ErrStat >= AbortErrLev) RETURN CALL CD_AGG_UpdateStates_Moving( Inst(id)%agg, Inst(id)%ws_pos, Inst(id)%ws_vel, Inst(id)%ws_acc, es, em, & orientation=Inst(id)%ws_orient, angular_velocity=Inst(id)%ws_omega, & angular_acceleration=Inst(id)%ws_alpha ) @@ -2760,9 +2781,11 @@ SUBROUTINE CD_InitVars(Vars, u, p, x, y, m, inst_, Linearize, ErrStat, ErrMsg) DO ic = 1, inst_%agg%ncable csz = CD_HFMF_MirrorSize( inst_%agg%cables(ic) ) IF (csz <= 0) CYCLE ! uninitialised cable contributes no states - ! free DOFs; mirror = [v_free; q_free; a_free] then the friction anchors (if any) + ! free DOFs; mirror = [v_free; q_free; a_free] then the friction anchors, the + ! force-blend state and the torsion state (if any) nf = (csz - CD_HFMF_FrictionMirrorSize( inst_%agg%cables(ic) ) - & - CD_HFMF_ForceMirrorSize( inst_%agg%cables(ic) ))/3 + CD_HFMF_ForceMirrorSize( inst_%agg%cables(ic) ) - & + CD_HFMF_TorsionMirrorSize( inst_%agg%cables(ic) ))/3 LinStr = 'Cable '//TRIM(Num2LStr(ic)) ! Build the per-DOF linearization names in an explicit pre-allocated loop, NOT an ! inline implied-do array constructor: an impure function (Num2LStr) evaluated inside @@ -2794,8 +2817,9 @@ SUBROUTINE CD_InitVars(Vars, u, p, x, y, m, inst_, Linearize, ErrStat, ErrMsg) iAry=koff + 2*nf + 1, Num=nf, Perturb=0.1_R8Ki, & LinNames=CblLinAcc ) DEALLOCATE (CblLinVel, CblLinPos, CblLinAcc) - ! stick-slip friction anchors (x, y per node) and the force-blend committed force - ! (flag + force) after the acceleration block: coverage-only, like the acceleration block + ! stick-slip friction anchors (x, y per node), the force-blend committed force + ! (flag + force) and the torsion state (Theta, Phi, end frames) after the acceleration + ! block: coverage-only, like the acceleration block IF (csz > 3*nf) THEN ALLOCATE (CblLinVel(csz - 3*nf), STAT=ErrStat2) IF (ErrStat2 /= 0) THEN @@ -3137,27 +3161,8 @@ SUBROUTINE reload_interiors_ary(inst_, m, states, t_clock, ErrStat, ErrMsg) END BLOCK END IF END DO - koff = 0 - IF (inst_%nlines > 0) koff = m%LineStateIsN(inst_%nlines) - DO ic = 1, inst_%agg%ncable - csz = CD_HFMF_MirrorSize( inst_%agg%cables(ic) ) - IF (csz <= 0) CYCLE - IF (koff + csz > SIZE(states)) THEN - CALL SetErrStat( ErrID_Fatal, 'CableDyn mooring module: cable '//TRIM(Num2LStr(ic))// & - ' mirror extends past the state vector.', ErrStat, ErrMsg, RoutineName ) - RETURN - END IF - IF (ALLOCATED(inst_%ws_cbuf)) THEN - IF (SIZE(inst_%ws_cbuf) /= csz) DEALLOCATE (inst_%ws_cbuf) - END IF - IF (.NOT. ALLOCATED(inst_%ws_cbuf)) ALLOCATE (inst_%ws_cbuf(csz)) - inst_%ws_cbuf = REAL(states(koff + 1:koff + csz), wp) - CALL CD_HFMF_UnpackMirror( inst_%agg%cables(ic), inst_%ws_cbuf, t_clock, es, em ) - IF (es /= CD_HFMF_OK) THEN - CALL SetErrStat( ErrID_Fatal, TRIM(em), ErrStat, ErrMsg, RoutineName ); RETURN - END IF - koff = koff + csz - END DO + CALL reload_cable_mirrors( inst_, m, states, t_clock, .FALSE., koff, ErrStat, ErrMsg ) + IF (ErrStat >= AbortErrLev) RETURN ! coupled Rigid6 6-DOF body state: restore after the cable block, before the dynamic points ! (the body drives its attachment points, so the restored pose re-derives them next advance) IF (CD_AGG_HasRigid6( inst_%agg )) THEN @@ -3299,6 +3304,54 @@ SUBROUTINE reload_interiors_ary(inst_, m, states, t_clock, ErrStat, ErrMsg) END IF END SUBROUTINE reload_interiors_ary + SUBROUTINE reload_cable_mirrors(inst_, m, states, t_clock, torsion_only, koff, ErrStat, ErrMsg) + !! Unpack each cable's [v; q; a] free-DOF mirror (with its torsion tail) from the + !! checkpoint x%states layout. koff returns the offset past the cable block. With + !! torsion_only, only the cables restrained in torsion are unpacked: the checkpoint + !! rebuild restores their committed twist before it moves the fairlead to the restart + !! pose, whose preflight bounds the twist change against that committed value. + TYPE(CD_OF_Instance), INTENT(INOUT) :: inst_ + TYPE(CD_MiscVarType), INTENT(IN) :: m + REAL(R8Ki), INTENT(IN) :: states(:) + REAL(wp), INTENT(IN) :: t_clock + LOGICAL, INTENT(IN) :: torsion_only + INTEGER(IntKi), INTENT(OUT) :: koff + INTEGER(IntKi), INTENT(OUT) :: ErrStat + CHARACTER(*), INTENT(OUT) :: ErrMsg + + character(*), parameter :: RoutineName = 'CableDyn:reload_cable_mirrors' + INTEGER(IntKi) :: es, ic, csz + CHARACTER(512) :: em + + ErrStat = ErrID_None + ErrMsg = '' + koff = 0 + IF (inst_%nlines > 0) koff = m%LineStateIsN(inst_%nlines) + DO ic = 1, inst_%agg%ncable + csz = CD_HFMF_MirrorSize( inst_%agg%cables(ic) ) + IF (csz <= 0) CYCLE + IF (koff + csz > SIZE(states)) THEN + CALL SetErrStat( ErrID_Fatal, 'CableDyn mooring module: cable '//TRIM(Num2LStr(ic))// & + ' mirror extends past the state vector.', ErrStat, ErrMsg, RoutineName ) + RETURN + END IF + IF (torsion_only .AND. .NOT. inst_%agg%cables(ic)%line%torsion%active) THEN + koff = koff + csz + CYCLE + END IF + IF (ALLOCATED(inst_%ws_cbuf)) THEN + IF (SIZE(inst_%ws_cbuf) /= csz) DEALLOCATE (inst_%ws_cbuf) + END IF + IF (.NOT. ALLOCATED(inst_%ws_cbuf)) ALLOCATE (inst_%ws_cbuf(csz)) + inst_%ws_cbuf = REAL(states(koff + 1:koff + csz), wp) + CALL CD_HFMF_UnpackMirror( inst_%agg%cables(ic), inst_%ws_cbuf, t_clock, es, em ) + IF (es /= CD_HFMF_OK) THEN + CALL SetErrStat( ErrID_Fatal, TRIM(em), ErrStat, ErrMsg, RoutineName ); RETURN + END IF + koff = koff + csz + END DO + END SUBROUTINE reload_cable_mirrors + SUBROUTINE pack_state_mirror(inst_, m, x, ErrStat, ErrMsg) TYPE(CD_OF_Instance), INTENT(INOUT) :: inst_ TYPE(CD_MiscVarType), INTENT(IN) :: m diff --git a/tests/test_coupled_torsion.f90 b/tests/test_coupled_torsion.f90 new file mode 100644 index 00000000..fcfe2fe0 --- /dev/null +++ b/tests/test_coupled_torsion.f90 @@ -0,0 +1,509 @@ +! File: tests/test_coupled_torsion.f90 +! SPDX-License-Identifier: Apache-2.0 +! Copyright (c) 2026 Jae Hoon Seo, SMI Lab, Inha University +PROGRAM test_coupled_torsion + !! Condensed torsion of a finite-EI line on the coupled OpenFAST route: the aggregate surface + !! the OpenFAST and FAST.Farm shells drive, built with host_orientation. The line is the + !! straight 100 m neutral line of test_torsion_deck (GJ 5e4 N m^2, both ends clamped and + !! restrained in torsion, no pretwist), its End A on the platform fairlead (0, 0, -50) and + !! End B on a fixed anchor. Rolling the platform by phi about the line axis (+x) twists the + !! line by -phi: Twist1 = -phi and Torq = GJ (-phi) / L, with no torsional inertia. + !! 1. feedthrough: a non-stepping update with a rolled orientation gives that twist and + !! torque, and the fairlead moment is the restoring torque about the line axis; + !! 2. march: the platform rolls at 60 deg/s; every step gives Twist1 = -phi(t) and the + !! quasi-static torque (the coupled twin of the standalone vessel-roll gate), and the + !! single-cable entry driven with the same calls gives the same values bit for bit; + !! 3. unwrapping: 1.5 turns of roll in 18 deg steps, with no 2 pi slip; + !! 4. rewind: snapshot, step, restore and the same step again are bit-identical; + !! 5. a non-stepping turn of more than pi/2 fails by name and leaves the state unchanged; + !! 6. ptfm_init: an initial platform yaw over a vertical line hanging under the fairlead + !! (End A on the yaw axis) gives the static twist +yaw (a turn of -yaw about the line + !! direction A to B, -z); + !! 7. restart: the shell's checkpoint recipe (rebuild, torsion mirror first, coupled + !! kinematics, full mirror) after 150 deg of roll continues bit-identically; without the + !! torsion mirror first the coupled update is refused (the pi/2 bound); + !! 8. FAST.Farm: the vertical torsion line under Turbine2 with a farm_ptfm_init yaw gives + !! the static twist and follows that turbine's yaw. + USE CableDyn_Precision, ONLY: wp + USE CableDyn_DeckDriver, ONLY: CD_Init_Deck_HermiteCable, CD_DECKDRV_OK + USE CableDyn_OpenFAST_Aggregate, ONLY: CD_AGG_ModuleType, CD_AGG_Init_From_Deck, CD_AGG_NMovingPoints, & + CD_AGG_GetMovingPointMesh, CD_AGG_UpdateStates_Moving, & + CD_AGG_Step_Moving, CD_AGG_CalcOutput, CD_AGG_Snapshot, CD_AGG_Restore, & + CD_AGG_EvalChannel, CD_AGG_End, CD_AGG_OK + USE CableDyn_OpenFAST_HermiteFMF, ONLY: CD_HFMF_ModuleType, CD_HFMF_UpdateStates, CD_HFMF_CalcOutput, & + CD_HFMF_MirrorSize, CD_HFMF_PackMirror, CD_HFMF_UnpackMirror, & + CD_HFMF_End, CD_HFMF_OK + USE, INTRINSIC :: IEEE_ARITHMETIC, ONLY: IEEE_IS_FINITE + IMPLICIT NONE + + REAL(wp), PARAMETER :: PI = 3.14159265358979323846_wp, RHOW = 1025.0_wp + REAL(wp), PARAMETER :: GJ = 5.0e4_wp, L = 100.0_wp, DT = 0.05_wp, DEG = PI/180.0_wp + INTEGER :: n_fail = 0 + CHARACTER(160) :: neutral_type + + ! neutral 0.2 m section: mass = rhoW pi d^2 / 4; EA 1e7, EI 1e6, GAs 1e8, GJ 5e4 + WRITE (neutral_type, '(A,ES24.16,A)') 'cab 0.2 ', RHOW*0.25_wp*PI*0.04_wp, & + ' 1.0e7 0.0 1.0e6 1.0e8 5.0e4 1.0 1.0 0.0 0.0 0.0 0.0' + + CALL check_feedthrough() + CALL check_march() + CALL check_unwrap() + CALL check_rewind() + CALL check_large_turn_refused() + CALL check_ptfm_init() + CALL check_restart() + CALL check_farm() + IF (n_fail > 0) THEN + WRITE (*, '(A,I0,A)') 'FAIL: ', n_fail, ' coupled torsion check(s) failed' + ERROR STOP 1 + END IF + WRITE (*, '(A)') 'PASS: coupled torsion (feedthrough, march, unwrapping, rewind, refusal, PtfmInit, '// & + 'restart, FAST.Farm)' + +CONTAINS + + INCLUDE 'nan_max_abs.inc' + + SUBROUTINE require(cond, msg) + LOGICAL, INTENT(IN) :: cond + CHARACTER(*), INTENT(IN) :: msg + IF (.NOT. cond) THEN + n_fail = n_fail + 1 + WRITE (*, '(A,A)') 'FAILED: ', msg + END IF + END SUBROUTINE require + + SUBROUTINE write_deck(path, point_a, vertical, anchor_x) + !! The straight neutral torsion line, End A on point_a, outputs Torq1N1, Torq1N41, Twist1: + !! along +x from (0, 0, -50) to (100, 0, -50), or with vertical from (0, 0, -20) down to + !! (anchor_x, 0, -120) (anchor_x: the farm-global x of the turbine the line hangs under). + CHARACTER(*), INTENT(IN) :: path, point_a + LOGICAL, INTENT(IN), OPTIONAL :: vertical + REAL(wp), INTENT(IN), OPTIONAL :: anchor_x + INTEGER :: u + LOGICAL :: vert + REAL(wp) :: ax + CHARACTER(48) :: anchor + vert = .FALSE. + IF (PRESENT(vertical)) vert = vertical + ax = 0.0_wp + IF (PRESENT(anchor_x)) ax = anchor_x + anchor = '2 Fixed 100.0 0.0 -50.0 0 0 0 0' + IF (vert) WRITE (anchor, '(A,F8.1,A)') '2 Fixed ', ax, ' 0.0 -120.0 0 0 0 0' + OPEN (NEWUNIT=u, FILE=path, STATUS='REPLACE', ACTION='WRITE') + WRITE (u, '(A)') 'coupled torsion gate' + WRITE (u, '(A)') '--- LINE TYPES ---' + WRITE (u, '(A)') 'Name Diam Mass EA BA EI GAs GJ Irt Irn Cdn Cdt Can Cat' + WRITE (u, '(A)') '(-) (m) (kg/m) (N) (-) (Nm2) (N) (Nm2) (kgm) (kgm) (-) (-) (-) (-)' + WRITE (u, '(A)') TRIM(neutral_type) + WRITE (u, '(A)') '--- POINTS ---' + WRITE (u, '(A)') 'ID Type X Y Z Mass Vol CdA Ca' + WRITE (u, '(A)') '(-) (-) (m) (m) (m) (kg) (m3) (m2) (-)' + IF (vert) THEN + WRITE (u, '(A)') '1 '//point_a//' 0.0 0.0 -20.0 0 0 0 0' + ELSE + WRITE (u, '(A)') '1 '//point_a//' 0.0 0.0 -50.0 0 0 0 0' + END IF + WRITE (u, '(A)') TRIM(anchor) + WRITE (u, '(A)') '--- LINES ---' + WRITE (u, '(A)') 'ID NodeA NodeB Outputs' + WRITE (u, '(A)') '(-) (-) (-) (-)' + WRITE (u, '(A)') '1 1 2 -' + WRITE (u, '(A)') '--- SECTIONS ---' + WRITE (u, '(A)') 'LineID LineType Length NumSegs' + WRITE (u, '(A)') '(-) (-) (m) (-)' + WRITE (u, '(A)') '1 cab 100.0 40' + WRITE (u, '(A)') '--- END CONNECTIONS ---' + WRITE (u, '(A)') 'LineID End Stiffness EzX EzY EzZ TorsStiffness NxX NxY NxZ Pretwist' + WRITE (u, '(A)') '(-) (-) (N-m/rad) (-) (-) (-) (N-m/rad) (-) (-) (-) (deg)' + IF (vert) THEN + WRITE (u, '(A)') '1 A Rigid 0 0 -1 Rigid 1 0 0 0' + WRITE (u, '(A)') '1 B Rigid 0 0 -1 Rigid 1 0 0 0' + ELSE + WRITE (u, '(A)') '1 A Rigid 1 0 0 Rigid 0 0 1 0' + WRITE (u, '(A)') '1 B Rigid 1 0 0 Rigid 0 0 1 0' + END IF + WRITE (u, '(A)') '--- OPTIONS ---' + WRITE (u, '(A)') '9.80665 g' + WRITE (u, '(A)') '1025.0 rhoW' + WRITE (u, '(A)') '0.05 dtM' + WRITE (u, '(A)') '--- OUTPUTS ---' + WRITE (u, '(A)') 'Torq1N1' + WRITE (u, '(A)') 'Torq1N41' + WRITE (u, '(A)') 'Twist1' + WRITE (u, '(A)') '--- END ---' + CLOSE (u) + END SUBROUTINE write_deck + + FUNCTION roll_dcm(phi) RESULT(r) + !! OpenFAST mesh orientation (global to local) of a roll phi about +x. + REAL(wp), INTENT(IN) :: phi + REAL(wp) :: r(3, 3) + r = 0.0_wp + r(1, 1) = 1.0_wp + r(2, 2) = COS(phi) + r(2, 3) = SIN(phi) + r(3, 2) = -SIN(phi) + r(3, 3) = COS(phi) + END FUNCTION roll_dcm + + FUNCTION yaw_dcm(psi) RESULT(r) + !! OpenFAST mesh orientation (global to local) of a yaw psi about +z. + REAL(wp), INTENT(IN) :: psi + REAL(wp) :: r(3, 3) + r = 0.0_wp + r(3, 3) = 1.0_wp + r(1, 1) = COS(psi) + r(1, 2) = SIN(psi) + r(2, 1) = -SIN(psi) + r(2, 2) = COS(psi) + END FUNCTION yaw_dcm + + SUBROUTINE channels(agg, torq_a, torq_b, twist) + TYPE(CD_AGG_ModuleType), INTENT(IN) :: agg + REAL(wp), INTENT(OUT) :: torq_a, torq_b, twist + INTEGER :: es + CHARACTER(256) :: em + CALL CD_AGG_EvalChannel(agg, 1, torq_a, es, em) + CALL require(es == CD_AGG_OK, 'Torq1N1 evaluates: '//TRIM(em)) + CALL CD_AGG_EvalChannel(agg, 2, torq_b, es, em) + CALL require(es == CD_AGG_OK, 'Torq1N41 evaluates: '//TRIM(em)) + CALL CD_AGG_EvalChannel(agg, 3, twist, es, em) + CALL require(es == CD_AGG_OK, 'Twist1 evaluates: '//TRIM(em)) + END SUBROUTINE channels + + SUBROUTINE init_agg(agg, path, ok) + TYPE(CD_AGG_ModuleType), INTENT(INOUT) :: agg + CHARACTER(*), INTENT(IN) :: path + LOGICAL, INTENT(OUT) :: ok + INTEGER :: es + CHARACTER(512) :: em + CALL CD_AGG_Init_From_Deck(agg, path, DT, es, em, host_orientation=.TRUE.) + ok = es == CD_AGG_OK + CALL require(ok, 'coupled torsion deck builds on the aggregate: '//TRIM(em)) + IF (ok) THEN + ok = agg%ncable == 1 .AND. CD_AGG_NMovingPoints(agg, es, em) == 1 + CALL require(ok, 'the deck is one coupled cable with one moving point') + END IF + END SUBROUTINE init_agg + + ! ------------------------------------------------------------------------------------------ + SUBROUTINE check_feedthrough() + TYPE(CD_AGG_ModuleType) :: agg + REAL(wp) :: pos(3, 1), vel(3, 1), acc(3, 1), load(3, 1), moment(3, 1), orient(3, 3, 1) + REAL(wp) :: ta, tb, tw, phi, m_ref + INTEGER :: es + LOGICAL :: ok + CHARACTER(512) :: em + CALL write_deck('ctors_feed.dat', 'Coupled') + CALL init_agg(agg, 'ctors_feed.dat', ok) + IF (.NOT. ok) RETURN + CALL channels(agg, ta, tb, tw) + CALL require(ABS(ta) <= 1.0e-6_wp .AND. ABS(tw) <= 1.0e-9_wp, '1: no pretwist, no torque at rest') + CALL CD_AGG_GetMovingPointMesh(agg, pos, vel, acc, load, es, em, orientation=orient, moment=moment) + phi = 20.0_wp*DEG + orient(:, :, 1) = roll_dcm(phi) + CALL CD_AGG_UpdateStates_Moving(agg, pos, vel, acc, es, em, orientation=orient) + CALL require(es == CD_AGG_OK, '1: a rolled orientation is accepted: '//TRIM(em)) + CALL CD_AGG_CalcOutput(agg, es, em) + CALL channels(agg, ta, tb, tw) + m_ref = GJ*(-phi)/L + WRITE (*, '(A,3ES15.7,A,ES15.7)') '1 feedthrough: Torq A/B, Twist ', ta, tb, tw, '; ref torque ', m_ref + CALL require(ABS(tw + 20.0_wp) <= 1.0e-6_wp, '1: Twist1 = -roll') + CALL require(ABS(ta - m_ref) <= 1.0e-6_wp*ABS(m_ref) .AND. ABS(tb - m_ref) <= 1.0e-6_wp*ABS(m_ref), & + '1: Torq = GJ (-roll) / L at both ends') + CALL CD_AGG_GetMovingPointMesh(agg, pos, vel, acc, load, es, em, moment=moment) + WRITE (*, '(A,3ES15.7)') '1 feedthrough: fairlead moment ', moment(:, 1) + CALL require(ABS(ABS(moment(1, 1)) - ABS(m_ref)) <= 1.0e-6_wp*ABS(m_ref), & + '1: the fairlead moment about the line axis is the torque') + CALL require(moment(1, 1)*phi < 0.0_wp, '1: the moment on the platform resists its roll') + CALL require(MAX(ABS(moment(2, 1)), ABS(moment(3, 1))) <= 1.0e-6_wp*ABS(m_ref), & + '1: a straight line returns no bending moment') + CALL CD_AGG_End(agg, es, em) + END SUBROUTINE check_feedthrough + + ! ------------------------------------------------------------------------------------------ + SUBROUTINE check_march() + !! 60 deg/s roll for 10 steps; the single-cable entry driven with the same calls must match. + REAL(wp), PARAMETER :: RATE = 60.0_wp*DEG + TYPE(CD_AGG_ModuleType) :: agg + TYPE(CD_HFMF_ModuleType) :: cab + REAL(wp) :: pos(3, 1), vel(3, 1), acc(3, 1), load(3, 1), moment(3, 1), orient(3, 3, 1) + REAL(wp) :: omega(3, 1), alpha(3, 1), ta, tb, tw, phi, terr, werr, derr + REAL(wp) :: f_cab(3), m_cab(3) + INTEGER :: es, ni, k, node + LOGICAL :: ok, cv, st + CHARACTER(512) :: em + CALL write_deck('ctors_march.dat', 'Coupled') + CALL init_agg(agg, 'ctors_march.dat', ok) + IF (.NOT. ok) RETURN + CALL CD_Init_Deck_HermiteCable('ctors_march.dat', DT, cab, node, es, em, host_orientation=.TRUE.) + CALL require(es == CD_DECKDRV_OK, '2: the single-cable entry builds: '//TRIM(em)) + IF (es /= CD_DECKDRV_OK) RETURN + CALL CD_AGG_GetMovingPointMesh(agg, pos, vel, acc, load, es, em, orientation=orient) + omega = 0.0_wp + alpha = 0.0_wp + omega(1, 1) = RATE + terr = 0.0_wp + werr = 0.0_wp + derr = 0.0_wp + DO k = 1, 10 + phi = RATE*DT*k + orient(:, :, 1) = roll_dcm(phi) + CALL CD_AGG_Step_Moving(agg, DT, pos, vel, acc, cv, st, ni, es, em, orientation=orient, & + angular_velocity=omega, angular_acceleration=alpha) + CALL require(es == CD_AGG_OK .AND. cv, '2: rolling step converges: '//TRIM(em)) + IF (es /= CD_AGG_OK) EXIT + CALL CD_AGG_CalcOutput(agg, es, em) + CALL channels(agg, ta, tb, tw) + werr = MAX(werr, ABS(tw + phi/DEG)) + terr = MAX(terr, ABS(ta - GJ*(-phi)/L), ABS(tb - ta)) + CALL CD_HFMF_UpdateStates(cab, pos(:, 1), vel(:, 1), acc(:, 1), es, em, u_orientation=orient(:, :, 1), & + u_angular_velocity=omega(:, 1), u_angular_acceleration=alpha(:, 1)) + CALL require(es == CD_HFMF_OK, '2: the single cable steps: '//TRIM(em)) + CALL CD_AGG_GetMovingPointMesh(agg, pos, vel, acc, load, es, em, moment=moment) + CALL CD_HFMF_CalcOutput(cab, f_cab, es, em, y_moment=m_cab) + derr = MAX(derr, nan_max_abs(agg%cables(1)%line%q - cab%line%q), nan_max_abs(load(:, 1) - f_cab), & + nan_max_abs(moment(:, 1) - m_cab), & + ABS(agg%cables(1)%line%torsion%theta - cab%line%torsion%theta)) + END DO + WRITE (*, '(A,ES10.3,A,ES10.3,A,ES10.3)') '2 march: Twist1 error ', werr, ' deg, torque error ', terr, & + ' N m; aggregate vs single cable ', derr + CALL require(werr <= 1.0e-6_wp, '2: Twist1 = -roll(t) at every step') + CALL require(terr <= 1.0e-6_wp*GJ, '2: Torq = GJ Twist / L at both ends at every step (quasi-static)') + CALL require(derr <= 0.0_wp, '2: the aggregate column equals the single coupled cable bit for bit') + CALL CD_HFMF_End(cab) + CALL CD_AGG_End(agg, es, em) + END SUBROUTINE check_march + + ! ------------------------------------------------------------------------------------------ + SUBROUTINE check_unwrap() + !! 1.5 turns of roll in 18 deg steps (30 steps). + TYPE(CD_AGG_ModuleType) :: agg + REAL(wp) :: pos(3, 1), vel(3, 1), acc(3, 1), load(3, 1), orient(3, 3, 1), omega(3, 1), alpha(3, 1) + REAL(wp) :: ta, tb, tw, phi, werr + INTEGER :: es, ni, k + LOGICAL :: ok, cv, st + CHARACTER(512) :: em + CALL write_deck('ctors_unwrap.dat', 'Coupled') + CALL init_agg(agg, 'ctors_unwrap.dat', ok) + IF (.NOT. ok) RETURN + CALL CD_AGG_GetMovingPointMesh(agg, pos, vel, acc, load, es, em, orientation=orient) + omega = 0.0_wp + alpha = 0.0_wp + omega(1, 1) = 18.0_wp*DEG/DT + werr = 0.0_wp + DO k = 1, 30 + phi = 18.0_wp*DEG*k + orient(:, :, 1) = roll_dcm(phi) + CALL CD_AGG_Step_Moving(agg, DT, pos, vel, acc, cv, st, ni, es, em, orientation=orient, & + angular_velocity=omega, angular_acceleration=alpha) + CALL require(es == CD_AGG_OK .AND. cv, '3: 18 deg roll step converges: '//TRIM(em)) + IF (es /= CD_AGG_OK) EXIT + CALL CD_AGG_CalcOutput(agg, es, em) + CALL channels(agg, ta, tb, tw) + werr = MAX(werr, ABS(tw + 18.0_wp*k), ABS(ta - GJ*(-phi)/L)/GJ) + END DO + WRITE (*, '(A,F9.3,A,ES10.3)') '3 unwrap: final Twist1 ', tw, ' deg (ref -540), max error ', werr + CALL require(werr <= 1.0e-6_wp, '3: 1.5 turns of roll unwrap without a 2 pi slip') + CALL CD_AGG_End(agg, es, em) + END SUBROUTINE check_unwrap + + ! ------------------------------------------------------------------------------------------ + SUBROUTINE check_rewind() + TYPE(CD_AGG_ModuleType) :: agg + REAL(wp) :: pos(3, 1), vel(3, 1), acc(3, 1), load(3, 1), orient(3, 3, 1), omega(3, 1), alpha(3, 1) + REAL(wp) :: moment(3, 1), m1(3), m2(3), th1, th2, tw1, tw2, ta, tb + REAL(wp), ALLOCATABLE :: qa(:), qb(:) + INTEGER :: es, ni + LOGICAL :: ok, cv, st + CHARACTER(512) :: em + CALL write_deck('ctors_rewind.dat', 'Coupled') + CALL init_agg(agg, 'ctors_rewind.dat', ok) + IF (.NOT. ok) RETURN + CALL CD_AGG_GetMovingPointMesh(agg, pos, vel, acc, load, es, em, orientation=orient) + omega = 0.0_wp + alpha = 0.0_wp + omega(1, 1) = 30.0_wp*DEG/DT + orient(:, :, 1) = roll_dcm(30.0_wp*DEG) + CALL CD_AGG_Snapshot(agg, es, em) + CALL require(es == CD_AGG_OK, '4: snapshot: '//TRIM(em)) + CALL CD_AGG_Step_Moving(agg, DT, pos, vel, acc, cv, st, ni, es, em, orientation=orient, & + angular_velocity=omega, angular_acceleration=alpha) + CALL require(es == CD_AGG_OK .AND. cv, '4: first step: '//TRIM(em)) + CALL CD_AGG_CalcOutput(agg, es, em) + CALL CD_AGG_GetMovingPointMesh(agg, pos, vel, acc, load, es, em, moment=moment) + qa = agg%cables(1)%line%q + m1 = moment(:, 1) + th1 = agg%cables(1)%line%torsion%theta + CALL channels(agg, ta, tb, tw1) + CALL CD_AGG_Restore(agg, es, em) + CALL require(es == CD_AGG_OK, '4: restore: '//TRIM(em)) + CALL require(ABS(agg%cables(1)%line%torsion%theta) <= 1.0e-12_wp, '4: restore rewinds the twist') + CALL CD_AGG_Step_Moving(agg, DT, pos, vel, acc, cv, st, ni, es, em, orientation=orient, & + angular_velocity=omega, angular_acceleration=alpha) + CALL require(es == CD_AGG_OK .AND. cv, '4: repeated step: '//TRIM(em)) + CALL CD_AGG_CalcOutput(agg, es, em) + CALL CD_AGG_GetMovingPointMesh(agg, pos, vel, acc, load, es, em, moment=moment) + qb = agg%cables(1)%line%q + m2 = moment(:, 1) + th2 = agg%cables(1)%line%torsion%theta + CALL channels(agg, ta, tb, tw2) + CALL require(nan_max_abs(qa - qb) <= 0.0_wp .AND. nan_max_abs(m1 - m2) <= 0.0_wp .AND. & + ABS(th1 - th2) <= 0.0_wp .AND. ABS(tw1 - tw2) <= 0.0_wp, & + '4: snapshot, step, restore, step is bit-identical (state, twist, torque moment)') + CALL CD_AGG_End(agg, es, em) + END SUBROUTINE check_rewind + + ! ------------------------------------------------------------------------------------------ + SUBROUTINE check_large_turn_refused() + TYPE(CD_AGG_ModuleType) :: agg + REAL(wp) :: pos(3, 1), vel(3, 1), acc(3, 1), load(3, 1), orient(3, 3, 1) + REAL(wp) :: th0, ta, tb, tw + REAL(wp), ALLOCATABLE :: q0(:) + INTEGER :: es + LOGICAL :: ok + CHARACTER(512) :: em + CALL write_deck('ctors_large.dat', 'Coupled') + CALL init_agg(agg, 'ctors_large.dat', ok) + IF (.NOT. ok) RETURN + CALL CD_AGG_GetMovingPointMesh(agg, pos, vel, acc, load, es, em, orientation=orient) + q0 = agg%cables(1)%line%q + th0 = agg%cables(1)%line%torsion%theta + orient(:, :, 1) = roll_dcm(100.0_wp*DEG) + CALL CD_AGG_UpdateStates_Moving(agg, pos, vel, acc, es, em, orientation=orient) + WRITE (*, '(A,A)') '5 large turn: ', TRIM(em) + CALL require(es /= CD_AGG_OK .AND. INDEX(em, 'pi/2') > 0, '5: a 100 deg non-stepping turn is refused by name') + CALL require(nan_max_abs(agg%cables(1)%line%q - q0) <= 0.0_wp .AND. & + ABS(agg%cables(1)%line%torsion%theta - th0) <= 0.0_wp, '5: the refused update changes no state') + CALL channels(agg, ta, tb, tw) + CALL require(ABS(tw) <= 1.0e-9_wp, '5: the twist is still zero after the refusal') + CALL CD_AGG_End(agg, es, em) + END SUBROUTINE check_large_turn_refused + + ! ------------------------------------------------------------------------------------------ + SUBROUTINE check_ptfm_init() + !! ptfm_init yaws the platform about the vertical axis through the origin, which carries the + !! vertical line's fairlead (0, 0, -20) onto itself: only its frame turns. + TYPE(CD_AGG_ModuleType) :: agg + REAL(wp) :: ta, tb, tw, psi + INTEGER :: es + CHARACTER(512) :: em + psi = 15.0_wp*DEG + CALL write_deck('ctors_ptfm.dat', 'Coupled', vertical=.TRUE.) + CALL CD_AGG_Init_From_Deck(agg, 'ctors_ptfm.dat', DT, es, em, ptfm_init=[0.0_wp, 0.0_wp, 0.0_wp, 0.0_wp, & + 0.0_wp, psi], host_orientation=.TRUE.) + CALL require(es == CD_AGG_OK, '6: the torsion deck builds at a yawed initial platform pose: '//TRIM(em)) + IF (es /= CD_AGG_OK) RETURN + CALL channels(agg, ta, tb, tw) + WRITE (*, '(A,F10.5,A,ES15.7,A,ES15.7)') '6 PtfmInit yaw 15 deg: Twist1 ', tw, ', Torq ', ta, '; ref ', & + GJ*psi/L + CALL require(ABS(tw - 15.0_wp) <= 1.0e-5_wp, '6: the static twist is +PtfmInit yaw') + CALL require(ABS(ta - GJ*psi/L) <= 1.0e-5_wp*GJ*psi/L, '6: the static torque is GJ yaw / L') + CALL CD_AGG_End(agg, es, em) + END SUBROUTINE check_ptfm_init + + ! ------------------------------------------------------------------------------------------ + SUBROUTINE check_restart() + !! Reference A rolls 150 deg in 15 deg steps, then 4 more steps. B is rebuilt from A's + !! mirror at 150 deg with the shell's recipe and steps the same 4 steps. + TYPE(CD_AGG_ModuleType) :: a, b + REAL(wp) :: pos(3, 1), vel(3, 1), acc(3, 1), load(3, 1), orient(3, 3, 1), omega(3, 1), alpha(3, 1) + REAL(wp) :: ta, tb, twa, twb, tqa, tqb, phi, t + REAL(wp), ALLOCATABLE :: mirror(:) + INTEGER :: es, ni, k, nm + LOGICAL :: ok, cv, st, same + CHARACTER(512) :: em + CALL write_deck('ctors_restart.dat', 'Coupled') + CALL init_agg(a, 'ctors_restart.dat', ok) + IF (.NOT. ok) RETURN + CALL CD_AGG_GetMovingPointMesh(a, pos, vel, acc, load, es, em, orientation=orient) + omega = 0.0_wp + alpha = 0.0_wp + omega(1, 1) = 15.0_wp*DEG/DT + DO k = 1, 10 + orient(:, :, 1) = roll_dcm(15.0_wp*DEG*k) + CALL CD_AGG_Step_Moving(a, DT, pos, vel, acc, cv, st, ni, es, em, orientation=orient, & + angular_velocity=omega, angular_acceleration=alpha) + CALL require(es == CD_AGG_OK .AND. cv, '7: reference roll step: '//TRIM(em)) + IF (es /= CD_AGG_OK) RETURN + END DO + t = DT*10 + nm = CD_HFMF_MirrorSize(a%cables(1)) + ALLOCATE (mirror(nm)) + CALL CD_HFMF_PackMirror(a%cables(1), mirror, es, em) + CALL require(es == CD_HFMF_OK, '7: pack the checkpoint mirror: '//TRIM(em)) + ! the previous order (coupled kinematics before the mirror) is refused by the pi/2 bound + CALL init_agg(b, 'ctors_restart.dat', ok) + IF (.NOT. ok) RETURN + CALL CD_AGG_UpdateStates_Moving(b, pos, vel, acc, es, em, orientation=orient, angular_velocity=omega, & + angular_acceleration=alpha) + CALL require(es /= CD_AGG_OK .AND. INDEX(em, 'pi/2') > 0, & + '7: kinematics at 150 deg before the torsion mirror are refused (the old rebuild order)') + CALL CD_AGG_End(b, es, em) + ! the shell's recipe: torsion mirror, coupled kinematics, full mirror + CALL init_agg(b, 'ctors_restart.dat', ok) + IF (.NOT. ok) RETURN + CALL CD_HFMF_UnpackMirror(b%cables(1), mirror, t, es, em) + CALL require(es == CD_HFMF_OK, '7: torsion mirror first: '//TRIM(em)) + CALL CD_AGG_UpdateStates_Moving(b, pos, vel, acc, es, em, orientation=orient, angular_velocity=omega, & + angular_acceleration=alpha) + CALL require(es == CD_AGG_OK, '7: coupled kinematics at the restart pose: '//TRIM(em)) + CALL CD_HFMF_UnpackMirror(b%cables(1), mirror, t, es, em) + CALL require(es == CD_HFMF_OK, '7: full mirror: '//TRIM(em)) + same = .TRUE. + DO k = 11, 14 + phi = 15.0_wp*DEG*k + orient(:, :, 1) = roll_dcm(phi) + CALL CD_AGG_Step_Moving(a, DT, pos, vel, acc, cv, st, ni, es, em, orientation=orient, & + angular_velocity=omega, angular_acceleration=alpha) + CALL require(es == CD_AGG_OK .AND. cv, '7: reference continues: '//TRIM(em)) + CALL CD_AGG_Step_Moving(b, DT, pos, vel, acc, cv, st, ni, es, em, orientation=orient, & + angular_velocity=omega, angular_acceleration=alpha) + CALL require(es == CD_AGG_OK .AND. cv, '7: restarted run continues: '//TRIM(em)) + CALL channels(a, tqa, ta, twa) + CALL channels(b, tqb, tb, twb) + same = same .AND. nan_max_abs(a%cables(1)%line%q - b%cables(1)%line%q) <= 0.0_wp .AND. & + ABS(tqa - tqb) <= 0.0_wp .AND. ABS(twa - twb) <= 0.0_wp + END DO + WRITE (*, '(A,F10.4,A,F10.4)') '7 restart: Twist1 reference ', twa, ', restarted ', twb + CALL require(same, '7: the restarted run continues bit-identically through the twist') + CALL require(ABS(twa + 210.0_wp) <= 1.0e-6_wp, '7: the continued twist is -210 deg') + CALL CD_AGG_End(a, es, em) + CALL CD_AGG_End(b, es, em) + END SUBROUTINE check_restart + + ! ------------------------------------------------------------------------------------------ + SUBROUTINE check_farm() + !! Two turbines 500 m apart; the vertical torsion line hangs under Turbine2. + TYPE(CD_AGG_ModuleType) :: agg + REAL(wp) :: ref_pos(3, 2), farm_init(6, 2), ta, tb, tw, psi + REAL(wp), ALLOCATABLE :: pos(:, :), vel(:, :), acc(:, :), load(:, :), orient(:, :, :) + INTEGER :: es, ncp + CHARACTER(512) :: em + psi = 10.0_wp*DEG + CALL write_deck('ctors_farm.dat', 'Turbine2', vertical=.TRUE., anchor_x=500.0_wp) + ref_pos = 0.0_wp + ref_pos(1, 2) = 500.0_wp + farm_init = 0.0_wp + farm_init(6, 2) = psi + CALL CD_AGG_Init_From_Deck(agg, 'ctors_farm.dat', DT, es, em, n_turbines=2, turbine_ref_pos=ref_pos, & + farm_ptfm_init=farm_init, forbid_deck_ambient=.TRUE., host_orientation=.TRUE.) + CALL require(es == CD_AGG_OK, '8: the farm deck with a torsion line on Turbine2 builds: '//TRIM(em)) + IF (es /= CD_AGG_OK) RETURN + CALL channels(agg, ta, tb, tw) + WRITE (*, '(A,F10.5,A,ES15.7)') '8 farm: Turbine2 yaw 10 deg: Twist1 ', tw, ', Torq ', ta + CALL require(ABS(tw - 10.0_wp) <= 1.0e-5_wp, '8: the static twist is the yaw of Turbine2') + CALL require(ABS(ta - GJ*psi/L) <= 1.0e-5_wp*GJ*psi/L, '8: the static torque is GJ yaw / L') + ncp = CD_AGG_NMovingPoints(agg, es, em) + ALLOCATE (pos(3, ncp), vel(3, ncp), acc(3, ncp), load(3, ncp), orient(3, 3, ncp)) + CALL CD_AGG_GetMovingPointMesh(agg, pos, vel, acc, load, es, em, orientation=orient) + orient(:, :, ncp) = yaw_dcm(psi + 20.0_wp*DEG) + CALL CD_AGG_UpdateStates_Moving(agg, pos, vel, acc, es, em, orientation=orient) + CALL require(es == CD_AGG_OK, '8: Turbine2 turns its fairlead: '//TRIM(em)) + CALL channels(agg, ta, tb, tw) + CALL require(ABS(tw - 30.0_wp) <= 1.0e-5_wp, '8: the twist follows Turbine2 to 30 deg') + CALL CD_AGG_End(agg, es, em) + END SUBROUTINE check_farm + +END PROGRAM test_coupled_torsion diff --git a/tests/test_torsion_deck.f90 b/tests/test_torsion_deck.f90 index 37080d7c..428fa7ac 100644 --- a/tests/test_torsion_deck.f90 +++ b/tests/test_torsion_deck.f90 @@ -949,13 +949,39 @@ SUBROUTINE check_errors() [CHARACTER(16) :: '1 1 2 -'], [CHARACTER(24) :: '1 cab 100.0 40'], & [CHARACTER(96) :: '1 A Rigid 1 0 0 Rigid 0 0 1 0', '1 B Rigid 1 0 0 Rigid 0 0 1 90'], & [CHARACTER(24) :: '0.1 dtM'], [CHARACTER(16) :: 'FairTen1']) + ! a caller that does not pass the fairlead orientation (the C API, the standalone mixed + ! route) is refused by name; one that does (the OpenFAST and FAST.Farm shells) builds the + ! line with its torsion CALL CD_Init_Deck_Aggregate('tdeck_e12.dat', 0.1_wp, agg, es, em) - CALL require(es /= CD_DECKDRV_OK .AND. INDEX(em, 'nor in coupled OpenFAST or FAST.Farm runs') > 0, & - 'the coupled aggregate refuses torsion by name (got: '//TRIM(em)//')') + CALL require(es /= CD_DECKDRV_OK .AND. INDEX(em, 'needs a host that turns its fairlead frame') > 0, & + 'an aggregate caller without orientations refuses torsion by name (got: '//TRIM(em)//')') CALL CD_End_Deck_Aggregate(agg) CALL CD_Init_Deck_HermiteCable('tdeck_e12.dat', 0.1_wp, cab, node, es, em) - CALL require(es /= CD_DECKDRV_OK .AND. INDEX(em, 'not yet supported in coupled OpenFAST runs') > 0, & - 'the coupled single-cable entry refuses torsion by name (got: '//TRIM(em)//')') + CALL require(es /= CD_DECKDRV_OK .AND. INDEX(em, 'needs a host that turns its fairlead frame') > 0, & + 'a single-cable caller without orientations refuses torsion by name (got: '//TRIM(em)//')') + CALL CD_HFMF_End(cab) + CALL CD_Init_Deck_Aggregate('tdeck_e12.dat', 0.1_wp, agg, es, em, host_orientation=.TRUE.) + CALL require(es == CD_DECKDRV_OK, 'an orientation-passing host builds the coupled torsion line (got: '// & + TRIM(em)//')') + CALL CD_End_Deck_Aggregate(agg) + CALL CD_Init_Deck_HermiteCable('tdeck_e12.dat', 0.1_wp, cab, node, es, em, host_orientation=.TRUE.) + CALL require(es == CD_DECKDRV_OK, 'an orientation-passing host builds the single coupled torsion cable '// & + '(got: '//TRIM(em)//')') + CALL require(cab%line%torsion%active, 'the single coupled cable carries its torsion') + CALL CD_HFMF_End(cab) + ! a coupled run is always dynamic: the configuration blend is refused with torsion + CALL write_deck('tdeck_e15.dat', [neutral_type], no_rows, & + [CHARACTER(48) :: '1 Coupled 0.0 0.0 -50.0 0 0 0 0', '2 Fixed 100.0 0.0 -50.0 0 0 0 0'], & + [CHARACTER(16) :: '1 1 2 -'], [CHARACTER(24) :: '1 cab 100.0 40'], & + [CHARACTER(96) :: '1 A Rigid 1 0 0 Rigid 0 0 1 0', '1 B Rigid 1 0 0 Rigid 0 0 1 90'], & + [CHARACTER(32) :: '0.1 dtM', 'False alpha_force_blend'], [CHARACTER(16) :: 'FairTen1']) + CALL CD_Init_Deck_Aggregate('tdeck_e15.dat', 0.1_wp, agg, es, em, host_orientation=.TRUE.) + CALL require(es /= CD_DECKDRV_OK .AND. INDEX(em, 'force-blended generalised-alpha') > 0, & + 'the coupled aggregate refuses torsion with the configuration blend (got: '//TRIM(em)//')') + CALL CD_End_Deck_Aggregate(agg) + CALL CD_Init_Deck_HermiteCable('tdeck_e15.dat', 0.1_wp, cab, node, es, em, host_orientation=.TRUE.) + CALL require(es /= CD_DECKDRV_OK .AND. INDEX(em, 'force-blended generalised-alpha') > 0, & + 'the coupled single cable refuses torsion with the configuration blend (got: '//TRIM(em)//')') CALL CD_HFMF_End(cab) CALL check_scope_refusals() ! the channel units of the torsion channels, as the range files label them From 1e25ca2766cdc01a61d52712bc40a728aa873b25 Mon Sep 17 00:00:00 2001 From: Jae Hoon Seo Date: Thu, 15 Oct 2026 04:22:09 +0900 Subject: [PATCH 06/31] test: compare the linearisation and FAST.Farm runs with MoorDyn (#12) Two items of the coupled-route validation backlog, and a build note. Linearisation. The release check gated only invariants of CableDyn's stiffness block and reported MoorDyn's zero-frequency reduction D - C A^-1 B as unusable. OpenFAST writes the .lin matrices in the .fst OutFmt, and with the usual 4-digit format D (about 1e8 N/m) cancels to a 1e4 N/m result; the same case reproduces the asymmetric block that way. openfast_lin_ab.py now writes both twins at full precision (ES24.15E3), lets MoorDyn settle, linearises at t = 0, refuses a reference with fewer than 10 digits or asymmetric above 1e-3, and gates CableDyn against it to 0.5 %. On the IEA-15 MW UMaine twin the fairlead stiffness agrees to 0.07-0.10 % (0.29 % for the transverse H/X term), the platform 6 x 6 diagonals to 0.10 %, and standalone static solves reproduce the block by finite differences to 1.5e-5. FAST.Farm. fastfarm_shared_ab.py prepares the r-test MD_Shared farm for both shared-mooring modules (identical inputs, every anchor-leg anchor tension added to the outputs) and compares complete runs only. Over 600 s, from 100 s on, tension means agree to 0.02 %, extremes to 0.25 %, platform motions to millimetres; the shared lines' tension std is 2.2-2.7 % lower with CableDyn and 1.0 % lower at half the mooring step (implicit 0.05 s step against MoorDyn's 1e-4 s explicit one). On a line with no Fixed end FairTen and AnchTen name the opposite ends from MoorDyn's; the migration guide now says so. Build. OpenFAST's CMake raises the Windows stack to 16 MB only for Cygwin and Visual Studio; a MinGW FAST.Farm.exe kept 2 MB and overflowed in ElastoDyn. DEVELOPMENT.md adds the linker flag. Signed-off-by: Jae Hoon Seo --- CHANGELOG.md | 14 + DEVELOPMENT.md | 6 + RELEASE.md | 11 +- VALIDATION.md | 22 +- doc/migrating.rst | 9 +- doc/openfast.rst | 5 +- validation/scripts/fastfarm_shared_ab.py | 223 +++++++++++++++ validation/scripts/openfast_lin_ab.py | 337 +++++++++++++++++------ 8 files changed, 540 insertions(+), 87 deletions(-) create mode 100644 validation/scripts/fastfarm_shared_ab.py diff --git a/CHANGELOG.md b/CHANGELOG.md index 4c95d454..3d552ce6 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -46,6 +46,20 @@ All notable changes to CableDyn are recorded in this file. The format follows outer iterations per step. The junction converges to the same tolerance, so results differ only within it, and by no more than the tolerance already allowed against a tightly converged run: tensions by about 2e-6 relative and the body position by under 1 µm. +- The OpenFAST linearisation check (`validation/scripts/openfast_lin_ab.py`) now compares + CableDyn's quasi-static mooring stiffness entry by entry with stock MoorDyn's zero-frequency + reduction `D - C A^-1 B`, and fails above 0.5 %. It writes the `.lin` files with the + full-precision `OutFmt` `ES24.15E3`, lets MoorDyn settle its initial condition, and + linearises at t = 0. Its default case is the `examples/openfast` IEA-15 UMaine twin. On + that case the per-fairlead stiffness agrees to 0.07–0.10 % (0.29 % for the transverse + term), and the platform 6 × 6 diagonals agree to 0.10 % or better. The earlier record had + called MoorDyn's reduction unusable; with the 4-digit default `OutFmt` the same case + reproduces that asymmetric reduction, so the check now refuses a reference written below + full precision. VALIDATION.md and the OpenFAST page of the manual are updated. +- The FAST.Farm shared-mooring comparison with stock MoorDyn now covers 600 s of the r-test + `MD_Shared` farm (`validation/scripts/fastfarm_shared_ab.py`): tension means agree to 0.02 %, + extremes to 0.25 %, and platform motions to millimetres. The migration guide now says that on + a line with no `Fixed` end `FairTen` and `AnchTen` name the opposite ends from MoorDyn's. ### Fixed diff --git a/DEVELOPMENT.md b/DEVELOPMENT.md index bad3ba8e..7e3c14f9 100644 --- a/DEVELOPMENT.md +++ b/DEVELOPMENT.md @@ -169,6 +169,12 @@ cmake -S -B -DCABLEDYN_ROOT= powershell -File integration/openfast/openfast_build_gate.ps1 -BuildDir -CaseFst ``` +With the MinGW gfortran of the conda environment, add +`-DCMAKE_EXE_LINKER_FLAGS="-Wl,--stack,16777216"` to the configure line. OpenFAST's +CMake raises the 2 MB default stack to 16 MB only for Cygwin and Visual Studio builds, +and a MinGW `FAST.Farm.exe` (`-DBUILD_FASTFARM=ON`) with the default stack stops with a +stack overflow while ElastoDyn initialises. + `openfast_build_gate.ps1` builds `openfast.exe`, runs a `CompMooring = 5` case, checks that the CableDyn banner appears in the log, and checks that the output is finite. diff --git a/RELEASE.md b/RELEASE.md index ad8f6270..1d3a1e8a 100644 --- a/RELEASE.md +++ b/RELEASE.md @@ -68,9 +68,14 @@ only the `cabledyn` package and its metadata. `openfast.exe` with CableDyn, checks that a coupled run prints the CableDyn banner, and checks that the output is finite. 2. **Linearisation check**: with the built executable, run - `python validation/scripts/openfast_lin_ab.py --exe --case-dir `. - The CableDyn mooring block must be symmetric to ≤ 1e-3 with negative restoring - diagonals and bounded sway coupling. + `python validation/scripts/openfast_lin_ab.py --exe --case-dir `, + where `` holds the `examples/openfast` IEA-15 UMaine twin decks and + the r-test `MD_Shared` turbine-1 ElastoDyn, HydroDyn, SeaState and HydroData + inputs (listed in the script docstring). The CableDyn mooring block must be + symmetric to ≤ 1e-3 with negative restoring diagonals and bounded sway + coupling. Its per-fairlead blocks and platform 6×6 stiffness must match stock + MoorDyn's quasi-static reduction to 0.5%. The script writes the `.lin` files + at full precision. 3. Confirm that [VALIDATION.md](VALIDATION.md) matches the results at the release commit. diff --git a/VALIDATION.md b/VALIDATION.md index c93346d7..04b223b7 100644 --- a/VALIDATION.md +++ b/VALIDATION.md @@ -330,6 +330,24 @@ scripts, results, and source provenance are in bit-identical (`correction_rewind`); a 40 s `NumCrctn = 1` OpenFAST run matches stock MoorDyn to **≤0.16%** of range and is bit-identical to its own `NumCrctn = 0` run. + - *Linearisation* + ([`validation/scripts/openfast_lin_ab.py`](https://github.com/SMI-Lab-Inha/CableDyn/blob/main/validation/scripts/openfast_lin_ab.py)): + the twin decks linearise once at t = 0. Each run has platform DOFs only, still water, and HydroDyn + `ExctnMod = RdtnMod = 0`. MoorDyn's relaxation runs for `TmaxIC = 400 s`, and both `.lin` files are + written with `OutFmt = ES24.15E3`. CableDyn's quasi-static `dYdu` (no states) is compared with + MoorDyn's zero-frequency reduction `D − C A⁻¹ B` over 882 states. The per-fairlead stiffness agrees + to **0.07–0.10%** (line 1: 49 741 / 49 706 N/m in-plane horizontal) and the transverse `H/X` term + to 0.29%. The platform 6×6 diagonals agree to **≤0.10%** (surge 77 211 / 77 156 N/m, + roll 2.6473e8 / 2.6466e8 N·m/rad), and every entry to ≤1.0e-3 of √(KᵢᵢKⱼⱼ). Standalone CableDyn + static solves reproduce the block by finite differences to 1.5e-5, and its transverse term equals + the analytic `H/X`. Both 50-segment models sit 7–12% above the continuous elastic catenary + because of the touchdown discretisation; refining to 800 segments converges to it within 0.1%. + MoorDyn's reduction needs the full-precision `OutFmt`. With the usual `ES10.3E2` (4 digits), + `D ≈ 1e8 N/m` cancels to a ~1e4 N/m result and the block is 57% asymmetric with sign-flipped + diagonals; the script refuses such a reference. In the full-system ElastoDyn linearisation, roll + and pitch are 7.29e6 N·m/rad below the module-level 6×6 for both mooring modules. A run with no + mooring and only a constant −6.084e6 N vertical load at the platform reference point (HydroDyn + `AddF0`) reproduces this term, so it comes from ElastoDyn/glue code and not from the mooring module. The mooring-only A/B compares an all-chain system that both codes model in the same way; the finite-EI cable under coupled motion is compared with OrcaFlex in L4-1c. @@ -707,8 +725,8 @@ stop with a named error. | Correction iterations (`NumCrctn > 0`) | Pass verified | bit-identical to own `NumCrctn = 0` run | | SeaState wave/current kinematics | Pass verified | wave A/B ≤0.16% of range | | Checkpoint-restart (incl. Free/Connect points) | Pass verified | restarted window = continuous run to 0.0 | -| Linearisation | Pass scoped | quasi-static `dYdu`; invariants tested; not compared entry by entry with MoorDyn's `-lin` output, which is sensitive to the seabed-contact operating point in this case | -| FAST.Farm shared moorings + clumps + channel record | Pass verified | 60 s farm A/B against stock MoorDyn; tension differences range from 0.04% to 3% across the compared statistics | +| Linearisation | Pass verified (quasi-static stiffness) | quasi-static `dYdu` compared entry by entry with stock MoorDyn's zero-frequency reduction `D − C A⁻¹ B` (full-precision `.lin` output): fairlead stiffness 0.07–0.10%, transverse `H/X` term 0.29%, platform 6×6 diagonals ≤0.10%; standalone static FD 1.5e-5; transverse term equals `H/X`. Velocity/acceleration columns are zero by design ([`openfast_lin_ab.py`](https://github.com/SMI-Lab-Inha/CableDyn/blob/main/validation/scripts/openfast_lin_ab.py)) | +| FAST.Farm shared moorings + clumps + channel record | Pass verified | 600 s A/B of the r-test `MD_Shared` farm against stock MoorDyn (same deck, analysis from 100 s; [`fastfarm_shared_ab.py`](https://github.com/SMI-Lab-Inha/CableDyn/blob/main/validation/scripts/fastfarm_shared_ab.py)): tension means ≤0.02%, minima and maxima ≤0.25%, platform motions within millimetres and 0.001°; shared-line tension std 2.2–2.7% lower, 1.0% at half the mooring step (CableDyn's implicit step at the 0.05 s coupling step against MoorDyn's 1e-4 s explicit step). On the shared lines, which have no Fixed end, `FairTen`/`AnchTen` name the opposite ends from MoorDyn's (see the migration guide). MoorDyn's initial settling does not converge for the anchor legs 6 and 7 (2.4 m excess length at t = 0), a start-up transient over by 100 s that most likely set the 3% end of the earlier 60 s record | | Slack-line tension convention | Pass verified | tension-only dynamics; BA on slack lines matches `MoorDyn_Line.f90` | | Farm + restart / Farm + linearisation | Not applicable | FAST.Farm has no restart and does not call module linearisation; the same applies to stock MoorDyn | | Line failures (`FAILURE` table) | Pass verified | MoorDyn semantics on both paths (reserve-point pre-allocation, time or tension trigger, detach onto a massless Free point); standalone (point systems and free Rigid6 bodies), coupled, and checkpoint-replay tests | diff --git a/doc/migrating.rst b/doc/migrating.rst index c2954251..e987db21 100644 --- a/doc/migrating.rst +++ b/doc/migrating.rst @@ -34,7 +34,11 @@ elements — exactly equivalent to a CableDyn ``LINES`` row ``1 4 1 -`` plus one ``1 chain 850.0 50``. MoorDyn writes lines anchor-first; when ``AttachA`` is a ``Fixed`` anchor and ``AttachB`` a ``Vessel``/``Coupled``/``Body`` fairlead, CableDyn swaps the ends so that **End A is the fairlead**, as everywhere in CableDyn. Endpoint channels therefore keep their -physical meaning: ``FairTen`` is at the fairlead, ``AnchTen`` at the anchor. +physical meaning: ``FairTen`` is at the fairlead, ``AnchTen`` at the anchor. A line with no +``Fixed`` end (a shared line between two turbines or through a clump) keeps the order written: +CableDyn's ``FairTen`` is at ``AttachA`` and ``AnchTen`` at ``AttachB``, while MoorDyn writes +``FairTen`` at ``AttachB`` (its last node) and ``AnchTen`` at ``AttachA``. Compare such lines +by end, not by channel name. ``examples/openfast/MoorDyn_UMaine.dat`` is such a stock deck. For a standalone run it needs only what OpenFAST (maintained by NLR, the National Laboratory of the Rockies, formerly NREL) @@ -112,7 +116,8 @@ Keyword map decks in OpenFAST (the standalone driver rejects it). A deck with a finite-EI cable rejects both * - ``FairTen``, ``AnchTen``, point/node channels - - same names; tensions in N (:doc:`outputs`) + - same names; tensions in N (:doc:`outputs`). On a line with no ``Fixed`` end the two + end channels name the opposite ends from MoorDyn's (see above) What differs on purpose ~~~~~~~~~~~~~~~~~~~~~~~ diff --git a/doc/openfast.rst b/doc/openfast.rst index 3791536a..1e701366 100644 --- a/doc/openfast.rst +++ b/doc/openfast.rst @@ -256,7 +256,10 @@ without an auxiliary process: ``MooringFile`` and removed after use, so side files resolve as on restart. Set ``dtM = DT`` and linearise at the initial operating point (``CalcSteady = False``, ``LinTimes = 0``, platform at its still-water equilibrium, rotor speed and pitch at their - steady values). Contact switching makes derivatives near touchdown non-smooth. A deck with + steady values). Contact switching makes derivatives near touchdown non-smooth. OpenFAST writes + the ``.lin`` matrices in the ``.fst`` ``OutFmt``; to compare them with MoorDyn's + ``D - C A^-1 B``, use a full-precision format such as ``"ES24.15E3"``, because the usual + 4-digit format cannot resolve that reduction. A deck with Rigid6 bodies or rods is rejected at initialisation: the quasi-static reduction would hold them at their deck pose instead of re-solving their equilibrium. * **FAST.Farm** selects CableDyn with ``Mod_SharedMooring = 5`` for shared lines and diff --git a/validation/scripts/fastfarm_shared_ab.py b/validation/scripts/fastfarm_shared_ab.py new file mode 100644 index 00000000..5843e155 --- /dev/null +++ b/validation/scripts/fastfarm_shared_ab.py @@ -0,0 +1,223 @@ +#!/usr/bin/env python3 +# SPDX-License-Identifier: Apache-2.0 +"""FAST.Farm shared-mooring A/B: CableDyn (Mod_SharedMooring = 5) vs stock MoorDyn (= 3). + +Twin runs of OpenFAST's r-test case ``glue-codes/fast-farm/MD_Shared`` (two IEA-15 MW UMaine +turbines, three shared lines through two clumps, four anchor legs, steady 8 m/s wind, polar +wake, JONSWAP waves), identical except for the shared-mooring module. CableDyn reads the stock +MoorDyn deck ``SharedMooring2.dat`` unchanged. + +``prepare`` copies the r-test folder twice and edits, identically in both copies except for +``Mod_SharedMooring``: ``TMax``, ``WrMooringVis False``, turbine ``WrVTK 0``, and the +anchor-leg anchor tensions ``AnchTen5``-``AnchTen7`` (the r-test deck writes ``AnchTen1``- +``AnchTen4`` only) and the clump position channels ``Point2p*``/``Point3p*`` added to the +deck's OUTPUTS. Run ``FAST.Farm.exe +FAST.Farm.fstf`` in each copy (one OpenMP thread), then ``compare``. + +Channel pairing. MoorDyn writes ``FairTen`` at the line's last node (deck ``AttachB``) and +``AnchTen`` at its first (``AttachA``) for every line. CableDyn writes ``FairTen`` at its +End A and ``AnchTen`` at its End B, and swaps a stock line's ends only when ``AttachA`` is a +Fixed anchor. On the anchor legs 4-7 the names therefore agree; on the shared lines 1-3, which +have no Fixed end, the same physical end carries the opposite name, and ``compare`` pairs them +by end (both pairings are printed for the record). + +Usage: + python -I validation/scripts/fastfarm_shared_ab.py prepare --rtest \\ + --out [--tmax 600] + python -I validation/scripts/fastfarm_shared_ab.py compare --md \\ + --cd [--t-start 100] [--csv ] + +Outputs compared (window t >= t-start): shared-line and anchor-leg tensions, clump positions, +and both turbines' platform motions; mean, std, min, max as (CD - MD)/|MD| and the RMS of the +difference over the MoorDyn std. +""" + +from __future__ import annotations + +import argparse +import re +import shutil +import sys +from pathlib import Path + +import numpy as np + +TURBINE_FILES = ("IEA-15-240-RWT-UMaineSemi_T1.fst", "IEA-15-240-RWT-UMaineSemi_T2.fst") + + +def die(msg: str) -> None: + print(f"FAIL: {msg}") + sys.exit(1) + + +def set_value(text: str, key: str, value: str, what: str) -> str: + """Replace the value field (first word) of the line whose key is `key`.""" + pat = re.compile(r"^(\s*)(\S+)(\s+" + re.escape(key) + r"\b)", re.M) + new, n = pat.subn(lambda m: m.group(1) + value + m.group(3), text, count=1) + if n != 1: + die(f"{what}: key {key} not found") + return new + + +def prepare(rtest: Path, out: Path, tmax: float) -> None: + if not (rtest / "FAST.Farm.fstf").is_file(): + die(f"{rtest} is not the MD_Shared r-test folder (no FAST.Farm.fstf)") + for tag, mod in (("md", 3), ("cd", 5)): + run = out / tag + if run.exists(): + die(f"{run} exists; choose an empty --out") + shutil.copytree(rtest, run, ignore=shutil.ignore_patterns("*.out", "*.outb", "*.vtp")) + fstf = run / "FAST.Farm.fstf" + t = fstf.read_text() + t = set_value(t, "TMax", f"{tmax:.1f}", fstf.name) + t = set_value(t, "Mod_SharedMooring", str(mod), fstf.name) + t = set_value(t, "WrMooringVis", "False", fstf.name) + fstf.write_text(t) + for name in TURBINE_FILES: + f = run / name + f.write_text(set_value(f.read_text(), "WrVTK", "0", name)) + deck = run / "SharedMooring2.dat" + t = deck.read_text() + marker = "FairTen7\n" + if marker not in t: + die("SharedMooring2.dat: OUTPUTS marker FairTen7 not found") + extra = "".join(f"AnchTen{line}\n" for line in (5, 6, 7)) + extra += "".join(f"Point{p}p{c}\n" for p in (2, 3) for c in "xyz") + deck.write_text(t.replace(marker, marker + extra, 1)) + print(f"prepared {run} (Mod_SharedMooring = {mod}, TMax = {tmax:g} s)") + + +def read_table(path: Path) -> dict[str, np.ndarray]: + """A FAST-style or CableDyn table: a 'Time' header row, a units row, then numbers.""" + if not path.is_file(): + die(f"missing output {path}") + lines = path.read_text().splitlines() + try: + i = next(k for k, line in enumerate(lines) if line.split() and line.split()[0] == "Time") + except StopIteration: + die(f"{path}: no 'Time' header") + names = lines[i].split() + data = np.array([line.split() for line in lines[i + 2 :] if line.strip()], dtype=float) + if data.ndim != 2 or data.shape[1] != len(names) or not np.all(np.isfinite(data)): + die(f"{path}: malformed or non-finite table") + return {n.upper(): data[:, j] for j, n in enumerate(names)} + + +def run_tmax(run: Path) -> float: + """TMax of a prepared run folder, from its FAST.Farm.fstf.""" + fstf = run / "FAST.Farm.fstf" + if not fstf.is_file(): + die(f"missing {fstf}") + m = re.search(r"^\s*(\S+)\s+TMax\b", fstf.read_text(), re.M) + if not m: + die(f"{fstf}: no TMax") + return float(m.group(1)) + + +def require_complete(table: dict, tmax: float, what: str) -> None: + """A run that stopped early would leave a shorter shared window: refuse it by name. A + complete table ends within one output interval of TMax (FAST.Farm's MoorDyn output omits + the last row).""" + t = table["TIME"] + if t.size < 2: + die(f"{what} has fewer than two rows") + t_end = float(t[-1]) + dt_out = float(np.median(np.diff(t))) + if t_end < tmax - 1.5 * dt_out: + die(f"{what} ends at t = {t_end:g} s, before TMax = {tmax:g} s (incomplete run)") + + +def align(a: dict, b: dict, t0: float, cadence_ms: int = 50) -> tuple[np.ndarray, np.ndarray]: + """Indices of the samples both tables share on a 1 ms grid, every cadence_ms, from t0.""" + ta = np.round(a["TIME"] * 1000).astype(np.int64) + tb = np.round(b["TIME"] * 1000).astype(np.int64) + common, ia, ib = np.intersect1d(ta, tb, return_indices=True) + keep = (common >= round(t0 * 1000)) & (common % cadence_ms == 0) + if not np.any(keep): + die("the two runs share no samples in the window") + return ia[keep], ib[keep] + + +def row(label: str, xm: np.ndarray, xc: np.ndarray) -> dict: + sm = np.array([xm.mean(), xm.std(), xm.min(), xm.max()]) + sc = np.array([xc.mean(), xc.std(), xc.min(), xc.max()]) + with np.errstate(divide="ignore", invalid="ignore"): + rel = np.where(np.abs(sm) > 0, (sc - sm) / np.abs(sm), np.nan) + rms = float(np.sqrt(np.mean((xc - xm) ** 2))) + return {"channel": label, "md": sm, "cd": sc, "rel": rel, + "rms_over_std": rms / sm[1] if sm[1] > 0 else np.nan} + + +def compare(md_dir: Path, cd_dir: Path, t0: float, csv: Path | None) -> None: + tmax = run_tmax(md_dir) + if abs(run_tmax(cd_dir) - tmax) > 1.0e-9 * max(1.0, tmax): + die("the two runs have different TMax") + md = read_table(md_dir / "FAST.Farm.FarmMD.MD.out") + cd = read_table(cd_dir / "FAST.Farm.FarmCD.out") + require_complete(md, tmax, "MoorDyn mooring output") + require_complete(cd, tmax, "CableDyn mooring output") + ia, ib = align(md, cd, t0) + pairs = [] + ends = {1: ("T1 fairlead", "clump 2"), 2: ("clump 2", "clump 3"), 3: ("clump 3", "T2 fairlead")} + for line, (a, b) in ends.items(): + pairs.append((f"L{line} end A, {a} [MD AnchTen{line} / CD FairTen{line}]", + f"ANCHTEN{line}", f"FAIRTEN{line}")) + pairs.append((f"L{line} end B, {b} [MD FairTen{line} / CD AnchTen{line}]", + f"FAIRTEN{line}", f"ANCHTEN{line}")) + for line in (4, 5, 6, 7): + pairs.append((f"L{line} anchor [AnchTen{line}]", f"ANCHTEN{line}", f"ANCHTEN{line}")) + pairs.append((f"L{line} fairlead [FairTen{line}]", f"FAIRTEN{line}", f"FAIRTEN{line}")) + for p in (2, 3): + for c in "XYZ": + pairs.append((f"Point{p}p{c.lower()} (clump)", f"POINT{p}P{c}", f"POINT{p}P{c}")) + rows = [] + for label, km, kc in pairs: + if km not in md or kc not in cd: + die(f"channel {km} / {kc} missing (run 'prepare' first)") + rows.append(row(label, md[km][ia], cd[kc][ib])) + same = [row(f"same name {k}{line}", md[f"{k}{line}"][ia], cd[f"{k}{line}"][ib]) + for line in (1, 2, 3) for k in ("FAIRTEN", "ANCHTEN")] + for tw in ("T1", "T2"): + a = read_table(md_dir / f"FAST.Farm.{tw}.out") + b = read_table(cd_dir / f"FAST.Farm.{tw}.out") + require_complete(a, tmax, f"MoorDyn run {tw} output") + require_complete(b, tmax, f"CableDyn run {tw} output") + ja, jb = align(a, b, t0) + for ch in ("PtfmSurge", "PtfmSway", "PtfmHeave", "PtfmRoll", "PtfmPitch", "PtfmYaw"): + rows.append(row(f"{tw} {ch}", a[ch.upper()][ja], b[ch.upper()][jb])) + print(f"window t >= {t0:g} s; % = (CD - MD)/|MD|; rms/std = RMS(CD - MD)/std(MD)") + print(f"{'channel':54s} {'MD mean':>11s} {'mean%':>8s} {'std%':>8s} {'min%':>8s} {'max%':>8s} {'rms/std':>8s}") + lines = ["channel,MD_mean,CD_mean,MD_std,CD_std,MD_min,CD_min,MD_max,CD_max," + "rel_mean,rel_std,rel_min,rel_max,rms_over_std"] + for r in rows + same: + m, c, rel = r["md"], r["cd"], 100 * r["rel"] + print(f"{r['channel']:54s} {m[0]:11.5g} {rel[0]:8.3f} {rel[1]:8.2f} {rel[2]:8.3f} " + f"{rel[3]:8.3f} {r['rms_over_std']:8.3f}") + vals = [m[0], c[0], m[1], c[1], m[2], c[2], m[3], c[3], *r["rel"], r["rms_over_std"]] + lines.append(",".join([f'"{r["channel"]}"'] + [f"{v:.8g}" for v in vals])) + if csv: + csv.write_text("\n".join(lines) + "\n") + print(f"wrote {csv}") + + +def main() -> None: + ap = argparse.ArgumentParser(description=__doc__.splitlines()[0]) + sub = ap.add_subparsers(dest="cmd", required=True) + p = sub.add_parser("prepare", help="copy and edit the r-test case for both modules") + p.add_argument("--rtest", type=Path, required=True) + p.add_argument("--out", type=Path, required=True) + p.add_argument("--tmax", type=float, default=600.0) + c = sub.add_parser("compare", help="compare the MoorDyn and CableDyn runs") + c.add_argument("--md", type=Path, required=True) + c.add_argument("--cd", type=Path, required=True) + c.add_argument("--t-start", type=float, default=100.0) + c.add_argument("--csv", type=Path) + args = ap.parse_args() + if args.cmd == "prepare": + prepare(args.rtest, args.out, args.tmax) + else: + compare(args.md, args.cd, args.t_start, args.csv) + + +if __name__ == "__main__": + main() diff --git a/validation/scripts/openfast_lin_ab.py b/validation/scripts/openfast_lin_ab.py index 32cb0ebf..c8c72970 100644 --- a/validation/scripts/openfast_lin_ab.py +++ b/validation/scripts/openfast_lin_ab.py @@ -5,32 +5,68 @@ Twin still-water IEA-15MW UMaine runs, identical except for the mooring module, each linearized once at the same time with module-level output (LinOutMod). -WHAT IS GATED -- CableDyn's quasi-static dYdu stiffness block (force rows vs -translation-displacement columns, matched by ROW/COLUMN LABELS) must satisfy -the invariants of a true mooring tangent stiffness at equilibrium: - * symmetry (a conservative static tangent); - * negative displacement diagonals (restoring); - * spread-symmetry: a collective surge produces (near-)zero net sway force - on this y-symmetric three-line spread. -Measured on this model the block is symmetric to machine noise and its -collective surge stiffness is stable across operating points (~75 kN/m). - -WHAT IS REPORTED, NOT GATED -- the same block from stock MoorDyn's -zero-frequency reduction K_md = D - C A^-1 B. Measured on this catenary + -seabed model, MoorDyn's own FD linearization is contact-noisy: its block is -asymmetric (~14 %) and violates the spread's y-symmetry by orders of -magnitude, so it is NOT a usable reference here (the numbers are printed as -evidence). The rigorous cross-code check is the finite-displacement settled -A/B (displaced-start static solves in both codes, `openfast_settled_ab.py`). +The script derives the linearization decks from a time-domain twin pair: + * .fst: one linearization at --t-lin (default 0, the still-water initial + operating point the CableDyn documentation prescribes), LinInputs = + LinOutputs = 2, LinOutMod, and a FULL-PRECISION OutFmt (--outfmt, default + ES24.15E3). OpenFAST writes the .lin matrices with OutFmt; the usual + ES10.3E2 keeps 4 significant digits, which cannot resolve MoorDyn's + D - C A^-1 B (D ~ 1e8 N/m, the result ~ 1e4 N/m) -- the cancellation + turns the reduction into noise; + * HydroDyn: ExctnMod = RdtnMod = NewmanApp = 0 (HydroDyn refuses to + linearize DFT excitation, convolution radiation and Newman drift); + * SeaState: WaveMod = 0 (still water; SeaState linearizes only still water); + * MoorDyn deck: TmaxIC = --md-tmaxic (default 400 s) and threshIC = 1e-7, + so the dynamic-relaxation initial state is settled, and no + `SeaState WaterKin` row (no effect in still water). + +WHAT IS GATED + 1. CableDyn invariants of a tangent mooring stiffness at equilibrium, on its + quasi-static dYdu (force rows vs translation-displacement columns, matched + by ROW/COLUMN LABELS): symmetry, negative (restoring) displacement + diagonals, and no net sway force under a collective surge of this + y-symmetric spread. + 2. The reference itself: MoorDyn's zero-frequency reduction + K_md = D - C A^-1 B must be symmetric (<= 1e-3) and its .lin matrices + must carry >= 10 significant digits; otherwise the comparison is refused + with a named error (the usual cause is a low-precision OutFmt). + 3. CableDyn against MoorDyn, entry by entry: + * per-fairlead 3x3 stiffness blocks: entries >= 10 % of the block's + largest within --gate-pct (default 0.5 %), every entry >= 1 % of it + within 2 x --gate-pct; cross-fairlead entries ~0 in both; + * the 6x6 platform stiffness about the global origin (rigid platform + motion of the fairleads plus the geometric term of each code's own + operating-point fairlead loads): diagonals within --gate-pct, every + entry within --gate-pct of sqrt(K_ii K_jj). + Measured on this model (OutFmt ES24.15E3, TmaxIC 400 s, t = 0): the + dominant fairlead entries agree to 0.07-0.10 %, the small transverse + (H/X) entry to 0.29 %, the 6x6 diagonals to <= 0.10 % and every 6x6 + entry to 1.0e-3 of sqrt(K_ii K_jj) or better. + +The 6x6 is the module-level stiffness. A full-system ElastoDyn linearization +additionally contains a term of ElastoDyn/glue origin proportional to the +static vertical platform load (identical for both modules; see VALIDATION.md). + +Case directory: the twin pair examples/openfast/IEA-15-UMaine_CompMooring5_CableDyn.fst +and IEA-15-UMaine_CompMooring3_MoorDyn.fst (the --ref-cd/--ref-md defaults) +with their mooring decks CableDyn_UMaine.dat and MoorDyn_UMaine.dat, plus the +files they reference that are not in the repository: the ElastoDyn (with its +tower and blade files), HydroDyn and SeaState inputs and the WAMIT HydroData +folder of OpenFAST r-test glue-codes/fast-farm/MD_Shared (turbine 1, with the +pose reset to zero as described in examples/openfast/README.md). The script +writes its Main_lin_* decks and *_lin input copies into that directory. Fail-closed: missing .lin files, unparseable sections, empty matched blocks (e.g. a module whose coupled-mesh inputs did not enter the linearization set), -and non-finite entries all abort with a named error. +mismatched fairlead geometry between the two decks, and non-finite entries all +abort with a named error. Usage: python validation/scripts/openfast_lin_ab.py --exe --case-dir - [--ref-cd Main_settle_cd5.fst] [--ref-md Main_settle_md3.fst] - [--t-lin 60.0] [--gate-pct 5.0] [--skip-run] + [--ref-cd IEA-15-UMaine_CompMooring5_CableDyn.fst] + [--ref-md IEA-15-UMaine_CompMooring3_MoorDyn.fst] + [--t-lin 0.0] [--gate-pct 0.5] [--outfmt ES24.15E3] [--md-tmaxic 400] + [--skip-run] """ from __future__ import annotations @@ -44,6 +80,7 @@ import numpy as np LIN_BLOCK = re.compile(r"^-+\s*LINEARIZATION\s*-+", re.IGNORECASE) +MIN_DIGITS = 10 # significant digits the .lin matrices must carry for the MoorDyn reduction def die(msg: str) -> None: @@ -51,14 +88,17 @@ def die(msg: str) -> None: sys.exit(1) -def swap_keys(src: Path, dst: Path, swaps: dict[str, str], required: bool, what: str) -> set[str]: +def swap_keys(src: Path, dst: Path, swaps: dict[str, str], required: bool, what: str, + drop: re.Pattern | None = None) -> set[str]: """Copy a value-first OpenFAST input file, replacing the value field of the named keys. The key is the LAST word before ' - ' (LinTimes carries a - comma-separated value list).""" + comma-separated value list). Lines matching `drop` are left out.""" lines = src.read_text().splitlines(keepends=True) out: list[str] = [] seen: set[str] = set() for ln in lines: + if drop is not None and drop.match(ln): + continue m = re.match(r"^\s*[^-\s].*?(\w+)\s+-\s", ln) key = m.group(1) if m else None if key in swaps: @@ -74,12 +114,37 @@ def swap_keys(src: Path, dst: Path, swaps: dict[str, str], required: bool, what: return seen -def prepare_lin_deck(src: Path, dst: Path, t_lin: float) -> None: +def file_entry(text: str, key: str, where: str) -> str: + m = re.search(rf'"([^"]+)"\s+{key}\b', text) + if not m: + die(f"{where}: {key} entry not found") + return m.group(1) + + +def derive(dst_fst: Path, text: str, key: str, suffix: str, swaps: dict[str, str], + need: set[str], what: str, drop: re.Pattern | None = None) -> str: + """Write a modified copy of the input file the .fst names under `key` and + point the .fst text at it.""" + name = file_entry(text, key, dst_fst.name) + src = (dst_fst.parent / name).resolve() + if not src.is_file(): + die(f"{dst_fst.name}: {key} file not found: {src}") + dst = dst_fst.parent / (src.stem + suffix + src.suffix) + seen = swap_keys(src, dst, swaps, required=False, what=what, drop=drop) + if need and not need & seen: + die(f"{src.name}: none of {sorted(need)} found -- cannot make the {what} deck") + return text.replace(f'"{name}"', f'"{dst.name}"') + + +def prepare_lin_deck(src: Path, dst: Path, t_lin: float, outfmt: str, md_tmaxic: float) -> None: """Copy an .fst deck, enabling one linearization snapshot at t_lin, and derive - a linearization-compatible HydroDyn twin (no DFT excitation, no convolution - radiation, no Newman 2nd-order -- HydroDyn refuses to linearize those).""" + linearization-compatible HydroDyn/SeaState twins (and, for MoorDyn, a settled + initial-condition deck).""" + if not src.is_file(): + die(f"reference deck not found: {src}") swap_keys(src, dst, { - "TMax": f"{t_lin:.1f}", + "TMax": f"{max(t_lin, 0.1):.6f}", + "OutFmt": f'"{outfmt}"', "Linearize": "True", "CalcSteady": "False", "NLinTimes": "1", @@ -94,20 +159,17 @@ def prepare_lin_deck(src: Path, dst: Path, t_lin: float) -> None: }, required=True, what="linearization") text = dst.read_text() - m = re.search(r'"([^"]+)"\s+HydroFile', text) - if not m: - die(f"{dst.name}: HydroFile entry not found") - hydro_src = (dst.parent / m.group(1)).resolve() - hydro_dst = dst.parent / (hydro_src.stem + "_lin" + hydro_src.suffix) - seen = swap_keys(hydro_src, hydro_dst, { - "ExctnMod": "0", - "RdtnMod": "0", - "NewmanApp": "0", - }, required=False, what="HydroDyn linearization") - if not {"ExctnMod", "RdtnMod"} & seen: - die(f"{hydro_src.name}: neither ExctnMod nor RdtnMod found -- cannot make " - f"the HydroDyn deck linearization-compatible") - dst.write_text(text.replace(m.group(1), hydro_dst.name)) + text = derive(dst, text, "HydroFile", "_lin", + {"ExctnMod": "0", "RdtnMod": "0", "NewmanApp": "0"}, + {"ExctnMod", "RdtnMod"}, "HydroDyn linearization") + if re.search(r'^\s*1\s+CompSeaSt\b', text, re.M): + text = derive(dst, text, "SeaStFile", "_lin", {"WaveMod": "0"}, {"WaveMod"}, + "SeaState still-water") + if re.search(r'^\s*3\s+CompMooring\b', text, re.M): + text = derive(dst, text, "MooringFile", "_lin", + {"TmaxIC": f"{md_tmaxic:.1f}", "threshIC": "1.0e-7"}, {"TmaxIC"}, + "MoorDyn settled-IC", drop=re.compile(r"^\s*SeaState\s+WaterKin\b", re.I)) + dst.write_text(text) def run_case(exe: Path, fst: Path) -> None: @@ -123,8 +185,30 @@ def run_case(exe: Path, fst: Path) -> None: die(f"openfast failed on {fst.name} (rc={proc.returncode}):\n{tail}") +def coupled_points(fst: Path) -> np.ndarray: + """Coordinates of the Coupled/Vessel points of the mooring deck named by the .fst, + in deck order (the order of the coupled-mesh nodes in both modules).""" + text = fst.read_text() + deck = (fst.parent / file_entry(text, "MooringFile", fst.name)).resolve() + if not deck.is_file(): + die(f"{fst.name}: MooringFile not found: {deck}") + pts: list[list[float]] = [] + in_points = False + for ln in deck.read_text().splitlines(): + if ln.lstrip().startswith("-"): + in_points = "POINTS" in ln.upper() or "CONNECTION" in ln.upper() + continue + tok = ln.split() + if in_points and len(tok) >= 5 and tok[0].isdigit() and \ + tok[1].lower() in ("coupled", "vessel", "cpld", "ves"): + pts.append([float(v) for v in tok[2:5]]) + if not pts: + die(f"{deck.name}: no Coupled/Vessel points found in the POINTS section") + return np.array(pts) + + def parse_module_lin(path: Path) -> dict: - """Parse an OpenFAST module .lin file: sizes, labels, and A/B/C/D matrices.""" + """Parse an OpenFAST module .lin file: sizes, labels, operating points, A/B/C/D.""" if not path.is_file(): die(f"missing linearization file: {path}") text = path.read_text().splitlines() @@ -166,6 +250,7 @@ def read_labels(header: str, count: int) -> list[str]: u_labels = read_labels("Order of inputs", n_u) if n_u else [] y_labels = read_labels("Order of outputs", n_y) if n_y else [] + digits = [99] def read_matrix(name: str, rows: int, cols: int) -> np.ndarray: if rows == 0 or cols == 0: @@ -187,6 +272,9 @@ def read_matrix(name: str, rows: int, cols: int) -> np.ndarray: flat.extend(float(v) for v in toks) except ValueError: break + if len(flat) == len(toks): # first data row: mantissa digits + mant = toks[0].lstrip("+-").upper().split("E")[0].replace(".", "") + digits[0] = min(digits[0], len(mant)) if len(flat) != rows * cols: die(f"{path.name}: {name} yielded {len(flat)} values, expected {rows * cols}") mat = np.array(flat).reshape(rows, cols) @@ -196,15 +284,13 @@ def read_matrix(name: str, rows: int, cols: int) -> np.ndarray: die(f"{path.name}: matrix {name} ({rows}x{cols}) not found") raise AssertionError - return { - "n_x": n_x, - "u_labels": u_labels, - "y_labels": y_labels, + mats = { "A": read_matrix("A", n_x, n_x), "B": read_matrix("B", n_x, n_u), "C": read_matrix("C", n_y, n_x), "D": read_matrix("D", n_y, n_u), } + return {"n_x": n_x, "u_labels": u_labels, "y_labels": y_labels, "digits": digits[0], **mats} def match_indices(labels: list[str], must: list[str]) -> list[int]: @@ -212,56 +298,88 @@ def match_indices(labels: list[str], must: list[str]) -> list[int]: return idx +def op_values(labels: list[str], idx: list[int]) -> np.ndarray: + """Operating-point column (second token) of the selected label rows.""" + return np.array([float(labels[i].split()[1].rstrip(",")) for i in idx]) + + def static_impedance(mod: dict) -> np.ndarray: """K = D - C A^+ B (reduces to D when the module carries no states). - A^+ is the pseudo-inverse: a lumped-mass mooring on a FRICTIONLESS seabed has - neutral horizontal modes on its grounded nodes (zero restoring force), so A is - singular and a naive solve fills the block with junk (measured: asymmetric, - sign-flipped diagonals). The minimum-norm solution projects the neutral modes - out -- they stay put under a static boundary displacement, which is exactly the - quasi-static physics.""" + A^+ is the pseudo-inverse when A is numerically singular: a lumped-mass + mooring on a FRICTIONLESS seabed can have neutral horizontal modes on its + grounded nodes (zero restoring force). The minimum-norm solution projects the + neutral modes out -- they stay put under a static boundary displacement, which + is exactly the quasi-static physics. On the settled UMaine deck with full + precision A is regular (the seabed penalty and line tension restrain every + node) and the plain solve is used.""" if mod["n_x"] == 0: return mod["D"] A = mod["A"] sv = np.linalg.svd(A, compute_uv=False) cond = sv[0] / max(sv[-1], 1e-300) + print(f"MD state matrix: {A.shape[0]} states, cond ~ {cond:.2e}") if cond > 1e10: - print(f"note: state matrix cond ~ {cond:.2e} (neutral modes); using the " - f"pseudo-inverse zero-frequency reduction") + print("note: neutral modes; using the pseudo-inverse zero-frequency reduction") X = np.linalg.lstsq(A, mod["B"], rcond=1e-8)[0] else: X = np.linalg.solve(A, mod["B"]) return mod["D"] - mod["C"] @ X -def block(mod: dict, K: np.ndarray, row_must: list[str], col_must: list[str], what: str) -> np.ndarray: +def block(mod: dict, K: np.ndarray, row_must: list[str], col_must: list[str], what: str) -> tuple: rows = match_indices(mod["y_labels"], row_must) cols = match_indices(mod["u_labels"], col_must) if not rows or not cols: die(f"{what}: no labels matched rows={row_must} ({len(rows)}) cols={col_must} ({len(cols)}) " f"-- the module's coupled mesh did not enter the linearization set") - return K[np.ix_(rows, cols)] + return K[np.ix_(rows, cols)], rows + + +def skew(v: np.ndarray) -> np.ndarray: + return np.array([[0.0, -v[2], v[1]], [v[2], 0.0, -v[0]], [-v[1], v[0], 0.0]]) + + +def platform_stiffness(K: np.ndarray, r: np.ndarray, F0: np.ndarray) -> np.ndarray: + """6x6 stiffness -d[F; M]/d[u; theta] about the global origin for a rigid motion + of the fairleads (d_i = u + theta x r_i), from the nodal stiffness K = -dF/dx and + the operating-point fairlead loads F0 (load on the platform): the moment + linearisation adds the geometric term (theta x r_i) x F_i.""" + n = r.shape[0] + T = np.zeros((3 * n, 6)) + for i in range(n): + T[3 * i:3 * i + 3, 0:3] = np.eye(3) + T[3 * i:3 * i + 3, 3:6] = -skew(r[i]) + dF = -K @ T + L = np.zeros((6, 6)) + for i in range(n): + L[0:3] += dF[3 * i:3 * i + 3] + L[3:6] += skew(r[i]) @ dF[3 * i:3 * i + 3] + L[3:6, 3:6] += skew(F0[i]) @ skew(r[i]) + return -L def main() -> None: ap = argparse.ArgumentParser() ap.add_argument("--exe", type=Path, required=True) ap.add_argument("--case-dir", type=Path, required=True) - ap.add_argument("--ref-cd", default="Main_settle_cd5.fst") - ap.add_argument("--ref-md", default="Main_settle_md3.fst") - ap.add_argument("--t-lin", type=float, default=60.0) - # accepted for compatibility with the other A/B scripts; the pass criteria here are the - # invariants above, not a percentage - ap.add_argument("--gate-pct", type=float, default=5.0) + ap.add_argument("--ref-cd", default="IEA-15-UMaine_CompMooring5_CableDyn.fst") + ap.add_argument("--ref-md", default="IEA-15-UMaine_CompMooring3_MoorDyn.fst") + ap.add_argument("--t-lin", type=float, default=0.0) + ap.add_argument("--gate-pct", type=float, default=0.5, + help="CableDyn vs MoorDyn tolerance in %% (see the module docstring)") + ap.add_argument("--outfmt", default="ES24.15E3", + help="OutFmt written into both decks; the .lin matrices use it") + ap.add_argument("--md-tmaxic", type=float, default=400.0, + help="MoorDyn dynamic-relaxation time TmaxIC (s)") ap.add_argument("--skip-run", action="store_true") args = ap.parse_args() case = args.case_dir cd_fst = case / "Main_lin_cd5.fst" md_fst = case / "Main_lin_md3.fst" - prepare_lin_deck(case / args.ref_cd, cd_fst, args.t_lin) - prepare_lin_deck(case / args.ref_md, md_fst, args.t_lin) + prepare_lin_deck(case / args.ref_cd, cd_fst, args.t_lin, args.outfmt, args.md_tmaxic) + prepare_lin_deck(case / args.ref_md, md_fst, args.t_lin, args.outfmt, args.md_tmaxic) if not args.skip_run: for fst in (cd_fst, md_fst): @@ -276,12 +394,19 @@ def main() -> None: die("CableDyn module reported continuous states under linearization " "(the dYdu-only reduction must register Nx = 0)") + r_cd = coupled_points(cd_fst) + r_md = coupled_points(md_fst) + if r_cd.shape != r_md.shape or np.abs(r_cd - r_md).max() > 1e-6: + die(f"the two mooring decks have different Coupled/Vessel fairleads:\nCD {r_cd}\nMD {r_md}") + K_cd = static_impedance(cd) K_md = static_impedance(md) - # The gated block: CD's quasi-static stiffness invariants. - kb_cd = block(cd, K_cd, ["force"], ["translation displacement"], "CD stiffness") + # 1. CableDyn's quasi-static stiffness invariants. + kb_cd, rows_cd = block(cd, K_cd, ["force"], ["translation displacement"], "CD stiffness") n = kb_cd.shape[0] + if n != 3 * r_cd.shape[0] or kb_cd.shape[1] != n: + die(f"CD stiffness block {kb_cd.shape} does not match {r_cd.shape[0]} coupled fairleads") sym = np.linalg.norm(kb_cd - kb_cd.T) / max(np.linalg.norm(kb_cd), 1e-30) print(f"CD stiffness block {kb_cd.shape}: symmetry |K-K^T|/|K| = {sym:.2e} (gate 1e-3)") diag = np.diag(kb_cd) @@ -292,21 +417,75 @@ def main() -> None: fy = float(kb_cd[1::3, :] @ e @ np.ones(n // 3)) print(f"CD collective surge stiffness: dFx = {fx:.5g} N/m, net sway leak |dFy/dFx| = " f"{abs(fy) / max(abs(fx), 1e-30):.2e} (gate 1e-2 on this y-symmetric spread)") - ok = sym <= 1e-3 and bool(np.all(diag < 0.0)) and abs(fy) <= 1e-2 * abs(fx) - - # Reported, not gated: stock MoorDyn's zero-frequency reduction on the same - # block. Measured contact-noisy on catenary + seabed decks (asymmetric, - # y-symmetry-violating) -- printed as evidence, not used as a reference. - kb_md = block(md, K_md, ["force"], ["translation displacement"], "MD stiffness") + failures: list[str] = [] + if not (sym <= 1e-3 and bool(np.all(diag < 0.0)) and abs(fy) <= 1e-2 * abs(fx)): + failures.append("CD stiffness block violates the quasi-static invariants") + + # 2. The reference: MoorDyn's zero-frequency reduction on the same block. + kb_md, rows_md = block(md, K_md, ["force"], ["translation displacement"], "MD stiffness") + if kb_md.shape != kb_cd.shape: + die(f"MD stiffness block {kb_md.shape} differs from CD {kb_cd.shape}") sym_md = np.linalg.norm(kb_md - kb_md.T) / max(np.linalg.norm(kb_md), 1e-30) - fx_md = float(kb_md[0::3, :] @ e @ np.ones(n // 3)) - fy_md = float(kb_md[1::3, :] @ e @ np.ones(n // 3)) - print(f"MD (informational): collective surge dFx = {fx_md:.5g} N/m, asymmetry {sym_md:.2f}, " - f"sway leak |dFy/dFx| = {abs(fy_md) / max(abs(fx_md), 1e-30):.2f} -- a symmetric spread " - f"must have ~zero leak; MoorDyn's -lin FD is contact-noisy here and is not the reference") - - if not ok: - die("CD stiffness block violates the quasi-static invariants (see above)") + print(f"MD reference: .lin digits {md['digits']} (gate >= {MIN_DIGITS}), " + f"symmetry |K-K^T|/|K| = {sym_md:.2e} (gate 1e-3)") + if md["digits"] < MIN_DIGITS or sym_md > 1e-3: + failures.append(f"MoorDyn reference unusable (digits {md['digits']}, asymmetry {sym_md:.2e}): " + f"write the .lin files with a full-precision OutFmt (e.g. ES24.15E3) and " + f"settle the MoorDyn initial condition (TmaxIC)") + + # 3. CableDyn vs MoorDyn, entry by entry. + F0_cd = op_values(cd["y_labels"], rows_cd).reshape(-1, 3) + F0_md = op_values(md["y_labels"], rows_md).reshape(-1, 3) + dF0 = np.abs(F0_cd - F0_md).max() / np.abs(F0_md).max() + print(f"operating-point fairlead loads: max |CD-MD| / max|F| = {dF0:.2e} (gate 1e-2)") + if dF0 > 1e-2: + failures.append("the two operating points differ (fairlead loads)") + K = -kb_cd # stiffness = -dF/dx + Kr = -kb_md + tol = args.gate_pct / 100.0 + worst_dom, worst_all, worst_x = 0.0, 0.0, 0.0 + print("per-fairlead 3x3 blocks (K = -dF/dx, N/m), CD / MD / rel. diff:") + for p in range(n // 3): + s = slice(3 * p, 3 * p + 3) + b, br = K[s, s], Kr[s, s] + big = np.abs(br).max() + for i in range(3): + row = [] + for j in range(3): + rel = (b[i, j] - br[i, j]) / br[i, j] if abs(br[i, j]) > 1e-2 * big else 0.0 + if abs(br[i, j]) >= 0.1 * big: + worst_dom = max(worst_dom, abs(rel)) + if abs(br[i, j]) >= 1e-2 * big: + worst_all = max(worst_all, abs(rel)) + row.append(f"{b[i, j]:11.5g} / {br[i, j]:11.5g} / {rel:+.2e}") + print(f" fairlead {p + 1} {'xyz'[i]}: " + " | ".join(row)) + for q in range(n // 3): + if q != p: + t = slice(3 * q, 3 * q + 3) + worst_x = max(worst_x, float(np.abs(K[s, t]).max() + np.abs(Kr[s, t]).max()) / big) + print(f"fairlead blocks: dominant entries max rel. diff {worst_dom:.2e} (gate {tol:.1e}); " + f"all entries >= 1% of block max {worst_all:.2e} (gate {2 * tol:.1e}); " + f"cross-fairlead / block max {worst_x:.1e} (gate 1e-6)") + if worst_dom > tol or worst_all > 2 * tol or worst_x > 1e-6: + failures.append("per-fairlead stiffness differs from MoorDyn beyond the gate") + + K6 = platform_stiffness(K, r_cd, F0_cd) + K6r = platform_stiffness(Kr, r_md, F0_md) + dofs = ["Surge", "Sway", "Heave", "Roll", "Pitch", "Yaw"] + print("platform 6x6 stiffness about the origin, diagonal (CD / MD / rel. diff):") + rel_d = np.diag(K6) / np.diag(K6r) - 1.0 + for i in range(6): + print(f" {dofs[i]:5s} {K6[i, i]:13.6e} / {K6r[i, i]:13.6e} / {rel_d[i]:+.2e}") + norm = np.abs(K6 - K6r) / np.sqrt(np.abs(np.outer(np.diag(K6r), np.diag(K6r)))) + i, j = np.unravel_index(int(norm.argmax()), norm.shape) + print(f" surge-pitch {K6[0, 4]:.6e} / {K6r[0, 4]:.6e}, sway-roll {K6[1, 3]:.6e} / {K6r[1, 3]:.6e}") + print(f"6x6: max |diag rel. diff| {np.abs(rel_d).max():.2e} (gate {tol:.1e}); " + f"max |dK_ij|/sqrt(K_ii K_jj) {norm.max():.2e} at ({dofs[i]},{dofs[j]}) (gate {tol:.1e})") + if np.abs(rel_d).max() > tol or norm.max() > tol: + failures.append("platform 6x6 stiffness differs from MoorDyn beyond the gate") + + if failures: + die("; ".join(failures)) print("PASS") From 330a8153e08dbb86dbf189787a139ffcef567653 Mon Sep 17 00:00:00 2001 From: Jae Hoon Seo Date: Thu, 15 Oct 2026 05:46:13 +0900 Subject: [PATCH 07/31] test: hold the vertical coupled-torsion lines taut (#13) The PtfmInit and FAST.Farm checks of coupled_torsion hang a neutrally buoyant 100 m line under the fairlead with its anchor exactly 100 m below, so the static solve starts from zero tension, where it has no catenary seed and its result depends on round-off. With OPENBLAS_CORETYPE=Prescott (the workaround for the OpenBLAS 0.3.34 modal crash) the FAST.Farm check failed deterministically: the mesh-sequenced fallback stopped on a kinked state. The anchor now sits 0.5 m lower, so the line hangs taut at 0.5 % strain; the twist and torque checks are unchanged (the torsion compliance uses the unstretched length) and pass with the default, Prescott, Haswell and SkylakeX kernels. Signed-off-by: Jae Hoon Seo --- tests/test_coupled_torsion.f90 | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/tests/test_coupled_torsion.f90 b/tests/test_coupled_torsion.f90 index fcfe2fe0..fe2aaea2 100644 --- a/tests/test_coupled_torsion.f90 +++ b/tests/test_coupled_torsion.f90 @@ -76,7 +76,10 @@ END SUBROUTINE require SUBROUTINE write_deck(path, point_a, vertical, anchor_x) !! The straight neutral torsion line, End A on point_a, outputs Torq1N1, Torq1N41, Twist1: !! along +x from (0, 0, -50) to (100, 0, -50), or with vertical from (0, 0, -20) down to - !! (anchor_x, 0, -120) (anchor_x: the farm-global x of the turbine the line hangs under). + !! (anchor_x, 0, -120.5) (anchor_x: the farm-global x of the turbine the line hangs under). + !! The vertical line is held taut at 0.5 % strain: at zero tension its static solve has no + !! catenary seed and its result depends on round-off (it failed with OpenBLAS's Prescott + !! kernels). CHARACTER(*), INTENT(IN) :: path, point_a LOGICAL, INTENT(IN), OPTIONAL :: vertical REAL(wp), INTENT(IN), OPTIONAL :: anchor_x @@ -89,7 +92,7 @@ SUBROUTINE write_deck(path, point_a, vertical, anchor_x) ax = 0.0_wp IF (PRESENT(anchor_x)) ax = anchor_x anchor = '2 Fixed 100.0 0.0 -50.0 0 0 0 0' - IF (vert) WRITE (anchor, '(A,F8.1,A)') '2 Fixed ', ax, ' 0.0 -120.0 0 0 0 0' + IF (vert) WRITE (anchor, '(A,F8.1,A)') '2 Fixed ', ax, ' 0.0 -120.5 0 0 0 0' OPEN (NEWUNIT=u, FILE=path, STATUS='REPLACE', ACTION='WRITE') WRITE (u, '(A)') 'coupled torsion gate' WRITE (u, '(A)') '--- LINE TYPES ---' From 8878f9987a894de90d67bf720e276092204a3992 Mon Sep 17 00:00:00 2001 From: Jae Hoon Seo Date: Thu, 15 Oct 2026 10:15:41 +0900 Subject: [PATCH 08/31] fix: carry the end weight moment at an anchor resting on the seabed (#14) A one-hour coupled OpenFAST run of the IEA-15 MW mixed deck showed the power cable's anchor tension jump from 1.22 kN to 3.1 kN about 25 s in and stay there while the platform drifted toward the anchor; without seabed friction it declined to 0.6 kN. The friction law is not at fault. The seabed contact acts at the nodes, which carry no moment, so at a held anchor end resting on the floor the consistent end moment of the end element's weight (w L^2 / 12) had nothing to react it: the free end tangent turned 1.9 deg into the floor, the element dipped 27 mm below the seabed between its nodes, and membrane locking put -47 kN to +127 kN of axial force in it about a 1.2 kN line tension. The compressed part buckles sideways once the hang-off sways, and friction locks the drawn-in nodes. The seabed now carries that end moment at a held line end resting on the floor, along the floor normal on a slope, in the statics and the dynamics, scaled by a C1 smoothstep of the inner node's elastic normal force over its half share of the element weight: a laid element keeps the full support, an element rising from an anchor on the floor gets none (its line is bit-identical to the same line without a seabed). Each energy line search holds the share of its starting point, so the potential stays a potential of the residual. The laid cable's static tension is uniform (1218.204 N); in the coupled run the anchor tension stays at a median of 1.39 kN with sub-second stick-slip peaks. Lines whose held end is off the floor are byte-identical; the shipped finite-EI examples with a grounded anchor change by at most 0.34 N. Two decks of the statics matrix change outcome, with the evidence in the matrix: LW_1015__cur_fr fails closed (its old hairpin is reachable only through compression, which its tension-only deck rules out), and CUR_1013 now finds the equilibrium with the grounded run turned sideways, because a refinement stopped on compression in a current now names the current limit and the driver retries out of the plane. The slope-polish test moves its fairlead to x = 200 m, out of a knife-edge layout that failed on Linux. VALIDATION.md records the full-turbine touchdown run. Signed-off-by: Jae Hoon Seo --- CHANGELOG.md | 27 ++++ VALIDATION.md | 2 +- doc/theory.rst | 9 +- src/CableDyn_HermiteCableDynamic.f90 | 119 ++++++++++++++- src/CableDyn_HermiteCableStatic.f90 | 168 ++++++++++++++++++++- src/CableDyn_SeabedContact.f90 | 42 ++++++ tests/data/cable_statics_matrix.json | 12 +- tests/test_cable_statics_matrix.py | 11 +- tests/test_deck_hermite_cable.f90 | 94 ++++++++++++ tests/test_hermite_cable_static.f90 | 212 +++++++++++++++++++++++++-- 10 files changed, 670 insertions(+), 26 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 3d552ce6..d54a8406 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -75,6 +75,33 @@ All notable changes to CableDyn are recorded in this file. The format follows routines and a 4 × 4 eigensolve, none of which passes DGEMM an inner dimension above 128, and the released Windows executables use reference LAPACK, so results are unchanged. An existing environment takes the exclusion with `conda env update -f environment.yml`, followed by a fresh build directory. +- The anchor tension of a finite-EI cable laid on the seabed no longer jumps when the line moves + out of its plane. The seabed contact acts at the nodes, which carry no moment, so at an + anchor resting on the floor the end moment of the end element's weight turned the free end + tangent into the floor: the element dipped below the seabed between its nodes (27 mm for the + power cable of `examples/iea15mw_umaine_mixed_cabledyn.dat`) and carried axial forces from + −47 kN to +127 kN about a line tension of 1.2 kN. Once the hang-off swayed, the element + buckled sideways; with seabed friction the anchor tension then locked at about 2.5 times its + static value for the rest of the run (1.22 kN to 3.1 kN in a coupled OpenFAST run while the + platform drifted toward the anchor), and without friction the end nodes wandered by up to + 0.18 m. The seabed now carries the end element's weight with its end moment at a held line end + resting on the floor (along the floor normal on a sloped bathymetry), in the statics and the + dynamics alike, in the share in which the element lies on the floor: the contact force of + its inner node against half the element's weight, through a smooth step that is zero when + that node is clear of the floor and one from half the weight up. Lines whose held end does + not rest on the seabed, or whose end element rises from it (a taut line anchored on the + floor), are unchanged. In the + shipped finite-EI examples with an anchor on the seabed the end tensions change by at most + 0.34 N (0.004 %). Two decks of the statics robustness matrix change outcome. A lazy wave + in a 1 m/s current on a frictional bed (`LW_1015__cur_fr`) had been reported as a hairpin + past its anchor only at its exact seabed stiffness. It now fails closed: the friction-held + touchdown goes into compression at about 0.33 m/s, before any tension-only equilibrium is + reached from the still-water layout, and a slow current ramp in the dynamics with + `tensile_safety` stops at the same point. A short line in a 1.9 m/s current on a + frictionless bed (`CUR_1013`) had failed closed. It now finds the equilibrium with the + grounded run turned sideways on the seabed: when the refinement of the catenary + continuation stops on a compression in a current, its failure now names the current limit, + so the driver retries out of the plane. ## [0.1.1] - 2026-10-09 diff --git a/VALIDATION.md b/VALIDATION.md index 04b223b7..2fcc76c8 100644 --- a/VALIDATION.md +++ b/VALIDATION.md @@ -734,7 +734,7 @@ stop with a named error. | Active tension (`CtrlChan`) | Pass verified | CONTROL parsing, last-segment length/rate modulation, and exact unit tests; coupled A/B in which a ServoDyn cable-control DLL drives the same pay-out/haul-in `DeltaL` schedule into `=5` (CableDyn) and `=3` (stock MoorDyn) in one binary: hold tensions agree to <0.03% and the tension responses to <0.6% (controlled fairleads) / <0.7% (anchors) ([`validation/scripts/activetension/`](https://github.com/SMI-Lab-Inha/CableDyn/tree/main/validation/scripts/activetension), [`validation/scripts/openfast_activetension_ab.py`](https://github.com/SMI-Lab-Inha/CableDyn/blob/main/validation/scripts/openfast_activetension_ab.py)) | | Coupled `Rigid6` bodies + `Point3` buoys | Pass verified | 6-DOF `Rigid6` motion with hydrostatic (`C33`/`C44`/`C55`) restoring, checkpoint state (bit-identical `openfast -restart` of a 13.9 MN-swinging tethered body), and SeaState drag / Froude–Krylov / added mass. `Point3` buoys take buoyancy and drag/added-mass/FK; a submerged volume-only buoy takes FK. Tests: `case_coupled_rigid6`/`_mirror`/`_fluid`, `case_coupled_point3_buoy`/`_fluid` | | Coupled rigid rods | Pass verified | host-driven `RodA/B` endpoints, correction rewind, bit-identical 24-scalar-per-rod checkpoint state, and two Gauss fluid nodes per rod with SeaState drag/Froude–Krylov/added mass; `case_coupled_rod`, `_mirror`, and `_fluid` pass, and the OpenFAST module compiles with rod decks enabled | -| Coupled finite-EI touchdown/contact | Pass verified | flat `WtrDpth` and equivalent constant structured bathymetry initialise and step with matching loads; friction and checkpoint restore are tested. The IEA-15 mixed example has 38 grounded nodes and completes a 20 s aggregate trajectory at `dtM=0.025 s` with 2 m surge, 1 m heave, and 0.5 m/s host current, without fallback or stall recovery, at most 14 Newton iterations. This is an aggregate integration test, not a full-turbine touchdown DLC | +| Coupled finite-EI touchdown/contact | Pass verified | flat `WtrDpth` and equivalent constant structured bathymetry initialise and step with matching loads; friction and checkpoint restore are tested. The IEA-15 mixed example has 38 grounded nodes and completes a 20 s aggregate trajectory at `dtM=0.025 s` with 2 m surge, 1 m heave, and 0.5 m/s host current, without fallback or stall recovery, at most 14 Newton iterations. A full-turbine run of the same model (one hour after a 200 s transient; TurbSim normal turbulence, 10.6 m/s, 17 % TI; JONSWAP Hs 8 m, Tp 12 s, aligned with the wind and the cable; AeroDyn with the rotor held at 7.55 rpm, no controller, rigid blades and tower; SeaState grid covering the lines) completes without recoveries or non-finite values. The cable's hang-off tension is 11.5 ± 1.1 kN (static 11.9 kN, maximum 17.9 kN), the same 38 nodes stay grounded, and the peak curvature, 0.160 1/m at the hog bend, is mesh-converged (0.156 1/m on a refined mesh); the 10 m elements of the laid section under-resolve the touchdown curvature by about 30 %. The chain-only twin of the run matches stock MoorDyn over 1200 s to 0.3 % in platform motion and fairlead tension statistics. The anchor tension of the laid cable is 1.39 kN (median, static 1.22 kN) with wave-frequency stick-slip peaks up to 4.1 kN lasting under 1 s; before the anchor-end correction of this release it locked at about 2.75 kN for the whole run | | `WaterKin` from file | Pass verified | See [WaterKin and SeaState modes](#waterkin-and-seastate-modes) | | Syrope polyester (`SYROPE:` syntax; [Falkenberg et al., 2017](https://cabledyn.readthedocs.io/en/latest/references.html#ref-falkenberg2017)) | Pass verified | MoorDyn-F/C `BA_s|BA_d` rate and force equations; analytic position/velocity tangents with finite-difference checks; projected, bracketed backward-Euler slow-state update with a strong-unloading boundary test; OWC running maximum; `SYROPE IC` `Tmax0/Tmean0` history with range/order checks; both states carried through every lifecycle stage and the coupled checkpoint. `BA_s` is kept separate from line axial damping (`BA`) and tested against double counting. Composite, hydrodynamic, finite-EI, current, and wave combinations stop with a named error | | VIV (`compVIV`) | Not supported | outside CableDyn's scope | diff --git a/doc/theory.rst b/doc/theory.rst index ef2b08c8..e19b426e 100644 --- a/doc/theory.rst +++ b/doc/theory.rst @@ -1031,7 +1031,14 @@ The fallback and the dynamic Hermite path use - **continuation in** ``EI``, and, for a net-buoyant line, **continuation in buoyancy**, which tracks the smooth branch of the buoyant arch from the seed; - the **consistent Hermite self-weight**, :math:`wL_0/2` on each end :math:`r_z` and - :math:`\pm wL_0^2/12` on the end :math:`m_z`; + :math:`\pm wL_0^2/12` on the end :math:`m_z`. At a held line end resting on the seabed the + floor carries the end element's weight with this end moment (its normal share + :math:`\cos\theta\,\mathbf{n}` on a floor of slope :math:`\theta` and upward normal + :math:`\mathbf{n}`), in the share :math:`3r^2 - 2r^3` (:math:`0 \le r \le 1`) in which the + element lies on the floor, :math:`r` the elastic contact force of its inner node over half the + element's weight: the nodal contact carries no moment, and the unbalanced end moment would + otherwise turn the end tangent of a laid element into the floor, while an element rising + from an anchor on the floor (:math:`r = 0`) keeps it; - **mesh sequencing**: the equilibrium is selected on a coarse mesh that preserves section, load, and contact-diameter interfaces, prolonged through the Hermite interpolant, and polished on each finer level and finally on the exact user mesh with the same residual test. Deterministic diff --git a/src/CableDyn_HermiteCableDynamic.f90 b/src/CableDyn_HermiteCableDynamic.f90 index f0ae7584..006360ff 100644 --- a/src/CableDyn_HermiteCableDynamic.f90 +++ b/src/CableDyn_HermiteCableDynamic.f90 @@ -67,7 +67,8 @@ MODULE CableDyn_HermiteCableDynamic CD_Component_Wave_Kinematics, CD_Solve_Dispersion_Wavenumber, CD_HYDRO_OK USE CableDyn_SeabedContact, ONLY: CD_Seabed_Normal_Law, CD_Seabed_Contact_Gate, CD_SEABED_CONTACT_BLEND, & CD_Seabed_Friction_Stick_Slip, CD_Seabed_Friction_Aniso, & - CD_Seabed_Friction_Mu_Dir, CD_FRICTION_STICK_SLIP + CD_Seabed_Friction_Mu_Dir, CD_FRICTION_STICK_SLIP, CD_Seabed_End_Support, & + CD_Seabed_End_Element_Share USE CableDyn_Bathymetry, ONLY: CD_BathymetryType, CD_Bathymetry_Is_Initialized, & CD_Bathymetry_Floor_Gradient, CD_End_Bathymetry, CD_BATHY_OK USE CableDyn_HermiteTorsion, ONLY: CD_HermiteTorsionType, CD_HermiteTorsion_Line, CD_HermiteTorsion_Unwrap, & @@ -5278,7 +5279,8 @@ SUBROUTINE assemble_residual(model, q_cfg, v_cfg, t_eval, want_residual, want_ta REAL(wp) :: fdry(4), kdry(4, 4), dry_wl, dry_b, dry_r INTEGER :: zdof(4), b LOGICAL :: dry - REAL(wp) :: endconn_d0_eval(3, 2) + REAL(wp) :: endconn_d0_eval(3, 2), support(3), dsupport(3), nin(3), mend + INTEGER :: inode, jr, jc CHARACTER(200) :: em2 ErrStat = CD_HCDYN_OK; ErrMsg = '' @@ -5356,6 +5358,15 @@ SUBROUTINE assemble_residual(model, q_cfg, v_cfg, t_eval, want_residual, want_ta R(6*e + 3) = R(6*e + 3) + model%w(e)*0.5_wp*model%l0(e) R(6*e + 6) = R(6*e + 6) - model%w(e)*model%l0(e)*model%l0(e)/12.0_wp END DO + ! A held end whose end element lies on the floor: the seabed carries the element's + ! weight with its consistent end moment (CD_Seabed_End_Support and + ! CD_Seabed_End_Element_Share), which the nodal contact cannot. + IF (model%has_contact .OR. model%kn > CD_ZERO) THEN + IF (held_end_floor_support(model, q_cfg, 1, support, dsupport, inode, nin)) & + R(4:6) = R(4:6) - (model%w(1)*model%l0(1)*model%l0(1)/12.0_wp)*support + IF (held_end_floor_support(model, q_cfg, 2, support, dsupport, inode, nin)) & + R(6*ne + 4:6*ne + 6) = R(6*ne + 4:6*ne + 6) + (model%w(ne)*model%l0(ne)*model%l0(ne)/12.0_wp)*support + END IF END IF IF (model%has_attach) THEN CALL assemble_attachments(model, q_cfg, v_cfg, want_residual, want_tangent, R, Kb, Kvb, es, em2) @@ -5416,6 +5427,26 @@ SUBROUTINE assemble_residual(model, q_cfg, v_cfg, t_eval, want_residual, want_ta END IF END DO END IF + ! The floor-carried end moment of a held end follows the contact of the end element's + ! inner node (inode, floor normal nin): its tangent couples the end tangent to that node. + IF (want_tangent .AND. (model%has_contact .OR. model%kn > CD_ZERO)) THEN + IF (held_end_floor_support(model, q_cfg, 1, support, dsupport, inode, nin)) THEN + mend = model%w(1)*model%l0(1)*model%l0(1)/12.0_wp + DO jc = 1, 3 + DO jr = 1, 3 + CALL scatter_contact_band(Kb, 3 + jr, 6*inode - 6 + jc, mend*dsupport(jr)*nin(jc)) + END DO + END DO + END IF + IF (held_end_floor_support(model, q_cfg, 2, support, dsupport, inode, nin)) THEN + mend = model%w(ne)*model%l0(ne)*model%l0(ne)/12.0_wp + DO jc = 1, 3 + DO jr = 1, 3 + CALL scatter_contact_band(Kb, 6*ne + 3 + jr, 6*inode - 6 + jc, -mend*dsupport(jr)*nin(jc)) + END DO + END DO + END IF + END IF ! Scatter the element-private hydrodynamic tangents in the same phase and element ! order as the serial formulation, retaining its floating-point accumulation order. @@ -5871,6 +5902,90 @@ SUBROUTINE assemble_contact(model, q_cfg, v_cfg, want_residual, want_tangent, Er END DO END SUBROUTINE assemble_contact + LOGICAL FUNCTION held_end_floor_support(model, q_cfg, iend, support, dsupport, inode, nin) RESULT(held) + !! Floor reaction carrying the weight of the end element at line end iend (1: node 1, + !! 2: node nn) of a model with seabed contact, per unit weight: the floor's normal share + !! cos(slope) n of the weight (n the upward floor normal at the end, e_z on a flat bed) + !! times the share of the element lying on the floor. Its consistent end moment cancels + !! the weight's on a grounded end element; the along-floor part of the weight stays with + !! the line. The share is CD_Seabed_End_Support of the end node (on or below the floor) + !! times CD_Seabed_End_Element_Share of the element's inner node inode (the normal force + !! of its elastic contact law against half the element's weight): zero for an element + !! rising from an anchor on the floor, one for a laid element, smooth in between. + !! dsupport is d(support)/d(gap) of the inner node, whose gap gradient is -nin (nin its + !! floor normal). False (support zero) unless the end node's translations are all held + !! (not free), its end element is net-heavy and the share is positive. + TYPE(CD_HermiteCableDynType), INTENT(IN) :: model + REAL(wp), INTENT(IN) :: q_cfg(:) + INTEGER, INTENT(IN) :: iend + REAL(wp), INTENT(OUT) :: support(3), dsupport(3), nin(3) + INTEGER, INTENT(OUT) :: inode + INTEGER :: node, e, ix, es + REAL(wp) :: gap, sfac, share, nvec(3), sfac_in, gap_in, normal, normal_gap, elem, delem + CHARACTER(200) :: em + support = CD_ZERO + dsupport = CD_ZERO + nin = [CD_ZERO, CD_ZERO, CD_ONE] + held = .FALSE. + IF (iend == 1) THEN + node = 1; e = 1; inode = 2 + ELSE + node = model%nn; e = model%ne; inode = model%nn - 1 + END IF + IF (.NOT. (model%w(e) > CD_ZERO)) RETURN + ix = 6*node - 5 + IF (ANY(model%freemask(ix:ix + 2))) RETURN + CALL floor_gap(node, gap, nvec, sfac, es) + IF (es /= CD_BATHY_OK) RETURN + share = CD_Seabed_End_Support(gap) + IF (.NOT. (share > CD_ZERO)) RETURN + CALL floor_gap(inode, gap_in, nin, sfac_in, es) + IF (es /= CD_BATHY_OK) RETURN + IF (model%has_contact) THEN + CALL CD_Seabed_Normal_Law(gap_in, model%contact_kn(inode), normal, normal_gap) + ELSE IF (gap_in > CD_ZERO) THEN + normal = model%kn*model%trib(inode)*gap_in + normal_gap = model%kn*model%trib(inode) + ELSE + normal = CD_ZERO + normal_gap = CD_ZERO + END IF + CALL CD_Seabed_End_Element_Share(normal, normal_gap, 0.5_wp*model%w(e)*model%l0(e), elem, delem) + IF (.NOT. (elem > CD_ZERO)) RETURN + held = .TRUE. + support = (share*elem/sfac)*nvec + dsupport = (share*delem/sfac)*nvec + + CONTAINS + + SUBROUTINE floor_gap(k, gap_k, n_k, sfac_k, es_k) + !! Normal penetration gap_k, upward floor normal n_k and slope factor of node k, on the + !! floor the contact assembly uses (structured bathymetry or the flat seabed plane). A + !! failed bathymetry query (es_k) fails closed in the contact assembly at the same point. + INTEGER, INTENT(IN) :: k + REAL(wp), INTENT(OUT) :: gap_k, n_k(3), sfac_k + INTEGER, INTENT(OUT) :: es_k + REAL(wp) :: xg, yg, z_floor, gxg, gyg, gx, gy + INTEGER :: kx + kx = 6*k - 5 + es_k = CD_BATHY_OK + gx = CD_ZERO + gy = CD_ZERO + z_floor = model%seabed_z + IF (model%has_contact .AND. model%has_contact_bathymetry) THEN + xg = model%contact_frame_c*q_cfg(kx) - model%contact_frame_s*q_cfg(kx + 1) + yg = model%contact_frame_s*q_cfg(kx) + model%contact_frame_c*q_cfg(kx + 1) + CALL CD_Bathymetry_Floor_Gradient(model%contact_bathymetry, xg, yg, z_floor, gxg, gyg, es_k, em) + IF (es_k /= CD_BATHY_OK) RETURN + gx = model%contact_frame_c*gxg + model%contact_frame_s*gyg + gy = -model%contact_frame_s*gxg + model%contact_frame_c*gyg + END IF + sfac_k = SQRT(CD_ONE + gx*gx + gy*gy) + n_k = [-gx, -gy, CD_ONE]/sfac_k + gap_k = (z_floor - q_cfg(kx + 2))/sfac_k + END SUBROUTINE floor_gap + END FUNCTION held_end_floor_support + SUBROUTINE commit_friction_anchors(model) !! Return mapping of the elastic-plastic friction springs at the committed state: a !! spring stretched beyond the capacity mu*normal moves its anchor to the capacity diff --git a/src/CableDyn_HermiteCableStatic.f90 b/src/CableDyn_HermiteCableStatic.f90 index aa56c90e..ff182a3b 100644 --- a/src/CableDyn_HermiteCableStatic.f90 +++ b/src/CableDyn_HermiteCableStatic.f90 @@ -43,7 +43,7 @@ MODULE CableDyn_HermiteCableStatic CD_ENDCONN_RIGID USE CableDyn_SeabedContact, ONLY: CD_Seabed_Normal_Law, CD_SEABED_CONTACT_BLEND, CD_Seabed_Friction_Spring, & CD_Seabed_Friction_Aniso, CD_Seabed_Friction_Mu_Dir, CD_FRICTION_SPRING, & - CD_Seabed_Normal_Contact + CD_Seabed_Normal_Contact, CD_Seabed_End_Support, CD_Seabed_End_Element_Share USE CableDyn_Bathymetry, ONLY: CD_BathymetryType, CD_Bathymetry_Is_Initialized, & CD_Bathymetry_Floor, CD_Bathymetry_Floor_Gradient, CD_BATHY_OK USE CableDyn_HermiteCableDynamic, ONLY: CD_HermiteCable_Drag_Element, CD_HCDYN_OK @@ -271,7 +271,8 @@ SUBROUTINE CD_HermiteCable_Static_Solve(l0, EA, EI, w, seed, fixed_dofs, seabed_ endconn_stiffness, endconn_direction, endconn_mode, & waterline_z, dry_buoyancy, merit_line_search, pseudo_transient, & energy_minimization, stable, water_weight, current, residual_out, & - tangent_out, friction, residual_unmet, torsion) + tangent_out, friction, residual_unmet, torsion, energy_out, & + end_share_hold) !! 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, @@ -396,6 +397,15 @@ SUBROUTINE CD_HermiteCable_Static_Solve(l0, EA, EI, w, seed, fixed_dofs, seabed_ !! iters_out and res_out include the twist stages. Not !! combined with pseudo_transient, !! equilibrate_linear_system or tangent_out. + !! energy_out (optional, out) : the total potential energy of energy_minimization at + !! the returned state (with residual_out, a check that + !! the residual is its gradient). + !! end_share_hold (optional, 2) : shares in [0, 1] of the end elements lying on the + !! floor (node 1 end, node nn end) at which the potential + !! takes the floor-carried end moments of held ends + !! resting on the seabed; the residual keeps the shares of + !! each iterate (CD_Seabed_End_Element_Share). Omitted, an + !! energy line search holds the shares of its start. REAL(wp), INTENT(IN) :: l0(:), EA(:), EI(:), w(:), seed(:) INTEGER, INTENT(IN) :: fixed_dofs(:) REAL(wp), INTENT(IN) :: seabed_z, kn, tol, damping @@ -430,6 +440,8 @@ SUBROUTINE CD_HermiteCable_Static_Solve(l0, EA, EI, w, seed, fixed_dofs, seabed_ ! NOCONVERGE, "Newton did not converge"): the state is a finite best iterate a caller ! may continue from. LOGICAL, INTENT(OUT), OPTIONAL :: residual_unmet + REAL(wp), INTENT(OUT), OPTIONAL :: energy_out + REAL(wp), INTENT(IN), OPTIONAL :: end_share_hold(2) TYPE(CD_HermiteTorsionType), INTENT(INOUT), OPTIONAL :: torsion INTEGER :: ne, nn, ndof, c, it, es, i, b, nci, n_buoy, omp_threads, axial_order, bending_order @@ -475,7 +487,13 @@ SUBROUTINE CD_HermiteCable_Static_Solve(l0, EA, EI, w, seed, fixed_dofs, seabed_ REAL(wp), ALLOCATABLE :: tors_g(:), tors_gr(:), tors_h(:, :), tors_v(:), tors_rhs(:), tors_q(:), tors_gs(:) REAL(wp), ALLOCATABLE :: tors_grs(:), tors_gt(:) REAL(wp), ALLOCATABLE :: tors_rhs2(:, :) - REAL(wp) :: contact_cs(2) + REAL(wp) :: contact_cs(2), end_support(3, 2), end_floor(3), end_g(2), end_sfac + ! Floor-carried end moments in the potential: the end element shares of the last + ! evaluation, and the shares held (end_share_held) by an energy line search or the caller. + REAL(wp) :: end_share_last(2), end_share_pi(2) + LOGICAL :: end_share_held, end_share_caller + INTEGER :: end_es + CHARACTER(200) :: end_em ErrStat = CD_HCSTAT_OK ErrMsg = '' @@ -784,6 +802,44 @@ SUBROUTINE CD_HermiteCable_Static_Solve(l0, EA, EI, w, seed, fixed_dofs, seabed_ trib(i) = trib(i) + 0.5_wp*l0(i) trib(i + 1) = trib(i + 1) + 0.5_wp*l0(i) END DO + ! A held end resting on the floor: the seabed can carry the end element's weight with its + ! consistent end moment (CD_Seabed_End_Support; per unit weight, the floor's normal + ! share cos(slope) n of the weight), which the nodal contact cannot. Held translations + ! keep their seed, so this factor is fixed for the solve; the share of the element lying + ! on the floor (end_element_share) follows the iterate. + end_support = CD_ZERO + end_share_last = CD_ZERO + end_share_pi = CD_ZERO + end_share_caller = PRESENT(end_share_hold) + IF (end_share_caller) THEN + IF (.NOT. CD_All_Finite(end_share_hold) .OR. ANY(end_share_hold < CD_ZERO) .OR. & + ANY(end_share_hold > CD_ONE)) THEN + CALL fail('end_share_hold must lie in [0, 1]'); RETURN + END IF + end_share_pi = end_share_hold + END IF + end_share_held = end_share_caller + IF (use_nodal_contact .OR. kn > CD_ZERO) THEN + DO i = 1, 2 + c = MERGE(1, nn, i == 1) + b = 6*(c - 1) + IF (ANY(freemask(b + 1:b + 3)) .OR. .NOT. (w(MERGE(1, ne, i == 1)) > CD_ZERO)) CYCLE + end_floor(1) = seabed_z + end_g = CD_ZERO + IF (use_bathymetry) THEN + CALL CD_Bathymetry_Floor_Gradient(bathymetry, contact_cs(1)*q(b + 1) - contact_cs(2)*q(b + 2), & + contact_cs(2)*q(b + 1) + contact_cs(1)*q(b + 2), & + end_floor(1), end_floor(2), end_floor(3), end_es, end_em) + ! A failed query fails closed in the contact assembly at the same point. + IF (end_es /= CD_BATHY_OK) CYCLE + end_g = [contact_cs(1)*end_floor(2) + contact_cs(2)*end_floor(3), & + -contact_cs(2)*end_floor(2) + contact_cs(1)*end_floor(3)] + END IF + end_sfac = SQRT(CD_ONE + end_g(1)*end_g(1) + end_g(2)*end_g(2)) + end_support(:, i) = (CD_Seabed_End_Support((end_floor(1) - q(b + 3))/end_sfac)/(end_sfac*end_sfac))* & + [-end_g(1), -end_g(2), CD_ONE] + END DO + END IF use_friction = .FALSE. fr_frozen = .FALSE. fr_mu = CD_ZERO @@ -915,6 +971,7 @@ SUBROUTINE CD_HermiteCable_Static_Solve(l0, EA, EI, w, seed, fixed_dofs, seabed_ res_out = rnorm IF (PRESENT(residual_out)) residual_out = R IF (PRESENT(tangent_out)) tangent_out = ab + IF (PRESENT(energy_out)) energy_out = pi_total IF (PRESENT(stable)) THEN ! A seabed friction capacity mu*N follows the normal force, so a sliding node's ! friction row depends on its vertical position with no reciprocal term: a @@ -1084,6 +1141,16 @@ RECURSIVE SUBROUTINE newton_step(rnorm, es, em, do_update) pi_total = pi_total + e_term pi_abs = pi_abs + ABS(e_term) END DO + ! the floor-carried end moments of held ends whose end element lies on the seabed + es2 = CD_HCSTAT_OK + IF (end_support(3, 1) > CD_ZERO) CALL add_end_support(1, 1, 2, -CD_ONE, es2, em2) + IF (es2 /= CD_HCSTAT_OK) THEN + es = CD_HCSTAT_NOCONVERGE; em = TRIM(em2); RETURN + END IF + IF (end_support(3, 2) > CD_ZERO) CALL add_end_support(2, ne, nn - 1, CD_ONE, es2, em2) + IF (es2 /= CD_HCSTAT_OK) THEN + es = CD_HCSTAT_NOCONVERGE; em = TRIM(em2); RETURN + END IF ! ---- dry-part buoyancy recovery above the optional free surface ---- ! Configuration-dependent through the waterline crossings, so it adds the crossing @@ -1460,7 +1527,7 @@ RECURSIVE SUBROUTINE energy_update(es, em) REAL(wp), PARAMETER :: ARMIJO = 1.0e-4_wp INTEGER, PARAMETER :: MAX_SHIFTS = 60, MAX_HALVINGS = 30 REAL(wp), PARAMETER :: NEWTON_MERIT = 1.0e-4_wp, NEWTON_MU = 1.0e-6_wp - REAL(wp) :: pi0, pi_abs0, merit0, dmax, gd, alpha, trial_norm, sc + REAL(wp) :: pi0, pi_abs0, merit0, dmax, gd, alpha, trial_norm, sc, share0(2) INTEGER :: shift, bt, j, i, es_trial, info LOGICAL :: accepted CHARACTER(200) :: em_trial @@ -1477,6 +1544,10 @@ RECURSIVE SUBROUTINE energy_update(es, em) pi0 = pi_total pi_abs0 = pi_abs merit0 = rmerit + ! The floor-carried end moments enter the energy at the end element shares of q_energy, + ! held over the line search below: along it the residual's end-support load is then the + ! gradient of the energy the Armijo test uses (gd = R.dq), at the start and at every trial. + share0 = end_share_last ! Close to equilibrium (small residual, and the energy steps needing at most a ! negligible shift, i.e. a positive definite tangent), a plain Newton step on the ! full (possibly nonsymmetric) tangent with a residual-merit line search comes first. The energy is only a @@ -1523,6 +1594,10 @@ RECURSIVE SUBROUTINE energy_update(es, em) DO j = 1, ndof IF (solve_mask(j)) dmax = MAX(dmax, ABS(ab_energy(KL_H + KU_H + 1, j))) END DO + IF (.NOT. end_share_caller) THEN + end_share_pi = share0 + end_share_held = .TRUE. + END IF DO shift = 1, MAX_SHIFTS ! Symmetric part of K + mu*D in LAPACK lower band storage; fixed DOFs decoupled. sym = CD_ZERO @@ -1585,6 +1660,7 @@ RECURSIVE SUBROUTINE energy_update(es, em) END IF IF (accepted) THEN skip_tangent = .FALSE. + end_share_held = end_share_caller IF (tors_on) tors_theta_acc = tors_theta_eval IF (bt == 0) THEN lm_mu = 0.25_wp*lm_mu @@ -1599,6 +1675,7 @@ RECURSIVE SUBROUTINE energy_update(es, em) IF (lm_mu > 1.0e12_wp) EXIT END DO skip_tangent = .FALSE. + end_share_held = end_share_caller q = q_energy stalled = .TRUE. END SUBROUTINE energy_update @@ -1958,6 +2035,11 @@ SUBROUTINE torsion_descent(ok, why) RETURN END IF e0 = pi_total + ! the energies compared below take the end element shares of this state (energy_update) + IF (.NOT. end_share_caller) THEN + end_share_pi = end_share_last + end_share_held = .TRUE. + END IF tors_rhs = tors_v IF (use_rigid) CALL rigid_increment_to_global(tors_rhs) vscale = CD_ZERO @@ -1969,6 +2051,7 @@ SUBROUTINE torsion_descent(ok, why) END IF END DO IF (.NOT. (vscale > CD_ZERO)) THEN + end_share_held = end_share_caller why = 'the unstable mode vanishes on the free DOFs' RETURN END IF @@ -1994,6 +2077,7 @@ SUBROUTINE torsion_descent(ok, why) EXIT END IF END DO + end_share_held = end_share_caller IF (.NOT. moved) THEN q = tors_q tors_theta_acc = th0 @@ -2384,6 +2468,76 @@ SUBROUTINE add_end_connection(node, k_rot, d0, ec_stat, ec_msg) END DO END SUBROUTINE add_end_connection + SUBROUTINE add_end_support(iend, e, inode, sgn, sp_stat, sp_msg) + !! Scatter the floor-carried end moment of held end iend (end element e, inner node + !! inode; sgn = -1 at node 1, +1 at node nn) into the residual and the band tangent: + !! the element's consistent weight moment w l0^2/12 along end_support(:, iend) times + !! the share of the element lying on the floor (CD_Seabed_End_Element_Share of the + !! inner node's elastic normal force, the same contact law as the assembly below). The + !! share couples the end tangent to the inner node's translations. The load is not + !! conservative where the share is between 0 and 1 (its conjugate force on the inner + !! node, mom (dS/dgap) (d.m) n, would be a contact force the floor does not exert), so + !! the potential takes the share end_share_pi (the share at the iterate, or the share + !! held by an energy line search, see energy_update): the residual is then the gradient + !! of the potential along a search, as for the other non-potential loads (current drag, + !! friction). The share at the iterate is recorded in end_share_last. + INTEGER, INTENT(IN) :: iend, e, inode + REAL(wp), INTENT(IN) :: sgn + INTEGER, INTENT(OUT) :: sp_stat + CHARACTER(*), INTENT(OUT) :: sp_msg + REAL(wp) :: z_fl, gxg_s, gyg_s, g_s(2), sf, n_in(3), pen_s, normal_s, normal_gap_s, elem, delem, mom + REAL(wp) :: elem_pi + INTEGER :: base, bin, i, j + CHARACTER(200) :: em_s + sp_stat = CD_HCSTAT_OK + sp_msg = '' + base = MERGE(3, 6*(nn - 1) + 3, iend == 1) ! end tangent DOFs are base+1 .. base+3 + bin = 6*(inode - 1) ! inner-node translations bin+1 .. bin+3 + z_fl = seabed_z + g_s = CD_ZERO + IF (use_bathymetry) THEN + CALL CD_Bathymetry_Floor_Gradient(bathymetry, contact_cs(1)*q(bin + 1) - contact_cs(2)*q(bin + 2), & + contact_cs(2)*q(bin + 1) + contact_cs(1)*q(bin + 2), & + z_fl, gxg_s, gyg_s, sp_stat, em_s) + IF (sp_stat /= CD_BATHY_OK) THEN + sp_stat = CD_HCSTAT_NOCONVERGE; sp_msg = 'bathymetry query failed: '//TRIM(em_s); RETURN + END IF + g_s = [contact_cs(1)*gxg_s + contact_cs(2)*gyg_s, -contact_cs(2)*gxg_s + contact_cs(1)*gyg_s] + END IF + sf = SQRT(CD_ONE + g_s(1)*g_s(1) + g_s(2)*g_s(2)) + n_in = [-g_s(1), -g_s(2), CD_ONE]/sf + pen_s = (z_fl - q(bin + 3))/sf + IF (use_nodal_contact) THEN + CALL CD_Seabed_Normal_Law(pen_s, contact_kn(inode), normal_s, normal_gap_s) + ELSE IF (pen_s > CD_ZERO) THEN + normal_s = kn*trib(inode)*pen_s + normal_gap_s = kn*trib(inode) + ELSE + normal_s = CD_ZERO + normal_gap_s = CD_ZERO + END IF + CALL CD_Seabed_End_Element_Share(normal_s, normal_gap_s, 0.5_wp*w_cur(e)*l0(e), elem, delem) + end_share_last(iend) = elem + elem_pi = elem + IF (end_share_held) elem_pi = end_share_pi(iend) + mom = sgn*w_cur(e)*l0(e)*l0(e)/12.0_wp + IF (elem_pi > CD_ZERO) THEN + pi_total = pi_total + mom*elem_pi*DOT_PRODUCT(end_support(:, iend), q(base + 1:base + 3)) + pi_abs = pi_abs + ABS(mom*elem_pi*DOT_PRODUCT(end_support(:, iend), q(base + 1:base + 3))) + END IF + IF (.NOT. (elem > CD_ZERO)) RETURN + R(base + 1:base + 3) = R(base + 1:base + 3) + (mom*elem)*end_support(:, iend) + ! d(gap)/d(r_inner) = -n_in (floor gradient held over the node) + IF (delem /= CD_ZERO) THEN + DO j = 1, 3 + DO i = 1, 3 + ab(KL_H + KU_H + 1 + base + i - bin - j, bin + j) = ab(KL_H + KU_H + 1 + base + i - bin - j, bin + j) - & + mom*delem*end_support(i, iend)*n_in(j) + END DO + END DO + END IF + END SUBROUTINE add_end_support + PURE REAL(wp) FUNCTION residual_merit(residual) RESULT(value) !! Half the squared two-norm of the scaled residual over free DOFs. The !! common force scale is omitted because it does not change descent. @@ -6168,6 +6322,12 @@ SUBROUTINE CD_HermiteCable_Static_Solve_AutoMesh(l0, EA, EI, w, seed, fixed_dofs diag_out%axial_strain_min_elem, ', xi=', diag_out%axial_strain_min_xi, & ', strain=', diag_out%axial_strain_min END IF + ! In a current, name the limit the compression of this state shows (the grounded run + ! pushed into its end, or into a friction-held touchdown): the driver's out-of-plane + ! retry of a planar current needs it, as for the other routes' failures. + IF (PRESENT(current)) wbuf = TRIM(current_compression_note(l0_out, EA_out, q_out, seabed_z, & + .NOT. PRESENT(bathymetry), & + ALLOCATED(current%friction)))//TRIM(wbuf) ErrMsg = wbuf RETURN END IF diff --git a/src/CableDyn_SeabedContact.f90 b/src/CableDyn_SeabedContact.f90 index 6562ddb3..301647a1 100644 --- a/src/CableDyn_SeabedContact.f90 +++ b/src/CableDyn_SeabedContact.f90 @@ -16,6 +16,7 @@ MODULE CableDyn_SeabedContact PUBLIC :: CD_Seabed_Normal_Law PUBLIC :: CD_Seabed_Normal_Contact PUBLIC :: CD_Seabed_Contact_Gate + PUBLIC :: CD_Seabed_End_Support, CD_Seabed_End_Element_Share PUBLIC :: CD_Seabed_Friction_Spring PUBLIC :: CD_Seabed_Friction_Stick_Slip PUBLIC :: CD_Seabed_Friction_Aniso, CD_Seabed_Friction_Mu_Dir @@ -99,6 +100,47 @@ PURE SUBROUTINE CD_Seabed_Contact_Gate(gap, gate, dgate_dgap) END IF END SUBROUTINE CD_Seabed_Contact_Gate + PURE REAL(wp) FUNCTION CD_Seabed_End_Support(gap) RESULT(support) + !! Share of the consistent end moment w l0^2/12 of a net-heavy end element that the + !! seabed can carry at a HELD line end (translations fixed or prescribed) at signed normal + !! penetration gap = z_floor - z, before the element's own contact + !! (CD_Seabed_End_Element_Share) is weighed in. The nodal penalty is the end-point (Lobatto) + !! integration of the floor reaction and carries no moment, so on a grounded end + !! element the weight's end moment would otherwise turn the free end tangent into the + !! floor: the element dips below the seabed between its nodes and, on a high-EA line, + !! carries large spurious axial forces of both signs. One for an end on or below the + !! floor, zero above the contact blend, linear in between (CD_Seabed_Contact_Gate + !! shifted by one blend length, so that an anchor placed exactly on the floor rests on + !! it). The end is held, so this factor is constant within a solve and adds no tangent. + REAL(wp), INTENT(IN) :: gap + REAL(wp) :: dgate_dgap + CALL CD_Seabed_Contact_Gate(gap + CD_SEABED_CONTACT_BLEND, support, dgate_dgap) + END FUNCTION CD_Seabed_End_Support + + PURE SUBROUTINE CD_Seabed_End_Element_Share(normal, normal_gap, weight_share, share, dshare_dgap) + !! Share of an end element lying on the floor, from the contact of its inner node: the + !! ratio r of that node's elastic normal force to the element's weight share it would + !! carry laid on the floor (half the element's weight), through the C1 smoothstep + !! 3 r^2 - 2 r^3 on 0 <= r <= 1 (zero at r <= 0, one at r >= 1). A laid element (r near + !! 2, the node also carrying its other element) is fully on the floor, an element rising + !! from its end into the water (node clear of the floor) not at all, and the share is + !! continuous with a continuous derivative through touchdown and lift-off of the node. + !! normal_gap is d(normal)/d(gap); dshare_dgap the derivative of the share in that gap. + REAL(wp), INTENT(IN) :: normal, normal_gap, weight_share + REAL(wp), INTENT(OUT) :: share, dshare_dgap + REAL(wp) :: r + share = CD_ZERO + dshare_dgap = CD_ZERO + IF (.NOT. (weight_share > CD_ZERO)) RETURN + r = normal/weight_share + IF (r >= CD_ONE) THEN + share = CD_ONE + ELSE IF (r > CD_ZERO) THEN + share = r*r*(3.0_wp - 2.0_wp*r) + dshare_dgap = 6.0_wp*r*(CD_ONE - r)*normal_gap/weight_share + END IF + END SUBROUTINE CD_Seabed_End_Element_Share + PURE SUBROUTINE CD_Seabed_Friction_Spring(d, stiffness, capacity, force, dforce_dd, dforce_dcap) !! Static seabed friction spring: the resisting force of a horizontal spring of !! stiffness k stretched by d from its reference, capped smoothly at the capacity C, diff --git a/tests/data/cable_statics_matrix.json b/tests/data/cable_statics_matrix.json index 74077f8e..9dbfcde3 100644 --- a/tests/data/cable_statics_matrix.json +++ b/tests/data/cable_statics_matrix.json @@ -1292,7 +1292,8 @@ }, { "id": "LW_1015__cur_fr", - "expect": "admissible", + "expect": "current_friction_compression", + "why": "A seabed-friction current deck: the tension-only branch from the still-water layout ends near drag fraction 0.11 (about 0.33 m/s), where the friction-held touchdown goes into compression; a slow current ramp in the dynamics with tensile_safety stops there too (0.37 m/s). A hairpin past the anchor is reached only through that compression. Earlier releases reported it as an equilibrium through the mesh-sequenced coarse levels, whose anchor element dipped below the floor, and only at this exact kBot (not at kBot 1e5 +/- 0.001 % or at currents of 0.3 to 0.7 m/s).", "deck": "--------------------- CableDyn Input File ---------------------------\nLW_1015__cur_fr\n--------------------- LINE TYPES ------------------------------------\nTypeName Diam MassDenInAir EA BA EI Cd_n Cd_t Ca_n Ca_t\n(-) (m) (kg/m) (N) (-) (N-m2) (-) (-) (-) (-)\nbare 0.100445767 11.22757908 177452628.2 0 8881.762177 1.2 0.1 1 0\nbuoy 0.2900604656 65.36363376 177452628.2 0 11763.70697 1.2 0.1 1 0\n--------------------- POINTS ----------------------------------------\nID Type X Y Z\n(-) (-) (m) (m) (m)\n1 Coupled 0 0 -21.032628\n2 Fixed 515.799336 0 -439.732\n--------------------- LINES -----------------------------------------\nID NodeA NodeB Outputs\n(-) (-) (-) (-)\n1 1 2 -\n--------------------- SECTIONS --------------------------------------\nLineID LineType Length NumSegs\n(-) (-) (m) (-)\n1 bare 231.9579 123\n1 buoy 115.9305 61\n1 bare 480.7763 255\n--------------------- OPTIONS ---------------------------------------\n0.5 frictionMu\n9.80665 g\n1025.0 rhoW\n439.732 WtrDpth\n100000 kBot\n1.0e4 cBot\n0.05 dtM\n0.0 TMax\nFalse adaptive_mesh\nTrue tensile_safety\nuniform 1.0 0.0 0.0 current\n--------------------- OUTPUTS ---------------------------------------\n\"FairTen1\"\n\"AnchTen1\"\n--------------------- need this line --------------------------------\n", "lines": { "1": { @@ -1303,7 +1304,8 @@ }, { "id": "LW_1015__cur_fr__rest", - "expect": "admissible", + "expect": "current_friction_compression", + "why": "The at-rest twin of LW_1015__cur_fr, which has no tension-only static equilibrium (see there).", "deck": "--------------------- CableDyn Input File ---------------------------\nLW_1015__cur_fr__rest\n--------------------- LINE TYPES ------------------------------------\nTypeName Diam MassDenInAir EA BA EI Cd_n Cd_t Ca_n Ca_t\n(-) (m) (kg/m) (N) (-) (N-m2) (-) (-) (-) (-)\nbare 0.100445767 11.22757908 177452628.2 0 8881.762177 1.2 0.1 1 0\nbuoy 0.2900604656 65.36363376 177452628.2 0 11763.70697 1.2 0.1 1 0\n--------------------- POINTS ----------------------------------------\nID Type X Y Z\n(-) (-) (m) (m) (m)\n1 Coupled 0 0 -21.032628\n2 Fixed 515.799336 0 -439.732\n--------------------- LINES -----------------------------------------\nID NodeA NodeB Outputs\n(-) (-) (-) (-)\n1 1 2 -\n--------------------- SECTIONS --------------------------------------\nLineID LineType Length NumSegs\n(-) (-) (m) (-)\n1 bare 231.9579 123\n1 buoy 115.9305 61\n1 bare 480.7763 255\n--------------------- OPTIONS ---------------------------------------\n0.5 frictionMu\n9.80665 g\n1025.0 rhoW\n439.732 WtrDpth\n100000 kBot\n1.0e4 cBot\n0.05 dtM\n1.0 TMax\nFalse adaptive_mesh\nTrue tensile_safety\nuniform 1.0 0.0 0.0 current\n--------------------- OUTPUTS ---------------------------------------\n\"FairTen1\"\n\"AnchTen1\"\n--------------------- need this line --------------------------------\n", "lines": { "1": { @@ -1475,14 +1477,16 @@ }, { "id": "CUR_1013", - "expect": "current_compression", + "expect": "admissible", + "why": "The planar route stops with the grounded run pushed into its anchor; the out-of-plane retry then finds the run turned sideways on the seabed (tension at least 0.48 kN, no self-contact). Earlier releases did not run that retry for this deck because the catenary-continuation failure did not name the current limit.", "deck": "--------------------- CableDyn Input File ---------------------------\nCUR_1013\n--------------------- LINE TYPES ------------------------------------\nTypeName Diam MassDenInAir EA BA EI Cd_n Cd_t Ca_n Ca_t\n(-) (m) (kg/m) (N) (-) (N-m2) (-) (-) (-) (-)\nbare 0.1784650716 82.63060908 255233842 0 25945.91551 1.2 0.1 1 0\nbuoy 0.4710966462 88.94142595 255233842 0 40205.41756 1.2 0.1 1 0\n--------------------- POINTS ----------------------------------------\nID Type X Y Z\n(-) (-) (m) (m) (m)\n1 Coupled 0 0 -13.08348484\n2 Fixed 41.77649681 0 -42.543\n--------------------- LINES -----------------------------------------\nID NodeA NodeB Outputs\n(-) (-) (-) (-)\n1 1 2 -\n--------------------- SECTIONS --------------------------------------\nLineID LineType Length NumSegs\n(-) (-) (m) (-)\n1 bare 20.5504 2\n1 buoy 7.3589 1\n1 bare 35.1167 4\n--------------------- OPTIONS ---------------------------------------\n9.80665 g\n1025.0 rhoW\n42.543 WtrDpth\n3e+06 kBot\n1.0e4 cBot\n0.05 dtM\n0.0 TMax\nFalse adaptive_mesh\nTrue tensile_safety\nuniform 1.906 0.0 0.0 current\n--------------------- OUTPUTS ---------------------------------------\n\"FairTen1\"\n\"AnchTen1\"\n--------------------- need this line --------------------------------\n", "lines": { "1": { "oracle_tfair": [], "lambda_over_length": 0.0 } - } + }, + "note": "past its anchor, where it folds back" }, { "id": "LWM_1002", diff --git a/tests/test_cable_statics_matrix.py b/tests/test_cable_statics_matrix.py index 16697d3f..7ebbb1b6 100644 --- a/tests/test_cable_statics_matrix.py +++ b/tests/test_cable_statics_matrix.py @@ -25,6 +25,10 @@ naming the axial compression; * ``current_compression`` decks (a current pushing the grounded run along the frictionless seabed into compression: no tension-only equilibrium) must fail closed with that diagnosis; +* ``current_friction_compression`` decks (on a frictional seabed the current pushes the + suspended span into the friction-held touchdown before any tension-only equilibrium is + reached from the still-water layout) must fail closed with that diagnosis; a deck's ``why`` + records the evidence; * an admissible deck with a ``note`` must print it: a very strong current on a frictionless seabed folds the line back past its anchor (a hairpin), a stable equilibrium the driver keeps and names; @@ -221,6 +225,10 @@ def check_case(case: dict, res: dict) -> list: if res["rc"] == 0 or "run on the seabed is in axial compression" not in log: errs.append("expected the grounded-run compression diagnosis, rc=%s" % res["rc"]) return errs + if exp == "current_friction_compression": + if res["rc"] == 0 or "the friction holds the grounded run" not in log: + errs.append("expected the friction-held touchdown compression diagnosis, rc=%s" % res["rc"]) + return errs if res["rc"] != 0: tail = [ln for ln in log.splitlines() if "CableDyn_DeckDriver" in ln] errs.append("admissible deck failed rc=%s: %s" % (res["rc"], (tail[-1] if tail else "")[:300])) @@ -321,7 +329,8 @@ def main() -> int: errs.append("CPU time %.1f s beyond the %.0f s per-deck bound" % ( res["cpu"], case.get("cpu_limit", DECK_CPU_LIMIT) * a.cpu_limit / DECK_CPU_LIMIT)) rest = case.get("rest_of") - if rest and not errs: + # an at-rest twin of a deck expected to fail closed fails closed itself (checked above) + if rest and not errs and case["expect"] == "admissible": pr = byid.get(rest) if pr is None or pr["rc"] != 0 or "forces" not in pr: errs.append("static parent %s did not converge" % rest) diff --git a/tests/test_deck_hermite_cable.f90 b/tests/test_deck_hermite_cable.f90 index a0ce238e..8d6e6a7c 100644 --- a/tests/test_deck_hermite_cable.f90 +++ b/tests/test_deck_hermite_cable.f90 @@ -16,6 +16,7 @@ PROGRAM test_deck_hermite_cable CD_HFMF_MinSpanZ, CD_HFMF_Snapshot, CD_HFMF_Restore, & CD_HFMF_End, CD_HFMF_OK USE CableDyn_EndConnection, ONLY: CD_ENDCONN_RIGID + USE CableDyn_HermiteCableDynamic, ONLY: CD_HermiteCable_Dyn_End_Force, CD_HCDYN_OK USE, INTRINSIC :: IEEE_ARITHMETIC, ONLY: IEEE_IS_NAN IMPLICIT NONE INTEGER :: nfail @@ -31,6 +32,7 @@ PROGRAM test_deck_hermite_cable CALL case_azimuthal_frame_objectivity() CALL case_reject_motionfile() CALL case_coupled_seabed_contact() + CALL case_grounded_anchor_end() IF (nfail > 0) THEN WRITE (*, '(A,I0,A)') 'FAIL: ', nfail, ' assertion(s) failed' ERROR STOP 1 @@ -550,6 +552,98 @@ SUBROUTINE case_coupled_seabed_contact() CALL CD_HFMF_End(cable) END SUBROUTINE case_coupled_seabed_contact + SUBROUTINE case_grounded_anchor_end() + !! A lazy-wave power cable laid on a frictional flat bed up to its pinned anchor on the + !! floor (Line 4 of examples/iea15mw_umaine_mixed_cabledyn.dat: 200 m depth, kBot 3e6, + !! frictionMu 0.35, 10 m grounded elements). The seabed carries the weight of the anchor + !! element, so its free end tangent stays along the floor; turned into the floor by the + !! unbalanced end moment of the weight, the element dipped about 27 mm below the bed, + !! carried axial forces from -47 kN to +127 kN about the 1.2 kN line tension, and + !! buckled sideways once the hang-off swayed, after which the friction locked the anchor + !! tension at about 2.5 times its static value while the line slackened. + TYPE(CD_HFMF_ModuleType), ALLOCATABLE :: cable + INTEGER :: cn, es, base, k + CHARACTER(256) :: em + REAL(wp) :: u0(3), u_pos(3), u_vel(3), u_acc(3), f(3), t, r, rd, rdd, s, c, ten0, ten_max, tz + REAL(wp), PARAMETER :: DT = 0.025_wp, AMP = 2.0_wp, PER = 10.0_wp, RAMP = 5.0_wp, TEND = 30.0_wp + REAL(wp), PARAMETER :: PI = 3.141592653589793_wp + INTEGER :: u, ios + OPEN (NEWUNIT=u, FILE='hcab_deck_grounded_anchor.dat', STATUS='REPLACE', ACTION='WRITE', IOSTAT=ios) + WRITE (u, '(A)') 'lazy-wave power cable laid on a frictional bed up to its anchor' + 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)') 'buoy 0.29 59.53 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 30.0 0.0 -20.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 80.0 20' + WRITE (u, '(A)') '1 buoy 100.0 25' + WRITE (u, '(A)') '1 bare 420.0 42' + WRITE (u, '(A)') '--- OPTIONS ---' + WRITE (u, '(A)') '9.80665 g' + WRITE (u, '(A)') '1025.0 rhoW' + WRITE (u, '(A)') '200.0 WtrDpth' + WRITE (u, '(A)') '3.0e6 kBot' + WRITE (u, '(A)') '3.0e5 cBot' + WRITE (u, '(A)') '0.35 frictionMu' + WRITE (u, '(A)') '0.4 rhoInf' + WRITE (u, '(A)') '--- need this line ---' + CLOSE (u) + ALLOCATE (cable) + CALL CD_Init_Deck_HermiteCable('hcab_deck_grounded_anchor.dat', DT, cable, cn, es, em) + CALL require(es == CD_DECKDRV_OK, 'grounded-anchor cable initializes: '//TRIM(em)) + IF (es /= CD_DECKDRV_OK) RETURN + CALL require(cable%line%fr_active, 'grounded-anchor cable carries seabed friction') + ! The anchor is model node 1: its end tangent lies along the floor in the static state. + tz = ABS(cable%line%q(6))/NORM2(cable%line%q(4:6)) + CALL require(tz <= 1.0e-3_wp, 'anchor end tangent stays along the floor') + IF (tz > 1.0e-3_wp) WRITE (*, '(A,ES12.4)') ' anchor tangent z share ', tz + CALL CD_HermiteCable_Dyn_End_Force(cable%line, 1, f, es, em) + CALL require(es == CD_HCDYN_OK, 'static anchor force: '//TRIM(em)) + ten0 = NORM2(f) + ! Sway the hang-off sideways (2 m, 10 s, C2 quintic start): the in-plane line is then + ! perturbed out of its plane, which seeds the end-element buckling within ~25 s. + base = 6*(cn - 1) + u0 = cable%line%q(base + 1:base + 3) + ten_max = ten0 + DO k = 1, NINT(TEND/DT) + t = k*DT + IF (t < RAMP) THEN + s = t/RAMP + r = 10.0_wp*s**3 - 15.0_wp*s**4 + 6.0_wp*s**5 + rd = (30.0_wp*s**2 - 60.0_wp*s**3 + 30.0_wp*s**4)/RAMP + rdd = (60.0_wp*s - 180.0_wp*s**2 + 120.0_wp*s**3)/RAMP**2 + ELSE + r = 1.0_wp; rd = 0.0_wp; rdd = 0.0_wp + END IF + s = SIN(2.0_wp*PI*t/PER) + c = COS(2.0_wp*PI*t/PER) + u_pos = u0 + [0.0_wp, AMP*r*s, 0.0_wp] + u_vel = [0.0_wp, AMP*(rd*s + r*(2.0_wp*PI/PER)*c), 0.0_wp] + u_acc = [0.0_wp, AMP*(rdd*s + 2.0_wp*rd*(2.0_wp*PI/PER)*c - r*(2.0_wp*PI/PER)**2*s), 0.0_wp] + CALL CD_HFMF_UpdateStates(cable, u_pos, u_vel, u_acc, es, em) + IF (es /= CD_HFMF_OK) EXIT + CALL CD_HermiteCable_Dyn_End_Force(cable%line, 1, f, es, em) + IF (es /= CD_HCDYN_OK) EXIT + ten_max = MAX(ten_max, NORM2(f)) + END DO + CALL require(es == CD_HFMF_OK, 'swayed grounded-anchor march converges: '//TRIM(em)) + CALL require(ten_max <= 1.1_wp*ten0, 'friction does not ratchet the anchor tension up') + IF (ten_max > 1.1_wp*ten0) WRITE (*, '(A,2ES12.4)') ' anchor tension static / peak ', ten0, ten_max + CALL CD_HFMF_End(cable) + END SUBROUTINE case_grounded_anchor_end + SUBROUTINE write_cable_deck(path, extra_option, fairlead_y, omit_time, endpoints, second_extra_option, & endconn_row, second_endconn_row, stock_order, ba_value) !! A realistic dynamic power cable in the LAZY-WAVE configuration -- the flagship regime and diff --git a/tests/test_hermite_cable_static.f90 b/tests/test_hermite_cable_static.f90 index 16e654f5..c1b6d44e 100644 --- a/tests/test_hermite_cable_static.f90 +++ b/tests/test_hermite_cable_static.f90 @@ -19,7 +19,8 @@ PROGRAM test_hermite_cable_static CD_HermiteCable_Dyn_Set_Drag, CD_HermiteCable_Dyn_Reaction, & CD_HermiteCable_Dyn_End, CD_HCDYN_OK, CD_HermiteCable_Dyn_End_Force, & CD_HermiteCable_Drag_Element, CD_HermiteCable_Dyn_Step - USE CableDyn_SeabedContact, ONLY: CD_HermiteCable_Friction_Spring => CD_Seabed_Friction_Spring + USE CableDyn_SeabedContact, ONLY: CD_HermiteCable_Friction_Spring => CD_Seabed_Friction_Spring, & + CD_Seabed_End_Element_Share, CD_Seabed_Normal_Law USE CableDyn_Line, ONLY: CD_Nodal_Seabed_Stiffness, CD_LINE_OK USE CableDyn_Bathymetry, ONLY: CD_BathymetryType, CD_Init_Bathymetry USE, INTRINSIC :: IEEE_ARITHMETIC, ONLY: IEEE_IS_FINITE @@ -39,6 +40,8 @@ PROGRAM test_hermite_cable_static CALL check_dry_buoyancy_static() CALL check_seabed_mesh_jump() CALL check_scalar_contact_on_slope() + CALL check_taut_line_anchored_on_floor() + CALL check_end_support_energy_gradient() CALL check_frictionless_slope_run() CALL check_long_sequence_hierarchy() CALL check_current_static() @@ -309,17 +312,196 @@ SUBROUTINE check_seabed_mesh_jump() CALL require(dev < 0.1_wp*pen0, 'mesh-jump penetration stays near w/(kBot d)') END SUBROUTINE check_seabed_mesh_jump + SUBROUTINE check_taut_line_anchored_on_floor() + !! The floor carries the end element's weight moment only where the element lies on it. + !! A taut line anchored on the floor rises into the water from its anchor: its end element + !! is clear of the floor beyond the anchor node, the seabed supports none of it, and the + !! line takes the bending of the same line without a seabed. Its static state (with the + !! curvature at the pinned anchor) and its held dynamic march must equal those of the + !! line with no seabed bit for bit. With the floor support decided by the anchor alone, + !! the cancelled end moment w l0^2/12 moved the line by 7 mm and raised the anchor + !! curvature by half (2.9e-3 to 4.3e-3 1/m). The element share itself is zero clear of + !! the floor, one laid, and C1 through touchdown. + INTEGER, PARAMETER :: NE = 20, NN = NE + 1 + REAL(wp) :: l0(NE), EA(NE), EI(NE), w(NE), rho_a(NE), seed(6*NN), qa(6*NN), qb(6*NN), ca(NN), cb(NN), res + REAL(wp) :: trib(NN), kn, share, dshare, share_p, share_m, dsh_p, dsh_m, r + REAL(wp), PARAMETER :: RATIOS(3) = [1.0e-3_wp, 0.5_wp, 0.999_wp] + INTEGER :: fixed(6 + 2*NN), nfix, i, es, it, k + TYPE(CD_HermiteCableDynType) :: dyn_a, dyn_b + CHARACTER(512) :: em + l0 = 100.2_wp/NE; EA = 5.0e8_wp; EI = 2.0e4_wp; w = 800.0_wp; rho_a = 120.0_wp; kn = 2.0e5_wp + trib = 0.0_wp + DO i = 1, NE + trib(i) = trib(i) + 0.5_wp*l0(i); trib(i + 1) = trib(i + 1) + 0.5_wp*l0(i) + END DO + ! anchor on the 100 m floor, fairlead 60 m away and 80 m up: chord 100 m, length 100.2 m + CALL CD_HermiteCable_Trivial_Seed([0.0_wp, 0.0_wp, -100.0_wp], [60.0_wp, 0.0_wp, -20.0_wp], l0, -100.0_wp, & + seed, es, em) + CALL require(es == CD_HCSTAT_OK, 'taut anchored seed: '//TRIM(em)) + fixed(1:6) = [1, 2, 3, 6*NE + 1, 6*NE + 2, 6*NE + 3] + nfix = 6 + DO i = 1, NN + fixed(nfix + 1:nfix + 2) = [6*i - 4, 6*i - 1] + nfix = nfix + 2 + END DO + CALL CD_HermiteCable_Static_Solve(l0, EA, EI, w, seed, fixed(1:nfix), -100.0_wp, 0.0_wp, 4, 200, 1.0e-10_wp, & + 1.0_wp, qa, ca, res, it, es, em, contact_kn=kn*trib) + CALL require(es == CD_HCSTAT_OK, 'taut anchored line on the floor: '//TRIM(em)) + CALL CD_HermiteCable_Static_Solve(l0, EA, EI, w, seed, fixed(1:nfix), -1.0e4_wp, 0.0_wp, 4, 200, 1.0e-10_wp, & + 1.0_wp, qb, cb, res, it, es, em) + CALL require(es == CD_HCSTAT_OK, 'taut anchored line without seabed: '//TRIM(em)) + CALL require(qa(6*2 - 3) + 100.0_wp > 1.0_wp, 'taut anchored line rises from its anchor') + CALL require(ALL(qa == qb), 'taut anchored line: the floor carries none of the rising end element') + CALL require(ALL(ca == cb), 'taut anchored line keeps the bending of the line without seabed') + ! The held dynamics with the scalar floor at the anchor height equal those without a floor. + CALL CD_HermiteCable_Dyn_Init(dyn_a, l0, EA, EI, rho_a, w, qa, fixed(1:nfix), -100.0_wp, kn, 0.8_wp, es, em) + CALL require(es == CD_HCDYN_OK, 'taut anchored dynamics with floor: '//TRIM(em)) + CALL CD_HermiteCable_Dyn_Init(dyn_b, l0, EA, EI, rho_a, w, qa, fixed(1:nfix), -1.0e4_wp, 0.0_wp, 0.8_wp, es, em) + CALL require(es == CD_HCDYN_OK, 'taut anchored dynamics without floor: '//TRIM(em)) + DO k = 1, 5 + CALL CD_HermiteCable_Dyn_Step(dyn_a, 0.05_wp, 30, 1.0e-9_wp, es, em) + CALL require(es == CD_HCDYN_OK, 'taut anchored step with floor: '//TRIM(em)) + CALL CD_HermiteCable_Dyn_Step(dyn_b, 0.05_wp, 30, 1.0e-9_wp, es, em) + CALL require(es == CD_HCDYN_OK, 'taut anchored step without floor: '//TRIM(em)) + END DO + CALL require(ALL(dyn_a%q == dyn_b%q) .AND. ALL(dyn_a%v == dyn_b%v), & + 'taut anchored dynamics: the floor carries none of the rising end element') + CALL CD_HermiteCable_Dyn_End(dyn_a) + CALL CD_HermiteCable_Dyn_End(dyn_b) + ! the element share: ratio r of the inner node's normal force to half the element weight + CALL CD_Seabed_End_Element_Share(0.0_wp, 0.0_wp, 100.0_wp, share, dshare) + CALL require(share == 0.0_wp .AND. dshare == 0.0_wp, 'end element share: clear of the floor') + CALL CD_Seabed_End_Element_Share(200.0_wp, 1.0e4_wp, 100.0_wp, share, dshare) + CALL require(share == 1.0_wp .AND. dshare == 0.0_wp, 'end element share: laid') + DO k = 1, 3 + r = RATIOS(k) + ! normal = 100 r with d(normal)/d(gap) = 1e4: central difference of the share in the gap + CALL CD_Seabed_End_Element_Share(100.0_wp*r, 1.0e4_wp, 100.0_wp, share, dshare) + CALL CD_Seabed_End_Element_Share(100.0_wp*r + 1.0e-4_wp, 1.0e4_wp, 100.0_wp, share_p, dsh_p) + CALL CD_Seabed_End_Element_Share(100.0_wp*r - 1.0e-4_wp, 1.0e4_wp, 100.0_wp, share_m, dsh_m) + CALL require(ABS((share_p - share_m)/2.0e-8_wp - dshare) <= 1.0e-5_wp*MAX(1.0_wp, ABS(dshare)), & + 'end element share: derivative matches its difference quotient') + CALL require(ABS(share - r*r*(3.0_wp - 2.0_wp*r)) <= 1.0e-15_wp, 'end element share: smoothstep') + END DO + END SUBROUTINE check_taut_line_anchored_on_floor + + SUBROUTINE check_end_support_energy_gradient() + !! The energy line search (energy_minimization) tests the potential against R.dq, so the + !! residual must be the gradient of the potential it evaluates. With the end element's + !! inner node half way through its touchdown (share S = 1/2), the floor-carried end + !! moment depends on that node's height; the potential then takes the share held at the + !! search's start (end_share_hold), and central differences of it along several + !! directions reproduce R.d. With the share left to follow the trial states, the + !! difference along the inner node's height misses the end-support term by about + !! (w l0^2/12) (dS/dgap) m_z, here near 1 MN: no potential of R. + INTEGER, PARAMETER :: NE = 20, NN = NE + 1, NDIR = 4 + REAL(wp), PARAMETER :: H = 1.0e-5_wp + REAL(wp) :: l0(NE), EA(NE), EI(NE), w(NE), seed(6*NN), qa(6*NN), q(6*NN), c(NN), res, r0(6*NN) + REAL(wp) :: trib(NN), kn, floor_z, gap, normal, normal_gap, share, dshare, ep, em_, rd, fd, fd_free, d(6*NN) + INTEGER :: fixed(6 + 2*NN), nfix, i, es, it, k + CHARACTER(512) :: em + l0 = 100.2_wp/NE; EA = 5.0e8_wp; EI = 2.0e4_wp; w = 800.0_wp; kn = 2.0e5_wp + trib = 0.0_wp + DO i = 1, NE + trib(i) = trib(i) + 0.5_wp*l0(i); trib(i + 1) = trib(i + 1) + 0.5_wp*l0(i) + END DO + CALL CD_HermiteCable_Trivial_Seed([0.0_wp, 0.0_wp, -100.0_wp], [60.0_wp, 0.0_wp, -20.0_wp], l0, -100.0_wp, & + seed, es, em) + fixed(1:6) = [1, 2, 3, 6*NE + 1, 6*NE + 2, 6*NE + 3] + nfix = 6 + DO i = 1, NN + fixed(nfix + 1:nfix + 2) = [6*i - 4, 6*i - 1] + nfix = nfix + 2 + END DO + ! the taut line without a seabed, then a floor placed just above its node 2 (the anchor + ! is held below it): node 2 carries a quarter of its share, r = 1/2 of half the element + CALL CD_HermiteCable_Static_Solve(l0, EA, EI, w, seed, fixed(1:nfix), -1.0e4_wp, 0.0_wp, 4, 200, 1.0e-10_wp, & + 1.0_wp, qa, c, res, it, es, em) + CALL require(es == CD_HCSTAT_OK, 'energy-gradient line: '//TRIM(em)) + floor_z = qa(9) + 0.5_wp*(0.5_wp*w(1)*l0(1))/(kn*trib(2)) + gap = floor_z - qa(9) + CALL CD_Seabed_Normal_Law(gap, kn*trib(2), normal, normal_gap) + CALL CD_Seabed_End_Element_Share(normal, normal_gap, 0.5_wp*w(1)*l0(1), share, dshare) + CALL require(share > 0.4_wp .AND. share < 0.6_wp, 'energy-gradient: inner node inside the touchdown') + CALL end_support_evaluation(l0, EA, EI, w, fixed(1:nfix), floor_z, kn*trib, qa, ep, [share, 0.0_wp], r0) + DO k = 1, NDIR + d = 0.0_wp + SELECT CASE (k) + CASE (1) + d(9) = 1.0_wp ! the inner node's height + CASE (2) + d(4) = 0.6_wp; d(6) = -0.8_wp ! the anchor's end tangent + CASE (3) + d(7) = 0.3_wp; d(9) = -0.5_wp; d(4) = 0.2_wp; d(15) = 0.4_wp + CASE (4) + DO i = 2, NE + d(6*i - 5) = 0.1_wp*SIN(REAL(i, wp)); d(6*i - 3) = 0.1_wp*COS(REAL(i, wp)) + d(6*i - 2) = 0.01_wp*SIN(2.0_wp*i); d(6*i) = 0.01_wp*COS(2.0_wp*i) + END DO + d(4) = 0.01_wp; d(6) = 0.01_wp + END SELECT + rd = DOT_PRODUCT(r0, d) + CALL end_support_evaluation(l0, EA, EI, w, fixed(1:nfix), floor_z, kn*trib, qa + H*d, ep, [share, 0.0_wp]) + CALL end_support_evaluation(l0, EA, EI, w, fixed(1:nfix), floor_z, kn*trib, qa - H*d, em_, [share, 0.0_wp]) + fd = (ep - em_)/(2.0_wp*H) + CALL require(ABS(fd - rd) <= 1.0e-5_wp*MAX(ABS(rd), 1.0e3_wp), & + 'energy-gradient: the held-share potential differentiates to R') + IF (ABS(fd - rd) > 1.0e-5_wp*MAX(ABS(rd), 1.0e3_wp)) WRITE (*, '(A,I2,2ES16.8)') ' direction, FD, R.d', k, fd, rd + IF (k == 1) THEN + CALL end_support_evaluation(l0, EA, EI, w, fixed(1:nfix), floor_z, kn*trib, qa + H*d, ep) + CALL end_support_evaluation(l0, EA, EI, w, fixed(1:nfix), floor_z, kn*trib, qa - H*d, em_) + fd_free = (ep - em_)/(2.0_wp*H) + CALL require(ABS(fd_free - rd) > 1.0e5_wp, 'energy-gradient: a share following the state is no potential') + END IF + END DO + + END SUBROUTINE check_end_support_energy_gradient + + SUBROUTINE end_support_evaluation(l0, EA, EI, w, fixed, floor_z, contact_kn, qx, energy, hold, residual) + !! Potential (energy_minimization's) and residual of a Hermite line at qx: an evaluation + !! only (a tolerance no state misses), with the end element shares held at hold if given. + REAL(wp), INTENT(IN) :: l0(:), EA(:), EI(:), w(:), floor_z, contact_kn(:), qx(:) + INTEGER, INTENT(IN) :: fixed(:) + REAL(wp), INTENT(OUT) :: energy + REAL(wp), INTENT(IN), OPTIONAL :: hold(2) + REAL(wp), INTENT(OUT), OPTIONAL :: residual(:) + REAL(wp) :: qo(SIZE(qx)), co(SIZE(l0) + 1), ro(SIZE(qx)), rs + INTEGER :: ito, eso + CHARACTER(512) :: emo + IF (PRESENT(hold)) THEN + CALL CD_HermiteCable_Static_Solve(l0, EA, EI, w, qx, fixed, floor_z, 0.0_wp, 1, 1, HUGE(1.0_wp), & + 1.0_wp, qo, co, rs, ito, eso, emo, contact_kn=contact_kn, & + residual_out=ro, energy_out=energy, end_share_hold=hold) + ELSE + CALL CD_HermiteCable_Static_Solve(l0, EA, EI, w, qx, fixed, floor_z, 0.0_wp, 1, 1, HUGE(1.0_wp), & + 1.0_wp, qo, co, rs, ito, eso, emo, contact_kn=contact_kn, & + residual_out=ro, energy_out=energy) + END IF + CALL require(eso == CD_HCSTAT_OK, 'energy-gradient evaluation: '//TRIM(emo)) + IF (PRESENT(residual)) residual = ro + END SUBROUTINE end_support_evaluation + SUBROUTINE check_scalar_contact_on_slope() !! The scalar-kn contact path on a structured (sloped) bathymetry includes the slope !! terms of the penetration in its tangent: from a perturbed equilibrium it converges - !! quadratically to the same state as the nodal path with the equivalent stiffness. - !! The perturbation is a few centimetres: the frictionless reaction is normal to the - !! slope, so it couples x and z at every grounded node on this coarse mesh (elements - !! longer than the bending length), and the full-step Newton basin is that small. + !! as fast as, and to the same state as, the nodal path with the equivalent stiffness. + !! The frictionless reaction is normal to the slope, so it couples x and z at every + !! grounded node of this coarse mesh (elements longer than the bending length). The + !! layout is chosen so that the problem is well posed on every platform: the line, held + !! taut by a fairlead 200 m from the anchor, lies on the slope from its anchor + !! (on the floor) to a touchdown between nodes, every clear node stands at least 0.3 m + !! above the floor (no node in the contact blend), and the equilibrium is a stable one. + !! A slacker layout (fairlead at 150 m) touched down at a node and admitted neighbouring + !! equilibria within 3 cm that the polish reached or not depending on round-off (the + !! OpenBLAS kernel, the platform). The perturbation (7.5 mm in x, 5 mm in z) is a quarter + !! of the largest one from which both backtracking polishes return to the reference + !! under the Prescott, Haswell and SkylakeX kernels and the default one; backtracking + !! (the same option on both paths) keeps each Newton update a residual decrease. INTEGER, PARAMETER :: NE = 20, NN = NE + 1 - REAL(wp) :: l0(NE), EA(NE), EI(NE), w(NE), seed(6*NN), q1(6*NN), q2(6*NN), qs(6*NN), curv(NN), res + REAL(wp) :: l0(NE), EA(NE), EI(NE), w(NE), seed(6*NN), q1(6*NN), q2(6*NN), qs(6*NN), qr(6*NN), curv(NN), res REAL(wp) :: trib(NN), kn, xg(2), yg(2), dep(2, 2) INTEGER :: fixed(6 + 2*NN), nfix, i, es, it1, it2 + LOGICAL :: stable TYPE(CD_BathymetryType) :: bed CHARACTER(512) :: em xg = [-50.0_wp, 300.0_wp]; yg = [-50.0_wp, 50.0_wp] @@ -331,7 +513,7 @@ SUBROUTINE check_scalar_contact_on_slope() DO i = 1, NE trib(i) = trib(i) + 6.5_wp; trib(i + 1) = trib(i + 1) + 6.5_wp END DO - CALL CD_HermiteCable_Trivial_Seed([0.0_wp, 0.0_wp, -100.0_wp], [150.0_wp, 0.0_wp, -20.0_wp], l0, -100.0_wp, & + CALL CD_HermiteCable_Trivial_Seed([0.0_wp, 0.0_wp, -100.0_wp], [200.0_wp, 0.0_wp, -20.0_wp], l0, -100.0_wp, & seed, es, em) CALL require(es == CD_HCSTAT_OK, 'slope seed: '//TRIM(em)) fixed(1:6) = [1, 2, 3, 6*NE + 1, 6*NE + 2, 6*NE + 3] @@ -341,18 +523,22 @@ SUBROUTINE check_scalar_contact_on_slope() nfix = nfix + 2 END DO CALL CD_HermiteCable_Static_Solve(l0, EA, EI, w, seed, fixed(1:nfix), -100.0_wp, 0.0_wp, 8, 200, 1.0e-9_wp, & - 0.7_wp, q1, curv, res, it1, es, em, contact_kn=kn*trib, bathymetry=bed) + 0.7_wp, qr, curv, res, it1, es, em, contact_kn=kn*trib, bathymetry=bed, & + stable=stable) CALL require(es == CD_HCSTAT_OK, 'slope nodal reference: '//TRIM(em)) - qs = q1 + CALL require(stable, 'slope nodal reference is a stable equilibrium') + qs = qr DO i = 2, NE - qs(6*i - 5) = qs(6*i - 5) + 0.03_wp*SIN(REAL(i, wp)) - qs(6*i - 3) = qs(6*i - 3) + 0.02_wp*COS(REAL(i, wp)) + qs(6*i - 5) = qs(6*i - 5) + 0.0075_wp*SIN(REAL(i, wp)) + qs(6*i - 3) = qs(6*i - 3) + 0.005_wp*COS(REAL(i, wp)) END DO CALL CD_HermiteCable_Static_Solve(l0, EA, EI, w, qs, fixed(1:nfix), -100.0_wp, 0.0_wp, 1, 60, 1.0e-10_wp, & - 1.0_wp, q1, curv, res, it1, es, em, contact_kn=kn*trib, bathymetry=bed) + 1.0_wp, q1, curv, res, it1, es, em, contact_kn=kn*trib, bathymetry=bed, & + backtracking=.TRUE.) CALL require(es == CD_HCSTAT_OK, 'slope nodal polish: '//TRIM(em)) + CALL require(nan_max_abs(q1 - qr) < 1.0e-6_wp, 'slope nodal polish returns to the reference') CALL CD_HermiteCable_Static_Solve(l0, EA, EI, w, qs, fixed(1:nfix), -100.0_wp, kn, 1, 60, 1.0e-10_wp, & - 1.0_wp, q2, curv, res, it2, es, em, bathymetry=bed) + 1.0_wp, q2, curv, res, it2, es, em, bathymetry=bed, backtracking=.TRUE.) CALL require(es == CD_HCSTAT_OK, 'slope scalar polish converges: '//TRIM(em)) CALL require(it2 <= it1 + 2, 'slope scalar polish converges as fast as the nodal path') CALL require(nan_max_abs(q2 - q1) < 1.0e-5_wp, 'slope scalar and nodal paths reach the same equilibrium') From 0e2e511f30405594b9e9501eafa43e639f3ad36f Mon Sep 17 00:00:00 2001 From: Jae Hoon Seo Date: Fri, 16 Oct 2026 01:18:25 +0900 Subject: [PATCH 09/31] fix: refine coarse finite-EI statics that fail the stability test (#15) A finite-EI line whose static solve fails its stability test on a deck mesh longer than half the bending length (EI/|w|)^(1/3) is now solved again on the mesh that resolves that length, and accepted when stable there. A lazy-wave power cable restrained in torsion, with 10 m elements along its grounded run, stopped with "unstable equilibrium": its free-DOF tangent had one negative eigenvalue because the pointwise axial force of the stiff-EA elements oscillated into compression at touchdown (-14.5 kN to +21 kN against a 1.2-1.5 kN tension). Refinement removes it, and the positions converge as h^2. The catenary-continuation route, the mesh-sequenced route and the symmetry-broken in-current route each retry on the refined mesh (with the routes' tolerance ladder), and a planar state in an in-plane current is refined before it is classified as a physical saddle. Decks that solved before are byte-identical. A finite-EI line solved in its vertical plane starts dynamics with its out-of-plane DOFs released; the hand-off now runs one stability test with the dynamic end constraints (also on the discrete state of an attachment polish, planar or 3D) and prints a note naming the line, its coarsest element against its half bending length and the refinement that meets it. No result changes. The IEA-15 MW mixed example's power cable is meshed to the rule (248 elements instead of 87); its static tensions now match a 1 m mesh, and the one-hour full-turbine record is rerun: hang-off tension unchanged, touchdown curvature 0.109 1/m, and the anchor tension flat at its static 1.23 kN where the coarse mesh showed stick-slip peaks to 4.1 kN. The statics-matrix hang guard now scales with the configured CPU bound, so slow but healthy Debug runs are not stopped as hung. Signed-off-by: Jae Hoon Seo --- CHANGELOG.md | 42 +- CMakeLists.txt | 59 ++ VALIDATION.md | 8 +- doc/modeling.rst | 16 + doc/openfast.rst | 2 +- doc/troubleshooting.rst | 34 ++ doc/tutorial_openfast.rst | 15 +- examples/iea15mw_umaine_mixed_cabledyn.dat | 15 +- src/CableDyn_DeckDriver.f90 | 510 +++++++++++++++++- .../lazy_wave_touchdown_planar_coarse.dat | 44 ++ .../lazy_wave_touchdown_planar_coarse_att.dat | 48 ++ .../lazy_wave_touchdown_planar_refined.dat | 41 ++ ...lazy_wave_touchdown_planar_refined_att.dat | 45 ++ .../lazy_wave_touchdown_torsion_coarse.dat | 47 ++ ...ave_touchdown_torsion_coarse_sequenced.dat | 44 ++ tests/data/lozon_coupled_harmonics.dat | 2 +- tests/test_cable_statics_matrix.py | 15 +- tests/test_deck_hermite_cable.f90 | 14 +- tests/test_openfast_aggregate.f90 | 10 +- validation/OPENFAST_DLC_VERIFICATION.md | 19 +- 20 files changed, 968 insertions(+), 62 deletions(-) create mode 100644 tests/data/lazy_wave_touchdown_planar_coarse.dat create mode 100644 tests/data/lazy_wave_touchdown_planar_coarse_att.dat create mode 100644 tests/data/lazy_wave_touchdown_planar_refined.dat create mode 100644 tests/data/lazy_wave_touchdown_planar_refined_att.dat create mode 100644 tests/data/lazy_wave_touchdown_torsion_coarse.dat create mode 100644 tests/data/lazy_wave_touchdown_torsion_coarse_sequenced.dat diff --git a/CHANGELOG.md b/CHANGELOG.md index d54a8406..7cc4c055 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -19,6 +19,15 @@ All notable changes to CableDyn are recorded in this file. The format follows `EI = 0` + finite-EI route) the finite-EI cable steps with their residual, tangent and solve counts and times. Every output file is the same with and without it. See the manual's command-line page (Run-time profile). +- A note when a finite-EI line starts its dynamics from a static state that is unstable out of + its vertical plane. A line solved in that plane (free in torsion, no current or end direction + across it) has its out-of-plane DOFs held in the statics and released in the dynamics. On + elements longer than half the bending length the touchdown can make that state unstable out of + the plane, which the planar solve does not see. One stability test with the dynamic + constraints now runs at the hand-off (0.35 ms on an 87-element lazy wave, 6 ms on 2048 + elements; on a line with `ATTACHMENTS`, on the discrete equilibrium after the attachment + polish) and the note names the line, its mesh and the factor that meets the bending length, + and recommends a finer mesh or `adaptive_mesh True`. Results do not change. - Torsion of finite-EI lines in coupled OpenFAST (`CompMooring = 5`) and FAST.Farm runs. The End A frame of a line restrained in torsion turns with the platform orientation, the torque moment is returned to the platform, `PtfmInit` twists the line in the static initialisation, @@ -60,6 +69,19 @@ All notable changes to CableDyn are recorded in this file. The format follows `MD_Shared` farm (`validation/scripts/fastfarm_shared_ab.py`): tension means agree to 0.02 %, extremes to 0.25 %, and platform motions to millimetres. The migration guide now says that on a line with no `Fixed` end `FairTen` and `AnchTen` name the opposite ends from MoorDyn's. +- The power cable of `examples/iea15mw_umaine_mixed_cabledyn.dat` is meshed to the + half-bending-length rule: 248 elements (2 m, 2.5 m and 2.5 m in its three sections) instead + of 87 (4 m, 4 m and 10 m). On the 10 m grounded elements the touchdown was under-resolved and + the static state, solved in the vertical plane of the cable, was unstable out of that plane. + The static fairlead tension of the cable changes from 11 898 N to 11 922 N (11 921 N on a + 1 m mesh), its anchor tension from 1218 N to 1230 N, and the touchdown curvature from + 0.058 1/m to 0.079 1/m (0.080 1/m on the 1 m mesh). The curvature output moves with the + mesh: `Curv4N20`/`BendMom4N20` (76 m from the hang-off) become `Curv4N38`/`BendMom4N38` + (74 m, the peak of the sag bend). In the one-hour full-turbine run of the validation record + the hang-off tension statistics are unchanged (11.5 ± 1.1 kN), the touchdown curvature peaks + at 0.109 1/m instead of 0.075 1/m, and the anchor tension stays at its static 1.23 kN, where + the coarse mesh showed stick-slip peaks up to 4.1 kN. The validation record and the tutorials + are updated. ### Fixed @@ -79,9 +101,9 @@ All notable changes to CableDyn are recorded in this file. The format follows out of its plane. The seabed contact acts at the nodes, which carry no moment, so at an anchor resting on the floor the end moment of the end element's weight turned the free end tangent into the floor: the element dipped below the seabed between its nodes (27 mm for the - power cable of `examples/iea15mw_umaine_mixed_cabledyn.dat`) and carried axial forces from - −47 kN to +127 kN about a line tension of 1.2 kN. Once the hang-off swayed, the element - buckled sideways; with seabed friction the anchor tension then locked at about 2.5 times its + power cable of `examples/iea15mw_umaine_mixed_cabledyn.dat` on its former 10 m grounded + elements) and carried axial forces from −47 kN to +127 kN about a line tension of 1.2 kN. + Once the hang-off swayed, the element buckled sideways; with seabed friction the anchor tension then locked at about 2.5 times its static value for the rest of the run (1.22 kN to 3.1 kN in a coupled OpenFAST run while the platform drifted toward the anchor), and without friction the end nodes wandered by up to 0.18 m. The seabed now carries the end element's weight with its end moment at a held line end @@ -102,6 +124,20 @@ All notable changes to CableDyn are recorded in this file. The format follows grounded run turned sideways on the seabed: when the refinement of the catenary continuation stops on a compression in a current, its failure now names the current limit, so the driver retries out of the plane. +- A finite-EI line solved in 3D (restrained in torsion, or with an end connection direction or + a current out of the vertical plane of its chord) on a deck mesh too coarse at touchdown or at a section + change no longer stops with "the converged state is an unstable equilibrium". The stable + equilibrium had read as a saddle: elements longer than the bending length cannot follow + the bend, the axial force at their Gauss points oscillates into compression, and that + compression lowered the out-of-plane stiffness until the stability test failed. Such a + state is now refined, from the mesh the route returned, to the mesh whose elements are at + most half the bending length: the catenary-continuation route is repeated there, as for a + failed polish, and the state of the mesh-sequenced route is prolongated there and polished. + This also covers a mesh that an adaptive or safety refinement left too coarse; a mesh that + already meets the rule is not refined again. A note names both meshes. An equilibrium that + is still unstable on the refined mesh stops as before. Decks that solved before give the + same results. `tests/data/lazy_wave_touchdown_torsion_coarse.dat` is the regression case, + solved with each route first. ## [0.1.1] - 2026-10-09 diff --git a/CMakeLists.txt b/CMakeLists.txt index b3d6db2d..7d28801b 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -2014,6 +2014,65 @@ add_test(NAME driver_clamped_cable_pinned_rod -DWORKDIR=${CMAKE_CURRENT_BINARY_DIR}/driver_clamped_cable_pinned_rod -P ${CMAKE_CURRENT_SOURCE_DIR}/tests/check_driver_output.cmake) set_tests_properties(driver_clamped_cable_pinned_rod PROPERTIES LABELS "fortran;driver;integration") +# A lazy-wave cable restrained in torsion (3D static solve) whose deck mesh is too coarse at +# touchdown: the deck-mesh equilibrium reads as unstable, the refined one is stable and used. +add_test(NAME driver_lazy_wave_torsion_coarse_refined + COMMAND ${CMAKE_COMMAND} -DDRIVER=$ -DEXPECT_RC=0 + "-DARGS=${CMAKE_CURRENT_SOURCE_DIR}/tests/data/lazy_wave_touchdown_torsion_coarse.dat|coarse" + "-DONCE=failed the stability test with elements longer than half the bending length" + "-DMUST_MATCH=stable on the refined mesh of 348 elements;torsion solved" + -DWORKDIR=${CMAKE_CURRENT_BINARY_DIR}/driver_lazy_wave_torsion_coarse_refined + -P ${CMAKE_CURRENT_SOURCE_DIR}/tests/check_driver_output.cmake) +set_tests_properties(driver_lazy_wave_torsion_coarse_refined PROPERTIES + LABELS "fortran;driver;integration;static;torsion") +# The same deck with the mesh-sequenced route first: its state is prolongated to the refined mesh. +add_test(NAME driver_lazy_wave_torsion_coarse_sequenced + COMMAND ${CMAKE_COMMAND} -DDRIVER=$ -DEXPECT_RC=0 + "-DARGS=${CMAKE_CURRENT_SOURCE_DIR}/tests/data/lazy_wave_touchdown_torsion_coarse_sequenced.dat|coarse" + "-DONCE=failed the stability test with elements longer than half the bending length" + "-DMUST_MATCH=stable on the refined mesh of 348 elements;torsion solved" + -DWORKDIR=${CMAKE_CURRENT_BINARY_DIR}/driver_lazy_wave_torsion_coarse_sequenced + -P ${CMAKE_CURRENT_SOURCE_DIR}/tests/check_driver_output.cmake) +set_tests_properties(driver_lazy_wave_torsion_coarse_sequenced PROPERTIES + LABELS "fortran;driver;integration;static;torsion") +# The same cable free in torsion (planar static): the coarse planar state is unstable out of its +# plane and the hand-off names it once; on a mesh that resolves the bending length it does not. +add_test(NAME driver_lazy_wave_planar_coarse_note + COMMAND ${CMAKE_COMMAND} -DDRIVER=$ -DEXPECT_RC=0 + "-DARGS=${CMAKE_CURRENT_SOURCE_DIR}/tests/data/lazy_wave_touchdown_planar_coarse.dat|coarse" + "-DONCE=starts the dynamics from a static state solved in its vertical plane that is unstable" + "-DMUST_MATCH=mesh of 87 elements, the coarsest 10.00 m long;4x meets that length" + -DWORKDIR=${CMAKE_CURRENT_BINARY_DIR}/driver_lazy_wave_planar_coarse_note + -P ${CMAKE_CURRENT_SOURCE_DIR}/tests/check_driver_output.cmake) +set_tests_properties(driver_lazy_wave_planar_coarse_note PROPERTIES + LABELS "fortran;driver;integration;static") +add_test(NAME driver_lazy_wave_planar_refined_quiet + COMMAND ${CMAKE_COMMAND} -DDRIVER=$ -DEXPECT_RC=0 + "-DARGS=${CMAKE_CURRENT_SOURCE_DIR}/tests/data/lazy_wave_touchdown_planar_refined.dat|refined" + "-DMUST_NOT=unstable out of" + -DWORKDIR=${CMAKE_CURRENT_BINARY_DIR}/driver_lazy_wave_planar_refined_quiet + -P ${CMAKE_CURRENT_SOURCE_DIR}/tests/check_driver_output.cmake) +set_tests_properties(driver_lazy_wave_planar_refined_quiet PROPERTIES + LABELS "fortran;driver;integration;static") +# The same pair with the buoyant stretch built from discrete ATTACHMENTS: the hand-off check runs +# on the discrete equilibrium the attachment polish gives. +add_test(NAME driver_lazy_wave_planar_coarse_att_note + COMMAND ${CMAKE_COMMAND} -DDRIVER=$ -DEXPECT_RC=0 + "-DARGS=${CMAKE_CURRENT_SOURCE_DIR}/tests/data/lazy_wave_touchdown_planar_coarse_att.dat|coarse_att" + "-DONCE=starts the dynamics from a static state solved in its vertical plane that is unstable" + "-DMUST_MATCH=mesh of 87 elements, the coarsest 10.00 m long;4x meets that length;25 attachment.s. lumped" + -DWORKDIR=${CMAKE_CURRENT_BINARY_DIR}/driver_lazy_wave_planar_coarse_att_note + -P ${CMAKE_CURRENT_SOURCE_DIR}/tests/check_driver_output.cmake) +set_tests_properties(driver_lazy_wave_planar_coarse_att_note PROPERTIES + LABELS "fortran;driver;integration;static") +add_test(NAME driver_lazy_wave_planar_refined_att_quiet + COMMAND ${CMAKE_COMMAND} -DDRIVER=$ -DEXPECT_RC=0 + "-DARGS=${CMAKE_CURRENT_SOURCE_DIR}/tests/data/lazy_wave_touchdown_planar_refined_att.dat|refined_att" + "-DMUST_NOT=unstable out of" + -DWORKDIR=${CMAKE_CURRENT_BINARY_DIR}/driver_lazy_wave_planar_refined_att_quiet + -P ${CMAKE_CURRENT_SOURCE_DIR}/tests/check_driver_output.cmake) +set_tests_properties(driver_lazy_wave_planar_refined_att_quiet PROPERTIES + LABELS "fortran;driver;integration;static") if(WIN32 AND CABLEDYN_RUNTIME_DLLS) add_test( diff --git a/VALIDATION.md b/VALIDATION.md index 2fcc76c8..6349554c 100644 --- a/VALIDATION.md +++ b/VALIDATION.md @@ -317,10 +317,10 @@ scripts, results, and source provenance are in ~3% std. Tension agreement with MoorDyn is scored in the settled case above and in the DLC matrix below. - *Mixed deck*: the shipped example `iea15mw_umaine_mixed_cabledyn.dat` (three - chain moorings and an 87-element finite-EI power cable that touches down on the + chain moorings and a 248-element finite-EI power cable that touches down on the 200 m seabed) runs to completion under full coupled physics with finite, bounded - channels. Coupled touchdown is covered by the 40 Hz `openfast_touchdown` test; no - full-DLC touchdown result is claimed. + channels. Coupled touchdown is covered by the 40 Hz `openfast_touchdown` test and by + the one-hour full-turbine run in the coupled finite-EI touchdown row below. - *Wall-clock*: see *Coupled throughput* under [L5](#wall-clock-time). - *`PtfmInit`*: MoorDyn-F's convention (rigid transform of Coupled/Vessel points, undisplaced reference `Position` + `TranslationDisp`); tested by @@ -734,7 +734,7 @@ stop with a named error. | Active tension (`CtrlChan`) | Pass verified | CONTROL parsing, last-segment length/rate modulation, and exact unit tests; coupled A/B in which a ServoDyn cable-control DLL drives the same pay-out/haul-in `DeltaL` schedule into `=5` (CableDyn) and `=3` (stock MoorDyn) in one binary: hold tensions agree to <0.03% and the tension responses to <0.6% (controlled fairleads) / <0.7% (anchors) ([`validation/scripts/activetension/`](https://github.com/SMI-Lab-Inha/CableDyn/tree/main/validation/scripts/activetension), [`validation/scripts/openfast_activetension_ab.py`](https://github.com/SMI-Lab-Inha/CableDyn/blob/main/validation/scripts/openfast_activetension_ab.py)) | | Coupled `Rigid6` bodies + `Point3` buoys | Pass verified | 6-DOF `Rigid6` motion with hydrostatic (`C33`/`C44`/`C55`) restoring, checkpoint state (bit-identical `openfast -restart` of a 13.9 MN-swinging tethered body), and SeaState drag / Froude–Krylov / added mass. `Point3` buoys take buoyancy and drag/added-mass/FK; a submerged volume-only buoy takes FK. Tests: `case_coupled_rigid6`/`_mirror`/`_fluid`, `case_coupled_point3_buoy`/`_fluid` | | Coupled rigid rods | Pass verified | host-driven `RodA/B` endpoints, correction rewind, bit-identical 24-scalar-per-rod checkpoint state, and two Gauss fluid nodes per rod with SeaState drag/Froude–Krylov/added mass; `case_coupled_rod`, `_mirror`, and `_fluid` pass, and the OpenFAST module compiles with rod decks enabled | -| Coupled finite-EI touchdown/contact | Pass verified | flat `WtrDpth` and equivalent constant structured bathymetry initialise and step with matching loads; friction and checkpoint restore are tested. The IEA-15 mixed example has 38 grounded nodes and completes a 20 s aggregate trajectory at `dtM=0.025 s` with 2 m surge, 1 m heave, and 0.5 m/s host current, without fallback or stall recovery, at most 14 Newton iterations. A full-turbine run of the same model (one hour after a 200 s transient; TurbSim normal turbulence, 10.6 m/s, 17 % TI; JONSWAP Hs 8 m, Tp 12 s, aligned with the wind and the cable; AeroDyn with the rotor held at 7.55 rpm, no controller, rigid blades and tower; SeaState grid covering the lines) completes without recoveries or non-finite values. The cable's hang-off tension is 11.5 ± 1.1 kN (static 11.9 kN, maximum 17.9 kN), the same 38 nodes stay grounded, and the peak curvature, 0.160 1/m at the hog bend, is mesh-converged (0.156 1/m on a refined mesh); the 10 m elements of the laid section under-resolve the touchdown curvature by about 30 %. The chain-only twin of the run matches stock MoorDyn over 1200 s to 0.3 % in platform motion and fairlead tension statistics. The anchor tension of the laid cable is 1.39 kN (median, static 1.22 kN) with wave-frequency stick-slip peaks up to 4.1 kN lasting under 1 s; before the anchor-end correction of this release it locked at about 2.75 kN for the whole run | +| Coupled finite-EI touchdown/contact | Pass verified | flat `WtrDpth` and equivalent constant structured bathymetry initialise and step with matching loads; friction and checkpoint restore are tested. The IEA-15 mixed example (its power cable on 248 elements, each at most half the bending length) has 149 grounded nodes and completes a 20 s aggregate trajectory at `dtM=0.025 s` with 2 m surge, 1 m heave, and 0.5 m/s host current, without fallback or stall recovery, at most 12 Newton iterations. A full-turbine run of the same model (one hour after a 200 s transient; TurbSim normal turbulence, 10.6 m/s, 17 % TI; JONSWAP Hs 8 m, Tp 12 s, aligned with the wind and the cable; AeroDyn with the rotor held at 7.55 rpm, no controller, rigid blades and tower; SeaState grid covering the lines) completes without recoveries or non-finite values. The cable's hang-off tension is 11.5 ± 1.1 kN (static 11.9 kN, maximum 17.9 kN). The 149 nodes grounded at the static state stay grounded, joined by one more once the platform has drifted (the touchdown moves 2.5 m toward the platform). The peak curvature is 0.156 1/m at the sag bend, 72 m from the hang-off, and 0.109 1/m at the touchdown. On the former 87-element mesh (10 m elements along the laid section) the peak was 0.160 1/m and the touchdown curvature 0.075 1/m, under-resolved by about 30 %. The chain-only twin of the run matches stock MoorDyn over 1200 s to 0.3 % in platform motion and fairlead tension statistics. The anchor tension of the laid cable stays at its static 1.23 kN (maximum 1.24 kN): the seabed friction of the 370 m laid section holds the tension changes at the touchdown. On the former mesh it read 1.39 kN (median) with wave-frequency stick-slip peaks up to 4.1 kN lasting under 1 s, which the resolved mesh does not show, and before the anchor-end correction of this release it locked at about 2.75 kN for the whole run. The run takes 27.1 min of wall time (18.8 min on the former mesh) | | `WaterKin` from file | Pass verified | See [WaterKin and SeaState modes](#waterkin-and-seastate-modes) | | Syrope polyester (`SYROPE:` syntax; [Falkenberg et al., 2017](https://cabledyn.readthedocs.io/en/latest/references.html#ref-falkenberg2017)) | Pass verified | MoorDyn-F/C `BA_s|BA_d` rate and force equations; analytic position/velocity tangents with finite-difference checks; projected, bracketed backward-Euler slow-state update with a strong-unloading boundary test; OWC running maximum; `SYROPE IC` `Tmax0/Tmean0` history with range/order checks; both states carried through every lifecycle stage and the coupled checkpoint. `BA_s` is kept separate from line axial damping (`BA`) and tested against double counting. Composite, hydrodynamic, finite-EI, current, and wave combinations stop with a named error | | VIV (`compVIV`) | Not supported | outside CableDyn's scope | diff --git a/doc/modeling.rst b/doc/modeling.rst index e3249cd0..ecaaf2d0 100644 --- a/doc/modeling.rst +++ b/doc/modeling.rst @@ -86,6 +86,22 @@ refine regions with high curvature or rapidly varying load: hang-off and bend-st buoyancy-module transitions, sag bends, touchdown, and short weighted attachments. Avoid using a material boundary solely as a substitute for mesh refinement. +**Starting mesh for a finite-EI line.** At touchdown, at a sag or hog bend and on each side of a +section change, keep the element length at most half the bending length +:math:`(EI/|w|)^{1/3}` of the section, with :math:`w` its submerged weight per metre. For a +power cable with :math:`EI = 2\times10^4` N m² and :math:`w = 158` N/m that is 2.5 m. A longer +element cannot follow the bend: it stays stiff in bending, and its stiff axial term absorbs the +mismatch, so the pointwise axial force oscillates about the element mean, by tens of kN on a +lazy wave of 1–2 kN tension at 10 m elements. The ``.t.out`` segment tensions, evaluated at the +element midpoints, show these spikes and negative values near touchdown and at section changes; +they shrink as the mesh is refined, and the element-mean force (what enters equilibrium, see +``tensile_safety`` in :doc:`theory`) is far smoother. The compressed Gauss points also lower the +out-of-plane stiffness: a line solved in 3D (restrained in torsion, or with an end connection +direction or a current out of its vertical plane) can read as an unstable equilibrium on such a +mesh. The static solve then refines that state to the rule above, whichever route reached it and +whether or not an adaptive refinement preceded, and reports it in a note (see +:doc:`troubleshooting`); meshing to the rule avoids the extra solve. + Perform a mesh study on engineering observables, not node identity. At minimum compare endpoint tension and the peak/position of curvature or touchdown response. Refine until the change is below the project tolerance. Cross-code comparisons should interpolate by normalised arc length as diff --git a/doc/openfast.rst b/doc/openfast.rst index 1e701366..2d7b6870 100644 --- a/doc/openfast.rst +++ b/doc/openfast.rst @@ -201,7 +201,7 @@ Mixed moorings and power cables One deck may combine ``EI = 0`` chains and finite-EI (``EI > 0``) power cables; each line uses its own element. In ``iea15mw_umaine_mixed_cabledyn.dat`` line 4 runs from a platform hang-off to a fixed termination on the 200 m seabed; its bare/buoyant/bare sections form the lazy wave and -a grounded tail (38 of 88 nodes on the seabed at equilibrium). ``WtrDpth``, ``kBot``, ``cBot``, +a grounded tail (149 of 249 nodes on the seabed at equilibrium). ``WtrDpth``, ``kBot``, ``cBot``, and ``frictionMu`` define contact; a structured ``bathymetryFile`` may replace the flat floor. CableDyn finds touchdown during static initialisation. Inspect ``.CD.static.out`` (curvature, grounded length, section transitions, minimum bend radius) before the time history. diff --git a/doc/troubleshooting.rst b/doc/troubleshooting.rst index 46468820..fbfe63b2 100644 --- a/doc/troubleshooting.rst +++ b/doc/troubleshooting.rst @@ -463,6 +463,17 @@ but a few geometries are genuinely hard: of the twist cannot be trusted beyond it): reduce ``dtM`` or slow the imposed roll. ``tangent turns by more than 120 degrees`` names an element or node pair where the twist of the centreline is no longer reliable: refine the mesh there. +- **A finite-EI equilibrium reported unstable.** ``found no physical equilibrium ... the + converged state is an unstable equilibrium (tangent stiffness not positive definite)`` means + the state that balanced its residual is a saddle of the potential energy: a compressed strut, a + buckled arch or an inverted fold. A coarse mesh can also produce it. On elements longer than + half the bending length :math:`(EI/|w|)^{1/3}` the axial force oscillates into compression at + Gauss points near touchdown or a section change, which lowers the out-of-plane stiffness of a + line solved in 3D. Each static route therefore refines such a state to a mesh that resolves + the bending length before it fails: the catenary-continuation route is repeated there, and + the mesh-sequenced state is prolongated and polished there. If the message names that refined + mesh as well (``still unstable on the refined mesh``), the instability is physical: check the + layout, the line length and the buoyancy. - **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. @@ -527,6 +538,29 @@ Warnings and notes that do not stop a run Newton system loses the precision to converge. An 80 m lazy wave (6.5 mm limit) solves at 8 mm elements and not at 4 to 6 mm, where the solve stops within seconds and names the mesh. Coarsen ``NumSegs`` to at least the length the note gives. + * - ``Note: line ...: the equilibrium on the deck mesh (... elements) failed the stability test + with elements longer than half the bending length; stable on the refined mesh of ... + elements`` (or ``the equilibrium on the mesh of ... elements (refined from the deck mesh of + ...) failed ...``) + - on the deck mesh, or on a refinement of it that was still too coarse, the static state + read as unstable, an artefact of elements longer than half the bending length + :math:`(EI/|w|)^{1/3}` (see :doc:`modeling`, step 5). The run uses + the refined mesh, statics and dynamics alike, and its outputs have that many segments. + Mesh the touchdown and section changes to that rule to keep the deck mesh. + * - ``Note: line ... starts the dynamics from a static state solved in its vertical plane that + is unstable out of that plane on its mesh of ... elements, the coarsest ... m long where + half the bending length (EI/|w|)^(1/3) is ... m; ...`` + - a finite-EI line free in torsion is solved in its vertical plane, and the dynamics release + its out-of-plane DOFs. On elements longer than half the bending length the axial force at + touchdown or a section change oscillates into compression and makes that planar state + unstable out of the plane, so a lateral disturbance (a cross current, a sway motion) can + move the line from it in a way the mesh, not the physics, decides. On a line with + ``ATTACHMENTS`` the test runs on the discrete equilibrium, after the attachment polish, + and the bending length uses the smeared weight of the buoyant stretch. The results are + those of the deck as written. Refine the mesh by the factor the note gives, or set + ``adaptive_mesh True``; a line restrained in torsion is solved in 3D and refined + automatically (see :doc:`modeling`, step 5). When ``adaptive_mesh True`` is already set, + its own refinement criteria stopped short of the bending length: refine the deck mesh. * - ``Note: line ... mesh too coarse for its bends`` - the element-mean axial force of a finite-EI line, averaged with its neighbours, is compressive, and the pointwise resultant oscillates well beyond it. Refine ``NumSegs`` in diff --git a/doc/tutorial_openfast.rst b/doc/tutorial_openfast.rst index 50fb7b8f..a04334e7 100644 --- a/doc/tutorial_openfast.rst +++ b/doc/tutorial_openfast.rst @@ -315,15 +315,18 @@ seabed. Copy it into the case folder and point a copy of the ``.fst`` at it: Created CableDyn model: 4 line object(s), 8 point(s), 6 section(s) [EI=0: 3, finite-EI: 1]. ... - Line 4 fairlead effective tension: 11898 N - force [Fx, Fy, Fz]: [1218.2, 0, -11835] N, inclination=84.123 deg - line tangent: inclination=83.927 deg, declination=173.93 deg, azimuth=0 deg + Line 4 fairlead effective tension: 11922 N + force [Fx, Fy, Fz]: [1230, 0, -11858] N, inclination=84.078 deg + line tangent: inclination=83.943 deg, declination=173.94 deg, azimuth=0 deg ... - Curv4N20 = 9.15231E-02 (1/m) - BendMom4N20 = 1821.3 (N.m) + Curv4N38 = 9.06020E-02 (1/m) + BendMom4N38 = 1803 (N.m) CableDyn found the cable's touchdown and lazy-wave shape by itself: in -``Mixed_CableDyn.CD.static.out``, 38 of line 4's 88 nodes lie on the seabed. The chain moorings +``Mixed_CableDyn.CD.static.out``, 149 of line 4's 249 nodes lie on the seabed. Node 38, 74 m +from the hang-off, is the peak of the sag bend. The cable's elements are at most half its bending +length :math:`(EI/|w|)^{1/3}` (the deck's comments give the numbers), which resolves the bends +and the touchdown. The chain moorings use the cable element and the power cable the cubic-Hermite bending element, in one deck and one coupled solve. Plot line 4's ``Curvature`` against ``ArcLength`` before looking at the time history, and request ``Curv4N``/``BendMom4N`` channels at the hang-off, sag bend, arch, and diff --git a/examples/iea15mw_umaine_mixed_cabledyn.dat b/examples/iea15mw_umaine_mixed_cabledyn.dat index 157284e4..2bd92fef 100644 --- a/examples/iea15mw_umaine_mixed_cabledyn.dat +++ b/examples/iea15mw_umaine_mixed_cabledyn.dat @@ -34,9 +34,14 @@ LineID LineType Length NumSegs 1 main 850.0 50 2 main 850.0 50 3 main 850.0 50 -4 bare 80.0 20 -4 buoy 100.0 25 -4 bare 420.0 42 +4 bare 80.0 40 +4 buoy 100.0 40 +4 bare 420.0 168 +-- Line 4 mesh: every element at most half the bending length (EI/|w|)^(1/3) of its section, so +-- the touchdown, the sag and hog bends and the section changes are resolved: bare cable +-- (w = 157.8 N/m) 5.02 m -> 2.51 m, 2.0 m and 2.5 m elements; buoyancy section (|w| = 80.1 N/m) +-- 6.28 m -> 3.14 m, 2.5 m elements. A coarser mesh (10 m along the grounded run) reads the +-- planar equilibrium as unstable out of its plane at touchdown (see doc/modeling.rst, step 5). --------------------------- OPTIONS ------------------------------------------- 9.80665 g - Gravitational acceleration (m/s^2); overridden by OpenFAST [default: 9.80665] 1025.0 rhoW - Water density (kg/m^3); overridden by OpenFAST [default: 1025] @@ -71,7 +76,7 @@ none waves - Wave model, height, period, and direction (m, s, d "AnchTen4" "FairIncl4" "AnchIncl4" -"Curv4N20" -"BendMom4N20" +"Curv4N38" +"BendMom4N38" END --------------------------- need this line ------------------------------------ diff --git a/src/CableDyn_DeckDriver.f90 b/src/CableDyn_DeckDriver.f90 index 6872c545..f51d51c5 100644 --- a/src/CableDyn_DeckDriver.f90 +++ b/src/CableDyn_DeckDriver.f90 @@ -1543,13 +1543,18 @@ RECURSIVE SUBROUTINE build_one_hermite_cable(ln, sections, types, points, opts, ! A planar equilibrium in a current that is a saddle out of its plane (see route_pass). REAL(wp), ALLOCATABLE :: l0_saddle(:), ea_saddle(:), ei_saddle(:), w_saddle(:), q_saddle(:), curv_saddle(:) INTEGER, ALLOCATABLE :: fixed_saddle(:) - LOGICAL :: saddle_tol_note, saddle_kink + LOGICAL :: saddle_tol_note, saddle_kink, saddle_stab + INTEGER :: saddle_stab_ne REAL(wp) :: saddle_res CHARACTER(320) :: saddle_notes LOGICAL :: primary_done, primary_inadmissible, tolerance_note, stable, kink_refined, sequence_done LOGICAL :: primary_walked, walk_rejected ! Why the bow behind the fairlead was not reached (bow_route), blank when not tried. - CHARACTER(1024) :: bow_msg + CHARACTER(1024) :: bow_msg, refine_msg + ! Set when the deck-mesh equilibrium failed the stability test and the refined one passed. + LOGICAL :: stability_refined + ! Elements of the mesh whose equilibrium failed the stability test before that refinement. + INTEGER :: stability_from_ne LOGICAL :: tensile_error CHARACTER(400) :: note_text CHARACTER(512) :: limit_text @@ -1993,11 +1998,15 @@ RECURSIVE SUBROUTINE build_one_hermite_cable(ln, sections, types, points, opts, resolution_note = '' tolerance_note = .FALSE. kink_refined = .FALSE. + stability_refined = .FALSE. + stability_from_ne = 0 sym_broken = .FALSE. planar_unstable = .FALSE. walk_rejected = .FALSE. saddle_tol_note = .FALSE. saddle_kink = .FALSE. + saddle_stab = .FALSE. + saddle_stab_ne = 0 saddle_res = CD_ZERO saddle_notes = '' ! In a current the traced path can end at a fold or a pitchfork of the planar branch @@ -2014,6 +2023,9 @@ RECURSIVE SUBROUTINE build_one_hermite_cable(ln, sections, types, points, opts, END IF END IF route_pass: DO pass = 1, 3 + ! set by the catenary-continuation route only: a state the sequenced route produced + ! was not walked + primary_walked = .FALSE. IF (primary_done) EXIT route_pass ! A planar equilibrium that is unstable out of its plane is not repeated by the ! mesh-sequenced route (also planar): the symmetry-breaking pass follows. @@ -2345,6 +2357,13 @@ RECURSIVE SUBROUTINE build_one_hermite_cable(ln, sections, types, points, opts, IF (.NOT. stable) THEN sequence_done = .FALSE. sequence_msg = 'the converged state is an unstable equilibrium (tangent stiffness not positive definite)' + ! As for the catenary-continuation route below, on the mesh that resolves the + ! bending length; the sequenced state is prolongated there, not re-solved. + IF (bending_refine_scale(l0_am, ei_am, w_am) >= 2) THEN + CALL sequenced_refined_polish(sequence_done, refine_msg) + IF (.NOT. sequence_done .AND. LEN_TRIM(refine_msg) > 0) & + sequence_msg = TRIM(sequence_msg)//'; '//TRIM(short_message(refine_msg, 240)) + END IF END IF END IF ELSE @@ -2405,6 +2424,16 @@ RECURSIVE SUBROUTINE build_one_hermite_cable(ln, sections, types, points, opts, IF (.NOT. stable) THEN primary_done = .FALSE. primary_msg = 'the converged state is an unstable equilibrium (tangent stiffness not positive definite)' + ! A mesh longer than half the bending length can turn a stable equilibrium into a + ! discrete saddle (see stability_refine in hermite_static_primary): the route is + ! repeated once on the mesh refined from the returned one to resolve that length, + ! and its state audited the same way. A returned mesh that already resolves it, + ! adaptively refined or not, is not refined again: its instability stands. + IF (.NOT. primary_walked .AND. bending_refine_scale(l0_am, ei_am, w_am) >= 2) THEN + CALL stability_refined_route(primary_done, refine_msg) + IF (.NOT. primary_done .AND. LEN_TRIM(refine_msg) > 0) & + primary_msg = TRIM(primary_msg)//'; '//TRIM(short_message(refine_msg, 240)) + END IF END IF END IF ! The equilibrium the anchor walk reached (the line too long to hang as a catenary) @@ -2452,6 +2481,14 @@ RECURSIVE SUBROUTINE build_one_hermite_cable(ln, sections, types, points, opts, ! toward its end can hold in the plane only as a saddle). Otherwise the out-of-plane ! (symmetry-breaking) pass finds the stable equilibrium. IF ((sequence_done .OR. primary_done) .AND. pass <= 2) THEN + ! On a mesh longer than half the bending length the out-of-plane negative mode can be + ! the mesh's, not a pitchfork of the line: the planar state is first carried to the + ! mesh that resolves that length and polished there (sequenced_refined_polish), and + ! kept if it is not a saddle there; otherwise the coarse state is restored and + ! classified as before. + IF (.NOT. primary_walked .AND. bending_refine_scale(l0_am, ei_am, w_am) >= 2) THEN + IF (planar_current_saddle()) CALL saddle_refined_retry() + END IF IF (planar_current_saddle()) THEN primary_done = .FALSE. sequence_done = .FALSE. @@ -2463,6 +2500,8 @@ RECURSIVE SUBROUTINE build_one_hermite_cable(ln, sections, types, points, opts, saddle_notes = compression_note saddle_tol_note = tolerance_note saddle_kink = kink_refined + saddle_stab = stability_refined + saddle_stab_ne = stability_from_ne saddle_res = res CALL MOVE_ALLOC(l0_am, l0_saddle) CALL MOVE_ALLOC(ea_am, ea_saddle) @@ -2474,6 +2513,7 @@ RECURSIVE SUBROUTINE build_one_hermite_cable(ln, sections, types, points, opts, compression_note = '' tolerance_note = .FALSE. kink_refined = .FALSE. + stability_refined = .FALSE. IF (ALLOCATED(sequence_iters)) DEALLOCATE (sequence_iters) IF (ALLOCATED(q_sequence)) DEALLOCATE (q_sequence) IF (ALLOCATED(q_coupled_tol)) DEALLOCATE (q_coupled_tol) @@ -2503,6 +2543,8 @@ RECURSIVE SUBROUTINE build_one_hermite_cable(ln, sections, types, points, opts, compression_note = saddle_notes tolerance_note = saddle_tol_note kink_refined = saddle_kink + stability_refined = saddle_stab + stability_from_ne = saddle_stab_ne res = saddle_res primary_done = .TRUE. saddle_kept = .TRUE. @@ -2558,6 +2600,19 @@ RECURSIVE SUBROUTINE build_one_hermite_cable(ln, sections, types, points, opts, CALL report_note('line '//TRIM(int_to_str(ln%id))//': '//TRIM(compression_note)) END IF END IF + IF (stability_refined .AND. (sequence_done .OR. primary_done)) THEN + IF (stability_from_ne == SIZE(l0)) THEN + WRITE (note_text, '(A,I0,A,I0,A,I0,A)') 'line ', ln%id, ': the equilibrium on the deck mesh (', SIZE(l0), & + ' elements) failed the stability test with elements longer than half the bending length; '// & + 'stable on the refined mesh of ', SIZE(l0_am), ' elements' + ELSE + WRITE (note_text, '(A,I0,A,I0,A,I0,A,I0,A)') 'line ', ln%id, ': the equilibrium on the mesh of ', & + stability_from_ne, ' elements (refined from the deck mesh of ', SIZE(l0), ') failed the stability '// & + 'test with elements longer than half the bending length; stable on the refined mesh of ', SIZE(l0_am), & + ' elements' + END IF + CALL report_note(note_text) + END IF IF (kink_refined .AND. primary_done) THEN WRITE (note_text, '(A,I0,A,I0,A,I0,A)') 'line ', ln%id, ': the deck mesh (', SIZE(l0), & ' elements) could not resolve the curvature of the equilibrium; refined to ', SIZE(l0_am), ' elements' @@ -2616,6 +2671,8 @@ RECURSIVE SUBROUTINE build_one_hermite_cable(ln, sections, types, points, opts, ', xi=', diag%axial_strain_min_xi, ', strain=', diag%axial_strain_min CALL fail_solve(ErrStat, ErrMsg, TRIM(em)); RETURN END IF + ! A line with ATTACHMENTS is checked on its discrete equilibrium, after the attachment polish. + IF (.NOT. has_att) CALL handoff_lateral_note(l0, l0_am, ea_am, ei_am, w_am, w_am, diam, dry_b, fixed_am, .FALSE.) ! Build the coarse Morison arrays, then map every per-element quantity onto the ! refined reference-arc mesh. This covers both global refinement and the local ! axial-oscillation refinement used by tensile safety. Every child inherits the @@ -2668,6 +2725,10 @@ RECURSIVE SUBROUTINE build_one_hermite_cable(ln, sections, types, points, opts, contact_enabled, contact_z, frame_cs, endconn_k, endconn_d0_local, & endconn_mode, opts, static_tol, ErrStat, ErrMsg, bathymetry, cur_obj) IF (ErrStat /= CD_DECKDRV_OK) RETURN + ! On the final mesh, with the bare weights the polished state carries; the bending-length + ! rule of the note uses the smeared section weights w. + CALL handoff_lateral_note(l0, l0, ea, ei, w_bare, w, diam, opts%rhoW*opts%g*QUARTER_PI*diam**2, fixed_dofs, & + .TRUE.) w = w_bare WRITE (note_text, '(A,I0,A,I0,A,ES10.3,A)') 'line ', ln%id, ': ', SIZE(att_node), & ' attachment(s) lumped at the nearest nodes (largest arc offset ', att_offset, ' m)' @@ -2932,6 +2993,214 @@ SUBROUTINE bow_route(done, why) END IF END SUBROUTINE bow_route + SUBROUTINE stability_refined_route(done, why) + !! The catenary-continuation route repeated on the mesh that resolves the bending length, + !! refined from the mesh the route returned (the deck mesh, or a refinement of it that is + !! still too coarse), after that state failed the stability test (hermite_static_primary + !! with stability_refine). done is set with the audited, stable refined state in the *_am + !! outputs; otherwise why says what stopped it. + LOGICAL, INTENT(OUT) :: done + CHARACTER(*), INTENT(OUT) :: why + REAL(wp), ALLOCATABLE :: l0_s(:), ea_s(:), ei_s(:), w_s(:), diam_s(:), dry_s(:) + INTEGER, ALLOCATABLE :: fixed_s(:) + INTEGER :: es_r + CHARACTER(1024) :: em_r + LOGICAL :: inadm_r, walked_r, tol_r, kink_r + done = .FALSE. + why = '' + stability_from_ne = SIZE(l0_am) + ! The returned mesh is the input of the repetition, whose outputs overwrite the *_am arrays. + CALL MOVE_ALLOC(l0_am, l0_s) + CALL MOVE_ALLOC(ea_am, ea_s) + CALL MOVE_ALLOC(ei_am, ei_s) + CALL MOVE_ALLOC(w_am, w_s) + CALL MOVE_ALLOC(fixed_am, fixed_s) + diam_s = diam_on(l0, l0_s, diam) + dry_s = dry_b + IF (SIZE(l0_s) /= SIZE(l0)) CALL remap_elem_by_reference_arc(dry_s, l0, l0_s) + IF (PRESENT(bathymetry) .AND. .NOT. bathymetry_flat) THEN + CALL hermite_static_primary(anchor, fairlead, l0_s, ea_s, ei_s, w_s, diam_s, dry_s, fixed_s, & + contact_enabled, contact_z, frame_cs, endconn_k, endconn_d0_local, & + endconn_mode, opts, static_tol, l0_am, ea_am, ei_am, w_am, q_static, curv, & + fixed_am, applied_scale, diag, res, iters, es_r, em_r, inadm_r, tol_r, kink_r, & + bathymetry=bathymetry, cur_obj=cur_obj, walked=walked_r, stability_refine=.TRUE.) + ELSE + CALL hermite_static_primary(anchor, fairlead, l0_s, ea_s, ei_s, w_s, diam_s, dry_s, fixed_s, & + contact_enabled, contact_z, frame_cs, endconn_k, endconn_d0_local, & + endconn_mode, opts, static_tol, l0_am, ea_am, ei_am, w_am, q_static, curv, & + fixed_am, applied_scale, diag, res, iters, es_r, em_r, inadm_r, tol_r, kink_r, & + cur_obj=cur_obj, walked=walked_r, stability_refine=.TRUE.) + END IF + IF (es_r /= CD_HCSTAT_OK) THEN + why = em_r + RETURN + END IF + ! A walked refined state is not substituted for an unwalked one. + IF (walked_r) THEN + why = 'the refined route reached its state by walking the anchor' + RETURN + END IF + CALL audit_refined_state(done, why) + IF (done) tolerance_note = tol_r + END SUBROUTINE stability_refined_route + + SUBROUTINE sequenced_refined_polish(done, why) + !! The mesh-sequenced route's counterpart of stability_refined_route: its state, which + !! failed the stability test on a mesh longer than half the bending length, is carried to + !! the mesh that resolves that length by cubic-Hermite prolongation and polished there, as + !! the route's own refinement does, so the branch the sequencing selected is kept and the + !! fine mesh is never cold-started. done is set with the audited, stable refined state in + !! the *_am outputs; otherwise why says what stopped it. + LOGICAL, INTENT(OUT) :: done + CHARACTER(*), INTENT(OUT) :: why + REAL(wp), ALLOCATABLE :: l0_r(:), q_r(:), ea_r(:), ei_r(:), w_r(:), diam_r(:), dry_r(:) + INTEGER, ALLOCATABLE :: fixed_r(:) + INTEGER :: es_r, it_r, scale, k, parent, k_tol + REAL(wp) :: tol_r(3) + REAL(wp), PARAMETER :: CONTACT_FLOOR_TOL = 1.0e-5_wp + CHARACTER(1024) :: em_r + done = .FALSE. + why = '' + stability_from_ne = SIZE(l0_am) + scale = bending_refine_scale(l0_am, ei_am, w_am) + IF (scale < 2) RETURN + CALL CD_HermiteCable_Refine_Mesh(l0_am, q_static, fixed_am, scale, l0_r, q_r, fixed_r, es_r, em_r, & + inherit_dofs=[2, 5]) + IF (es_r /= CD_HCSTAT_OK) THEN + why = em_r + RETURN + END IF + ALLOCATE (ea_r(SIZE(l0_r)), ei_r(SIZE(l0_r)), w_r(SIZE(l0_r))) + DO k = 1, SIZE(l0_r) + parent = (k - 1)/scale + 1 + ea_r(k) = ea_am(parent) + ei_r(k) = ei_am(parent) + w_r(k) = w_am(parent) + END DO + diam_r = diam_on(l0, l0_r, diam) + dry_r = dry_b + CALL remap_elem_by_reference_arc(dry_r, l0, l0_r) + ! The tolerance ladder of the routes (the tight target, the coupled static tolerance, the + ! contact floor): the state refined here may have been accepted only at one of the + ! relaxed tolerances, which the refined polish must be allowed to reach as well. + tol_r = [static_tol, MAX(static_tol, COUPLED_STATIC_TOL), & + MERGE(MAX(static_tol, CONTACT_FLOOR_TOL), CD_ZERO, contact_enabled)] + DO k_tol = 1, 3 + IF (k_tol > 1) THEN + IF (.NOT. (tol_r(k_tol) > MAXVAL(tol_r(1:k_tol - 1)))) CYCLE + IF (INDEX(em_r, 'Newton did not converge') == 0) EXIT + END IF + IF (ALLOCATED(l0_am)) DEALLOCATE (l0_am) + IF (ALLOCATED(ea_am)) DEALLOCATE (ea_am) + IF (ALLOCATED(ei_am)) DEALLOCATE (ei_am) + IF (ALLOCATED(w_am)) DEALLOCATE (w_am) + IF (ALLOCATED(q_static)) DEALLOCATE (q_static) + IF (ALLOCATED(curv)) DEALLOCATE (curv) + IF (ALLOCATED(fixed_am)) DEALLOCATE (fixed_am) + IF (PRESENT(bathymetry) .AND. .NOT. bathymetry_flat) THEN + CALL CD_HermiteCable_Static_Solve_AutoMesh(l0_r, ea_r, ei_r, w_r, q_r, fixed_r, contact_z, CD_ZERO, & + 8, 80, tol_r(k_tol), 0.7_wp, CD_HC_HKAPPA_TARGET, CD_ZERO, & + CD_HC_REFINE_CAP, [2, 5], l0_am, ea_am, ei_am, w_am, & + q_static, curv, fixed_am, applied_scale, diag, res, it_r, & + es_r, em_r, contact_diameter=diam_r, contact_kbot=opts%kbot, & + bathymetry=bathymetry, contact_frame_cs=frame_cs, & + initial_polish=.TRUE., require_resolved=opts%adaptive_mesh, & + axial_quadrature_order=opts%axial_quadrature_order, & + bending_quadrature_order=opts%bending_quadrature_order, & + require_tensile=tensile_error, & + compression_mode=CD_HC_COMPRESSION_STRICT, & + refine_non_axial=opts%adaptive_mesh, & + endconn_stiffness=endconn_k, endconn_direction=endconn_d0_local, & + endconn_mode=endconn_mode, waterline_z=CD_ZERO, & + dry_buoyancy=dry_r, water_weight=opts%rhoW*opts%g, current=cur_obj) + ELSE IF (contact_enabled) THEN + CALL CD_HermiteCable_Static_Solve_AutoMesh(l0_r, ea_r, ei_r, w_r, q_r, fixed_r, contact_z, CD_ZERO, & + 8, 80, tol_r(k_tol), 0.7_wp, CD_HC_HKAPPA_TARGET, CD_ZERO, & + CD_HC_REFINE_CAP, [2, 5], l0_am, ea_am, ei_am, w_am, & + q_static, curv, fixed_am, applied_scale, diag, res, it_r, & + es_r, em_r, contact_diameter=diam_r, contact_kbot=opts%kbot, & + contact_frame_cs=frame_cs, & + initial_polish=.TRUE., require_resolved=opts%adaptive_mesh, & + axial_quadrature_order=opts%axial_quadrature_order, & + bending_quadrature_order=opts%bending_quadrature_order, & + require_tensile=tensile_error, & + compression_mode=CD_HC_COMPRESSION_STRICT, & + refine_non_axial=opts%adaptive_mesh, & + endconn_stiffness=endconn_k, endconn_direction=endconn_d0_local, & + endconn_mode=endconn_mode, waterline_z=CD_ZERO, & + dry_buoyancy=dry_r, water_weight=opts%rhoW*opts%g, current=cur_obj) + ELSE + CALL CD_HermiteCable_Static_Solve_AutoMesh(l0_r, ea_r, ei_r, w_r, q_r, fixed_r, contact_z, CD_ZERO, & + 8, 80, tol_r(k_tol), 0.7_wp, CD_HC_HKAPPA_TARGET, CD_ZERO, & + CD_HC_REFINE_CAP, [2, 5], l0_am, ea_am, ei_am, w_am, & + q_static, curv, fixed_am, applied_scale, diag, res, it_r, & + es_r, em_r, & + initial_polish=.TRUE., require_resolved=opts%adaptive_mesh, & + axial_quadrature_order=opts%axial_quadrature_order, & + bending_quadrature_order=opts%bending_quadrature_order, & + require_tensile=tensile_error, & + compression_mode=CD_HC_COMPRESSION_STRICT, & + refine_non_axial=opts%adaptive_mesh, & + endconn_stiffness=endconn_k, endconn_direction=endconn_d0_local, & + endconn_mode=endconn_mode, waterline_z=CD_ZERO, & + dry_buoyancy=dry_r, water_weight=opts%rhoW*opts%g, current=cur_obj) + END IF + iters = iters + it_r + IF (es_r == CD_HCSTAT_OK) THEN + ! reported whenever the accepted tolerance is above the target, also when the outer + ! tolerance had already been relaxed before this polish + IF (tol_r(k_tol) > static_tol_target) tolerance_note = .TRUE. + EXIT + END IF + END DO + IF (es_r /= CD_HCSTAT_OK) THEN + WRITE (why, '(A,I0,A)') 'on the ', scale, 'x refined mesh: ' + why = TRIM(why)//' '//TRIM(em_r) + RETURN + END IF + CALL audit_refined_state(done, why) + END SUBROUTINE sequenced_refined_polish + + SUBROUTINE audit_refined_state(done, why) + !! The audit of a state refined after a failed stability test (stability_refined_route, + !! sequenced_refined_polish): the physical-branch audit and the stability test of the + !! routes, on the refined mesh. Sets stability_refined when both pass. + LOGICAL, INTENT(OUT) :: done + CHARACTER(*), INTENT(OUT) :: why + INTEGER :: es_r + CHARACTER(1024) :: em_r + LOGICAL :: stable_r + CALL audit_hermite_static(l0_am, q_static, ea_am, ei_am, w_am, diam_on(l0, l0_am, diam), endconn_mode, & + done, why, compression_note) + IF (.NOT. done) THEN + why = 'on the refined mesh: '//TRIM(why) + compression_note = '' + RETURN + END IF + IF (PRESENT(bathymetry) .AND. .NOT. bathymetry_flat) THEN + CALL hermite_static_stable(l0, l0_am, ea_am, ei_am, w_am, diam, dry_b, q_static, fixed_am, & + contact_enabled, contact_z, frame_cs, endconn_k, endconn_d0_local, & + endconn_mode, opts, stable_r, es_r, em_r, bathymetry=bathymetry, cur_obj=cur_obj) + ELSE + CALL hermite_static_stable(l0, l0_am, ea_am, ei_am, w_am, diam, dry_b, q_static, fixed_am, & + contact_enabled, contact_z, frame_cs, endconn_k, endconn_d0_local, & + endconn_mode, opts, stable_r, es_r, em_r, cur_obj=cur_obj) + END IF + IF (es_r /= CD_DECKDRV_OK) THEN + done = .FALSE. + why = em_r + ELSE IF (.NOT. stable_r) THEN + done = .FALSE. + WRITE (why, '(A,I0,A)') 'still unstable on the refined mesh of ', SIZE(l0_am), ' elements' + END IF + IF (done) THEN + stability_refined = .TRUE. + why = '' + ELSE + compression_note = '' + END IF + END SUBROUTINE audit_refined_state + SUBROUTINE still_water_compression(text) !! On a failed solve in a current: whether the same line without the current is !! already in axial compression (an element-mean force below -1e-3 of the peak @@ -3003,6 +3272,54 @@ LOGICAL FUNCTION symmetric_current_retry() RESULT(retry) retry = .TRUE. END FUNCTION symmetric_current_retry + SUBROUTINE saddle_refined_retry() + !! A planar state in an in-plane current that is a saddle out of its plane on a mesh + !! longer than half the bending length: polished on the refined mesh that resolves that + !! length (sequenced_refined_polish, which audits it with the planar constraints) and + !! kept when it is no saddle there; otherwise the coarse state and its notes are restored. + REAL(wp), ALLOCATABLE :: l0_c(:), ea_c(:), ei_c(:), w_c(:), q_c(:), curv_c(:) + INTEGER, ALLOCATABLE :: fixed_c(:) + TYPE(CD_HermiteResolutionType) :: diag_c + REAL(wp) :: res_c + INTEGER :: scale_c, ne_c + LOGICAL :: stab_c, done_r + CHARACTER(320) :: note_c + CHARACTER(1024) :: why_r + LOGICAL :: tol_c + l0_c = l0_am + ea_c = ea_am + ei_c = ei_am + w_c = w_am + q_c = q_static + curv_c = curv + fixed_c = fixed_am + diag_c = diag + res_c = res + scale_c = applied_scale + ne_c = stability_from_ne + stab_c = stability_refined + note_c = compression_note + tol_c = tolerance_note + CALL sequenced_refined_polish(done_r, why_r) + IF (done_r) THEN + IF (.NOT. planar_current_saddle()) RETURN + END IF + CALL MOVE_ALLOC(l0_c, l0_am) + CALL MOVE_ALLOC(ea_c, ea_am) + CALL MOVE_ALLOC(ei_c, ei_am) + CALL MOVE_ALLOC(w_c, w_am) + CALL MOVE_ALLOC(q_c, q_static) + CALL MOVE_ALLOC(curv_c, curv) + CALL MOVE_ALLOC(fixed_c, fixed_am) + diag = diag_c + res = res_c + applied_scale = scale_c + stability_from_ne = ne_c + stability_refined = stab_c + compression_note = note_c + tolerance_note = tol_c + END SUBROUTINE saddle_refined_retry + SUBROUTINE symmetric_current_polish(done) !! Pass 3 solved the line under the perturbed current: restore the exact current and !! polish from that state on its mesh, then audit it again. As on the @@ -3095,7 +3412,14 @@ SUBROUTINE symmetric_current_polish(done) CALL hermite_static_stable(l0, l0_am, ea_am, ei_am, w_am, diam, dry_b, q_static, fixed_am, & contact_enabled, contact_z, frame_cs, endconn_k, endconn_d0_local, & endconn_mode, opts, done, es_s, em_s, cur_obj=cur_obj) - IF (es_s /= CD_DECKDRV_OK) done = .FALSE. + IF (es_s /= CD_DECKDRV_OK) THEN + done = .FALSE. + RETURN + END IF + ! A polished 3D state that fails the stability test on a mesh longer than half the + ! bending length is carried to the mesh that resolves that length and polished there, + ! as the mesh-sequenced route's state is, before the planar saddle is fallen back on. + IF (.NOT. done) CALL sequenced_refined_polish(done, em_s) END SUBROUTINE symmetric_current_polish LOGICAL FUNCTION in_plane_current() RESULT(ok) @@ -3130,6 +3454,117 @@ LOGICAL FUNCTION planar_current_saddle() RESULT(saddle) saddle = es_p == CD_DECKDRV_OK .AND. .NOT. stable_3d END FUNCTION planar_current_saddle + SUBROUTINE handoff_lateral_note(l0_ref, l0_n, ea_n, ei_n, w_n, w_rule, diam_ref, dry_ref, fixed_n, after_polish) + !! A diagnostic of the hand-off, never a change of state: a static state solved in the + !! vertical plane of the line (out-of-plane DOFs held) starts dynamics in which only the + !! end positions are held. On elements longer than half the bending length the axial + !! force at Gauss points near touchdown or a section change oscillates into compression, + !! which can make that state unstable out of its plane (a line solved in 3D is refined + !! instead, see stability_refined_route). One stability test with the dynamic + !! constraints, a single tangent assembly and banded factorisation, names it in a note. + !! A test that cannot be evaluated prints nothing. Not run where another check covers + !! it: an in-plane current (planar_current_saddle) and a coarse pass of that current. + !! after_polish: the state is the discrete equilibrium of an attachment polish, which + !! no other stability test has seen (planar_current_saddle and the 3D audit run on the + !! smeared state), so neither an in-plane current nor a line solved in 3D skips it; a + !! line solved in 3D is tested with the same end constraints. The lumped attachment drag, + !! a fixed-point load of the polish, is not part of the tangent. The arrays describe the + !! state q_static is checked on: the final mesh l0_n with its + !! element properties and weights w_n (the bare weights after an attachment polish, + !! whose lumped nodal loads are dead loads and leave the tangent unchanged), diam_ref + !! and dry_ref on the mesh l0_ref, and the static constraints fixed_n. The bending-length + !! rule of the note uses the section weights w_rule (smeared over the attachments). + REAL(wp), INTENT(IN) :: l0_ref(:), l0_n(:), ea_n(:), ei_n(:), w_n(:), w_rule(:), diam_ref(:), dry_ref(:) + INTEGER, INTENT(IN) :: fixed_n(:) + LOGICAL, INTENT(IN) :: after_polish + ! Largest factor the note names (a bending length below 1e-6 of the element length is + ! named as at least this factor). + INTEGER, PARAMETER :: SCALE_NOTE_MAX = 2**20 + INTEGER, ALLOCATABLE :: fixed_3d(:) + INTEGER :: nd, es_h, k, scale_h + LOGICAL :: stable_h + REAL(wp) :: h_max, rule, need_h, ratio_h + CHARACTER(160) :: fix_h + CHARACTER(1024) :: em_h + CHARACTER(600) :: text_h + CHARACTER(160) :: state_h, tail_h + CHARACTER(9) :: at_least_h + LOGICAL :: solved_3d + IF (saddle_kept) RETURN + IF (.NOT. after_polish .AND. (require_3d_static .OR. in_plane_current())) RETURN + IF (PRESENT(coarse_pass)) THEN + IF (coarse_pass) RETURN + END IF + IF (.NOT. ALLOCATED(q_static)) RETURN + ! Only the end translations held: the state was solved in 3D (require_3d_static, or a + ! symmetry-broken retry of a planar saddle), which the static audit covered before an + ! attachment polish but not after it. + solved_3d = require_3d_static .OR. SIZE(fixed_n) <= 6 + IF (solved_3d .AND. .NOT. after_polish) RETURN + IF (solved_3d) THEN + state_h = 'its discrete attachment equilibrium, which is unstable' + tail_h = 'a disturbance can move the line away from it' + ELSE + state_h = 'a static state solved in its vertical plane that is unstable out of that plane' + tail_h = 'a lateral disturbance can move the line out of the plane' + END IF + nd = SIZE(q_static) + fixed_3d = [1, 2, 3, nd - 5, nd - 4, nd - 3] + IF (PRESENT(bathymetry) .AND. .NOT. bathymetry_flat) THEN + CALL hermite_static_stable(l0_ref, l0_n, ea_n, ei_n, w_n, diam_ref, dry_ref, q_static, fixed_3d, & + contact_enabled, contact_z, frame_cs, endconn_k, endconn_d0_local, & + endconn_mode, opts, stable_h, es_h, em_h, bathymetry=bathymetry, cur_obj=cur_obj) + ELSE + CALL hermite_static_stable(l0_ref, l0_n, ea_n, ei_n, w_n, diam_ref, dry_ref, q_static, fixed_3d, & + contact_enabled, contact_z, frame_cs, endconn_k, endconn_d0_local, & + endconn_mode, opts, stable_h, es_h, em_h, cur_obj=cur_obj) + END IF + IF (es_h /= CD_DECKDRV_OK .OR. stable_h) RETURN + ! The advice names the uncapped power of two that meets the rule (the automatic + ! refinement is capped, the deck mesh is not). + need_h = bending_refine_need(l0_n, ei_n, w_rule) + scale_h = 1 + DO WHILE (REAL(scale_h, wp) < need_h .AND. scale_h < SCALE_NOTE_MAX) + scale_h = 2*scale_h + END DO + at_least_h = '' + IF (REAL(scale_h, wp) < need_h) at_least_h = 'at least' + IF (need_h > CD_ONE) THEN + ! The coarsest element against its own half bending length (the element of the + ! largest ratio, which sets need_h). + h_max = CD_ZERO + rule = HUGE(CD_ONE) + ratio_h = CD_ZERO + DO k = 1, SIZE(l0_n) + IF (ei_n(k) > CD_ZERO .AND. ABS(w_rule(k)) > CD_ZERO) THEN + IF (l0_n(k)/(0.5_wp*(ei_n(k)/ABS(w_rule(k)))**(CD_ONE/3.0_wp)) > ratio_h) THEN + rule = 0.5_wp*(ei_n(k)/ABS(w_rule(k)))**(CD_ONE/3.0_wp) + h_max = l0_n(k) + ratio_h = h_max/rule + END IF + END IF + END DO + ! AutoMesh refines by its own criteria, which need not meet the bending length: a run + ! that already sets adaptive_mesh is told to refine the deck mesh. + IF (opts%adaptive_mesh) THEN + fix_h = 'x meets that length; adaptive_mesh True did not)' + ELSE + fix_h = 'x meets that length) or set adaptive_mesh True (a line restrained in torsion is '// & + 'refined automatically)' + END IF + WRITE (text_h, '(A,I0,A,I0,A,F0.2,A,F0.2,A,I0,A)', IOSTAT=k) 'line ', ln%id, & + ' starts the dynamics from '//TRIM(state_h)//' on its mesh of ', SIZE(l0_n), & + ' elements, the coarsest ', h_max, ' m long where half the bending length (EI/|w|)^(1/3) is ', rule, & + ' m; refine the deck mesh ('//TRIM(at_least_h)//REPEAT(' ', MIN(1, LEN_TRIM(at_least_h))), scale_h, & + TRIM(fix_h) + ELSE + WRITE (text_h, '(A,I0,A,I0,A)', IOSTAT=k) 'line ', ln%id, & + ' starts the dynamics from '//TRIM(state_h)//' on its mesh of ', SIZE(l0_n), & + ' elements, which resolves the bending length; '//TRIM(tail_h) + END IF + CALL report_note(text_h) + END SUBROUTINE handoff_lateral_note + LOGICAL FUNCTION coarse_current_eligible() RESULT(ok) !! coarse_current_first applies to an in-plane current (in_plane_current) without !! seabed friction or attachments, on a deck build that is not itself the coarse one, @@ -3621,12 +4056,43 @@ SUBROUTINE attachment_static_drag(q, node, att, opts, frame_cs, f, ErrStat, ErrM END DO END SUBROUTINE attachment_static_drag + 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 + !! at most half its bending length (EI/|w|)^(1/3); 1 when the mesh already meets it or the + !! caps allow no doubling. The resolution rule of the refined repetition of the static route + !! and of the stability retry. A capped factor can fall short of the rule: whether the mesh + !! meets it is bending_refine_need(...) <= 1. + REAL(wp), INTENT(IN) :: l0(:), ei(:), w(:) + ! Element cap of a refined repetition of the static route. + INTEGER, PARAMETER :: REFINED_MAX_ELEMENTS = 4096 + REAL(wp) :: need + need = bending_refine_need(l0, ei, w) + scale = 1 + DO WHILE (REAL(scale, wp) < need .AND. scale < CD_HC_REFINE_CAP .AND. SIZE(l0)*2*scale <= REFINED_MAX_ELEMENTS) + scale = 2*scale + END DO + END FUNCTION bending_refine_scale + + PURE REAL(wp) FUNCTION bending_refine_need(l0, ei, w) RESULT(need) + !! The uncapped refinement a finite-EI mesh needs for every element to be at most half its + !! bending length (EI/|w|)^(1/3): the largest ratio of element length to that length, at + !! least 1 (1 when the mesh meets the rule). + REAL(wp), INTENT(IN) :: l0(:), ei(:), w(:) + INTEGER :: k + need = CD_ONE + DO k = 1, SIZE(l0) + IF (ei(k) > CD_ZERO .AND. ABS(w(k)) > CD_ZERO) & + need = MAX(need, l0(k)/(0.5_wp*(ei(k)/ABS(w(k)))**(CD_ONE/3.0_wp))) + END DO + END FUNCTION bending_refine_need + RECURSIVE SUBROUTINE hermite_static_primary(anchor, fairlead, l0, ea, ei, w, diam, dry_b, fixed_dofs, & contact_enabled, contact_z, frame_cs, endconn_k, endconn_d0, & endconn_mode, opts, static_tol, l0_am, ea_am, ei_am, w_am, q_static, & curv, fixed_am, applied_scale, diag, res, iters, ErrStat, ErrMsg, & inadmissible, tolerance_note, kink_refined, bathymetry, refined_pass, & - cur_obj, walked, fold_walk) + cur_obj, walked, fold_walk, stability_refine) !! Primary finite-EI static route of a deck cable (the OrcaFlex/MoorPy practice of !! "catenary statics, then full statics"): !! @@ -3663,6 +4129,15 @@ RECURSIVE SUBROUTINE hermite_static_primary(anchor, fairlead, l0, ea, ei, w, dia !! refined-mesh polish of its (unresolved) solution: the whole route is then repeated !! once on a uniformly refined mesh whose elements are at most half the local bending !! length (refined_pass marks that repetition), which also sets kink_refined. + !! stability_refine (optional): run that refined repetition directly, refined from l0. The + !! caller passes it, with l0 the mesh the route returned (the deck mesh or a refinement of + !! it), when the equilibrium on that mesh failed the stability test: the pointwise axial + !! resultant of a stiff-EA element longer than half the bending length oscillates about + !! its element mean, and its compressed Gauss points lower the geometric stiffness of the + !! transverse DOFs, so an under-resolved touchdown or section change can read as a saddle. + !! A physical instability persists on the refined mesh; this artefact does not. ErrStat + !! is CD_HCSTAT_NOCONVERGE when l0 already resolves the bending length or the + !! refined route fails (ErrMsg says which). REAL(wp), INTENT(IN) :: anchor(3), fairlead(3), l0(:), ea(:), ei(:), w(:), diam(:), dry_b(:) INTEGER, INTENT(IN) :: fixed_dofs(:) LOGICAL, INTENT(IN) :: contact_enabled @@ -3685,6 +4160,8 @@ RECURSIVE SUBROUTINE hermite_static_primary(anchor, fairlead, l0, ea, ei, w, dia LOGICAL, INTENT(OUT), OPTIONAL :: walked ! Trace the bow behind the fairlead (see fold_walk above). LOGICAL, INTENT(IN), OPTIONAL :: fold_walk + ! Go straight to the refined repetition (see stability_refine above). + LOGICAL, INTENT(IN), OPTIONAL :: stability_refine ! Static tolerance of the coupled route; the floor accepted when the tighter ! dynamic-consistent tolerance is below the attainable residual. @@ -3698,8 +4175,6 @@ RECURSIVE SUBROUTINE hermite_static_primary(anchor, fairlead, l0, ea, ei, w, dia ! Continuation floor on a mesh finer than sqrt(EI/EA) (see budget_cont). INTEGER, PARAMETER :: FINE_MIN_ITERATIONS = 20 INTEGER, PARAMETER :: NFIT = 33 - ! Element cap of the refined repetition of the route. - INTEGER, PARAMETER :: REFINED_MAX_ELEMENTS = 4096 INTEGER :: nnode, ne, i, es, cont_iters, polish_iters, budget_cont, cmode, k_walk ! Anchor retreats tried for a line too long for its span (see seed_walk). INTEGER, PARAMETER :: WALK_MAX_TRIES = 6 @@ -3728,6 +4203,17 @@ RECURSIVE SUBROUTINE hermite_static_primary(anchor, fairlead, l0, ea, ei, w, dia res = CD_ZERO ne = SIZE(l0) nnode = ne + 1 + IF (PRESENT(stability_refine)) THEN + IF (stability_refine) THEN + ! refined_restart sets ErrStat only on success and appends why a refined mesh failed. + ErrStat = CD_HCSTAT_NOCONVERGE + ErrMsg = 'unstable on the returned mesh' + CALL refined_restart() + IF (ErrStat /= CD_HCSTAT_OK .AND. TRIM(ErrMsg) == 'unstable on the returned mesh') & + ErrMsg = 'unstable on the returned mesh, which already resolves the bending length' + RETURN + END IF + END IF origin = CD_ZERO IF (.NOT. PRESENT(bathymetry)) origin = anchor(1:2) @@ -4422,21 +4908,11 @@ RECURSIVE SUBROUTINE refined_restart() !! refined equilibrium is returned in the *_am outputs like an adaptive refinement. REAL(wp), ALLOCATABLE :: l0_r(:), q_r(:), q_ref_r(:), ea_r(:), ei_r(:), w_r(:), diam_r(:), dry_r(:) INTEGER, ALLOCATABLE :: fixed_r(:) - REAL(wp) :: need INTEGER :: scale, scale_need, k, es_r, parent CHARACTER(512) :: em_r LOGICAL :: inadm_r, walked_sub IF (PRESENT(refined_pass) .OR. fold) RETURN - need = CD_ONE - DO k = 1, ne - IF (ei(k) > CD_ZERO .AND. ABS(w(k)) > CD_ZERO) & - need = MAX(need, l0(k)/(0.5_wp*(ei(k)/ABS(w(k)))**(CD_ONE/3.0_wp))) - END DO - scale_need = 1 - DO WHILE (REAL(scale_need, wp) < need .AND. scale_need < CD_HC_REFINE_CAP .AND. & - ne*2*scale_need <= REFINED_MAX_ELEMENTS) - scale_need = 2*scale_need - END DO + scale_need = bending_refine_scale(l0, ei, w) IF (scale_need < 2) RETURN ! The needed factor first; when its continuation exhausts its element-scaled iteration ! budget, the coarser powers of two down to 2x (a halved mesh, still resolving the diff --git a/tests/data/lazy_wave_touchdown_planar_coarse.dat b/tests/data/lazy_wave_touchdown_planar_coarse.dat new file mode 100644 index 00000000..79068b9c --- /dev/null +++ b/tests/data/lazy_wave_touchdown_planar_coarse.dat @@ -0,0 +1,44 @@ +--------------------- CableDyn Input File ------------------------------------ +Lazy-wave power cable free in torsion, deck mesh too coarse at touchdown +-- The cable of lazy_wave_touchdown_torsion_coarse.dat free in torsion, so its static solve runs in +-- the vertical plane of the line. On the coarse deck mesh (10 m elements along the grounded run, +-- half the bending length is 2.5 m) that planar state is unstable out of its plane, and the dynamics +-- would start from it with the line free to leave the plane: the driver names it in a note, once, +-- and solves the deck unchanged. +--------------------- LINE TYPES --------------------------------------------- +Name Diam Mass EA BA EI GAs GJ Irt Irn Cdn Cdt Can Cat +(-) (m) (kg/m) (N) (-) (Nm2) (N) (Nm2) (kgm) (kgm) (-) (-) (-) (-) +bare 0.16 36.70 4.69e8 0.0 1.99e4 1.0e8 1.5e4 1.0 1.0 1.2 0.1 1.0 0.0 +buoy 0.29 59.53 4.69e8 0.0 1.99e4 1.0e8 1.5e4 1.0 1.0 1.2 0.1 1.0 0.0 +--------------------- POINTS ------------------------------------------------- +ID Type X Y Z +(-) (-) (m) (m) (m) +7 Coupled 30.0 0.0 -20.0 +8 Fixed 500.0 0.0 -200.0 +--------------------- LINES -------------------------------------------------- +ID NodeA NodeB Outputs +(-) (-) (-) (-) +4 7 8 - +--------------------- SECTIONS ----------------------------------------------- +LineID LineType Length NumSegs +(-) (-) (m) (-) +4 bare 80.0 20 +4 buoy 100.0 25 +4 bare 420.0 42 +--------------------- END CONNECTIONS ---------------------------------------- +LineID End Stiffness EzX EzY EzZ TorsStiffness NxX NxY NxZ Pretwist +(-) (-) (N-m/rad) (-) (-) (-) (N-m/rad) (-) (-) (-) (deg) +4 A Rigid 0.1058 0 -0.9944 Free 0 1 0 0 +4 B Rigid 1 0 0 Free 0 1 0 0 +--------------------- OPTIONS ------------------------------------------------ +9.80665 g +1025.0 rhoW +3.0e6 kBot +3.0e5 cBot +0.35 frictionMu +200.0 WtrDpth +0.025 dtM +0.0 TMax +--------------------- OUTPUTS ------------------------------------------------ +FairTen4 +--------------------- END ---------------------------------------------------- diff --git a/tests/data/lazy_wave_touchdown_planar_coarse_att.dat b/tests/data/lazy_wave_touchdown_planar_coarse_att.dat new file mode 100644 index 00000000..1330ddce --- /dev/null +++ b/tests/data/lazy_wave_touchdown_planar_coarse_att.dat @@ -0,0 +1,48 @@ +--------------------- CableDyn Input File ------------------------------------ +Lazy-wave power cable with discrete buoyancy modules, deck mesh too coarse at touchdown +-- The cable of lazy_wave_touchdown_planar_coarse.dat with its 100 m buoyant stretch built from the +-- bare cable plus 25 discrete buoyancy modules at a 4 m pitch, one on each node from 80 m to 176 m +-- (each carries the extra mass and displaced volume of 4 m of the buoy section). Its static solve +-- runs in the vertical plane of the line and ends with the attachment polish. On the coarse deck +-- mesh (10 m elements along the grounded run) the discrete planar state is unstable out of its +-- plane: the driver names it in a note, once, after the polish, and solves the deck unchanged. +--------------------- LINE TYPES --------------------------------------------- +Name Diam Mass EA BA EI GAs GJ Irt Irn Cdn Cdt Can Cat +(-) (m) (kg/m) (N) (-) (Nm2) (N) (Nm2) (kgm) (kgm) (-) (-) (-) (-) +bare 0.16 36.70 4.69e8 0.0 1.99e4 1.0e8 1.5e4 1.0 1.0 1.2 0.1 1.0 0.0 +--------------------- POINTS ------------------------------------------------- +ID Type X Y Z +(-) (-) (m) (m) (m) +7 Coupled 30.0 0.0 -20.0 +8 Fixed 500.0 0.0 -200.0 +--------------------- LINES -------------------------------------------------- +ID NodeA NodeB Outputs +(-) (-) (-) (-) +4 7 8 - +--------------------- SECTIONS ----------------------------------------------- +LineID LineType Length NumSegs +(-) (-) (m) (-) +4 bare 80.0 20 +4 bare 100.0 25 +4 bare 420.0 42 +--------------------- ATTACHMENTS ------------------------------------------- +LineID ArcLength Mass Volume CdA Ca CdAx +(-) (m) (kg) (m^3) (m^2) (-) (m^2) +4 80.0:4.0:176.0 91.32 0.18378 1.392 1.0 0.0 +--------------------- END CONNECTIONS ---------------------------------------- +LineID End Stiffness EzX EzY EzZ TorsStiffness NxX NxY NxZ Pretwist +(-) (-) (N-m/rad) (-) (-) (-) (N-m/rad) (-) (-) (-) (deg) +4 A Rigid 0.1058 0 -0.9944 Free 0 1 0 0 +4 B Rigid 1 0 0 Free 0 1 0 0 +--------------------- OPTIONS ------------------------------------------------ +9.80665 g +1025.0 rhoW +3.0e6 kBot +3.0e5 cBot +0.35 frictionMu +200.0 WtrDpth +0.025 dtM +0.0 TMax +--------------------- OUTPUTS ------------------------------------------------ +FairTen4 +--------------------- END ---------------------------------------------------- diff --git a/tests/data/lazy_wave_touchdown_planar_refined.dat b/tests/data/lazy_wave_touchdown_planar_refined.dat new file mode 100644 index 00000000..c7007f0f --- /dev/null +++ b/tests/data/lazy_wave_touchdown_planar_refined.dat @@ -0,0 +1,41 @@ +--------------------- CableDyn Input File ------------------------------------ +Lazy-wave power cable free in torsion, mesh resolving the bending length +-- lazy_wave_touchdown_planar_coarse.dat with every element at most 2.5 m, half the bending +-- length of the bare cable: the planar state is stable out of its plane and no note is printed. +--------------------- LINE TYPES --------------------------------------------- +Name Diam Mass EA BA EI GAs GJ Irt Irn Cdn Cdt Can Cat +(-) (m) (kg/m) (N) (-) (Nm2) (N) (Nm2) (kgm) (kgm) (-) (-) (-) (-) +bare 0.16 36.70 4.69e8 0.0 1.99e4 1.0e8 1.5e4 1.0 1.0 1.2 0.1 1.0 0.0 +buoy 0.29 59.53 4.69e8 0.0 1.99e4 1.0e8 1.5e4 1.0 1.0 1.2 0.1 1.0 0.0 +--------------------- POINTS ------------------------------------------------- +ID Type X Y Z +(-) (-) (m) (m) (m) +7 Coupled 30.0 0.0 -20.0 +8 Fixed 500.0 0.0 -200.0 +--------------------- LINES -------------------------------------------------- +ID NodeA NodeB Outputs +(-) (-) (-) (-) +4 7 8 - +--------------------- SECTIONS ----------------------------------------------- +LineID LineType Length NumSegs +(-) (-) (m) (-) +4 bare 80.0 40 +4 buoy 100.0 50 +4 bare 420.0 168 +--------------------- END CONNECTIONS ---------------------------------------- +LineID End Stiffness EzX EzY EzZ TorsStiffness NxX NxY NxZ Pretwist +(-) (-) (N-m/rad) (-) (-) (-) (N-m/rad) (-) (-) (-) (deg) +4 A Rigid 0.1058 0 -0.9944 Free 0 1 0 0 +4 B Rigid 1 0 0 Free 0 1 0 0 +--------------------- OPTIONS ------------------------------------------------ +9.80665 g +1025.0 rhoW +3.0e6 kBot +3.0e5 cBot +0.35 frictionMu +200.0 WtrDpth +0.025 dtM +0.0 TMax +--------------------- OUTPUTS ------------------------------------------------ +FairTen4 +--------------------- END ---------------------------------------------------- diff --git a/tests/data/lazy_wave_touchdown_planar_refined_att.dat b/tests/data/lazy_wave_touchdown_planar_refined_att.dat new file mode 100644 index 00000000..062bb095 --- /dev/null +++ b/tests/data/lazy_wave_touchdown_planar_refined_att.dat @@ -0,0 +1,45 @@ +--------------------- CableDyn Input File ------------------------------------ +Lazy-wave power cable with discrete buoyancy modules, mesh resolving the bending length +-- The cable of lazy_wave_touchdown_planar_coarse_att.dat (25 discrete buoyancy modules at a 4 m +-- pitch) on 2 m, 2 m and 2.5 m elements, each at most half the bending length: its discrete planar +-- state is stable out of its plane and the hand-off prints no note. +--------------------- LINE TYPES --------------------------------------------- +Name Diam Mass EA BA EI GAs GJ Irt Irn Cdn Cdt Can Cat +(-) (m) (kg/m) (N) (-) (Nm2) (N) (Nm2) (kgm) (kgm) (-) (-) (-) (-) +bare 0.16 36.70 4.69e8 0.0 1.99e4 1.0e8 1.5e4 1.0 1.0 1.2 0.1 1.0 0.0 +--------------------- POINTS ------------------------------------------------- +ID Type X Y Z +(-) (-) (m) (m) (m) +7 Coupled 30.0 0.0 -20.0 +8 Fixed 500.0 0.0 -200.0 +--------------------- LINES -------------------------------------------------- +ID NodeA NodeB Outputs +(-) (-) (-) (-) +4 7 8 - +--------------------- SECTIONS ----------------------------------------------- +LineID LineType Length NumSegs +(-) (-) (m) (-) +4 bare 80.0 40 +4 bare 100.0 50 +4 bare 420.0 168 +--------------------- ATTACHMENTS ------------------------------------------- +LineID ArcLength Mass Volume CdA Ca CdAx +(-) (m) (kg) (m^3) (m^2) (-) (m^2) +4 80.0:4.0:176.0 91.32 0.18378 1.392 1.0 0.0 +--------------------- END CONNECTIONS ---------------------------------------- +LineID End Stiffness EzX EzY EzZ TorsStiffness NxX NxY NxZ Pretwist +(-) (-) (N-m/rad) (-) (-) (-) (N-m/rad) (-) (-) (-) (deg) +4 A Rigid 0.1058 0 -0.9944 Free 0 1 0 0 +4 B Rigid 1 0 0 Free 0 1 0 0 +--------------------- OPTIONS ------------------------------------------------ +9.80665 g +1025.0 rhoW +3.0e6 kBot +3.0e5 cBot +0.35 frictionMu +200.0 WtrDpth +0.025 dtM +0.0 TMax +--------------------- OUTPUTS ------------------------------------------------ +FairTen4 +--------------------- END ---------------------------------------------------- diff --git a/tests/data/lazy_wave_touchdown_torsion_coarse.dat b/tests/data/lazy_wave_touchdown_torsion_coarse.dat new file mode 100644 index 00000000..c20db89d --- /dev/null +++ b/tests/data/lazy_wave_touchdown_torsion_coarse.dat @@ -0,0 +1,47 @@ +--------------------- CableDyn Input File ------------------------------------ +Lazy-wave power cable restrained in torsion, deck mesh too coarse at touchdown +-- A finite-EI lazy-wave cable clamped at both ends and restrained in torsion (Rigid, zero +-- pretwist), so its static solve runs in 3D. The deck mesh is 4 m up to the end of the +-- buoyancy section and 10 m along the grounded run, longer than half the bending length +-- (EI/w)^(1/3) = 5.0 m of the bare cable. On that mesh the pointwise axial resultant of the +-- under-resolved touchdown elements oscillates into compression at Gauss points, and the +-- tangent of the stable equilibrium shows a spurious out-of-plane negative eigenvalue there. +-- The static solve repeats the route on the refined mesh, which is stable, and reports it once. +--------------------- LINE TYPES --------------------------------------------- +Name Diam Mass EA BA EI GAs GJ Irt Irn Cdn Cdt Can Cat +(-) (m) (kg/m) (N) (-) (Nm2) (N) (Nm2) (kgm) (kgm) (-) (-) (-) (-) +bare 0.16 36.70 4.69e8 0.0 1.99e4 1.0e8 1.5e4 1.0 1.0 1.2 0.1 1.0 0.0 +buoy 0.29 59.53 4.69e8 0.0 1.99e4 1.0e8 1.5e4 1.0 1.0 1.2 0.1 1.0 0.0 +--------------------- POINTS ------------------------------------------------- +ID Type X Y Z +(-) (-) (m) (m) (m) +7 Coupled 30.0 0.0 -20.0 +8 Fixed 500.0 0.0 -200.0 +--------------------- LINES -------------------------------------------------- +ID NodeA NodeB Outputs +(-) (-) (-) (-) +4 7 8 - +--------------------- SECTIONS ----------------------------------------------- +LineID LineType Length NumSegs +(-) (-) (m) (-) +4 bare 80.0 20 +4 buoy 100.0 25 +4 bare 420.0 42 +--------------------- END CONNECTIONS ---------------------------------------- +LineID End Stiffness EzX EzY EzZ TorsStiffness NxX NxY NxZ Pretwist +(-) (-) (N-m/rad) (-) (-) (-) (N-m/rad) (-) (-) (-) (deg) +4 A Rigid 0.1058 0 -0.9944 Rigid 0 1 0 0 +4 B Rigid 1 0 0 Rigid 0 1 0 0 +--------------------- OPTIONS ------------------------------------------------ +9.80665 g +1025.0 rhoW +3.0e6 kBot +3.0e5 cBot +0.35 frictionMu +200.0 WtrDpth +0.025 dtM +0.0 TMax +--------------------- OUTPUTS ------------------------------------------------ +FairTen4 +Torq4N1 +--------------------- END ---------------------------------------------------- diff --git a/tests/data/lazy_wave_touchdown_torsion_coarse_sequenced.dat b/tests/data/lazy_wave_touchdown_torsion_coarse_sequenced.dat new file mode 100644 index 00000000..abba9478 --- /dev/null +++ b/tests/data/lazy_wave_touchdown_torsion_coarse_sequenced.dat @@ -0,0 +1,44 @@ +--------------------- CableDyn Input File ------------------------------------ +Lazy-wave power cable restrained in torsion, deck mesh too coarse at touchdown +-- lazy_wave_touchdown_torsion_coarse.dat with the mesh-sequenced static route first +-- (OPTIONS cable_statics sequenced): its deck-mesh state fails the stability test the same way, +-- and is prolongated to the mesh that resolves the bending length and polished there. +--------------------- LINE TYPES --------------------------------------------- +Name Diam Mass EA BA EI GAs GJ Irt Irn Cdn Cdt Can Cat +(-) (m) (kg/m) (N) (-) (Nm2) (N) (Nm2) (kgm) (kgm) (-) (-) (-) (-) +bare 0.16 36.70 4.69e8 0.0 1.99e4 1.0e8 1.5e4 1.0 1.0 1.2 0.1 1.0 0.0 +buoy 0.29 59.53 4.69e8 0.0 1.99e4 1.0e8 1.5e4 1.0 1.0 1.2 0.1 1.0 0.0 +--------------------- POINTS ------------------------------------------------- +ID Type X Y Z +(-) (-) (m) (m) (m) +7 Coupled 30.0 0.0 -20.0 +8 Fixed 500.0 0.0 -200.0 +--------------------- LINES -------------------------------------------------- +ID NodeA NodeB Outputs +(-) (-) (-) (-) +4 7 8 - +--------------------- SECTIONS ----------------------------------------------- +LineID LineType Length NumSegs +(-) (-) (m) (-) +4 bare 80.0 20 +4 buoy 100.0 25 +4 bare 420.0 42 +--------------------- END CONNECTIONS ---------------------------------------- +LineID End Stiffness EzX EzY EzZ TorsStiffness NxX NxY NxZ Pretwist +(-) (-) (N-m/rad) (-) (-) (-) (N-m/rad) (-) (-) (-) (deg) +4 A Rigid 0.1058 0 -0.9944 Rigid 0 1 0 0 +4 B Rigid 1 0 0 Rigid 0 1 0 0 +--------------------- OPTIONS ------------------------------------------------ +9.80665 g +1025.0 rhoW +3.0e6 kBot +3.0e5 cBot +0.35 frictionMu +200.0 WtrDpth +0.025 dtM +0.0 TMax +sequenced cable_statics +--------------------- OUTPUTS ------------------------------------------------ +FairTen4 +Torq4N1 +--------------------- END ---------------------------------------------------- diff --git a/tests/data/lozon_coupled_harmonics.dat b/tests/data/lozon_coupled_harmonics.dat index 627d49d6..7d5738e2 100644 --- a/tests/data/lozon_coupled_harmonics.dat +++ b/tests/data/lozon_coupled_harmonics.dat @@ -1,5 +1,5 @@ # L4-1c hang-off harmonic table (cos convention: A cos(2 pi t/T + phase_deg)) -# source: CableDyn coupled OpenFAST run of the IEA-15-240-RWT UMaine mixed example (Main_mixed_600.out); +# source: CableDyn coupled OpenFAST run of the IEA-15-240-RWT UMaine mixed example, 87-element cable mesh (Main_mixed_600.out); # offset (30.0,-20.0); window 232.4s; period<=40s; capture 85.4% 16 4.131042 0.131826 # period_s surge_amp surge_phase_deg heave_amp heave_phase_deg diff --git a/tests/test_cable_statics_matrix.py b/tests/test_cable_statics_matrix.py index 7ebbb1b6..769be723 100644 --- a/tests/test_cable_statics_matrix.py +++ b/tests/test_cable_statics_matrix.py @@ -59,9 +59,13 @@ from pathlib import Path # The per-deck bound is on the solver's CPU time, which does not grow with machine load; the -# wall-clock limit only stops a hung process and is scaled far above any loaded-machine run. +# wall-clock limit only stops a hung process and is scaled far above any loaded-machine run: +# at least DECK_WALL_LIMIT and WALL_PER_CPU times the configuration's CPU bound (--cpu-limit), +# so a Debug build, whose CPU bound is ten times larger, is not stopped as hung while it is +# still inside that bound. DECK_CPU_LIMIT = 60.0 DECK_WALL_LIMIT = 600.0 +WALL_PER_CPU = 4.0 def _windows_cpu_seconds(handle) -> float: @@ -190,7 +194,7 @@ def self_intersects(xyz: list) -> bool: return False -def run_case(exe: str, root: Path, case: dict) -> dict: +def run_case(exe: str, root: Path, case: dict, wall_limit: float = DECK_WALL_LIMIT) -> dict: cdir = root / case["id"] cdir.mkdir(parents=True, exist_ok=True) if case.get("bathy"): @@ -201,7 +205,7 @@ def run_case(exe: str, root: Path, case: dict) -> dict: env.setdefault("OMP_NUM_THREADS", "1") t0 = time.time() rc, log, cpu = run_measured([exe, str(cdir / "deck.dat"), str(cdir / "out")], str(cdir), env, - DECK_WALL_LIMIT) + wall_limit) return {"id": case["id"], "rc": rc, "log": log, "time": time.time() - t0, "cpu": cpu, "dir": cdir} @@ -314,16 +318,17 @@ def main() -> int: cases = json.loads(Path(a.cases).read_text(encoding="utf-8")) root = Path(a.output) root.mkdir(parents=True, exist_ok=True) + wall_limit = max(DECK_WALL_LIMIT, WALL_PER_CPU * a.cpu_limit) t0 = time.time() with ThreadPoolExecutor(a.workers) as ex: - results = list(ex.map(lambda c: run_case(a.exe, root, c), cases)) + results = list(ex.map(lambda c: run_case(a.exe, root, c, wall_limit), cases)) byid = {r["id"]: r for r in results} failures = 0 for case in cases: res = byid[case["id"]] errs = check_case(case, res) if res["rc"] == "TIMEOUT": - errs.append("no exit within the %.0f s wall-clock hang guard" % DECK_WALL_LIMIT) + errs.append("no exit within the %.0f s wall-clock hang guard" % wall_limit) # a deck's own bound (a fast failure) scales with the configuration's bound elif not res["cpu"] <= case.get("cpu_limit", DECK_CPU_LIMIT) * a.cpu_limit / DECK_CPU_LIMIT: errs.append("CPU time %.1f s beyond the %.0f s per-deck bound" % ( diff --git a/tests/test_deck_hermite_cable.f90 b/tests/test_deck_hermite_cable.f90 index 8d6e6a7c..6ab57782 100644 --- a/tests/test_deck_hermite_cable.f90 +++ b/tests/test_deck_hermite_cable.f90 @@ -553,14 +553,14 @@ SUBROUTINE case_coupled_seabed_contact() END SUBROUTINE case_coupled_seabed_contact SUBROUTINE case_grounded_anchor_end() - !! A lazy-wave power cable laid on a frictional flat bed up to its pinned anchor on the - !! floor (Line 4 of examples/iea15mw_umaine_mixed_cabledyn.dat: 200 m depth, kBot 3e6, - !! frictionMu 0.35, 10 m grounded elements). The seabed carries the weight of the anchor + !! A lazy-wave power cable laid on a frictional flat bed up to its pinned anchor on the floor + !! (Line 4 of examples/iea15mw_umaine_mixed_cabledyn.dat on its former mesh: 200 m depth, kBot + !! 3e6, frictionMu 0.35, 10 m grounded elements). The seabed carries the weight of the anchor !! element, so its free end tangent stays along the floor; turned into the floor by the - !! unbalanced end moment of the weight, the element dipped about 27 mm below the bed, - !! carried axial forces from -47 kN to +127 kN about the 1.2 kN line tension, and - !! buckled sideways once the hang-off swayed, after which the friction locked the anchor - !! tension at about 2.5 times its static value while the line slackened. + !! unbalanced end moment of the weight, the element dipped about 27 mm below the bed, carried + !! axial forces from -47 kN to +127 kN about the 1.2 kN line tension, and buckled sideways once + !! the hang-off swayed, after which the friction locked the anchor tension at about 2.5 times + !! its static value while the line slackened. TYPE(CD_HFMF_ModuleType), ALLOCATABLE :: cable INTEGER :: cn, es, base, k CHARACTER(256) :: em diff --git a/tests/test_openfast_aggregate.f90 b/tests/test_openfast_aggregate.f90 index b02aaba1..fe58f15a 100644 --- a/tests/test_openfast_aggregate.f90 +++ b/tests/test_openfast_aggregate.f90 @@ -4253,11 +4253,11 @@ SUBROUTINE write_lozon_semitaut_deck(path) END SUBROUTINE write_lozon_semitaut_deck SUBROUTINE case_touchdown_cable_end_tension() - !! The IEA-15MW touchdown power cable of the mixed example (line 2 beside one mooring - !! chain): bare / buoyant / bare sections, stiff EA = 4.69e8 N on 4-10 m elements, - !! ending on a 3e6 Pa/m seabed. Statics carry no horizontal load, so the anchor end sees - !! the grounded run's tension H (~1.2 kN). The node-sampled stretch EA*(|dr/ds| - 1) at - !! the held anchor read 78 kN; the element end force equals H. + !! The IEA-15MW touchdown power cable of the mixed example on its former mesh (line 2 beside one + !! mooring chain): bare / buoyant / bare sections, stiff EA = 4.69e8 N on 4-10 m elements, + !! ending on a 3e6 Pa/m seabed. Statics carry no horizontal load, so the anchor end sees the + !! grounded run's tension H (~1.2 kN). The node-sampled stretch EA*(|dr/ds| - 1) at the held + !! anchor read 78 kN; the element end force equals H. TYPE(CD_AGG_ModuleType) :: agg INTEGER :: u, ios, es, k REAL(wp) :: v(3) diff --git a/validation/OPENFAST_DLC_VERIFICATION.md b/validation/OPENFAST_DLC_VERIFICATION.md index e04cd1e7..8dab5f4e 100644 --- a/validation/OPENFAST_DLC_VERIFICATION.md +++ b/validation/OPENFAST_DLC_VERIFICATION.md @@ -169,14 +169,17 @@ Tensions and platform dynamic response agree to within 0.6 %, apart from the Ptf ### Finite-EI power cable, severe sea (Hs=11) The cases above use the all-chain mooring. This case uses the mixed deck -`examples/iea15mw_umaine_mixed_cabledyn.dat`: three chains plus an 87-element (20 + 25 + 42) -finite-EI cubic-Hermite lazy-wave cable that runs from the platform (point 7, `Coupled`) to a -touchdown on the 200 m seabed and ends at an anchor (point 8, `Fixed`), in the full turbine under -Hs=11 waves. The run completed (exit 0, all 2400 steps, 0 NaN/Inf), and its output contains the -finite-EI curvature and bending-moment channels `Curv4N20` and `BendMom4N20`, which confirms that -the cable ran on the finite-EI element. At the static initial state the standalone driver gives -`Curv4N20` = 0.0915 1/m and `BendMom4N20` = 1821 N·m on this deck. This case has no MoorDyn-F -twin and establishes completion only; cable accuracy is established against OrcaFlex in cases L3-4, L3-5, L3-6 and +`examples/iea15mw_umaine_mixed_cabledyn.dat`: three chains plus a finite-EI cubic-Hermite +lazy-wave cable that runs from the platform (point 7, `Coupled`) to a touchdown on the 200 m +seabed and ends at an anchor (point 8, `Fixed`), in the full turbine under Hs=11 waves. The run +used the deck's earlier 87-element (20 + 25 + 42) mesh of the cable; the example now meshes it +with 248 elements to resolve its bending length, and the one-hour full-turbine run of the +coupled finite-EI touchdown row in [`VALIDATION.md`](../VALIDATION.md) uses that mesh. The run +completed (exit 0, all 2400 steps, 0 NaN/Inf), and its output contains the finite-EI curvature +and bending-moment channels of the sag bend, which confirms that the cable ran on the finite-EI +element. At the static initial state the standalone driver gives 0.0915 1/m and 1821 N·m on +that mesh (`Curv4N20`, `BendMom4N20`), and 0.0906 1/m and 1803 N·m on the current one +(`Curv4N38`, `BendMom4N38`). This case has no MoorDyn-F twin and establishes completion only; cable accuracy is established against OrcaFlex in cases L3-4, L3-5, L3-6 and L4-1c of [`VALIDATION.md`](../VALIDATION.md). ### Coupled rod between two fairleads, still water From 1446317e0e64fadcad8a7e15c680759ef58e82a3 Mon Sep 17 00:00:00 2001 From: Jae Hoon Seo Date: Fri, 16 Oct 2026 05:59:32 +0900 Subject: [PATCH 10/31] fix: static equilibria over non-planar bathymetry (#16) Static equilibria over real (non-planar) bathymetry, the two failures a statics robustness campaign found that any survey grid can trigger. Finite-EI lines over a non-planar bathymetry failed even with 2 cm roughness (39 of 192 sweep runs): the catenary seed, laid on the plane fitted along the chord, was rejected as soon as a node sat about 1e-6 (L + |z|) below the real bed, the anchor walk was not allowed and the mesh-sequenced fallback ended on a kinked branch. Seed nodes deeper than their static penalty penetration are now draped onto the bed, the anchor walk runs with the walked anchor following the bed at its own height above it, and a failed walk there no longer marks the deck inadmissible. Planar beds keep the old checks; the final state is audited, stability-tested and kink-checked as before. Rough sweep 153/192 -> 192/192. EI = 0 lines resting in a crease of the bilinear bed (a trench bottom, a valley of a 2D grid) had no discrete equilibrium, because the contact normal jumps across a grid line. Each interior grid line is now rounded within a band of 5 % of the smaller adjacent spacing by the C2 fillet J (delta - |u|)^3 / (6 delta^2) of the slope jump, as a tensor product; the surface moves by at most |J| delta / 6 along one line, exactly planar grids stay bilinear bit for bit, and in a band the contact force is the gradient of the penalty potential with its Hessian as tangent, in statics and dynamics, while the friction capacity stays the scalar normal law on every route. A Fixed point at the tabulated depth of a creased node is placed on the rounded surface; one between the surfaces but near neither is judged against the rounded seabed. Trench depths 2-30 m: 5/11 -> 11/11; EI = 0 rough sweep 192/192. Rough-bed decks that solved before change by at most 0.04 % in FairTen (0.40 % for one deck settling in another valley) and up to 8.5 % in AnchTen, from removing the spurious horizontal reactions of one-sided normals; all examples and driver test decks are byte-identical. Signed-off-by: Jae Hoon Seo --- CHANGELOG.md | 63 ++++++ CMakeLists.txt | 17 ++ doc/file_formats.rst | 7 +- doc/python_postprocessing.rst | 3 +- doc/theory.rst | 68 ++++++- doc/troubleshooting.rst | 11 + python/cabledyn/clearance.py | 96 ++++++++- python/tests/test_clearance.py | 37 ++++ src/CableDyn_Bathymetry.f90 | 265 ++++++++++++++++++++++++- src/CableDyn_DeckDriver.f90 | 183 ++++++++++++++--- src/CableDyn_HermiteCableDynamic.f90 | 54 ++++- src/CableDyn_HermiteCableStatic.f90 | 11 +- src/CableDyn_Model.f90 | 34 ++-- src/CableDyn_SeabedContact.f90 | 30 ++- src/CableDyn_Static.f90 | 50 +++-- tests/data/anchor_crease_between.dat | 31 +++ tests/data/anchor_crease_tabulated.dat | 31 +++ tests/data/bathy_v_valley.txt | 103 ++++++++++ tests/data/cable_statics_matrix.json | 86 ++++++++ tests/test_bathymetry.f90 | 204 ++++++++++++++++++- tests/test_cable_statics_matrix.py | 2 +- tests/test_statics_robustness.py | 111 ++++++++++- 22 files changed, 1398 insertions(+), 99 deletions(-) create mode 100644 tests/data/anchor_crease_between.dat create mode 100644 tests/data/anchor_crease_tabulated.dat create mode 100644 tests/data/bathy_v_valley.txt diff --git a/CHANGELOG.md b/CHANGELOG.md index 7cc4c055..d5d89754 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -138,6 +138,69 @@ All notable changes to CableDyn are recorded in this file. The format follows is still unstable on the refined mesh stops as before. Decks that solved before give the same results. `tests/data/lazy_wave_touchdown_torsion_coarse.dat` is the regression case, solved with each route first. +- A finite-EI line over a bathymetry that is not a plane along its chord no longer fails its + statics on a few centimetres of roughness. The catenary seed is laid on the plane fitted to + the bathymetry along the chord, which need not pass through the anchor, and it was rejected + as soon as a node dipped about 1e-6 of the line length below that plane. The + catenary-continuation route then stopped at once, and the mesh-sequenced fallback often ended + on a kinked branch ("unresolved/kinked equilibrium"). In a sweep of a chain on a rough + seabed, 39 of 96 runs on a 25 m survey grid failed this way, at every roughness from 2 cm to + 0.5 m. The seed is now measured against the actual bed: a node deeper below it than its + static penalty penetration (submerged weight over `kBot` × `Diam` × length) is lifted onto + the bed, a shallower one is left to the contact solve, and the continuation, which queries + the full surface, settles the contact. The equilibrium is audited, tested for stability and + checked for kinks as before. A line too long for the fitted plane is also walked into place + from a retreated anchor over such a bathymetry (the moved anchor kept at its height above + the bed under it); as the bed can hold the excess length in its dips, a failed walk there + is not reported as proof that the line is too long, and the mesh-sequenced route still runs. + All 192 finite-EI runs of the sweep now solve, within 1 % of the fairlead force on a mesh + four times finer and 0.8 % of the `EI = 0` line. Decks over a flat seabed or a planar + bathymetry are unchanged, and so are all shipped examples and test decks. A deck over a + non-planar bathymetry that solved before can now take the catenary-continuation route + instead of the mesh-sequenced one, or start from a seed lifted out of a bump: in the sweep + 29 of 153 such runs changed, the fairlead force by at most 0.03 % and the anchor tension by + at most 2.2 % (on 0.5 m roughness, where the anchor tension of the same deck differs by up + to 13 % on a mesh four times finer). The decks `ROUGH_1001` to `ROUGH_1003` of the cable + statics matrix (with mesh twins) are the regression cases. +- A line resting in a trench, a valley or a pit of a gridded bathymetry now has a static + equilibrium. Along every interior grid line the bilinear surface has a crease, and a node on + it took the normal of one adjacent cell, so a node that had to rest in a concave crease was + pushed back across it from either side and had no equilibrium. An `EI = 0` chain whose + frictionless tension falls to zero inside a trench (its excess length resting slack at the + bottom) failed with "no admissible static equilibrium", and so did a grounded run on a + two-dimensional rough seabed, which slides sideways into a valley along a grid line; a + finite-EI line on such a seabed could fail its first dynamic step. Each crease is now + rounded within a band of half-width 5 % of the smaller grid spacing next to its line, by + the cubic fillet `J (d - |u|)^3 / (6 d^2)` of the slope jump `J` across the line, applied as + a tensor product in both directions, so that the surface is twice continuously + differentiable. It moves the surface by at most `|J| d / 6` along one line (1.7 cm for a + slope jump of 0.2 on a 10 m grid; at a crossing of two lines the two roundings add), and a + grid that is exactly planar, and every patch without a crease (one that would move the + surface by less than 1 µm), keep the bilinear surface bit for bit; the rounding errors of a + plane written to two or three decimals are themselves creases and are rounded by a fraction + of a millimetre. In a band the elastic contact force is the gradient of the penalty + potential of the normal penetration (up to the twist of a bilinear cell, which the tangent + leaves out as before), with its Hessian as the tangent, in the statics and the dynamics + alike. Every bathymetry query uses + this surface, the Python `Bathymetry` and its seabed clearance included. A `Fixed` point at + the tabulated depth of a creased grid node rests on the seabed and is placed on the rounded + surface. In the statics campaign the `EI = 0` decks on bathymetry solve 40 of 43 (32 + before; the three left have anchors below the seabed), a 30 m trench now solves at every + depth from 2 m to 30 m (5 of 11 before), with the anchor tension `w` times the trench depth + as for a chain piled at the bottom (the fairlead tension within 0.15 % of the same trench + sampled with a level bottom cell, on a mesh four times finer), and the `EI = 0` rough-seabed + sweep solves 192 of 192 (191). Decks over a flat seabed or a planar bathymetry are unchanged, and so are all shipped + examples and test decks. Decks over creased bathymetries that solved before change: the + fairlead tension by at most 0.04 % (0.4 % for an `EI = 0` run that settles in another valley + of a two-dimensional rough seabed), the anchor tension by up to 8.5 %. The rounding removes + horizontal reactions of the one-sided normals: on a 2 m trench the two ends' horizontal + forces now agree to 0.02 % (1.2 % before), and the anchor tension of a finite-EI line on a + rough two-dimensional seabed is half as far from the one on a mesh four times finer. The + decks `trench_touchdown_pile`, `trench_grounded_run_pile` and `rough2d_seabed` of the `EI = 0` + statics robustness matrix are the regression cases, with an independent nodal force balance + on the rounded surface. When the anchor walk of a finite-EI line over a non-planar bathymetry + reaches a state that is rejected, the failure no longer states that the line is too long for + its span to hang as a catenary, which is proven over a planar seabed only. ## [0.1.1] - 2026-10-09 diff --git a/CMakeLists.txt b/CMakeLists.txt index 7d28801b..57752120 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -2054,6 +2054,23 @@ add_test(NAME driver_lazy_wave_planar_refined_quiet -P ${CMAKE_CURRENT_SOURCE_DIR}/tests/check_driver_output.cmake) set_tests_properties(driver_lazy_wave_planar_refined_quiet PROPERTIES LABELS "fortran;driver;integration;static") +# A Fixed anchor in a crease of a bathymetry grid: at the tabulated depth it rests on the seabed +# and is placed on the rounded surface; 1 cm below the rounded surface, between it and the grid +# surface but within the seabed tolerance of neither, it is rejected. +add_test(NAME driver_anchor_crease_tabulated + COMMAND ${CMAKE_COMMAND} -DDRIVER=$ -DEXPECT_RC=0 + "-DARGS=${CMAKE_CURRENT_SOURCE_DIR}/tests/data/anchor_crease_tabulated.dat|tabulated" + "-DMUST_NOT=lies below the seabed" + -DWORKDIR=${CMAKE_CURRENT_BINARY_DIR}/driver_anchor_crease_tabulated + -P ${CMAKE_CURRENT_SOURCE_DIR}/tests/check_driver_output.cmake) +set_tests_properties(driver_anchor_crease_tabulated PROPERTIES LABELS "fortran;driver;static;seabed") +add_test(NAME driver_anchor_crease_between + COMMAND ${CMAKE_COMMAND} -DDRIVER=$ -DEXPECT_RC=1 + "-DARGS=${CMAKE_CURRENT_SOURCE_DIR}/tests/data/anchor_crease_between.dat|between" + "-DMUST_MATCH=POINT 2 .Fixed. lies below the seabed" + -DWORKDIR=${CMAKE_CURRENT_BINARY_DIR}/driver_anchor_crease_between + -P ${CMAKE_CURRENT_SOURCE_DIR}/tests/check_driver_output.cmake) +set_tests_properties(driver_anchor_crease_between PROPERTIES LABELS "fortran;driver;static;seabed") # The same pair with the buoyant stretch built from discrete ATTACHMENTS: the hand-off check runs # on the discrete equilibrium the attachment polish gives. add_test(NAME driver_lazy_wave_planar_coarse_att_note diff --git a/doc/file_formats.rst b/doc/file_formats.rst index 5958c113..4915efae 100644 --- a/doc/file_formats.rst +++ b/doc/file_formats.rst @@ -343,7 +343,12 @@ Validation ``16·ε`` relative. * Rows may come in any order. Grid spacing does not have to be uniform. -The seabed is interpolated bilinearly within each grid cell. On a slope the +The seabed is interpolated bilinearly within each grid cell, and the creases of that +surface along the interior grid lines are rounded within a band of half-width 5 % of +the smaller grid spacing next to each line (a cubic fillet that makes the surface +twice continuously differentiable; see :doc:`theory`). The rounding moves the surface +by at most a sixth of the slope jump across the line times the band half-width, and +leaves a planar grid and every patch without a crease exactly bilinear. On a slope the frictionless contact force acts along the surface normal, and its stiffness includes the slope of that surface. Outside the grid, depth is clamped to the value at the nearest edge. diff --git a/doc/python_postprocessing.rst b/doc/python_postprocessing.rst index b74ff64f..c9bd0a82 100644 --- a/doc/python_postprocessing.rst +++ b/doc/python_postprocessing.rst @@ -465,7 +465,8 @@ Clearance :func:`cabledyn.seabed_clearance` returns the vertical clearance ``z - z_floor(x, y)`` of every node at every sample, less an optional ``radius``, above a flat seabed (pass its elevation, ``-WtrDpth``) or a :class:`~cabledyn.Bathymetry` read with :func:`cabledyn.read_bathymetry` from -the deck's ``x y depth`` file (bilinear, clamped at the grid edges, as in the solver). It +the deck's ``x y depth`` file (bilinear with its creases rounded, clamped at the grid edges, as +in the solver). It reproduces the solver's ``Clearance`` range graph. The :class:`~cabledyn.SeabedClearance` reports the minimum with its time, node, and arc length, a profile at any time, and a range graph. diff --git a/doc/theory.rst b/doc/theory.rst index e19b426e..f8dee70b 100644 --- a/doc/theory.rst +++ b/doc/theory.rst @@ -790,12 +790,59 @@ A vertical axis (no horizontal projection) takes :math:`\mu_n`. An equal pair runs the isotropic law unchanged. A structured bathymetry grid gives :math:`z_\text{floor}(x, y)` by bilinear interpolation, -clamped to the nearest edge outside the grid. On a sloped patch the elastic contact is +clamped to the nearest edge outside the grid, with the creases of that surface rounded. +Along every interior grid line the bilinear surface has a crease: its slope across the line +jumps by :math:`J` (the second difference of the tabulated depths). A node that must rest in a +concave crease, a valley along a grid line or the bottom of a pit, takes the normal of one cell +or the other and has no static equilibrium there; a slack chain piled at the bottom of a +trench and a frictionless grounded run slid sideways into a valley both end there. Each +crease is therefore rounded within a band of half-width :math:`\delta_k`, 5 % of the smaller +grid spacing next to line :math:`k`. Along one axis the interpolant :math:`g(x)` becomes + +.. math:: + + \tilde g(x) = g(x) + J_k\,h(x - x_k), \qquad + h(u) = \frac{(\delta_k - |u|)^3}{6\,\delta_k^2} \quad (|u| < \delta_k), \qquad h = 0 \text{ elsewhere}. + +:math:`h'(0^+) - h'(0^-) = -1` cancels the slope jump, and :math:`h`, :math:`h'` and :math:`h''` +vanish at :math:`|u| = \delta_k`, so :math:`\tilde g` is :math:`C^2`. Its curvature +:math:`J_k (\delta_k - |u|)/\delta_k^2` has the sign of the jump, so a valley stays convex and +gains no spurious pit. The surface is the tensor product of the two rounded interpolants, +:math:`z_\text{floor} = f + h_x J_x(y) + h_y \big(J_y(x) + h_x M\big)`, with :math:`f` the +bilinear surface, :math:`J_x(y)` the jumps of the grid rows across the :math:`x` line +interpolated linearly along it, :math:`J_y(x)` likewise, and :math:`M` the mixed second +difference of the grid where two lines cross. Its height, gradient and curvature are +continuous everywhere within the grid. Outside the bands it is the bilinear surface, and +inside the band of one line it moves by at most :math:`|J|\,\delta/6`; where two bands +cross the two roundings and the mixed term add. A 0.2 slope jump on a 10 m grid moves +it by 1.7 cm, within the static penetration of a chain (``w/(kBot Diam)``, 11 cm for a +120 mm chain at ``kBot = 1e5``). A crease that would move the surface by less than 1 µm is not +rounded: an exactly planar grid and every patch without a crease keep the bilinear surface +exactly. A plane written to two or three decimals has creases of the size of its rounding, +which are rounded by a fraction of a millimetre. The grid edges are not rounded, and outside the grid the +surface stays level. Every height and gradient query uses this one surface: the contact of +the ``EI = 0`` and the Hermite path, statics and dynamics, the friction frame and capacity, +the seabed clearance and touchdown outputs, and the Python post-processing +(``cabledyn.Bathymetry``). The friction capacity uses the normal force :math:`f_n^{(k)}(g/s)`; +inside a band it leaves out the curvature term of the contact force below, of the order of +the penetration times the curvature. A ``Fixed`` point placed at the +tabulated depth of a creased grid node lies up to :math:`|J|\,\delta/6` below the rounded +surface; it rests on the seabed and is placed on the rounded surface. + +On a sloped patch the elastic contact is frictionless and normal to the surface, on the ``EI = 0`` and the Hermite path alike: with :math:`s = \sqrt{1 + z_{,x}^2 + z_{,y}^2}` the force is :math:`f_n^{(k)}(g/s)\,\mathbf{n}`, :math:`\mathbf{n} = (-z_{,x}, -z_{,y}, 1)/s`, and its tangent -:math:`f_n^{(k)\prime}\,\mathbf{n}\mathbf{n}^{\mathsf T}` (the grid curvature is not -differentiated); on a level floor this is exactly the vertical law above. Its damping acts on +:math:`f_n^{(k)\prime}\,\mathbf{n}\mathbf{n}^{\mathsf T}` (the twist of a bilinear cell is not +differentiated); on a level floor this is exactly the vertical law above. Inside a crease band, +where the surface curves, the elastic force is the gradient of the penalty potential +:math:`E(g/s)` of the normal penetration, :math:`-f_n^{(k)}\,\partial(g/s)/\partial\mathbf{q}`: +the normal force plus :math:`f_n^{(k)}\,g\,\nabla s/s^2`, a term of the order of the +penetration times the curvature, and its tangent is the Hessian of that potential (third +derivatives of the surface left out). The static energy minimisation then agrees with the +force up to the twist of the bilinear cell, which is left out of the tangent as on a sloped +patch, and a node held in a rounded valley by its curvature has a consistent stiffness. Its +damping acts on the velocity along :math:`\mathbf{n}`, and a friction capacity is :math:`\mu` times its magnitude. The static solve and the dynamics use the same law, so a grounded run on a slope rests at a static equilibrium of the march; its tension changes along the slope by the weight @@ -882,7 +929,14 @@ mesh-sequenced route described below first and this route as its fallback): declared seabed plane (flat ``WtrDpth``, or the least-squares plane of a structured bathymetry along the chord) or hung in mid-water when there is no seabed. The solve runs in the vertical plane of the chord, translated to the anchor, so a translated or rotated deck gives the same - numbers to round-off. When the only catenary through the endpoints passes below a planar + numbers to round-off. Over a bathymetry that is not a plane along the chord (a surveyed + seabed with roughness, bumps or dips), the seed laid on the fitted plane meets the actual bed + wherever the bed rises above that plane: every seed node deeper below the actual bed than its + static penalty penetration (nodal submerged weight over the nodal contact stiffness + ``kBot`` :math:`\times` ``Diam`` :math:`\times` length) is lifted onto the bed, and the + continuation below, which queries the full surface, settles the contact. Such a seed is + never rejected for its penetration; the equilibrium it leads to is audited like any other. + When the only catenary through the endpoints passes below a planar seabed (flat, or a structured bathymetry whose profile under the chord is straight), the line is too long for its span to hang as a catenary. Without buoyant sections the line is a convex curve between the chord and the seabed, so it cannot be longer than the path down to @@ -899,7 +953,11 @@ mesh-sequenced route described below first and this route as its fallback): short of the anchor (the bow snaps through, or the line would have to lie on itself), or the bathymetry does not continue its plane behind the anchor, the run stops and names the geometry: no admissible planar equilibrium clear of the seabed was found, the line being too - long for its span to hang as a catenary, with where the walk stopped. A walked state that + long for its span to hang as a catenary, with where the walk stopped. A line too long for + the plane fitted to a non-planar bathymetry is walked the same way, the moved anchor kept + at its height above the bed under it and the seed draped as above; as such a bed can hold + the excess length in its dips, a failed walk there proves nothing, and the mesh-sequenced + route runs before the run stops. A walked state that the audit below rejects (self-contact, instability) hands over to the mesh-sequenced route, and is named the same way when that finds none; with ``tensile_safety True`` a walked state in compression is rejected by name (a bow held by bending is compressed). diff --git a/doc/troubleshooting.rst b/doc/troubleshooting.rst index fbfe63b2..9fd5209f 100644 --- a/doc/troubleshooting.rst +++ b/doc/troubleshooting.rst @@ -453,6 +453,17 @@ but a few geometries are genuinely hard: exist: the surplus must fold or form another contact region. CableDyn rejects a resulting element-localized wad through the curvature safety check. This is not fixed by relaxing Newton tolerances; revise the physical support/contact model or geometry. +- **A line resting in a trench, valley or pit of a gridded bathymetry.** A frictionless grounded + run's tension :math:`T = T_0 + w\,(z - z_0)` falls with depth. In a trench deep enough it reaches + zero, and an ``EI = 0`` line then rests slack at the bottom with its excess length piled there; + the anchor tension of the run rising from the pile is :math:`w` times the depth of the trench + below the anchor, whatever the line length. On a two-dimensional rough bed the run slides + sideways into the valleys. Both rest in the creases of the bilinear grid, which the solver + rounds over 5 % of the grid spacing (see :doc:`theory`) so that a node has an equilibrium + there. A pile appears in the static profile as coincident nodes with zero tension and large + turning angles; a finite-EI line carries compression there instead, which the driver notes. + With 5 m elements on steep trench walls the end tensions of a pile still change by about 1 % + on a mesh four times finer: refine the line over the trench when they matter. - **A twisted finite-EI line.** ``torsion continuation stalled at Phi = ... (target ...)`` reports the imposed twist the static ramp reached: beyond it the line has no nearby static equilibrium on the path, typically because a loop is forming (hockling), which needs a diff --git a/python/cabledyn/clearance.py b/python/cabledyn/clearance.py index f587c545..e4f6d01e 100644 --- a/python/cabledyn/clearance.py +++ b/python/cabledyn/clearance.py @@ -63,6 +63,11 @@ # (sample, segment, segment) entries, bounding the temporary memory. _CHUNK = 250_000 _PLAIN_NUMBER = re.compile(r"[+-]?(?:\d+\.?\d*|\.\d+)(?:[eE][+-]?\d+)?") +# Crease rounding of the bathymetry surface, as in the solver (CableDyn_Bathymetry): band +# half-width as a fraction of the smaller grid spacing next to a line, and the smallest +# surface change [m] a crease must make to be rounded. +_CREASE_FRACTION = 0.05 +_CREASE_MIN_HEIGHT = 1.0e-6 def _readonly(values: npt.ArrayLike, dtype: Any = np.float64) -> npt.NDArray[Any]: @@ -83,8 +88,12 @@ class Bathymetry: """A structured seabed: water depth on a rectangular ``x``-``y`` grid. The seabed elevation is ``z_floor = -depth``. Between grid points it is - bilinear in each cell; outside the grid it takes the value at the nearest - grid edge, as in the solver. + bilinear in each cell, with the creases of that surface along the interior + grid lines rounded within a narrow band (the C2 fillet of the solver: a + crease with slope jump ``J`` is moved by ``J (delta - |u|)^3 / (6 delta^2)`` at + distance ``|u| < delta`` from its line, ``delta`` five per cent of the smaller + spacing next to it); outside the grid it takes the value at the nearest grid + edge, as in the solver. Attributes ---------- @@ -153,12 +162,68 @@ def depth_at(self, x: npt.ArrayLike, y: npt.ArrayLike) -> npt.NDArray[Any]: ix, tx = _cell(self.x, qx) iy, ty = _cell(self.y, qy) d = self.depth - return np.asarray( + bilinear = ( (1.0 - tx) * (1.0 - ty) * d[ix, iy] + tx * (1.0 - ty) * d[ix + 1, iy] + (1.0 - tx) * ty * d[ix, iy + 1] + tx * ty * d[ix + 1, iy + 1] ) + return np.asarray(bilinear - self._crease_rounding(qx, qy, ix, iy, tx, ty)) + + def _crease_rounding( + self, + qx: npt.NDArray[Any], + qy: npt.NDArray[Any], + ix: npt.NDArray[Any], + iy: npt.NDArray[Any], + tx: npt.NDArray[Any], + ty: npt.NDArray[Any], + ) -> npt.NDArray[Any]: + """Rise of the rounded surface over the bilinear one (zero outside the bands). + + ``hx Jx(y) + hy (Jy(x) + hx M)``: ``J`` the slope jumps of the grid rows + (columns) across the line, interpolated linearly along it, ``M`` the mixed + second difference at a crossing of two lines, ``h`` the fillet. + """ + kx, hx = _crease_band(self.x, ix, qx) + ky, hy = _crease_band(self.y, iy, qy) + z = -self.depth + rise = np.zeros(np.shape(qx)) + on_x = kx >= 0 + on_y = ky >= 0 + if not (np.any(on_x) or np.any(on_y)): + return rise + kxs = np.clip(kx, 1, self.x.size - 2) + kys = np.clip(ky, 1, self.y.size - 2) + dlx = _CREASE_FRACTION * np.minimum( + self.x[kxs] - self.x[kxs - 1], self.x[kxs + 1] - self.x[kxs] + ) + dly = _CREASE_FRACTION * np.minimum( + self.y[kys] - self.y[kys - 1], self.y[kys + 1] - self.y[kys] + ) + + def jump_x(j: npt.NDArray[Any]) -> npt.NDArray[Any]: + jump = (z[kxs + 1, j] - z[kxs, j]) / (self.x[kxs + 1] - self.x[kxs]) - ( + z[kxs, j] - z[kxs - 1, j] + ) / (self.x[kxs] - self.x[kxs - 1]) + return np.where(np.abs(jump) * dlx / 6.0 > _CREASE_MIN_HEIGHT, jump, 0.0) + + def jump_y(i: npt.NDArray[Any]) -> npt.NDArray[Any]: + jump = (z[i, kys + 1] - z[i, kys]) / (self.y[kys + 1] - self.y[kys]) - ( + z[i, kys] - z[i, kys - 1] + ) / (self.y[kys] - self.y[kys - 1]) + return np.where(np.abs(jump) * dly / 6.0 > _CREASE_MIN_HEIGHT, jump, 0.0) + + jx = (1.0 - ty) * jump_x(iy) + ty * jump_x(iy + 1) + jy = (1.0 - tx) * jump_y(ix) + tx * jump_y(ix + 1) + mxy = (jump_x(kys + 1) - jump_x(kys)) / (self.y[kys + 1] - self.y[kys]) - ( + jump_x(kys) - jump_x(kys - 1) + ) / (self.y[kys] - self.y[kys - 1]) + mxy = np.where( + on_x & on_y & (np.abs(mxy) * dlx * dly / 36.0 > _CREASE_MIN_HEIGHT), mxy, 0.0 + ) + rise = np.where(on_x, hx * jx, 0.0) + np.where(on_y, hy * (jy + hx * mxy), 0.0) + return np.asarray(rise) def floor(self, x: npt.ArrayLike, y: npt.ArrayLike) -> npt.NDArray[Any]: """Return the seabed elevation ``z_floor = -depth`` at points ``(x, y)``. @@ -190,6 +255,31 @@ def _cell( return index, np.clip(fraction, 0.0, 1.0) +def _crease_band( + axis: npt.NDArray[Any], index: npt.NDArray[Any], query: npt.NDArray[Any] +) -> tuple[npt.NDArray[Any], npt.NDArray[Any]]: + """Interior grid line whose crease band holds each query (-1: none) and the fillet there. + + The fillet is ``(delta - |u|)^3 / (6 delta^2)``, ``u`` the distance from the line and + ``delta`` the band half-width; a query outside the grid lies in no band. + """ + n = axis.size + inside = (query >= axis[0]) & (query <= axis[-1]) + line = np.full(np.shape(query), -1) + fillet = np.zeros(np.shape(query)) + for k in (index, index + 1): + interior = inside & (k >= 1) & (k <= n - 2) & (line < 0) + ks = np.clip(k, 1, max(n - 2, 1)) + if n < 3: + continue + delta = _CREASE_FRACTION * np.minimum(axis[ks] - axis[ks - 1], axis[ks + 1] - axis[ks]) + u = np.abs(query - axis[ks]) + hit = interior & (u < delta) + line = np.where(hit, k, line) + fillet = np.where(hit, (delta - u) ** 3 / (6.0 * delta * delta), fillet) + return line, fillet + + def _strip_comment(text: str) -> str: """Strip ``#``/``!`` comments and a ``--`` comment that starts a token.""" cut = len(text) diff --git a/python/tests/test_clearance.py b/python/tests/test_clearance.py index 860c6f43..d237fc14 100644 --- a/python/tests/test_clearance.py +++ b/python/tests/test_clearance.py @@ -132,6 +132,43 @@ def test_bathymetry_is_bilinear_and_clamped_outside_the_grid(): bathymetry.floor(math.nan, 0.0) +def test_bathymetry_rounds_the_creases_of_the_grid_as_the_solver(): + # a crease of slope jump J = -1 at x = 10 (level, then deepening 1 m per metre); the band + # half-width is 5 % of the smaller spacing, 0.5 m, and the fillet J (delta - |u|)^3/(6 delta^2) + crease = Bathymetry( + [0.0, 10.0, 20.0], [0.0, 1.0], [[100.0, 100.0], [100.0, 100.0], [110.0, 110.0]] + ) + np.testing.assert_allclose( + crease.depth_at([10.0, 10.2, 9.6, 9.5, 5.0, 10.5], 0.3), + [100.0 + 0.5 / 6.0, 100.218, 100.0 + 0.001 / 1.5, 100.0, 100.0, 100.5], + rtol=0.0, + atol=1e-12, + ) + # continuous height and slope across the line and at the band edges + for x0 in (10.0, 9.5, 10.5): + a, b = crease.depth_at([x0 - 1e-7, x0 + 1e-7], 0.5) + assert abs(a - b) < 2.1e-7 # the slope there is at most 1 + slope = crease.depth_at([x0 - 2e-4, x0 - 1e-4, x0 + 1e-4, x0 + 2e-4], 0.5) + assert abs((slope[1] - slope[0]) - (slope[3] - slope[2])) < 1e-6 + # a planar grid (here written to six decimals) is not rounded: bit-identical bilinear + x = np.array([0.0, 10.0, 25.0, 30.0]) + y = np.array([-5.0, 8.0, 20.0]) + plane = np.round(388.949782 + 0.0732 * x[:, None] - 0.0417 * y[None, :], 6) + planar = Bathymetry(x, y, plane) + qx, qy = np.meshgrid(np.linspace(-1.0, 31.0, 97), np.linspace(-6.0, 21.0, 55)) + ix = np.clip(np.searchsorted(x, qx, side="right") - 1, 0, x.size - 2) + iy = np.clip(np.searchsorted(y, qy, side="right") - 1, 0, y.size - 2) + tx = np.clip((qx - x[ix]) / (x[ix + 1] - x[ix]), 0.0, 1.0) + ty = np.clip((qy - y[iy]) / (y[iy + 1] - y[iy]), 0.0, 1.0) + bilinear = ( + (1.0 - tx) * (1.0 - ty) * plane[ix, iy] + + tx * (1.0 - ty) * plane[ix + 1, iy] + + (1.0 - tx) * ty * plane[ix, iy + 1] + + tx * ty * plane[ix + 1, iy + 1] + ) + assert np.array_equal(planar.depth_at(qx, qy), bilinear) + + @pytest.mark.parametrize( ("x", "y", "depth", "message"), [ diff --git a/src/CableDyn_Bathymetry.f90 b/src/CableDyn_Bathymetry.f90 index 1c8bc912..6c5db76a 100644 --- a/src/CableDyn_Bathymetry.f90 +++ b/src/CableDyn_Bathymetry.f90 @@ -6,9 +6,15 @@ MODULE CableDyn_Bathymetry !! water-depth queries. The grid stores positive water depth below still-water !! level at monotone x/y coordinates; the seabed elevation is z_floor = -depth. !! Queries clamp to the nearest grid edge outside the supplied domain and use - !! bilinear interpolation inside each cell. Contact is a frictionless penalty force - !! along the local upward surface normal at the normal penetration; its tangent holds - !! the surface gradient fixed over the node (the bilinear curvature is omitted). + !! bilinear interpolation inside each cell, with the creases of that surface along the + !! interior grid lines rounded to C2 within a narrow band (crease_blend): a node resting + !! in a valley or pit of the grid then meets a continuous normal, and has an + !! equilibrium there. Outside the bands, and wherever the grid has no crease, the + !! surface is exactly bilinear. Contact is a frictionless penalty force along the + !! local upward surface normal at the normal penetration; its tangent holds the + !! surface gradient fixed over the node (the twist of a bilinear cell is omitted). In a + !! crease band the force is the gradient of the penalty potential of the normal + !! penetration and its tangent that potential's Hessian (CD_Seabed_Normal_Contact). USE CableDyn_Precision, ONLY: wp, CD_ZERO, CD_All_Finite, CD_Is_Finite USE CableDyn_SeabedContact, ONLY: CD_Seabed_Normal_Contact IMPLICIT NONE @@ -21,8 +27,17 @@ MODULE CableDyn_Bathymetry PUBLIC :: CD_Bathymetry_Depth PUBLIC :: CD_Bathymetry_Floor PUBLIC :: CD_Bathymetry_Floor_Gradient + PUBLIC :: CD_Bathymetry_Grid_Floor + PUBLIC :: CD_Bathymetry_Rotate_Curvature PUBLIC :: CD_Bathymetry_Seabed_Load INTEGER, PARAMETER, PUBLIC :: CD_BATHY_OK = 0, CD_BATHY_BADINPUT = 1, CD_BATHY_ALLOCFAIL = 2 + ! Crease rounding (see crease_blend): band half-width as a fraction of the smaller grid + ! spacing next to the line, and the smallest surface change [m] a crease must make to be + ! rounded (below it the grid is treated as uncreased there: an exactly planar grid stays + ! exactly bilinear; the rounding errors of a plane written to two or three decimals are + ! creases above it and are rounded by a fraction of a millimetre). + REAL(wp), PARAMETER, PUBLIC :: CD_BATHY_CREASE_FRACTION = 0.05_wp + REAL(wp), PARAMETER, PUBLIC :: CD_BATHY_CREASE_MIN_HEIGHT = 1.0e-6_wp TYPE :: CD_BathymetryType INTEGER :: nx = 0, ny = 0 @@ -156,24 +171,58 @@ SUBROUTINE CD_Bathymetry_Floor(bathy, xq, yq, z_floor, ErrStat, ErrMsg) CALL floor_eval(bathy, xq, yq, z_floor, dfdx, dfdy, ErrStat, ErrMsg) END SUBROUTINE CD_Bathymetry_Floor - SUBROUTINE CD_Bathymetry_Floor_Gradient(bathy, xq, yq, z_floor, dfdx, dfdy, ErrStat, ErrMsg) + SUBROUTINE CD_Bathymetry_Grid_Floor(bathy, xq, yq, z_floor, ErrStat, ErrMsg) + !! Seabed elevation of the grid itself at a horizontal location: the bilinear + !! interpolation of the tabulated depths, without the crease rounding of + !! CD_Bathymetry_Floor. For checking an input point against the surveyed depths only + !! (a point at the tabulated depth of a creased grid node lies on this surface, within + !! a fraction of the band width of the rounded one); every contact, gradient and output + !! query uses CD_Bathymetry_Floor. + TYPE(CD_BathymetryType), INTENT(IN) :: bathy + REAL(wp), INTENT(IN) :: xq, yq + REAL(wp), INTENT(OUT) :: z_floor + INTEGER, INTENT(OUT) :: ErrStat + CHARACTER(*), INTENT(OUT) :: ErrMsg + REAL(wp) :: dfdx, dfdy + CALL floor_eval(bathy, xq, yq, z_floor, dfdx, dfdy, ErrStat, ErrMsg, rounded=.FALSE.) + END SUBROUTINE CD_Bathymetry_Grid_Floor + + SUBROUTINE CD_Bathymetry_Floor_Gradient(bathy, xq, yq, z_floor, dfdx, dfdy, ErrStat, ErrMsg, crease_curvature) !! Return seabed elevation and horizontal gradients dz_floor/dx, dz_floor/dy. + !! crease_curvature (optional): the second derivatives (z_xx, z_xy, z_yy) of the crease + !! rounding at the point (zero outside the crease bands), for a contact tangent that + !! follows the rounded surface; the twist of the bilinear cells is not included. TYPE(CD_BathymetryType), INTENT(IN) :: bathy REAL(wp), INTENT(IN) :: xq, yq REAL(wp), INTENT(OUT) :: z_floor, dfdx, dfdy INTEGER, INTENT(OUT) :: ErrStat CHARACTER(*), INTENT(OUT) :: ErrMsg + REAL(wp), INTENT(OUT), OPTIONAL :: crease_curvature(3) - CALL floor_eval(bathy, xq, yq, z_floor, dfdx, dfdy, ErrStat, ErrMsg) + CALL floor_eval(bathy, xq, yq, z_floor, dfdx, dfdy, ErrStat, ErrMsg, curvature=crease_curvature) END SUBROUTINE CD_Bathymetry_Floor_Gradient + PURE FUNCTION CD_Bathymetry_Rotate_Curvature(curv_g, cs) RESULT(curv_l) + !! Surface curvature (z_xx, z_xy, z_yy) of the global frame expressed in a frame turned + !! by the angle of cs = (cos, sin) about z (global x = cos xl - sin yl, y = sin xl + + !! cos yl): H_l = R^T H_g R, as the gradient turns to g_l = R^T g_g. + REAL(wp), INTENT(IN) :: curv_g(3), cs(2) + REAL(wp) :: curv_l(3) + REAL(wp) :: hg(2, 2), r(2, 2), hl(2, 2) + hg = RESHAPE([curv_g(1), curv_g(2), curv_g(2), curv_g(3)], [2, 2]) + r = RESHAPE([cs(1), cs(2), -cs(2), cs(1)], [2, 2]) + hl = MATMUL(TRANSPOSE(r), MATMUL(hg, r)) + curv_l = [hl(1, 1), 0.5_wp*(hl(1, 2) + hl(2, 1)), hl(2, 2)] + END FUNCTION CD_Bathymetry_Rotate_Curvature + SUBROUTINE CD_Bathymetry_Seabed_Load(bathy, nodes, k_n, f, k_resid, ErrStat, ErrMsg) !! Variable-elevation penalty contact against the bathymetry surface. !! For node i, g_i = z_floor(x_i,y_i) - z_i is the vertical penetration. The contact !! is frictionless: the force acts along the local upward surface normal with the !! shared C1 touchdown law evaluated at the normal penetration (CD_Seabed_Normal_Contact; !! exactly the vertical law on a level patch). The residual tangent is the node's - !! -d(force)/dq block, F' n n^T. + !! -d(force)/dq block, F' n n^T; in a crease band the force and tangent follow the + !! rounded surface (the gradient and Hessian of the penalty potential there). TYPE(CD_BathymetryType), INTENT(IN) :: bathy REAL(wp), INTENT(IN) :: nodes(:, :) REAL(wp), INTENT(IN) :: k_n(:) @@ -183,7 +232,7 @@ SUBROUTINE CD_Bathymetry_Seabed_Load(bathy, nodes, k_n, f, k_resid, ErrStat, Err CHARACTER(*), INTENT(OUT) :: ErrMsg INTEGER :: n_nodes, i, ix, iz - REAL(wp) :: z_floor, dfdx, dfdy, gap, fvec(3), jac(3, 3) + REAL(wp) :: z_floor, dfdx, dfdy, gap, fvec(3), jac(3, 3), curv(3) f = CD_ZERO k_resid = CD_ZERO @@ -216,23 +265,27 @@ SUBROUTINE CD_Bathymetry_Seabed_Load(bathy, nodes, k_n, f, k_resid, ErrStat, Err END IF DO i = 1, n_nodes - CALL floor_eval(bathy, nodes(1, i), nodes(2, i), z_floor, dfdx, dfdy, ErrStat, ErrMsg) + CALL floor_eval(bathy, nodes(1, i), nodes(2, i), z_floor, dfdx, dfdy, ErrStat, ErrMsg, curvature=curv) IF (ErrStat /= CD_BATHY_OK) RETURN gap = z_floor - nodes(3, i) ix = 3*i - 2 iz = ix + 2 - CALL CD_Seabed_Normal_Contact(gap, dfdx, dfdy, k_n(i), fvec, jac) + CALL CD_Seabed_Normal_Contact(gap, dfdx, dfdy, k_n(i), fvec, jac, curvature=curv) f(ix:iz) = fvec k_resid(ix:iz, ix:iz) = jac END DO END SUBROUTINE CD_Bathymetry_Seabed_Load - SUBROUTINE floor_eval(bathy, xq, yq, z_floor, dfdx, dfdy, ErrStat, ErrMsg) + SUBROUTINE floor_eval(bathy, xq, yq, z_floor, dfdx, dfdy, ErrStat, ErrMsg, rounded, curvature) + !! The seabed surface and its gradient: bilinear in each cell, its creases rounded + !! (crease_blend) unless rounded is .FALSE. (CD_Bathymetry_Grid_Floor). TYPE(CD_BathymetryType), INTENT(IN) :: bathy REAL(wp), INTENT(IN) :: xq, yq REAL(wp), INTENT(OUT) :: z_floor, dfdx, dfdy INTEGER, INTENT(OUT) :: ErrStat CHARACTER(*), INTENT(OUT) :: ErrMsg + LOGICAL, INTENT(IN), OPTIONAL :: rounded + REAL(wp), INTENT(OUT), OPTIONAL :: curvature(3) INTEGER :: ix, iy REAL(wp) :: tx, ty @@ -242,6 +295,7 @@ SUBROUTINE floor_eval(bathy, xq, yq, z_floor, dfdx, dfdy, ErrStat, ErrMsg) z_floor = CD_ZERO dfdx = CD_ZERO dfdy = CD_ZERO + IF (PRESENT(curvature)) curvature = CD_ZERO ErrStat = CD_BATHY_OK ErrMsg = '' IF (.NOT. CD_Bathymetry_Is_Initialized(bathy)) THEN @@ -266,8 +320,199 @@ SUBROUTINE floor_eval(bathy, xq, yq, z_floor, dfdx, dfdy, ErrStat, ErrMsg) (1.0_wp - tx)*ty*f01 + tx*ty*f11 IF (.NOT. clamp_x) dfdx = ((1.0_wp - ty)*(f10 - f00) + ty*(f11 - f01))/dx IF (.NOT. clamp_y) dfdy = ((1.0_wp - tx)*(f01 - f00) + tx*(f11 - f10))/dy + IF (PRESENT(rounded)) THEN + IF (.NOT. rounded) RETURN + END IF + IF (bathy%nx > 2 .OR. bathy%ny > 2) & + CALL crease_blend(bathy, xq, yq, ix, iy, tx, ty, clamp_x, clamp_y, z_floor, dfdx, dfdy, curvature) END SUBROUTINE floor_eval + SUBROUTINE crease_blend(bathy, xq, yq, ix, iy, tx, ty, clamp_x, clamp_y, z_floor, dfdx, dfdy, curvature) + !! Rounding of the creases of the bilinear surface (see the module header). The + !! surface is the tensor product of the two axes' piecewise-linear interpolants; each + !! interpolant has a slope jump J_k at an interior grid line k, which is rounded within + !! the band |u| < delta_k (u the distance from the line, delta_k = + !! CD_BATHY_CREASE_FRACTION times the smaller adjacent spacing) by adding J_k h(u), with + !! h(u) = (delta_k - |u|)^3/(6 delta_k^2): h'(0+) - h'(0-) = -1 cancels the slope jump, + !! and h, h' and h'' vanish at |u| = delta_k, so the rounded interpolant is C2 (its + !! curvature J (delta - |u|)/delta^2 has the sign of the jump: a valley stays convex). + !! Applied in both directions, the surface is f + h_x J_x(y) + h_y (J_y(x) + h_x M), + !! with J_x(y) the jumps of the grid rows across the x line interpolated linearly in y, + !! J_y(x) likewise, and M the mixed second difference of the grid at the crossing of + !! the two lines (the jump of J_x across the y line). It is the tensor product of C2 + !! interpolants, so its height, gradient and curvature are continuous everywhere + !! within the grid; it equals the bilinear surface outside the bands and moves it by + !! at most |J| delta/6. A jump that would + !! move the surface by less than CD_BATHY_CREASE_MIN_HEIGHT (a plane rounded to the + !! digits of its file) counts as none, so a planar grid and every patch without a + !! crease are exactly bilinear. The grid edges are not rounded (outside the grid the + !! surface is held level). + !! curvature (optional): (z_xx, z_xy, z_yy) of the rounding terms; left unchanged + !! (zero) outside the bands. + TYPE(CD_BathymetryType), INTENT(IN) :: bathy + REAL(wp), INTENT(IN) :: xq, yq, tx, ty + INTEGER, INTENT(IN) :: ix, iy + LOGICAL, INTENT(IN) :: clamp_x, clamp_y + REAL(wp), INTENT(INOUT) :: z_floor, dfdx, dfdy + REAL(wp), INTENT(INOUT), OPTIONAL :: curvature(3) + INTEGER :: kx, ky + REAL(wp) :: u, v, dlx, dly, hx, hxp, hxpp, hy, hyp, hypp, jx0, jx1, jy0, jy1, jxm, jxc, jxn, mxy + REAL(wp) :: jx, jxp, jy, jyp, c + LOGICAL :: on_x, on_y, on_m + + kx = 0 + ky = 0 + u = CD_ZERO + v = CD_ZERO + dlx = CD_ZERO + dly = CD_ZERO + IF (.NOT. clamp_x) CALL crease_band(bathy%x, ix, xq, kx, u, dlx) + IF (.NOT. clamp_y) CALL crease_band(bathy%y, iy, yq, ky, v, dly) + IF (kx == 0 .AND. ky == 0) RETURN + hx = CD_ZERO + hxp = CD_ZERO + hxpp = CD_ZERO + jx0 = CD_ZERO + jx1 = CD_ZERO + on_x = .FALSE. + on_m = .FALSE. + IF (kx > 0) THEN + CALL crease_fillet(u, dlx, kx == ix, hx, hxp, hxpp) + CALL x_jump(bathy, kx, iy, dlx, jx0, on_x) + CALL x_jump(bathy, kx, iy + 1, dlx, jx1, on_m) + on_x = on_x .OR. on_m + END IF + hy = CD_ZERO + hyp = CD_ZERO + hypp = CD_ZERO + jy0 = CD_ZERO + jy1 = CD_ZERO + on_y = .FALSE. + mxy = CD_ZERO + on_m = .FALSE. + IF (ky > 0) THEN + CALL crease_fillet(v, dly, ky == iy, hy, hyp, hypp) + CALL y_jump(bathy, ix, ky, dly, jy0, on_y) + CALL y_jump(bathy, ix + 1, ky, dly, jy1, on_m) + on_y = on_y .OR. on_m + on_m = .FALSE. + IF (kx > 0) THEN + ! the jump of J_x across the y line: its rows ky-1, ky and ky+1 + CALL x_jump(bathy, kx, ky - 1, dlx, jxm, on_m) + CALL x_jump(bathy, kx, ky, dlx, jxc, on_m) + CALL x_jump(bathy, kx, ky + 1, dlx, jxn, on_m) + mxy = (jxn - jxc)/(bathy%y(ky + 1) - bathy%y(ky)) - (jxc - jxm)/(bathy%y(ky) - bathy%y(ky - 1)) + on_m = ABS(mxy)*dlx*dly/36.0_wp > CD_BATHY_CREASE_MIN_HEIGHT + IF (.NOT. on_m) mxy = CD_ZERO + END IF + END IF + IF (on_x) THEN + jx = (1.0_wp - ty)*jx0 + ty*jx1 + jxp = CD_ZERO + IF (.NOT. clamp_y) jxp = (jx1 - jx0)/(bathy%y(iy + 1) - bathy%y(iy)) + z_floor = z_floor + hx*jx + dfdx = dfdx + hxp*jx + dfdy = dfdy + hx*jxp + IF (PRESENT(curvature)) THEN + curvature(1) = curvature(1) + hxpp*jx + curvature(2) = curvature(2) + hxp*jxp + END IF + END IF + IF (on_y .OR. on_m) THEN + jy = (1.0_wp - tx)*jy0 + tx*jy1 + jyp = CD_ZERO + IF (.NOT. clamp_x) jyp = (jy1 - jy0)/(bathy%x(ix + 1) - bathy%x(ix)) + c = jy + hx*mxy + z_floor = z_floor + hy*c + dfdx = dfdx + hy*(jyp + hxp*mxy) + dfdy = dfdy + hyp*c + IF (PRESENT(curvature)) THEN + curvature(1) = curvature(1) + hy*hxpp*mxy + curvature(2) = curvature(2) + hyp*(jyp + hxp*mxy) + curvature(3) = curvature(3) + hypp*c + END IF + END IF + END SUBROUTINE crease_blend + + PURE SUBROUTINE crease_band(axis, i0, q, k, u, dl) + !! The interior grid line k whose crease band |q - axis(k)| < dl holds q (0: none), for + !! q in the cell [axis(i0), axis(i0+1)]; u = q - axis(k). + REAL(wp), INTENT(IN) :: axis(:), q + INTEGER, INTENT(IN) :: i0 + INTEGER, INTENT(OUT) :: k + REAL(wp), INTENT(OUT) :: u, dl + k = 0 + u = CD_ZERO + dl = CD_ZERO + IF (i0 > 1) THEN + dl = CD_BATHY_CREASE_FRACTION*MIN(axis(i0) - axis(i0 - 1), axis(i0 + 1) - axis(i0)) + u = q - axis(i0) + IF (u < dl) THEN + k = i0 + RETURN + END IF + END IF + IF (i0 + 1 < SIZE(axis)) THEN + dl = CD_BATHY_CREASE_FRACTION*MIN(axis(i0 + 1) - axis(i0), axis(i0 + 2) - axis(i0 + 1)) + u = q - axis(i0 + 1) + IF (-u < dl) THEN + k = i0 + 1 + RETURN + END IF + END IF + u = CD_ZERO + dl = CD_ZERO + END SUBROUTINE crease_band + + PURE SUBROUTINE crease_fillet(u, dl, after, h, hp, hpp) + !! h(u) = (dl - |u|)^3/(6 dl^2) and its first and second derivatives; after: the query + !! cell lies after the line (u >= 0), so that at u = 0 the first derivative is the + !! one-sided value of that cell. + REAL(wp), INTENT(IN) :: u, dl + LOGICAL, INTENT(IN) :: after + REAL(wp), INTENT(OUT) :: h, hp, hpp + REAL(wp) :: r + r = dl - ABS(u) + h = r**3/(6.0_wp*dl*dl) + hp = r*r/(2.0_wp*dl*dl) + IF (after) hp = -hp + hpp = r/(dl*dl) + END SUBROUTINE crease_fillet + + PURE SUBROUTINE x_jump(bathy, k, j, dl, jump, active) + !! Slope jump of grid row j across the interior x line k (right slope less left + !! slope of z_floor = -depth); zero, and active unchanged, when the fillet of width dl + !! would move the surface by no more than CD_BATHY_CREASE_MIN_HEIGHT. active is set otherwise. + TYPE(CD_BathymetryType), INTENT(IN) :: bathy + INTEGER, INTENT(IN) :: k, j + REAL(wp), INTENT(IN) :: dl + REAL(wp), INTENT(OUT) :: jump + LOGICAL, INTENT(INOUT) :: active + jump = (bathy%depth(k, j) - bathy%depth(k + 1, j))/(bathy%x(k + 1) - bathy%x(k)) - & + (bathy%depth(k - 1, j) - bathy%depth(k, j))/(bathy%x(k) - bathy%x(k - 1)) + IF (ABS(jump)*dl/6.0_wp > CD_BATHY_CREASE_MIN_HEIGHT) THEN + active = .TRUE. + ELSE + jump = CD_ZERO + END IF + END SUBROUTINE x_jump + + PURE SUBROUTINE y_jump(bathy, i, k, dl, jump, active) + !! Slope jump of grid column i across the interior y line k (see x_jump). + TYPE(CD_BathymetryType), INTENT(IN) :: bathy + INTEGER, INTENT(IN) :: i, k + REAL(wp), INTENT(IN) :: dl + REAL(wp), INTENT(OUT) :: jump + LOGICAL, INTENT(INOUT) :: active + jump = (bathy%depth(i, k) - bathy%depth(i, k + 1))/(bathy%y(k + 1) - bathy%y(k)) - & + (bathy%depth(i, k - 1) - bathy%depth(i, k))/(bathy%y(k) - bathy%y(k - 1)) + IF (ABS(jump)*dl/6.0_wp > CD_BATHY_CREASE_MIN_HEIGHT) THEN + active = .TRUE. + ELSE + jump = CD_ZERO + END IF + END SUBROUTINE y_jump + SUBROUTINE locate_axis(axis, q, i0, t, clamped) REAL(wp), INTENT(IN) :: axis(:), q INTEGER, INTENT(OUT) :: i0 diff --git a/src/CableDyn_DeckDriver.f90 b/src/CableDyn_DeckDriver.f90 index f51d51c5..b57ea388 100644 --- a/src/CableDyn_DeckDriver.f90 +++ b/src/CableDyn_DeckDriver.f90 @@ -40,7 +40,7 @@ MODULE CableDyn_DeckDriver CD_STATIC_OK, CD_STATIC_BADINPUT USE CableDyn_Bathymetry, ONLY: CD_BathymetryType, CD_Init_Bathymetry, CD_End_Bathymetry, & CD_Bathymetry_Is_Initialized, CD_Bathymetry_Floor, & - CD_Bathymetry_Floor_Gradient, CD_BATHY_OK + CD_Bathymetry_Floor_Gradient, CD_Bathymetry_Grid_Floor, CD_BATHY_OK USE CableDyn_Line, ONLY: CD_LineType, CD_LineSection, CD_Build_Line_Mesh, & CD_Nodal_Seabed_Stiffness, CD_LINE_OK USE CableDyn_Catenary, ONLY: CD_Catenary_Seed, CD_CAT_OK, CD_CAT_NOSEED @@ -1548,7 +1548,7 @@ RECURSIVE SUBROUTINE build_one_hermite_cable(ln, sections, types, points, opts, REAL(wp) :: saddle_res CHARACTER(320) :: saddle_notes LOGICAL :: primary_done, primary_inadmissible, tolerance_note, stable, kink_refined, sequence_done - LOGICAL :: primary_walked, walk_rejected + LOGICAL :: primary_walked, walk_rejected, primary_walk_planar ! Why the bow behind the fairlead was not reached (bow_route), blank when not tried. CHARACTER(1024) :: bow_msg, refine_msg ! Set when the deck-mesh equilibrium failed the stability test and the refined one passed. @@ -2003,6 +2003,7 @@ RECURSIVE SUBROUTINE build_one_hermite_cable(ln, sections, types, points, opts, sym_broken = .FALSE. planar_unstable = .FALSE. walk_rejected = .FALSE. + primary_walk_planar = .TRUE. saddle_tol_note = .FALSE. saddle_kink = .FALSE. saddle_stab = .FALSE. @@ -2393,13 +2394,14 @@ RECURSIVE SUBROUTINE build_one_hermite_cable(ln, sections, types, points, opts, static_tol, l0_am, ea_am, ei_am, w_am, q_static, curv, fixed_am, & applied_scale, diag, res, iters, es, em, primary_inadmissible, & tolerance_note, kink_refined, bathymetry=bathymetry, cur_obj=cur_obj, & - walked=primary_walked) + walked=primary_walked, walk_planar=primary_walk_planar) ELSE CALL hermite_static_primary(anchor, fairlead, l0, ea, ei, w, diam, dry_b, fixed_dofs, contact_enabled, & contact_z, frame_cs, endconn_k, endconn_d0_local, endconn_mode, opts, & static_tol, l0_am, ea_am, ei_am, w_am, q_static, curv, fixed_am, & applied_scale, diag, res, iters, es, em, primary_inadmissible, & - tolerance_note, kink_refined, cur_obj=cur_obj, walked=primary_walked) + tolerance_note, kink_refined, cur_obj=cur_obj, walked=primary_walked, & + walk_planar=primary_walk_planar) END IF IF (es == CD_HCSTAT_OK) THEN ! adaptive_mesh refines while the resolution screen is fragile, up to its cap; an @@ -2556,6 +2558,17 @@ RECURSIVE SUBROUTINE build_one_hermite_cable(ln, sections, types, points, opts, '. Catenary-continuation route: '//TRIM(short_message(primary_msg, 360))// & '. Mesh-sequenced route: '//TRIM(short_message(sequence_msg, 360))); RETURN END IF + ! Over a seabed that is not planar under the line the walk started from the plane + ! fitted to it: that the line cannot hang as a catenary is not proven there. + IF (walk_rejected .AND. .NOT. primary_walk_planar) THEN + CALL fail_solve(ErrStat, ErrMsg, 'finite-EI cable static solve found no admissible equilibrium over '// & + 'the bathymetry: no catenary clears the plane fitted to the bathymetry along the chord, '// & + 'and the anchor walk toward an equilibrium held by the bending stiffness did not reach '// & + 'an accepted state ('// & + TRIM(short_message(primary_msg, 360))//'); mesh-sequenced route: '// & + TRIM(short_message(sequence_msg, 240))//'; check the line length and the seabed under it') + RETURN + END IF IF (walk_rejected) THEN CALL fail_solve(ErrStat, ErrMsg, 'finite-EI cable static solve found no admissible planar equilibrium '// & 'clear of the seabed: the net-heavy line is too long for its span to hang as a catenary, '// & @@ -4092,7 +4105,7 @@ RECURSIVE SUBROUTINE hermite_static_primary(anchor, fairlead, l0, ea, ei, w, dia endconn_mode, opts, static_tol, l0_am, ea_am, ei_am, w_am, q_static, & curv, fixed_am, applied_scale, diag, res, iters, ErrStat, ErrMsg, & inadmissible, tolerance_note, kink_refined, bathymetry, refined_pass, & - cur_obj, walked, fold_walk, stability_refine) + cur_obj, walked, fold_walk, stability_refine, walk_planar) !! Primary finite-EI static route of a deck cable (the OrcaFlex/MoorPy practice of !! "catenary statics, then full statics"): !! @@ -4100,7 +4113,9 @@ RECURSIVE SUBROUTINE hermite_static_primary(anchor, fairlead, l0, ea, ei, w, dia !! segments (signed submerged weight, so buoyancy sections are included), on the !! declared seabed plane -- flat WtrDpth, or the plane fitted to a structured !! bathymetry along the chord -- with the anchor at its actual height, or as a - !! line hung in mid-water when no seabed is declared; + !! line hung in mid-water when no seabed is declared; over a bathymetry that is + !! not a plane along the chord, the seed nodes deeper below the actual bed than + !! their static penalty penetration are draped onto it (drape_seed_on_bed); !! 2. trace the bending-stiffness family EI(lambda) = lambda*EI from a stiffness !! fraction whose bending length is below the element length up to lambda = 1 !! (CD_HermiteCable_Static_Solve_Continuation), with every load at full value; @@ -4113,7 +4128,9 @@ RECURSIVE SUBROUTINE hermite_static_primary(anchor, fairlead, l0, ea, ei, w, dia !! ErrStat follows CD_HCSTAT_*. inadmissible is set when no catenary clears the seabed !! (a heavy line longer than its horizontal span plus rise on a planar seabed) and the !! anchor walk (seed_walk, walk_anchor) reached no equilibrium held by the bending - !! stiffness either; callers fail closed naming the geometry, without fallback. + !! stiffness either; callers fail closed naming the geometry, without fallback. Over a + !! non-planar bathymetry the walk also runs (the excess length may rest in the dips of + !! the bed), but its failure proves nothing and leaves inadmissible unset. !! walked (optional) is set when the returned state was reached by that walk. !! fold_walk (optional, flat seabed): trace the bow behind the fairlead instead. The anchor is !! moved to the far side of the fairlead, where the line hangs as a lazy wave whose arch @@ -4158,6 +4175,9 @@ RECURSIVE SUBROUTINE hermite_static_primary(anchor, fairlead, l0, ea, ei, w, dia TYPE(CD_HermiteStaticCurrentType), INTENT(IN), OPTIONAL :: cur_obj ! Set when the returned state was reached by walking the anchor (see seed_walk). LOGICAL, INTENT(OUT), OPTIONAL :: walked + ! Whether the seabed under the line is planar (see planar_bed): a failed walk proves + ! the line too long for its span only then. + LOGICAL, INTENT(OUT), OPTIONAL :: walk_planar ! Trace the bow behind the fairlead (see fold_walk above). LOGICAL, INTENT(IN), OPTIONAL :: fold_walk ! Go straight to the refined repetition (see stability_refine above). @@ -4182,11 +4202,11 @@ RECURSIVE SUBROUTINE hermite_static_primary(anchor, fairlead, l0, ea, ei, w, dia CHARACTER(400) :: walk_msg_c REAL(wp) :: walk_d, a_seed(3) CHARACTER(512) :: walk_msg - LOGICAL :: tensile, refine_all, planar_bed + LOGICAL :: tensile, refine_all, planar_bed, walk_needed REAL(wp) :: h_target REAL(wp) :: origin(2), a_l(3), f_l(3), seabed_z, seabed_slope, horizontal_tension, grounded_length REAL(wp) :: lambda0, ratio, span(2), span_len, t, xg, yg, zf, sx, sz, sxx, sxz, xl, yl - REAL(wp) :: res_cont, cont_tol, phi, penetration, zfit(NFIT), fit_misfit, fine_limit + REAL(wp) :: res_cont, cont_tol, phi, penetration, zfit(NFIT), fit_misfit, fine_limit, seed_bed, anchor_bed REAL(wp), ALLOCATABLE :: pos(:), q_seed(:), q_cont(:), curv_cont(:), knnode(:), tdir(:, :), stretch(:) CHARACTER(512) :: em @@ -4196,6 +4216,7 @@ RECURSIVE SUBROUTINE hermite_static_primary(anchor, fairlead, l0, ea, ei, w, dia tolerance_note = .FALSE. kink_refined = .FALSE. IF (PRESENT(walked)) walked = .FALSE. + IF (PRESENT(walk_planar)) walk_planar = .TRUE. fold = .FALSE. IF (PRESENT(fold_walk)) fold = fold_walk applied_scale = 1 @@ -4260,15 +4281,28 @@ RECURSIVE SUBROUTINE hermite_static_primary(anchor, fairlead, l0, ea, ei, w, dia ! 1. exact elastic catenary seed (anchor = node 1, fairlead = node nnode) planar_bed = .NOT. PRESENT(bathymetry) .OR. & fit_misfit <= 1.0e-6_wp*MAX(CD_ONE, SUM(l0), ABS(seabed_z)) + IF (PRESENT(walk_planar)) walk_planar = planar_bed + ! Bed height under the anchor (a non-planar bathymetry; see the anchor walk). + anchor_bed = seabed_z + IF (contact_enabled .AND. .NOT. planar_bed) THEN + xg = frame_cs(1)*a_l(1) - frame_cs(2)*a_l(2) + yg = frame_cs(2)*a_l(1) + frame_cs(1)*a_l(2) + CALL CD_Bathymetry_Floor(bathymetry, xg, yg, anchor_bed, es, em) + IF (es /= CD_BATHY_OK) THEN + ErrStat = CD_HCSTAT_NOCONVERGE + ErrMsg = 'bathymetry query for the catenary seed failed: '//TRIM(em); RETURN + END IF + END IF ALLOCATE (pos(3*nnode), q_seed(6*nnode)) ! A line too long for its span has no EI = 0 (catenary) equilibrium clear of the seabed, ! but its bending stiffness can hold one (a bow in the vertical plane carrying the excess ! length). Such a state is reached by displacement control, as a line is laid: the ! anchor is moved back along the chord until the catenary exists, the line is solved - ! there, and the anchor is walked back to its position (walk_anchor below). Over a - ! planar seabed (flat, or a structured bathymetry that is a plane along the chord and - ! behind the anchor), on which the walked anchor keeps its height above the bed. - walk_ok = contact_enabled .AND. planar_bed + ! there, and the anchor is walked back to its position (walk_anchor below). The walked + ! anchor keeps its height above the bed: on the plane continued behind the anchor over + ! a planar seabed (flat, or a structured bathymetry that is a plane along the chord and + ! behind the anchor), on the bathymetry itself otherwise. + walk_ok = contact_enabled span_len = NORM2(a_l(1:2) - f_l(1:2)) IF (span_len <= 1.0e-6_wp*SUM(l0)) walk_ok = .FALSE. ! The bow behind the fairlead is traced over a flat seabed only (the bed must continue @@ -4294,23 +4328,37 @@ RECURSIVE SUBROUTINE hermite_static_primary(anchor, fairlead, l0, ea, ei, w, dia a_seed(3) = a_l(3) - seabed_slope*walk_d ! The bow behind the fairlead: the anchor mirrored about the fairlead, as far back. IF (fold) a_seed(1:2) = f_l(1:2) + (span_len + walk_d)*(f_l(1:2) - a_l(1:2))/span_len - IF (PRESENT(bathymetry)) THEN + END IF + seed_bed = seabed_z - seabed_slope*walk_d + IF (k_walk > 0 .AND. PRESENT(bathymetry)) THEN + xg = frame_cs(1)*a_seed(1) - frame_cs(2)*a_seed(2) + yg = frame_cs(2)*a_seed(1) + frame_cs(1)*a_seed(2) + CALL CD_Bathymetry_Floor(bathymetry, xg, yg, zf, es, em) + IF (planar_bed) THEN ! The bathymetry must continue the plane behind the anchor (it is held flat past ! the edge of its grid). - xg = frame_cs(1)*a_seed(1) - frame_cs(2)*a_seed(2) - yg = frame_cs(2)*a_seed(1) + frame_cs(1)*a_seed(2) - CALL CD_Bathymetry_Floor(bathymetry, xg, yg, zf, es, em) IF (es /= CD_BATHY_OK .OR. ABS(zf - (seabed_z - seabed_slope*walk_d)) > & 1.0e-6_wp*MAX(CD_ONE, SUM(l0), ABS(seabed_z))) THEN CALL walk_failed('the bathymetry does not continue its plane behind the anchor, where the '// & 'bending-supported equilibrium would be traced from') RETURN END IF + ELSE + IF (es /= CD_BATHY_OK) THEN + CALL walk_failed('the bathymetry behind the anchor, where the bending-supported equilibrium '// & + 'would be traced from, could not be queried ('//TRIM(em)//')') + RETURN + END IF + ! Any other bathymetry: the walked anchor keeps its height above the bed under it, + ! and the catenary seed is laid from there along the fitted slope (and draped onto + ! the bed below; see drape_seed_on_bed). + a_seed(3) = zf + (a_l(3) - anchor_bed) + seed_bed = zf END IF END IF IF (contact_enabled) THEN CALL CD_Catenary_Seed(a_seed, f_l, l0, ea, w, pos, horizontal_tension, grounded_length, es, em, & - seabed_z=seabed_z - seabed_slope*walk_d, seabed_slope=seabed_slope) + seabed_z=seed_bed, seabed_slope=seabed_slope) ELSE CALL CD_Catenary_Seed(a_seed, f_l, l0, ea, w, pos, horizontal_tension, grounded_length, es, em, & suspended=.TRUE.) @@ -4318,19 +4366,33 @@ RECURSIVE SUBROUTINE hermite_static_primary(anchor, fairlead, l0, ea, ei, w, dia IF (es /= CD_CAT_OK) THEN ErrStat = CD_HCSTAT_NOCONVERGE ErrMsg = 'catenary seed unavailable: '//TRIM(em) - ! Proven for a planar seabed under the line: a flat one, or a bathymetry whose profile - ! in the vertical plane of the line is straight (a uniform slope along the chord). - inadmissible = es == CD_CAT_NOSEED .AND. contact_enabled .AND. planar_bed .AND. & - ALL(w >= CD_ZERO) .AND. ANY(w > CD_ZERO) + ! A net-heavy line too long to lie in the vertical plane over the seabed plane: the + ! anchor walk traces the equilibrium its bending stiffness holds. That no catenary + ! equilibrium exists is proven for a planar seabed under the line only: a flat one, + ! or a bathymetry whose profile in the vertical plane of the line is straight (a + ! uniform slope along the chord). Over any other bathymetry the excess length may + ! rest in its dips, and the mesh-sequenced route still runs when the walk fails. + walk_needed = es == CD_CAT_NOSEED .AND. contact_enabled .AND. ALL(w >= CD_ZERO) .AND. ANY(w > CD_ZERO) + inadmissible = walk_needed .AND. planar_bed IF (k_walk == 0) walk_msg = ErrMsg - IF (walk_ok .AND. (inadmissible .OR. k_walk > 0)) CYCLE seed_walk + IF (walk_ok .AND. (walk_needed .OR. k_walk > 0)) CYCLE seed_walk RETURN END IF ! A catenary that closes the endpoints only by passing through the seabed is not an ! equilibrium. On a planar bed (flat, or a bathymetry whose profile under the chord is ! straight) this means that no in-plane EI = 0 equilibrium clears the bed: the - ! (net-heavy) line is too long for its span to hang as a catenary. - IF (contact_enabled) THEN + ! (net-heavy) line is too long for its span to hang as a catenary. Over any other + ! bathymetry the seed, laid on the plane fitted along the chord, meets the actual bed + ! wherever that rises above the plane (roughness, a bump or a ridge under the line): + ! those nodes are draped onto the bed instead (drape_seed_on_bed), and the bending- + ! stiffness continuation, which queries the full surface, settles the contact. + IF (contact_enabled .AND. .NOT. planar_bed) THEN + CALL drape_seed_on_bed(es, em) + IF (es /= CD_BATHY_OK) THEN + ErrStat = CD_HCSTAT_NOCONVERGE + ErrMsg = 'bathymetry query for the catenary seed failed: '//TRIM(em); RETURN + END IF + ELSE IF (contact_enabled) THEN penetration = CD_ZERO DO i = 1, nnode ! bed height along the chord, measured from the anchor toward the fairlead (signed: @@ -4580,9 +4642,36 @@ SUBROUTINE walk_failed(reason) CHARACTER(*), INTENT(IN) :: reason ErrStat = CD_HCSTAT_NOCONVERGE ErrMsg = TRIM(walk_msg)//'; '//TRIM(reason) - inadmissible = .TRUE. + ! Proven only over a planar seabed (see seed_walk); over any other bathymetry the + ! mesh-sequenced route still runs. + inadmissible = planar_bed END SUBROUTINE walk_failed + SUBROUTINE drape_seed_on_bed(es_d, em_d) + !! Drape the catenary seed pos, laid on the plane fitted along the chord to a non-planar + !! bathymetry, onto the actual bed: every interior node deeper below the bed than its + !! static penalty penetration (nodal submerged weight over the nodal contact stiffness + !! kBot*Diam*length) is lifted onto it; a node within that depth stays where the seed + !! put it, as the contact solve would settle it there. The ends stay held. + INTEGER, INTENT(OUT) :: es_d + CHARACTER(*), INTENT(OUT) :: em_d + INTEGER :: kk + REAL(wp) :: zb, xq, yq, kn, wn, sink + es_d = CD_BATHY_OK + em_d = '' + DO kk = 2, nnode - 1 + xq = frame_cs(1)*pos(3*kk - 2) - frame_cs(2)*pos(3*kk - 1) + yq = frame_cs(2)*pos(3*kk - 2) + frame_cs(1)*pos(3*kk - 1) + CALL CD_Bathymetry_Floor(bathymetry, xq, yq, zb, es_d, em_d) + IF (es_d /= CD_BATHY_OK) RETURN + kn = 0.5_wp*opts%kbot*(diam(kk - 1)*l0(kk - 1) + diam(kk)*l0(kk)) + wn = 0.5_wp*(w(kk - 1)*l0(kk - 1) + w(kk)*l0(kk)) + sink = CD_ZERO + IF (kn > CD_ZERO) sink = MAX(wn, CD_ZERO)/kn + IF (pos(3*kk) < zb - sink) pos(3*kk) = zb + END DO + END SUBROUTINE drape_seed_on_bed + SUBROUTINE walk_anchor() !! Displacement control of a line too long for its span: q_cont is its equilibrium !! with the anchor at a_seed, walk_d back along the chord; the anchor is moved back to @@ -4615,8 +4704,9 @@ SUBROUTINE walk_anchor() REAL(wp) :: tw, dt, dt_prev, a_cur(3), a_new(3), res_w, wgt, tol_w INTEGER :: it_w, es_w, k, total_it LOGICAL :: have_prev, energy, folded, fold_now - REAL(wp) :: fit, path_len, r_td(2), p, up(3), tl - INTEGER :: k_td, kk + REAL(wp) :: fit, path_len, r_td(2), p, up(3), tl, xb_w, yb_w, zb_w + INTEGER :: k_td, kk, es_b + CHARACTER(512) :: em_b CHARACTER(512) :: em_w ALLOCATE (q_try(6*nnode), q_new(6*nnode), q_prev(6*nnode), sref(nnode), curv_w(nnode)) sref(1) = CD_ZERO @@ -4691,8 +4781,22 @@ SUBROUTINE walk_anchor() path_len = NORM2(a_l - a_seed) IF (k_td > 1) dt = MIN(dt, MAX(WALK_DT_MIN, -fit/path_len)) END IF - a_cur = a_seed + tw*(a_l - a_seed) + a_cur = q_cont(1:3) a_new = a_seed + (tw + dt)*(a_l - a_seed) + ! Over a non-planar bathymetry the walked anchor follows the bed under it at the + ! anchor's own height above the bed (a straight path would cut through a ridge or + ! leave a dip); it ends at a_l, where that height is the deck's. + IF (.NOT. planar_bed .AND. PRESENT(bathymetry)) THEN + xb_w = frame_cs(1)*a_new(1) - frame_cs(2)*a_new(2) + yb_w = frame_cs(2)*a_new(1) + frame_cs(1)*a_new(2) + CALL CD_Bathymetry_Floor(bathymetry, xb_w, yb_w, zb_w, es_b, em_b) + IF (es_b /= CD_BATHY_OK) THEN + iters = iters + total_it + CALL walk_failed('the bathymetry under the walked anchor could not be queried ('//TRIM(em_b)//')') + RETURN + END IF + a_new(3) = zb_w + (a_l(3) - anchor_bed) + END IF IF (have_prev) THEN q_try = q_cont + (q_cont - q_prev)*(dt/dt_prev) ELSE @@ -13003,18 +13107,25 @@ SUBROUTINE reverse_line_sections(sections, line_id) END DO END SUBROUTINE reverse_line_sections - SUBROUTINE check_fixed_point_above_seabed(pt, z_floor, what, ErrStat, ErrMsg) + SUBROUTINE check_fixed_point_above_seabed(pt, z_floor, what, ErrStat, ErrMsg, z_grid) !! A Fixed point (anchor) must sit on or above the seabed. A point below it pins the !! attached line inside the penalty seabed, which is not a physical configuration !! (MoorDyn v2 rejects an anchor below the water depth the same way). An anchor within !! the practical seabed tolerance max(1 mm, 1e-5 |z_floor|) of the seabed, above or !! below (tabulated depths, rounded deck coordinates), rests on the seabed: its z is set !! to the seabed elevation. Further below is rejected. + !! z_grid (bathymetry): the bilinear surface of the tabulated depths, which the rounding + !! of a crease moves by up to a sixth of its slope jump times the band half-width (the + !! roundings of two lines add where their bands cross); an + !! anchor at the tabulated depth (within the tolerance of z_grid) rests on the seabed as + !! well and is placed on the rounded surface z_floor. An anchor between the two surfaces + !! but near neither is treated by its distance to z_floor alone. TYPE(DeckPoint), INTENT(INOUT) :: pt REAL(wp), INTENT(IN) :: z_floor CHARACTER(*), INTENT(IN) :: what INTEGER, INTENT(OUT) :: ErrStat CHARACTER(*), INTENT(OUT) :: ErrMsg + REAL(wp), INTENT(IN), OPTIONAL :: z_grid CHARACTER(32) :: zs, fs, ts REAL(wp) :: tol @@ -13025,6 +13136,12 @@ SUBROUTINE check_fixed_point_above_seabed(pt, z_floor, what, ErrStat, ErrMsg) pt%pos(3) = z_floor RETURN END IF + IF (PRESENT(z_grid)) THEN + IF (ABS(pt%pos(3) - z_grid) <= tol*(CD_ONE + 1.0e-9_wp)) THEN + pt%pos(3) = z_floor + RETURN + END IF + END IF IF (pt%pos(3) > z_floor) RETURN WRITE (zs, '(G0.8)') pt%pos(3) WRITE (fs, '(G0.8)') z_floor @@ -13044,7 +13161,7 @@ SUBROUTINE check_fixed_points_on_bathymetry(points, bathymetry, ErrStat, ErrMsg) INTEGER, INTENT(OUT) :: ErrStat CHARACTER(*), INTENT(OUT) :: ErrMsg INTEGER :: i, es - REAL(wp) :: z_floor + REAL(wp) :: z_floor, z_grid CHARACTER(160) :: em ErrStat = 0; ErrMsg = '' @@ -13052,8 +13169,10 @@ SUBROUTINE check_fixed_points_on_bathymetry(points, bathymetry, ErrStat, ErrMsg) IF (TRIM(points(i)%ptype) /= 'fixed') CYCLE CALL CD_Bathymetry_Floor(bathymetry, points(i)%pos(1), points(i)%pos(2), z_floor, es, em) IF (es /= CD_BATHY_OK) CYCLE + CALL CD_Bathymetry_Grid_Floor(bathymetry, points(i)%pos(1), points(i)%pos(2), z_grid, es, em) + IF (es /= CD_BATHY_OK) CYCLE CALL check_fixed_point_above_seabed(points(i), z_floor, 'the bathymetry seabed at its (x, y), z', & - ErrStat, ErrMsg) + ErrStat, ErrMsg, z_grid=z_grid) IF (ErrStat /= 0) RETURN END DO END SUBROUTINE check_fixed_points_on_bathymetry diff --git a/src/CableDyn_HermiteCableDynamic.f90 b/src/CableDyn_HermiteCableDynamic.f90 index 006360ff..c039dd69 100644 --- a/src/CableDyn_HermiteCableDynamic.f90 +++ b/src/CableDyn_HermiteCableDynamic.f90 @@ -68,9 +68,10 @@ MODULE CableDyn_HermiteCableDynamic USE CableDyn_SeabedContact, ONLY: CD_Seabed_Normal_Law, CD_Seabed_Contact_Gate, CD_SEABED_CONTACT_BLEND, & CD_Seabed_Friction_Stick_Slip, CD_Seabed_Friction_Aniso, & CD_Seabed_Friction_Mu_Dir, CD_FRICTION_STICK_SLIP, CD_Seabed_End_Support, & - CD_Seabed_End_Element_Share + CD_Seabed_End_Element_Share, CD_Seabed_Normal_Contact USE CableDyn_Bathymetry, ONLY: CD_BathymetryType, CD_Bathymetry_Is_Initialized, & - CD_Bathymetry_Floor_Gradient, CD_End_Bathymetry, CD_BATHY_OK + CD_Bathymetry_Floor_Gradient, CD_End_Bathymetry, CD_BATHY_OK, & + CD_Bathymetry_Rotate_Curvature USE CableDyn_HermiteTorsion, ONLY: CD_HermiteTorsionType, CD_HermiteTorsion_Line, CD_HermiteTorsion_Unwrap, & CD_HermiteTorsion_Compliance, CD_HermiteTorsion_Validate, CD_HTORS_OK, & CD_HTORS_MAX_STEP, CD_HermiteTorsionWorkType, CD_HermiteTorsion_Work_Init, & @@ -4526,6 +4527,7 @@ SUBROUTINE CD_HermiteCable_Dyn_End_Force(model, node, force, ErrStat, ErrMsg) REAL(wp) :: qe(12), ve(12), fe(12), fdrag(12), fdamp(12), energy, fdry(4), kdry(4, 4), r3(3), gate, gate_gap REAL(wp) :: dry_wl, dry_b, dry_r, gap, normal, normal_gap, z_floor, xg, yg, gxg, gyg REAL(wp) :: gx, gy, sfac, nvec(3), vn, rk(3), jrel(3, 3), jtan(3, 3) + REAL(wp) :: curv_e(3), fcrease_e(3), kcrease_e(3, 3) INTEGER :: e, i0, iz, zslot, es, k LOGICAL :: dry, has_jac CHARACTER(200) :: em2 @@ -4586,12 +4588,21 @@ SUBROUTINE CD_HermiteCable_Dyn_End_Force(model, node, force, ErrStat, ErrMsg) IF (model%has_contact_bathymetry) THEN xg = model%contact_frame_c*model%q(iz - 2) - model%contact_frame_s*model%q(iz - 1) yg = model%contact_frame_s*model%q(iz - 2) + model%contact_frame_c*model%q(iz - 1) - CALL CD_Bathymetry_Floor_Gradient(model%contact_bathymetry, xg, yg, z_floor, gxg, gyg, es, em2) + CALL CD_Bathymetry_Floor_Gradient(model%contact_bathymetry, xg, yg, z_floor, gxg, gyg, es, em2, & + crease_curvature=curv_e) IF (es /= CD_BATHY_OK) THEN ErrStat = CD_HCDYN_NOCONVERGE; ErrMsg = 'CD_HermiteCable_Dyn_End_Force: '//TRIM(em2); RETURN END IF gx = model%contact_frame_c*gxg + model%contact_frame_s*gyg gy = -model%contact_frame_s*gxg + model%contact_frame_c*gyg + ! the elastic force in a rounded crease (see assemble_contact) + IF (ANY(ABS(curv_e) > CD_ZERO)) THEN + CALL crease_contact_increment(z_floor - model%q(iz), gx, gy, model%contact_kn(node), & + CD_Bathymetry_Rotate_Curvature(curv_e, [model%contact_frame_c, & + model%contact_frame_s]), & + fcrease_e, kcrease_e) + r3 = r3 - fcrease_e + END IF END IF ! frictionless: along the upward floor normal, at the normal penetration and velocity sfac = SQRT(CD_ONE + gx*gx + gy*gy) @@ -5817,6 +5828,8 @@ SUBROUTINE assemble_contact(model, q_cfg, v_cfg, want_residual, want_tangent, Er REAL(wp) :: sfac, nvec(3), vn, dnormal_dv(3) REAL(wp) :: d_fr(2), mu_c REAL(wp) :: ffr(2), dfr_dd(2, 2), dfr_dc(2) + REAL(wp) :: curv_g(3), curv_l(3), fcrease(3), kcrease(3, 3) + LOGICAL :: creased CHARACTER(200) :: em ErrStat = CD_HCDYN_OK; ErrMsg = '' @@ -5831,15 +5844,25 @@ SUBROUTINE assemble_contact(model, q_cfg, v_cfg, want_residual, want_tangent, Er xl = q_cfg(ix); yl = q_cfg(iy) xg = model%contact_frame_c*xl - model%contact_frame_s*yl yg = model%contact_frame_s*xl + model%contact_frame_c*yl - CALL CD_Bathymetry_Floor_Gradient(model%contact_bathymetry, xg, yg, z_floor, gxg, gyg, es, em) + CALL CD_Bathymetry_Floor_Gradient(model%contact_bathymetry, xg, yg, z_floor, gxg, gyg, es, em, & + crease_curvature=curv_g) IF (es /= CD_BATHY_OK) THEN ErrStat = CD_HCDYN_NOCONVERGE; ErrMsg = 'bathymetry query failed: '//TRIM(em); RETURN END IF ! Chain the global floor gradient through the inverse local-to-global heading. gx = model%contact_frame_c*gxg + model%contact_frame_s*gyg gy = -model%contact_frame_s*gxg + model%contact_frame_c*gyg + creased = ANY(ABS(curv_g) > CD_ZERO) ELSE z_floor = model%seabed_z + creased = .FALSE. + END IF + ! In a rounded crease of the bathymetry the elastic force is the gradient of the + ! penalty potential of the static solve (CD_Seabed_Normal_Contact with the curvature): + ! its departure from the normal force F n, and its tangent, are added below. + IF (creased) THEN + curv_l = CD_Bathymetry_Rotate_Curvature(curv_g, [model%contact_frame_c, model%contact_frame_s]) + CALL crease_contact_increment(z_floor - q_cfg(iz), gx, gy, model%contact_kn(i), curv_l, fcrease, kcrease) END IF sfac = SQRT(CD_ONE + gx*gx + gy*gy) @@ -5869,6 +5892,16 @@ SUBROUTINE assemble_contact(model, q_cfg, v_cfg, want_residual, want_tangent, Er END DO END DO END IF + IF (creased) THEN + IF (want_residual) model%ws_R(ix:iz) = model%ws_R(ix:iz) - fcrease + IF (want_tangent) THEN + DO jc = 1, 3 + DO jr = 1, 3 + CALL scatter_contact_band(model%ws_Kb, ix + jr - 1, ix + jc - 1, kcrease(jr, jc)) + END DO + END DO + END IF + END IF IF (.NOT. model%fr_active) CYCLE ! Stick-slip friction spring to the committed anchor (CD_Seabed_Friction_Stick_Slip): @@ -5902,6 +5935,19 @@ SUBROUTINE assemble_contact(model, q_cfg, v_cfg, want_residual, want_tangent, Er END DO END SUBROUTINE assemble_contact + PURE SUBROUTINE crease_contact_increment(gap_v, gx, gy, kn, curv, fdelta, kdelta) + !! Elastic contact force and residual tangent of a node in a rounded bathymetry crease + !! (CD_Seabed_Normal_Contact with the surface curvature) less those of the normal + !! force F n at the same point: the increment added to the normal-force assembly. + REAL(wp), INTENT(IN) :: gap_v, gx, gy, kn, curv(3) + REAL(wp), INTENT(OUT) :: fdelta(3), kdelta(3, 3) + REAL(wp) :: fp(3), kp(3, 3) + CALL CD_Seabed_Normal_Contact(gap_v, gx, gy, kn, fdelta, kdelta, curvature=curv) + CALL CD_Seabed_Normal_Contact(gap_v, gx, gy, kn, fp, kp) + fdelta = fdelta - fp + kdelta = kdelta - kp + END SUBROUTINE crease_contact_increment + LOGICAL FUNCTION held_end_floor_support(model, q_cfg, iend, support, dsupport, inode, nin) RESULT(held) !! Floor reaction carrying the weight of the end element at line end iend (1: node 1, !! 2: node nn) of a model with seabed contact, per unit weight: the floor's normal share diff --git a/src/CableDyn_HermiteCableStatic.f90 b/src/CableDyn_HermiteCableStatic.f90 index ff182a3b..72b20cdc 100644 --- a/src/CableDyn_HermiteCableStatic.f90 +++ b/src/CableDyn_HermiteCableStatic.f90 @@ -45,7 +45,8 @@ MODULE CableDyn_HermiteCableStatic CD_Seabed_Friction_Aniso, CD_Seabed_Friction_Mu_Dir, CD_FRICTION_SPRING, & CD_Seabed_Normal_Contact, CD_Seabed_End_Support, CD_Seabed_End_Element_Share USE CableDyn_Bathymetry, ONLY: CD_BathymetryType, CD_Bathymetry_Is_Initialized, & - CD_Bathymetry_Floor, CD_Bathymetry_Floor_Gradient, CD_BATHY_OK + 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_Hydro, ONLY: CD_Current_Profile_Velocity, CD_HYDRO_OK USE CableDyn_HermiteTorsion, ONLY: CD_HermiteTorsionType, CD_HermiteTorsion_Line, CD_HermiteTorsion_Unwrap, & @@ -1062,6 +1063,7 @@ 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 + 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 ! Frictionless contact on a sloped floor: the force along the upward surface normal @@ -1219,15 +1221,18 @@ RECURSIVE SUBROUTINE newton_step(rnorm, es, em, do_update) DO a = 1, nn gi = 6*(a - 1) + 3 gx = CD_ZERO; gy = CD_ZERO; z_floor = seabed_z + curv_l = CD_ZERO IF (use_bathymetry) THEN xg = contact_cs(1)*q(gi - 2) - contact_cs(2)*q(gi - 1) yg = contact_cs(2)*q(gi - 2) + contact_cs(1)*q(gi - 1) - CALL CD_Bathymetry_Floor_Gradient(bathymetry, xg, yg, z_floor, gxg, gyg, es2, em2) + CALL CD_Bathymetry_Floor_Gradient(bathymetry, xg, yg, z_floor, gxg, gyg, es2, em2, crease_curvature=curv_g) IF (es2 /= CD_BATHY_OK) THEN es = CD_HCSTAT_NOCONVERGE; em = 'bathymetry query failed: '//TRIM(em2); RETURN END IF gx = contact_cs(1)*gxg + contact_cs(2)*gyg gy = -contact_cs(2)*gxg + contact_cs(1)*gyg + ! the curvature of a rounded crease, turned into the solve frame like the gradient + IF (ANY(ABS(curv_g) > CD_ZERO)) curv_l = CD_Bathymetry_Rotate_Curvature(curv_g, contact_cs) END IF pen = z_floor - q(gi) ! The penetration normal to the floor is pen/sfac (sfac = 1 on a level floor). @@ -1250,7 +1255,7 @@ RECURSIVE SUBROUTINE newton_step(rnorm, es, em, do_update) kn_eff = contact_kn(a) IF (use_bathymetry) THEN ! Frictionless: the force acts along the upward normal of the (sloped) floor. - CALL CD_Seabed_Normal_Contact(pen, gx, gy, kn_eff, fcon, jcon) + CALL CD_Seabed_Normal_Contact(pen, gx, gy, kn_eff, fcon, jcon, curvature=curv_l) e_term = seabed_potential(pen/sfac, kn_eff) pi_total = pi_total + e_term pi_abs = pi_abs + e_term diff --git a/src/CableDyn_Model.f90 b/src/CableDyn_Model.f90 index b2eb699f..4d2855c9 100644 --- a/src/CableDyn_Model.f90 +++ b/src/CableDyn_Model.f90 @@ -3622,7 +3622,7 @@ SUBROUTINE CD_Get_Model_EndNodeTangent(model, coupled_slot, k_block, c_block, Er REAL(wp), INTENT(OUT), OPTIONAL :: kv_neighbour(3) INTEGER :: e, node, d0, idx(6), i REAL(wp) :: q2(6), chord(3), ell, tang(3), tt(3, 3), strain, material, tension, ke(3, 3), v_other(3) - REAL(wp) :: z_floor, dfdx, dfdy, gap, fvec(3), jac3(3, 3), damp_force, damp_dgap, damp_dvz + REAL(wp) :: z_floor, dfdx, dfdy, gap, fvec(3), jac3(3, 3), damp_force, damp_dgap, damp_dvz, curv_end(3) k_block = CD_ZERO c_block = CD_ZERO IF (PRESENT(kv_neighbour)) kv_neighbour = CD_ZERO @@ -3683,7 +3683,8 @@ SUBROUTINE CD_Get_Model_EndNodeTangent(model, coupled_slot, k_block, c_block, Er IF (model%has_seabed) THEN ! the end node's seabed contact (its neighbour is the fixed seabed, so no kv term) IF (model%has_bathymetry) THEN - CALL model_floor_gradient(model, model%q(d0), model%q(d0 + 1), z_floor, dfdx, dfdy, ErrStat, ErrMsg) + CALL model_floor_gradient(model, model%q(d0), model%q(d0 + 1), z_floor, dfdx, dfdy, ErrStat, ErrMsg, & + curvature=curv_end) IF (ErrStat /= CD_MODEL_OK) THEN k_block = CD_ZERO c_block = CD_ZERO @@ -3694,9 +3695,10 @@ SUBROUTINE CD_Get_Model_EndNodeTangent(model, coupled_slot, k_block, c_block, Er z_floor = model%seabed_z_floor dfdx = CD_ZERO dfdy = CD_ZERO + curv_end = CD_ZERO END IF gap = z_floor - model%q(d0 + 2) - CALL CD_Seabed_Normal_Contact(gap, dfdx, dfdy, model%seabed_kn(node), fvec, jac3) + CALL CD_Seabed_Normal_Contact(gap, dfdx, dfdy, model%seabed_kn(node), fvec, jac3, curvature=curv_end) k_block = k_block + jac3 IF (model%has_seabed_damping) THEN BLOCK @@ -5603,7 +5605,7 @@ SUBROUTINE model_contributor_load_banded(model, q, v, free, kl, ku, force, jac_q REAL(wp) :: gap, normal, g(2), z_floor, dfdx, dfdy, tangent, dn_dv(3), dfc(2), nvec(3), vn LOGICAL :: sloped REAL(wp) :: d_fr(2), mu_c - REAL(wp) :: damp_force, damp_dgap, damp_dvz + REAL(wp) :: damp_force, damp_dgap, damp_dvz, curv_n(3) REAL(wp) :: q2(6), v2(6), f2(6), jq2(6, 6), jv2(6, 6), ea_d_eff, ea_1_eff, syr_tm, syr_ds LOGICAL :: free_map_ready REAL(wp) :: fluid2(3, 2), accel2(3, 2), wl2(2), dfdv(2, 2) @@ -5654,21 +5656,22 @@ SUBROUTINE model_contributor_load_banded(model, q, v, free, kl, ku, force, jac_q iy = 3*i - 1 iz = 3*i IF (model%has_bathymetry) THEN - CALL model_floor_gradient(model, q(ix), q(iy), z_floor, dfdx, dfdy, ErrStat, ErrMsg) + CALL model_floor_gradient(model, q(ix), q(iy), z_floor, dfdx, dfdy, ErrStat, ErrMsg, curvature=curv_n) IF (ErrStat /= CD_MODEL_OK) RETURN ELSE z_floor = model%seabed_z_floor dfdx = CD_ZERO dfdy = CD_ZERO + curv_n = CD_ZERO END IF gap = z_floor - q(iz) - IF (ABS(dfdx) > CD_ZERO .OR. ABS(dfdy) > CD_ZERO) THEN + IF (ABS(dfdx) > CD_ZERO .OR. ABS(dfdy) > CD_ZERO .OR. ANY(ABS(curv_n) > CD_ZERO)) THEN ! sloped seabed: frictionless contact along the surface normal (the static ! initializer uses the same law, so the initial condition is an equilibrium) BLOCK REAL(wp) :: fvec(3), jac3(3, 3) INTEGER :: ra, cb - CALL CD_Seabed_Normal_Contact(gap, dfdx, dfdy, model%seabed_kn(i), fvec, jac3) + CALL CD_Seabed_Normal_Contact(gap, dfdx, dfdy, model%seabed_kn(i), fvec, jac3, curvature=curv_n) force(ix:iz) = force(ix:iz) + fvec DO cb = 1, 3 DO ra = 1, 3 @@ -5917,11 +5920,11 @@ SUBROUTINE model_contributor_force(model, q, v, force, ErrStat, ErrMsg, end_node IF (model%has_bathymetry) THEN ! sloped seabed: frictionless contact along the surface normal BLOCK - REAL(wp) :: fvec(3), jac3(3, 3), gx, gy - CALL model_floor_gradient(model, q(ix), q(iy), z_floor, gx, gy, ErrStat, ErrMsg) + REAL(wp) :: fvec(3), jac3(3, 3), gx, gy, curv(3) + CALL model_floor_gradient(model, q(ix), q(iy), z_floor, gx, gy, ErrStat, ErrMsg, curvature=curv) IF (ErrStat /= CD_MODEL_OK) RETURN - IF (ABS(gx) > CD_ZERO .OR. ABS(gy) > CD_ZERO) THEN - CALL CD_Seabed_Normal_Contact(z_floor - q(iz), gx, gy, model%seabed_kn(i), fvec, jac3) + IF (ABS(gx) > CD_ZERO .OR. ABS(gy) > CD_ZERO .OR. ANY(ABS(curv) > CD_ZERO)) THEN + CALL CD_Seabed_Normal_Contact(z_floor - q(iz), gx, gy, model%seabed_kn(i), fvec, jac3, curvature=curv) force(slot(ix):slot(iz)) = force(slot(ix):slot(iz)) + fvec CYCLE END IF @@ -6321,17 +6324,20 @@ SUBROUTINE validate_seabed_friction(model, q, v, force, ErrStat, ErrMsg) END IF END SUBROUTINE validate_seabed_friction - SUBROUTINE model_floor_gradient(model, x, y, z_floor, dfdx, dfdy, ErrStat, ErrMsg) + SUBROUTINE model_floor_gradient(model, x, y, z_floor, dfdx, dfdy, ErrStat, ErrMsg, curvature) !! Seabed elevation and gradient of the model's bathymetry, with the bathymetry status - !! mapped to the model's (CD_MODEL_BADINPUT on a failed query). + !! mapped to the model's (CD_MODEL_BADINPUT on a failed query). curvature (optional): + !! the curvature of the crease rounding (CD_Bathymetry_Floor_Gradient). TYPE(CD_ModelType), INTENT(IN) :: model REAL(wp), INTENT(IN) :: x, y REAL(wp), INTENT(OUT) :: z_floor, dfdx, dfdy INTEGER, INTENT(OUT) :: ErrStat CHARACTER(*), INTENT(OUT) :: ErrMsg + REAL(wp), INTENT(OUT), OPTIONAL :: curvature(3) INTEGER :: es CHARACTER(160) :: em - CALL CD_Bathymetry_Floor_Gradient(model%bathymetry, x, y, z_floor, dfdx, dfdy, es, em) + CALL CD_Bathymetry_Floor_Gradient(model%bathymetry, x, y, z_floor, dfdx, dfdy, es, em, & + crease_curvature=curvature) IF (es == CD_BATHY_OK) THEN ErrStat = CD_MODEL_OK ErrMsg = '' diff --git a/src/CableDyn_SeabedContact.f90 b/src/CableDyn_SeabedContact.f90 index 301647a1..30c079c9 100644 --- a/src/CableDyn_SeabedContact.f90 +++ b/src/CableDyn_SeabedContact.f90 @@ -54,7 +54,7 @@ PURE SUBROUTINE CD_Seabed_Normal_Law(gap, stiffness, force, dforce_dgap) END IF END SUBROUTINE CD_Seabed_Normal_Law - PURE SUBROUTINE CD_Seabed_Normal_Contact(gap, dfdx, dfdy, stiffness, force, jac) + PURE SUBROUTINE CD_Seabed_Normal_Contact(gap, dfdx, dfdy, stiffness, force, jac, curvature) !! Frictionless penalty contact with a locally planar seabed z = f(x, y) of gradient !! (dfdx, dfdy). ``gap = f(x, y) - z`` is the vertical penetration; the penetration !! normal to the surface is gap/s, s = sqrt(1 + dfdx^2 + dfdy^2), and the contact force @@ -63,9 +63,17 @@ PURE SUBROUTINE CD_Seabed_Normal_Contact(gap, dfdx, dfdy, stiffness, force, jac) !! the vertical law. ``jac`` is the residual tangent -d(force)/dq = F'(gap/s) n n^T !! (the surface gradient is held fixed over the node, i.e. the bathymetry curvature !! term is omitted). + !! curvature (optional): the second derivatives (f_xx, f_xy, f_yy) of a curved patch of + !! the surface (the rounding of a bathymetry crease). Where it is nonzero the force is + !! the gradient of the penalty potential E(g) of the normal penetration g = gap/s, + !! force = -F(g) dg/dq with dg/dq = (f_x, f_y, -1)/s - gap grad(s)/s^2 (the normal + !! force F n plus F gap grad(s)/s^2, a term of the order of the penetration times the + !! curvature), and jac is the Hessian F' dg dg^T + F d2g/dq2 of that potential (third + !! derivatives of the surface left out), so that the static energy and the force agree. REAL(wp), INTENT(IN) :: gap, dfdx, dfdy, stiffness REAL(wp), INTENT(OUT) :: force(3), jac(3, 3) - REAL(wp) :: s, normal(3), magnitude, dmag + REAL(wp), INTENT(IN), OPTIONAL :: curvature(3) + REAL(wp) :: s, normal(3), magnitude, dmag, hm(2, 2), grad(2), ds(3), dgap(3), dg(3), d2s(2, 2) INTEGER :: a, b s = SQRT(CD_ONE + dfdx*dfdx + dfdy*dfdy) @@ -77,6 +85,24 @@ PURE SUBROUTINE CD_Seabed_Normal_Contact(gap, dfdx, dfdy, stiffness, force, jac) jac(a, b) = dmag*normal(a)*normal(b) END DO END DO + IF (.NOT. PRESENT(curvature)) RETURN + IF (.NOT. ANY(ABS(curvature) > CD_ZERO)) RETURN + hm = RESHAPE([curvature(1), curvature(2), curvature(2), curvature(3)], [2, 2]) + grad = [dfdx, dfdy] + ds = CD_ZERO + ds(1:2) = MATMUL(hm, grad)/s + dgap = [dfdx, dfdy, -CD_ONE] + dg = dgap/s - gap*ds/(s*s) + force = -magnitude*dg + ! d2s/dq2 on (x, y), third derivatives of the surface left out + d2s = (MATMUL(hm, hm) - RESHAPE([ds(1)*ds(1), ds(2)*ds(1), ds(1)*ds(2), ds(2)*ds(2)], [2, 2]))/s + DO b = 1, 3 + DO a = 1, 3 + jac(a, b) = dmag*dg(a)*dg(b) + magnitude*(-dgap(b)*ds(a) - dgap(a)*ds(b) + & + 2.0_wp*gap*ds(a)*ds(b)/s)/(s*s) + END DO + END DO + jac(1:2, 1:2) = jac(1:2, 1:2) + magnitude*(hm/s - gap*d2s/(s*s)) END SUBROUTINE CD_Seabed_Normal_Contact PURE SUBROUTINE CD_Seabed_Contact_Gate(gap, gate, dgate_dgap) diff --git a/src/CableDyn_Static.f90 b/src/CableDyn_Static.f90 index e5257f21..19aa16c8 100644 --- a/src/CableDyn_Static.f90 +++ b/src/CableDyn_Static.f90 @@ -867,7 +867,7 @@ SUBROUTINE eval_seabed(qe, f_contact, add_tangent, es_out, em_out) INTEGER, INTENT(OUT) :: es_out CHARACTER(*), INTENT(OUT) :: em_out INTEGER :: i, ix, iy, iz, a, b - REAL(wp) :: z_floor, dfdx, dfdy, gap, tangent, fvec(3), jac(3, 3), normal_i + REAL(wp) :: z_floor, dfdx, dfdy, gap, tangent, fvec(3), jac(3, 3), normal_i, curv(3), tang_n f_contact = CD_ZERO es_out = 0 @@ -876,8 +876,10 @@ SUBROUTINE eval_seabed(qe, f_contact, add_tangent, es_out, em_out) ix = 3*i - 2 iy = ix + 1 iz = ix + 2 + curv = CD_ZERO IF (bathymetry_active) THEN - CALL CD_Bathymetry_Floor_Gradient(bathymetry, qe(ix), qe(iy), z_floor, dfdx, dfdy, es_out, em_out) + CALL CD_Bathymetry_Floor_Gradient(bathymetry, qe(ix), qe(iy), z_floor, dfdx, dfdy, es_out, em_out, & + crease_curvature=curv) IF (es_out /= CD_BATHY_OK) RETURN ELSE z_floor = z_floor_local @@ -885,7 +887,7 @@ SUBROUTINE eval_seabed(qe, f_contact, add_tangent, es_out, em_out) dfdy = CD_ZERO END IF gap = z_floor - qe(iz) - IF (.NOT. (ABS(dfdx) > CD_ZERO .OR. ABS(dfdy) > CD_ZERO)) THEN + IF (.NOT. (ABS(dfdx) > CD_ZERO .OR. ABS(dfdy) > CD_ZERO .OR. ANY(ABS(curv) > CD_ZERO))) THEN ! level floor: the normal is vertical (the historical flat-floor evaluation) CALL CD_Seabed_Normal_Law(gap, kn(i), f_contact(iz), tangent) IF (add_tangent) CALL add_band(iz, iz, tangent) @@ -895,11 +897,21 @@ SUBROUTINE eval_seabed(qe, f_contact, add_tangent, es_out, em_out) END IF CYCLE END IF - CALL CD_Seabed_Normal_Contact(gap, dfdx, dfdy, kn(i), fvec, jac) + ! (the tangent follows the rounding of a bathymetry crease; zero curvature elsewhere) + CALL CD_Seabed_Normal_Contact(gap, dfdx, dfdy, kn(i), fvec, jac, curvature=curv) f_contact(ix:iz) = fvec ! on a slope the capacity follows the magnitude of the normal reaction (its - ! dependence on the position is left out of the tangent) - IF (friction_active) CALL add_friction(qe, f_contact, add_tangent, i, NORM2(fvec), CD_ZERO) + ! dependence on the position is left out of the tangent); in a crease band the + ! elastic force also carries the curvature term of the potential, so the capacity + ! is the scalar normal law there, as on the Hermite path and in the dynamics + IF (friction_active) THEN + IF (ANY(ABS(curv) > CD_ZERO)) THEN + CALL CD_Seabed_Normal_Law(gap/SQRT(CD_ONE + dfdx*dfdx + dfdy*dfdy), kn(i), normal_i, tang_n) + ELSE + normal_i = NORM2(fvec) + END IF + CALL add_friction(qe, f_contact, add_tangent, i, normal_i, CD_ZERO) + END IF IF (.NOT. add_tangent) CYCLE DO b = 1, 3 DO a = 1, 3 @@ -1228,7 +1240,7 @@ SUBROUTINE CD_Static_Friction_Anchors(q, current, seabed_kn, anchors, ErrStat, E REAL(wp), INTENT(IN), OPTIONAL :: seabed_z_floor TYPE(CD_BathymetryType), INTENT(IN), OPTIONAL :: bathymetry INTEGER :: n_nodes, i, es - REAL(wp) :: z_floor, dfdx, dfdy, normal, tangent, fvec(3), jac(3, 3), f(2), dfd(2, 2), dfc(2) + REAL(wp) :: z_floor, dfdx, dfdy, normal, tangent, fvec(3), jac(3, 3), f(2), dfd(2, 2), dfc(2), curv(3) CHARACTER(120) :: em ErrStat = CD_STATIC_OK ErrMsg = '' @@ -1251,8 +1263,10 @@ SUBROUTINE CD_Static_Friction_Anchors(q, current, seabed_kn, anchors, ErrStat, E z_floor = CD_ZERO dfdx = CD_ZERO dfdy = CD_ZERO + curv = CD_ZERO IF (PRESENT(bathymetry)) THEN - CALL CD_Bathymetry_Floor_Gradient(bathymetry, q(3*i - 2), q(3*i - 1), z_floor, dfdx, dfdy, es, em) + CALL CD_Bathymetry_Floor_Gradient(bathymetry, q(3*i - 2), q(3*i - 1), z_floor, dfdx, dfdy, es, em, & + crease_curvature=curv) IF (es /= CD_BATHY_OK) THEN CALL fail(ErrStat, ErrMsg, 'friction anchors: bathymetry query failed: '//TRIM(em)) RETURN @@ -1262,9 +1276,15 @@ SUBROUTINE CD_Static_Friction_Anchors(q, current, seabed_kn, anchors, ErrStat, E ELSE RETURN END IF - IF (ABS(dfdx) > CD_ZERO .OR. ABS(dfdy) > CD_ZERO) THEN - CALL CD_Seabed_Normal_Contact(z_floor - q(3*i), dfdx, dfdy, seabed_kn(i), fvec, jac) - normal = NORM2(fvec) + IF (ABS(dfdx) > CD_ZERO .OR. ABS(dfdy) > CD_ZERO .OR. ANY(ABS(curv) > CD_ZERO)) THEN + IF (ANY(ABS(curv) > CD_ZERO)) THEN + ! a crease band: the scalar normal law, as in the static residual + CALL CD_Seabed_Normal_Law((z_floor - q(3*i))/SQRT(CD_ONE + dfdx*dfdx + dfdy*dfdy), seabed_kn(i), & + normal, tangent) + ELSE + CALL CD_Seabed_Normal_Contact(z_floor - q(3*i), dfdx, dfdy, seabed_kn(i), fvec, jac) + normal = NORM2(fvec) + END IF ELSE CALL CD_Seabed_Normal_Law(z_floor - q(3*i), seabed_kn(i), normal, tangent) END IF @@ -2106,7 +2126,7 @@ SUBROUTINE CD_Static_Line_End_Forces(q, elem_conn, l0, ea, f_ext, tension_only, INTEGER :: n_dof, n_nodes, n_elem, k, e, a, b, node, es REAL(wp), ALLOCATABLE :: fint(:) - REAL(wp) :: zf, gx, gy, fvec(3), jac(3, 3), f2(6), jq2(6, 6), jv2(6, 6), va(3), vb(3), de, cn, ct, wla, wlb + REAL(wp) :: zf, gx, gy, fvec(3), jac(3, 3), curv(3), f2(6), jq2(6, 6), jv2(6, 6), va(3), vb(3), de, cn, ct, wla, wlb CHARACTER(200) :: em INTEGER :: ends(2) @@ -2139,8 +2159,10 @@ SUBROUTINE CD_Static_Line_End_Forces(q, elem_conn, l0, ea, f_ext, tension_only, IF (PRESENT(seabed_kn) .AND. (PRESENT(seabed_z_floor) .OR. PRESENT(bathymetry))) THEN DO k = 1, 2 node = ends(k) + curv = CD_ZERO IF (PRESENT(bathymetry)) THEN - CALL CD_Bathymetry_Floor_Gradient(bathymetry, q(3*node - 2), q(3*node - 1), zf, gx, gy, es, em) + CALL CD_Bathymetry_Floor_Gradient(bathymetry, q(3*node - 2), q(3*node - 1), zf, gx, gy, es, em, & + crease_curvature=curv) IF (es /= CD_BATHY_OK) THEN CALL fail(ErrStat, ErrMsg, 'end forces: '//TRIM(em)) RETURN @@ -2150,7 +2172,7 @@ SUBROUTINE CD_Static_Line_End_Forces(q, elem_conn, l0, ea, f_ext, tension_only, gx = CD_ZERO gy = CD_ZERO END IF - CALL CD_Seabed_Normal_Contact(zf - q(3*node), gx, gy, seabed_kn(node), fvec, jac) + CALL CD_Seabed_Normal_Contact(zf - q(3*node), gx, gy, seabed_kn(node), fvec, jac, curvature=curv) fint(3*node - 2:3*node) = fint(3*node - 2:3*node) + fvec END DO END IF diff --git a/tests/data/anchor_crease_between.dat b/tests/data/anchor_crease_between.dat new file mode 100644 index 00000000..a5a54460 --- /dev/null +++ b/tests/data/anchor_crease_between.dat @@ -0,0 +1,31 @@ +--------------------- CableDyn Input File ------------------------------------ +Fixed anchor 1 cm below the rounded valley floor, between it and the grid surface but within tolerance of neither: rejected +--------------------- LINE TYPES --------------------------------------------- +TypeName Diam MassDenInAir EA BA EI Cd_n Cd_t Ca_n Ca_t +(-) (m) (kg/m) (N) (-) (Nm2) (-) (-) (-) (-) +chain 0.12 300.0 1.2e9 -1 0 1.2 0.4 1 0 +--------------------- POINTS ------------------------------------------------- +ID Type X Y Z +(-) (-) (m) (m) (m) +1 Coupled 0.0 0.0 -20.0 +2 Fixed 300.0 0.0 -119.9933 +--------------------- LINES -------------------------------------------------- +ID NodeA NodeB Outputs +(-) (-) (-) (-) +1 1 2 - +--------------------- SECTIONS ----------------------------------------------- +LineID LineType Length NumSegs +(-) (-) (m) (-) +1 chain 350.0 35 +--------------------- OPTIONS ------------------------------------------------ +9.80665 g +1025.0 rhoW +bathy_v_valley.txt bathymetryFile +1.0e5 kBot +1.0e4 cBot +0.05 dtM +0.0 TMax +--------------------- OUTPUTS ------------------------------------------------ +FairTen1 +AnchTen1 +--------------------- END ---------------------------------------------------- diff --git a/tests/data/anchor_crease_tabulated.dat b/tests/data/anchor_crease_tabulated.dat new file mode 100644 index 00000000..cb51ec8a --- /dev/null +++ b/tests/data/anchor_crease_tabulated.dat @@ -0,0 +1,31 @@ +--------------------- CableDyn Input File ------------------------------------ +Fixed anchor at the tabulated depth of a creased grid node (V valley): rests on the seabed, placed on the rounded surface +--------------------- LINE TYPES --------------------------------------------- +TypeName Diam MassDenInAir EA BA EI Cd_n Cd_t Ca_n Ca_t +(-) (m) (kg/m) (N) (-) (Nm2) (-) (-) (-) (-) +chain 0.12 300.0 1.2e9 -1 0 1.2 0.4 1 0 +--------------------- POINTS ------------------------------------------------- +ID Type X Y Z +(-) (-) (m) (m) (m) +1 Coupled 0.0 0.0 -20.0 +2 Fixed 300.0 0.0 -120.0 +--------------------- LINES -------------------------------------------------- +ID NodeA NodeB Outputs +(-) (-) (-) (-) +1 1 2 - +--------------------- SECTIONS ----------------------------------------------- +LineID LineType Length NumSegs +(-) (-) (m) (-) +1 chain 350.0 35 +--------------------- OPTIONS ------------------------------------------------ +9.80665 g +1025.0 rhoW +bathy_v_valley.txt bathymetryFile +1.0e5 kBot +1.0e4 cBot +0.05 dtM +0.0 TMax +--------------------- OUTPUTS ------------------------------------------------ +FairTen1 +AnchTen1 +--------------------- END ---------------------------------------------------- diff --git a/tests/data/bathy_v_valley.txt b/tests/data/bathy_v_valley.txt new file mode 100644 index 00000000..69535adb --- /dev/null +++ b/tests/data/bathy_v_valley.txt @@ -0,0 +1,103 @@ +# x y depth: a V valley along y, deepest (120 m) at x = 300 m, slopes +-0.1 +0.0 -50.0 90.000000 +0.0 50.0 90.000000 +10.0 -50.0 91.000000 +10.0 50.0 91.000000 +20.0 -50.0 92.000000 +20.0 50.0 92.000000 +30.0 -50.0 93.000000 +30.0 50.0 93.000000 +40.0 -50.0 94.000000 +40.0 50.0 94.000000 +50.0 -50.0 95.000000 +50.0 50.0 95.000000 +60.0 -50.0 96.000000 +60.0 50.0 96.000000 +70.0 -50.0 97.000000 +70.0 50.0 97.000000 +80.0 -50.0 98.000000 +80.0 50.0 98.000000 +90.0 -50.0 99.000000 +90.0 50.0 99.000000 +100.0 -50.0 100.000000 +100.0 50.0 100.000000 +110.0 -50.0 101.000000 +110.0 50.0 101.000000 +120.0 -50.0 102.000000 +120.0 50.0 102.000000 +130.0 -50.0 103.000000 +130.0 50.0 103.000000 +140.0 -50.0 104.000000 +140.0 50.0 104.000000 +150.0 -50.0 105.000000 +150.0 50.0 105.000000 +160.0 -50.0 106.000000 +160.0 50.0 106.000000 +170.0 -50.0 107.000000 +170.0 50.0 107.000000 +180.0 -50.0 108.000000 +180.0 50.0 108.000000 +190.0 -50.0 109.000000 +190.0 50.0 109.000000 +200.0 -50.0 110.000000 +200.0 50.0 110.000000 +210.0 -50.0 111.000000 +210.0 50.0 111.000000 +220.0 -50.0 112.000000 +220.0 50.0 112.000000 +230.0 -50.0 113.000000 +230.0 50.0 113.000000 +240.0 -50.0 114.000000 +240.0 50.0 114.000000 +250.0 -50.0 115.000000 +250.0 50.0 115.000000 +260.0 -50.0 116.000000 +260.0 50.0 116.000000 +270.0 -50.0 117.000000 +270.0 50.0 117.000000 +280.0 -50.0 118.000000 +280.0 50.0 118.000000 +290.0 -50.0 119.000000 +290.0 50.0 119.000000 +300.0 -50.0 120.000000 +300.0 50.0 120.000000 +310.0 -50.0 119.000000 +310.0 50.0 119.000000 +320.0 -50.0 118.000000 +320.0 50.0 118.000000 +330.0 -50.0 117.000000 +330.0 50.0 117.000000 +340.0 -50.0 116.000000 +340.0 50.0 116.000000 +350.0 -50.0 115.000000 +350.0 50.0 115.000000 +360.0 -50.0 114.000000 +360.0 50.0 114.000000 +370.0 -50.0 113.000000 +370.0 50.0 113.000000 +380.0 -50.0 112.000000 +380.0 50.0 112.000000 +390.0 -50.0 111.000000 +390.0 50.0 111.000000 +400.0 -50.0 110.000000 +400.0 50.0 110.000000 +410.0 -50.0 109.000000 +410.0 50.0 109.000000 +420.0 -50.0 108.000000 +420.0 50.0 108.000000 +430.0 -50.0 107.000000 +430.0 50.0 107.000000 +440.0 -50.0 106.000000 +440.0 50.0 106.000000 +450.0 -50.0 105.000000 +450.0 50.0 105.000000 +460.0 -50.0 104.000000 +460.0 50.0 104.000000 +470.0 -50.0 103.000000 +470.0 50.0 103.000000 +480.0 -50.0 102.000000 +480.0 50.0 102.000000 +490.0 -50.0 101.000000 +490.0 50.0 101.000000 +500.0 -50.0 100.000000 +500.0 50.0 100.000000 diff --git a/tests/data/cable_statics_matrix.json b/tests/data/cable_statics_matrix.json index 9dbfcde3..f96d6514 100644 --- a/tests/data/cable_statics_matrix.json +++ b/tests/data/cable_statics_matrix.json @@ -1526,5 +1526,91 @@ "reference": "OrcaFlex 11.6 unseeded statics (bow behind the fairlead)" } } + }, + { + "id": "ROUGH_1001", + "expect": "admissible", + "deck": "--------------------- CableDyn Input File ---------------------------\nROUGH_1001\n--------------------- LINE TYPES ------------------------------------\nTypeName Diam MassDenInAir EA BA EI Cd_n Cd_t Ca_n Ca_t\n(-) (m) (kg/m) (N) (-) (N-m2) (-) (-) (-) (-)\nchain 0.216 286.56 1229760000 -1 10000 1.37 0.64 1 0\n--------------------- POINTS ----------------------------------------\nID Type X Y Z\n(-) (-) (m) (m) (m)\n1 Coupled 0 0 -10\n2 Fixed 450 0 -100\n--------------------- LINES -----------------------------------------\nID NodeA NodeB Outputs\n(-) (-) (-) (-)\n1 1 2 -\n--------------------- SECTIONS --------------------------------------\nLineID LineType Length NumSegs\n(-) (-) (m) (-)\n1 chain 520 52\n--------------------- OPTIONS ---------------------------------------\n9.80665 g\n1025.0 rhoW\nbathy.txt bathymetryFile\n100000 kBot\n1.0e4 cBot\n0.05 dtM\n0.0 TMax\n--------------------- OUTPUTS ---------------------------------------\n\"FairTen1\"\n\"AnchTen1\"\n--------------------- need this line --------------------------------\n", + "bathy": "# x y depth\n-100 -100 100.007047\n-100 100 100.007047\n-75 -100 100.013966\n-75 100 100.013966\n-50 -100 99.993963\n-50 100 99.993963\n-25 -100 100.017103\n-25 100 100.017103\n0 -100 99.998565\n0 100 99.998565\n25 -100 100.005372\n25 100 100.005372\n50 -100 100.017680\n50 100 100.017680\n75 -100 99.999703\n75 100 99.999703\n100 -100 100.018500\n100 100 100.018500\n125 -100 100.002654\n125 100 100.002654\n150 -100 100.017206\n150 100 100.017206\n175 -100 100.016371\n175 100 100.016371\n200 -100 100.003019\n200 100 100.003019\n225 -100 99.986926\n225 100 99.986926\n250 -100 100.015048\n250 100 100.015048\n275 -100 100.011070\n275 100 100.011070\n300 -100 99.994903\n300 100 99.994903\n325 -100 99.982092\n325 100 99.982092\n350 -100 99.996916\n350 100 99.996916\n375 -100 100.004133\n375 100 100.004133\n400 -100 99.980950\n400 100 99.980950\n425 -100 100.018137\n425 100 100.018137\n450 -100 100.000000\n450 100 100.000000\n475 -100 100.008416\n475 100 100.008416\n500 -100 100.014230\n500 100 100.014230\n525 -100 100.015288\n525 100 100.015288\n550 -100 100.007661\n550 100 100.007661\n575 -100 99.987355\n575 100 99.987355\n600 -100 100.012771\n600 100 100.012771\n", + "lines": { + "1": { + "oracle_tfair": [ + 243723.25360260083 + ], + "lambda_over_length": 0.003076732677984292 + } + }, + "why": "2 cm roughness on a 25 m survey grid along the chord: the catenary seed laid on the plane fitted along the chord dips below the actual bed and was rejected" + }, + { + "id": "ROUGH_1001__x4", + "expect": "admissible", + "deck": "--------------------- CableDyn Input File ---------------------------\nROUGH_1001\n--------------------- LINE TYPES ------------------------------------\nTypeName Diam MassDenInAir EA BA EI Cd_n Cd_t Ca_n Ca_t\n(-) (m) (kg/m) (N) (-) (N-m2) (-) (-) (-) (-)\nchain 0.216 286.56 1229760000 -1 10000 1.37 0.64 1 0\n--------------------- POINTS ----------------------------------------\nID Type X Y Z\n(-) (-) (m) (m) (m)\n1 Coupled 0 0 -10\n2 Fixed 450 0 -100\n--------------------- LINES -----------------------------------------\nID NodeA NodeB Outputs\n(-) (-) (-) (-)\n1 1 2 -\n--------------------- SECTIONS --------------------------------------\nLineID LineType Length NumSegs\n(-) (-) (m) (-)\n1 chain 520 208\n--------------------- OPTIONS ---------------------------------------\n9.80665 g\n1025.0 rhoW\nbathy.txt bathymetryFile\n100000 kBot\n1.0e4 cBot\n0.05 dtM\n0.0 TMax\n--------------------- OUTPUTS ---------------------------------------\n\"FairTen1\"\n\"AnchTen1\"\n--------------------- need this line --------------------------------\n", + "bathy": "# x y depth\n-100 -100 100.007047\n-100 100 100.007047\n-75 -100 100.013966\n-75 100 100.013966\n-50 -100 99.993963\n-50 100 99.993963\n-25 -100 100.017103\n-25 100 100.017103\n0 -100 99.998565\n0 100 99.998565\n25 -100 100.005372\n25 100 100.005372\n50 -100 100.017680\n50 100 100.017680\n75 -100 99.999703\n75 100 99.999703\n100 -100 100.018500\n100 100 100.018500\n125 -100 100.002654\n125 100 100.002654\n150 -100 100.017206\n150 100 100.017206\n175 -100 100.016371\n175 100 100.016371\n200 -100 100.003019\n200 100 100.003019\n225 -100 99.986926\n225 100 99.986926\n250 -100 100.015048\n250 100 100.015048\n275 -100 100.011070\n275 100 100.011070\n300 -100 99.994903\n300 100 99.994903\n325 -100 99.982092\n325 100 99.982092\n350 -100 99.996916\n350 100 99.996916\n375 -100 100.004133\n375 100 100.004133\n400 -100 99.980950\n400 100 99.980950\n425 -100 100.018137\n425 100 100.018137\n450 -100 100.000000\n450 100 100.000000\n475 -100 100.008416\n475 100 100.008416\n500 -100 100.014230\n500 100 100.014230\n525 -100 100.015288\n525 100 100.015288\n550 -100 100.007661\n550 100 100.007661\n575 -100 99.987355\n575 100 99.987355\n600 -100 100.012771\n600 100 100.012771\n", + "lines": { + "1": { + "oracle_tfair": [ + 243723.25360260083 + ], + "lambda_over_length": 0.003076732677984292 + } + }, + "mesh_of": "ROUGH_1001" + }, + { + "id": "ROUGH_1002", + "expect": "admissible", + "deck": "--------------------- CableDyn Input File ---------------------------\nROUGH_1002\n--------------------- LINE TYPES ------------------------------------\nTypeName Diam MassDenInAir EA BA EI Cd_n Cd_t Ca_n Ca_t\n(-) (m) (kg/m) (N) (-) (N-m2) (-) (-) (-) (-)\nchain 0.216 286.56 1229760000 -1 10000 1.37 0.64 1 0\n--------------------- POINTS ----------------------------------------\nID Type X Y Z\n(-) (-) (m) (m) (m)\n1 Coupled 0 0 -10\n2 Fixed 450 0 -100\n--------------------- LINES -----------------------------------------\nID NodeA NodeB Outputs\n(-) (-) (-) (-)\n1 1 2 -\n--------------------- SECTIONS --------------------------------------\nLineID LineType Length NumSegs\n(-) (-) (m) (-)\n1 chain 520 52\n--------------------- OPTIONS ---------------------------------------\n9.80665 g\n1025.0 rhoW\nbathy.txt bathymetryFile\n100000 kBot\n1.0e4 cBot\n0.05 dtM\n0.0 TMax\n--------------------- OUTPUTS ---------------------------------------\n\"FairTen1\"\n\"AnchTen1\"\n--------------------- need this line --------------------------------\n", + "bathy": "# x y depth\n-100 -50 100.479050\n-100 -25 99.956298\n-100 0 100.218847\n-100 25 100.234886\n-100 50 99.714902\n-75 -50 99.578038\n-75 -25 100.102743\n-75 0 99.621920\n-75 25 99.882227\n-75 50 100.389703\n-50 -50 100.372150\n-50 -25 99.618689\n-50 0 99.582234\n-50 25 99.722486\n-50 50 100.328091\n-25 -50 99.524724\n-25 -25 99.725183\n-25 0 99.607237\n-25 25 99.627638\n-25 50 100.023425\n0 -50 99.683432\n0 -25 99.909443\n0 0 100.233186\n0 25 100.222996\n0 50 99.915038\n25 -50 100.286135\n25 -25 100.072508\n25 0 100.326960\n25 25 99.748882\n25 50 99.869124\n50 -50 100.080335\n50 -25 100.445894\n50 0 100.118340\n50 25 99.974702\n50 50 99.750958\n75 -50 99.781334\n75 -25 99.715787\n75 0 100.486365\n75 25 100.386585\n75 50 100.394562\n100 -50 100.028569\n100 -25 100.208384\n100 0 99.796489\n100 25 99.981570\n100 50 99.645541\n125 -50 99.920140\n125 -25 99.752703\n125 0 99.599977\n125 25 100.419444\n125 50 99.596683\n150 -50 100.312931\n150 -25 100.199579\n150 0 99.590054\n150 25 99.985153\n150 50 100.495864\n175 -50 100.486862\n175 -25 100.063301\n175 0 100.271809\n175 25 100.208675\n175 50 99.791773\n200 -50 100.049937\n200 -25 100.096940\n200 0 99.894056\n200 25 100.318999\n200 50 99.944214\n225 -50 100.249489\n225 -25 99.564686\n225 0 99.944886\n225 25 99.544437\n225 50 100.146835\n250 -50 100.372658\n250 -25 100.043461\n250 0 100.065392\n250 25 100.122490\n250 50 99.729051\n275 -50 99.886257\n275 -25 100.078519\n275 0 100.146282\n275 25 99.880062\n275 50 99.977378\n300 -50 99.830789\n300 -25 100.054298\n300 0 100.175973\n300 25 99.827767\n300 50 100.184997\n325 -50 100.348974\n325 -25 100.036438\n325 0 100.480373\n325 25 99.809500\n325 50 100.419563\n350 -50 99.681901\n350 -25 99.863435\n350 0 100.316853\n350 25 99.532582\n350 50 100.114491\n375 -50 100.371317\n375 -25 100.443995\n375 0 100.182182\n375 25 99.845560\n375 50 99.832293\n400 -50 100.131142\n400 -25 99.566722\n400 0 99.528134\n400 25 100.381660\n400 50 100.126901\n425 -50 99.662861\n425 -25 99.928740\n425 0 99.789076\n425 25 100.369287\n425 50 99.786241\n450 -50 100.000000\n450 -25 100.000000\n450 0 100.000000\n450 25 100.000000\n450 50 100.000000\n475 -50 100.224425\n475 -25 100.243785\n475 0 99.818759\n475 25 99.752101\n475 50 100.021113\n500 -50 99.899723\n500 -25 100.093981\n500 0 99.828157\n500 25 100.294504\n500 50 99.920302\n525 -50 99.636143\n525 -25 100.274531\n525 0 100.395030\n525 25 100.181164\n525 50 100.046519\n550 -50 100.371789\n550 -25 100.433795\n550 0 99.509263\n550 25 99.987695\n550 50 99.518982\n575 -50 99.833524\n575 -25 99.741834\n575 0 99.961382\n575 25 100.177299\n575 50 100.360849\n600 -50 99.760829\n600 -25 99.511736\n600 0 100.499046\n600 25 100.282120\n600 50 100.050342\n", + "lines": { + "1": { + "oracle_tfair": [ + 243723.25360260083 + ], + "lambda_over_length": 0.003076732677984292 + } + }, + "why": "0.5 m roughness on a 25 m grid in both directions (the catenary seed meets the actual bed)" + }, + { + "id": "ROUGH_1002__x4", + "expect": "admissible", + "deck": "--------------------- CableDyn Input File ---------------------------\nROUGH_1002\n--------------------- LINE TYPES ------------------------------------\nTypeName Diam MassDenInAir EA BA EI Cd_n Cd_t Ca_n Ca_t\n(-) (m) (kg/m) (N) (-) (N-m2) (-) (-) (-) (-)\nchain 0.216 286.56 1229760000 -1 10000 1.37 0.64 1 0\n--------------------- POINTS ----------------------------------------\nID Type X Y Z\n(-) (-) (m) (m) (m)\n1 Coupled 0 0 -10\n2 Fixed 450 0 -100\n--------------------- LINES -----------------------------------------\nID NodeA NodeB Outputs\n(-) (-) (-) (-)\n1 1 2 -\n--------------------- SECTIONS --------------------------------------\nLineID LineType Length NumSegs\n(-) (-) (m) (-)\n1 chain 520 208\n--------------------- OPTIONS ---------------------------------------\n9.80665 g\n1025.0 rhoW\nbathy.txt bathymetryFile\n100000 kBot\n1.0e4 cBot\n0.05 dtM\n0.0 TMax\n--------------------- OUTPUTS ---------------------------------------\n\"FairTen1\"\n\"AnchTen1\"\n--------------------- need this line --------------------------------\n", + "bathy": "# x y depth\n-100 -50 100.479050\n-100 -25 99.956298\n-100 0 100.218847\n-100 25 100.234886\n-100 50 99.714902\n-75 -50 99.578038\n-75 -25 100.102743\n-75 0 99.621920\n-75 25 99.882227\n-75 50 100.389703\n-50 -50 100.372150\n-50 -25 99.618689\n-50 0 99.582234\n-50 25 99.722486\n-50 50 100.328091\n-25 -50 99.524724\n-25 -25 99.725183\n-25 0 99.607237\n-25 25 99.627638\n-25 50 100.023425\n0 -50 99.683432\n0 -25 99.909443\n0 0 100.233186\n0 25 100.222996\n0 50 99.915038\n25 -50 100.286135\n25 -25 100.072508\n25 0 100.326960\n25 25 99.748882\n25 50 99.869124\n50 -50 100.080335\n50 -25 100.445894\n50 0 100.118340\n50 25 99.974702\n50 50 99.750958\n75 -50 99.781334\n75 -25 99.715787\n75 0 100.486365\n75 25 100.386585\n75 50 100.394562\n100 -50 100.028569\n100 -25 100.208384\n100 0 99.796489\n100 25 99.981570\n100 50 99.645541\n125 -50 99.920140\n125 -25 99.752703\n125 0 99.599977\n125 25 100.419444\n125 50 99.596683\n150 -50 100.312931\n150 -25 100.199579\n150 0 99.590054\n150 25 99.985153\n150 50 100.495864\n175 -50 100.486862\n175 -25 100.063301\n175 0 100.271809\n175 25 100.208675\n175 50 99.791773\n200 -50 100.049937\n200 -25 100.096940\n200 0 99.894056\n200 25 100.318999\n200 50 99.944214\n225 -50 100.249489\n225 -25 99.564686\n225 0 99.944886\n225 25 99.544437\n225 50 100.146835\n250 -50 100.372658\n250 -25 100.043461\n250 0 100.065392\n250 25 100.122490\n250 50 99.729051\n275 -50 99.886257\n275 -25 100.078519\n275 0 100.146282\n275 25 99.880062\n275 50 99.977378\n300 -50 99.830789\n300 -25 100.054298\n300 0 100.175973\n300 25 99.827767\n300 50 100.184997\n325 -50 100.348974\n325 -25 100.036438\n325 0 100.480373\n325 25 99.809500\n325 50 100.419563\n350 -50 99.681901\n350 -25 99.863435\n350 0 100.316853\n350 25 99.532582\n350 50 100.114491\n375 -50 100.371317\n375 -25 100.443995\n375 0 100.182182\n375 25 99.845560\n375 50 99.832293\n400 -50 100.131142\n400 -25 99.566722\n400 0 99.528134\n400 25 100.381660\n400 50 100.126901\n425 -50 99.662861\n425 -25 99.928740\n425 0 99.789076\n425 25 100.369287\n425 50 99.786241\n450 -50 100.000000\n450 -25 100.000000\n450 0 100.000000\n450 25 100.000000\n450 50 100.000000\n475 -50 100.224425\n475 -25 100.243785\n475 0 99.818759\n475 25 99.752101\n475 50 100.021113\n500 -50 99.899723\n500 -25 100.093981\n500 0 99.828157\n500 25 100.294504\n500 50 99.920302\n525 -50 99.636143\n525 -25 100.274531\n525 0 100.395030\n525 25 100.181164\n525 50 100.046519\n550 -50 100.371789\n550 -25 100.433795\n550 0 99.509263\n550 25 99.987695\n550 50 99.518982\n575 -50 99.833524\n575 -25 99.741834\n575 0 99.961382\n575 25 100.177299\n575 50 100.360849\n600 -50 99.760829\n600 -25 99.511736\n600 0 100.499046\n600 25 100.282120\n600 50 100.050342\n", + "lines": { + "1": { + "oracle_tfair": [ + 243723.25360260083 + ], + "lambda_over_length": 0.003076732677984292 + } + }, + "mesh_of": "ROUGH_1002" + }, + { + "id": "ROUGH_1003", + "expect": "admissible", + "deck": "--------------------- CableDyn Input File ---------------------------\nROUGH_1003\n--------------------- LINE TYPES ------------------------------------\nTypeName Diam MassDenInAir EA BA EI Cd_n Cd_t Ca_n Ca_t\n(-) (m) (kg/m) (N) (-) (N-m2) (-) (-) (-) (-)\nchain 0.216 286.56 1229760000 -1 1000000 1.37 0.64 1 0\n--------------------- POINTS ----------------------------------------\nID Type X Y Z\n(-) (-) (m) (m) (m)\n1 Coupled 0 0 -10\n2 Fixed 450 0 -100\n--------------------- LINES -----------------------------------------\nID NodeA NodeB Outputs\n(-) (-) (-) (-)\n1 1 2 -\n--------------------- SECTIONS --------------------------------------\nLineID LineType Length NumSegs\n(-) (-) (m) (-)\n1 chain 545 109\n--------------------- OPTIONS ---------------------------------------\n9.80665 g\n1025.0 rhoW\nbathy.txt bathymetryFile\n100000 kBot\n1.0e4 cBot\n0.05 dtM\n0.0 TMax\n--------------------- OUTPUTS ---------------------------------------\n\"FairTen1\"\n\"AnchTen1\"\n--------------------- need this line --------------------------------\n", + "bathy": "# x y depth\n-100 -100 100.007047\n-100 100 100.007047\n-75 -100 100.013966\n-75 100 100.013966\n-50 -100 99.993963\n-50 100 99.993963\n-25 -100 100.017103\n-25 100 100.017103\n0 -100 99.998565\n0 100 99.998565\n25 -100 100.005372\n25 100 100.005372\n50 -100 100.017680\n50 100 100.017680\n75 -100 99.999703\n75 100 99.999703\n100 -100 100.018500\n100 100 100.018500\n125 -100 100.002654\n125 100 100.002654\n150 -100 100.017206\n150 100 100.017206\n175 -100 100.016371\n175 100 100.016371\n200 -100 100.003019\n200 100 100.003019\n225 -100 99.986926\n225 100 99.986926\n250 -100 100.015048\n250 100 100.015048\n275 -100 100.011070\n275 100 100.011070\n300 -100 99.994903\n300 100 99.994903\n325 -100 99.982092\n325 100 99.982092\n350 -100 99.996916\n350 100 99.996916\n375 -100 100.004133\n375 100 100.004133\n400 -100 99.980950\n400 100 99.980950\n425 -100 100.018137\n425 100 100.018137\n450 -100 100.000000\n450 100 100.000000\n475 -100 100.008416\n475 100 100.008416\n500 -100 100.014230\n500 100 100.014230\n525 -100 100.015288\n525 100 100.015288\n550 -100 100.007661\n550 100 100.007661\n575 -100 99.987355\n575 100 99.987355\n600 -100 100.012771\n600 100 100.012771\n", + "lines": { + "1": { + "oracle_tfair": [], + "lambda_over_length": 0.013625839599843271 + } + }, + "why": "a line 5 m longer than its span plus rise over the rough seabed: the anchor walk traces the equilibrium its bending stiffness holds (FairTen within 0.01 % of the flat-seabed walk)" + }, + { + "id": "ROUGH_1003__x2", + "expect": "admissible", + "deck": "--------------------- CableDyn Input File ---------------------------\nROUGH_1003\n--------------------- LINE TYPES ------------------------------------\nTypeName Diam MassDenInAir EA BA EI Cd_n Cd_t Ca_n Ca_t\n(-) (m) (kg/m) (N) (-) (N-m2) (-) (-) (-) (-)\nchain 0.216 286.56 1229760000 -1 1000000 1.37 0.64 1 0\n--------------------- POINTS ----------------------------------------\nID Type X Y Z\n(-) (-) (m) (m) (m)\n1 Coupled 0 0 -10\n2 Fixed 450 0 -100\n--------------------- LINES -----------------------------------------\nID NodeA NodeB Outputs\n(-) (-) (-) (-)\n1 1 2 -\n--------------------- SECTIONS --------------------------------------\nLineID LineType Length NumSegs\n(-) (-) (m) (-)\n1 chain 545 218\n--------------------- OPTIONS ---------------------------------------\n9.80665 g\n1025.0 rhoW\nbathy.txt bathymetryFile\n100000 kBot\n1.0e4 cBot\n0.05 dtM\n0.0 TMax\n--------------------- OUTPUTS ---------------------------------------\n\"FairTen1\"\n\"AnchTen1\"\n--------------------- need this line --------------------------------\n", + "bathy": "# x y depth\n-100 -100 100.007047\n-100 100 100.007047\n-75 -100 100.013966\n-75 100 100.013966\n-50 -100 99.993963\n-50 100 99.993963\n-25 -100 100.017103\n-25 100 100.017103\n0 -100 99.998565\n0 100 99.998565\n25 -100 100.005372\n25 100 100.005372\n50 -100 100.017680\n50 100 100.017680\n75 -100 99.999703\n75 100 99.999703\n100 -100 100.018500\n100 100 100.018500\n125 -100 100.002654\n125 100 100.002654\n150 -100 100.017206\n150 100 100.017206\n175 -100 100.016371\n175 100 100.016371\n200 -100 100.003019\n200 100 100.003019\n225 -100 99.986926\n225 100 99.986926\n250 -100 100.015048\n250 100 100.015048\n275 -100 100.011070\n275 100 100.011070\n300 -100 99.994903\n300 100 99.994903\n325 -100 99.982092\n325 100 99.982092\n350 -100 99.996916\n350 100 99.996916\n375 -100 100.004133\n375 100 100.004133\n400 -100 99.980950\n400 100 99.980950\n425 -100 100.018137\n425 100 100.018137\n450 -100 100.000000\n450 100 100.000000\n475 -100 100.008416\n475 100 100.008416\n500 -100 100.014230\n500 100 100.014230\n525 -100 100.015288\n525 100 100.015288\n550 -100 100.007661\n550 100 100.007661\n575 -100 99.987355\n575 100 99.987355\n600 -100 100.012771\n600 100 100.012771\n", + "lines": { + "1": { + "oracle_tfair": [], + "lambda_over_length": 0.013625839599843271 + } + }, + "mesh_of": "ROUGH_1003" } ] diff --git a/tests/test_bathymetry.f90 b/tests/test_bathymetry.f90 index 64420b66..b3a0b2cf 100644 --- a/tests/test_bathymetry.f90 +++ b/tests/test_bathymetry.f90 @@ -4,12 +4,15 @@ PROGRAM test_bathymetry !! Unit tests for the structured bathymetry service and variable-elevation !! seabed contact tangent. These tests are self-contained analytical checks: - !! bilinear interpolation on a plane, edge clamping, and fail-closed validation. + !! bilinear interpolation on a plane, edge clamping, fail-closed validation, and the + !! C2 rounding of the creases of a non-planar grid. USE CableDyn_Precision, ONLY: wp USE CableDyn_Bathymetry, ONLY: CD_BathymetryType, CD_Init_Bathymetry, CD_End_Bathymetry, & CD_Bathymetry_Depth, CD_Bathymetry_Floor, & CD_Bathymetry_Floor_Gradient, CD_Bathymetry_Seabed_Load, & - CD_Bathymetry_Is_Initialized, CD_BATHY_OK, CD_BATHY_BADINPUT + CD_Bathymetry_Is_Initialized, CD_BATHY_OK, CD_BATHY_BADINPUT, & + CD_Bathymetry_Grid_Floor, CD_Bathymetry_Rotate_Curvature, & + CD_BATHY_CREASE_FRACTION USE CableDyn_SeabedContact, ONLY: CD_SEABED_CONTACT_BLEND USE, INTRINSIC :: IEEE_ARITHMETIC, ONLY: IEEE_VALUE, IEEE_QUIET_NAN IMPLICIT NONE @@ -21,6 +24,9 @@ PROGRAM test_bathymetry CALL case_variable_seabed_contact_tangent() CALL case_variable_seabed_tangent_fd() CALL case_fail_closed_inputs() + CALL case_crease_rounding_c2() + CALL case_crease_rounding_planar_exact() + CALL case_crease_contact_tangent_fd() IF (nfail > 0) THEN WRITE (*, '(A,I0,A)') 'FAIL: ', nfail, ' assertion(s) failed' @@ -255,6 +261,200 @@ SUBROUTINE case_fail_closed_inputs() CALL CD_End_Bathymetry(bathy) END SUBROUTINE case_fail_closed_inputs + SUBROUTINE init_creased_bathy(bathy) + !! A non-planar grid with creases along every interior line (non-uniform spacing). + TYPE(CD_BathymetryType), INTENT(OUT) :: bathy + REAL(wp) :: x(5), y(4), depth(5, 4) + INTEGER :: i, j, es + CHARACTER(160) :: em + x = [0.0_wp, 10.0_wp, 25.0_wp, 30.0_wp, 42.0_wp] + y = [-5.0_wp, 8.0_wp, 20.0_wp, 26.0_wp] + DO j = 1, SIZE(y) + DO i = 1, SIZE(x) + depth(i, j) = 100.0_wp + 2.0_wp*SIN(0.37_wp*x(i) + 0.11_wp*y(j)) + & + 1.5_wp*COS(0.23_wp*y(j) - 0.05_wp*x(i)) + 0.1_wp*REAL(MOD(3*i + 5*j, 7), wp) + END DO + END DO + CALL CD_Init_Bathymetry(bathy, x, y, depth, es, em) + CALL expect_es(es, CD_BATHY_OK, 'crease:init') + END SUBROUTINE init_creased_bathy + + SUBROUTINE floor_at(bathy, x, y, z, g) + TYPE(CD_BathymetryType), INTENT(IN) :: bathy + REAL(wp), INTENT(IN) :: x, y + REAL(wp), INTENT(OUT) :: z, g(2) + INTEGER :: es + CHARACTER(160) :: em + CALL CD_Bathymetry_Floor_Gradient(bathy, x, y, z, g(1), g(2), es, em) + CALL expect_es(es, CD_BATHY_OK, 'crease:query') + END SUBROUTINE floor_at + + SUBROUTINE case_crease_rounding_c2() + !! The rounded surface is C2: height, gradient and the curvatures z_xx and z_yy are + !! continuous across every interior grid line (at a crossing as well) and at the edges + !! of the bands; the gradient is the derivative of the height and the curvature that + !! of the gradient (central differences); outside the bands the surface is the + !! bilinear one, bit for bit; inside a band it moves by at most a sixth of the slope + !! jump times the band half-width. + TYPE(CD_BathymetryType) :: bathy + REAL(wp), PARAMETER :: EPS = 1.0e-9_wp, H = 1.0e-5_wp + REAL(wp), PARAMETER :: LINES_X(3) = [10.0_wp, 25.0_wp, 30.0_wp], LINES_Y(2) = [8.0_wp, 20.0_wp] + REAL(wp), PARAMETER :: ALONG_X(4) = [3.0_wp, 8.0_wp, 8.1_wp, 19.95_wp] + REAL(wp), PARAMETER :: ALONG_Y(4) = [4.0_wp, 10.0_wp, 9.8_wp, 29.9_wp] + REAL(wp) :: za, zb, ga(2), gb(2), zg, z, g(2), gp(2), gm(2), zp, zm, curv(3), delta, dz, ca(3), cb(3) + REAL(wp) :: pts(2, 6), zpp, zpm, zmp, zmm, twist + INTEGER :: k, j, es + CHARACTER(160) :: em + + CALL init_creased_bathy(bathy) + ! across the x lines, away from and at the crossings with the y lines + DO k = 1, SIZE(LINES_X) + DO j = 1, SIZE(ALONG_X) + CALL CD_Bathymetry_Floor_Gradient(bathy, LINES_X(k) - EPS, ALONG_X(j), za, ga(1), ga(2), es, em, & + crease_curvature=ca) + CALL CD_Bathymetry_Floor_Gradient(bathy, LINES_X(k) + EPS, ALONG_X(j), zb, gb(1), gb(2), es, em, & + crease_curvature=cb) + CALL require(ABS(za - zb) <= 1.0e-8_wp, 'crease:x-line height continuous') + CALL require(MAXVAL(ABS(ga - gb)) <= 1.0e-6_wp, 'crease:x-line gradient continuous') + CALL require(ABS(ca(1) - cb(1)) <= 1.0e-5_wp .AND. ABS(ca(3) - cb(3)) <= 1.0e-5_wp, & + 'crease:x-line curvature continuous') + END DO + END DO + DO k = 1, SIZE(LINES_Y) + DO j = 1, SIZE(ALONG_Y) + CALL CD_Bathymetry_Floor_Gradient(bathy, ALONG_Y(j), LINES_Y(k) - EPS, za, ga(1), ga(2), es, em, & + crease_curvature=ca) + CALL CD_Bathymetry_Floor_Gradient(bathy, ALONG_Y(j), LINES_Y(k) + EPS, zb, gb(1), gb(2), es, em, & + crease_curvature=cb) + CALL require(ABS(za - zb) <= 1.0e-8_wp, 'crease:y-line height continuous') + CALL require(MAXVAL(ABS(ga - gb)) <= 1.0e-6_wp, 'crease:y-line gradient continuous') + CALL require(ABS(ca(1) - cb(1)) <= 1.0e-5_wp .AND. ABS(ca(3) - cb(3)) <= 1.0e-5_wp, & + 'crease:y-line curvature continuous') + END DO + END DO + ! at the band edge of the x line 25 (half-width 5 % of the smaller spacing, 5 m) + delta = CD_BATHY_CREASE_FRACTION*5.0_wp + CALL CD_Bathymetry_Floor_Gradient(bathy, 25.0_wp + delta - EPS, 3.0_wp, za, ga(1), ga(2), es, em, & + crease_curvature=ca) + CALL CD_Bathymetry_Floor_Gradient(bathy, 25.0_wp + delta + EPS, 3.0_wp, zb, gb(1), gb(2), es, em, & + crease_curvature=cb) + CALL require(ABS(za - zb) <= 1.0e-8_wp .AND. MAXVAL(ABS(ga - gb)) <= 1.0e-6_wp .AND. & + MAXVAL(ABS(ca - cb)) <= 1.0e-5_wp, 'crease:band edge C2') + ! outside every band (and outside the grid): exactly the bilinear surface + pts = RESHAPE([5.0_wp, 2.0_wp, 17.0_wp, 14.0_wp, 27.5_wp, 23.0_wp, 36.0_wp, 0.0_wp, -3.0_wp, 14.0_wp, & + 50.0_wp, 30.0_wp], [2, 6]) + DO j = 1, SIZE(pts, 2) + CALL floor_at(bathy, pts(1, j), pts(2, j), z, g) + CALL CD_Bathymetry_Grid_Floor(bathy, pts(1, j), pts(2, j), zg, es, em) + CALL require(z == zg, 'crease:outside the bands the surface is bilinear') + END DO + ! gradient and curvature against central differences inside bands and at crossings + pts = RESHAPE([10.2_wp, 3.0_wp, 24.9_wp, 14.0_wp, 4.0_wp, 7.7_wp, 29.92_wp, 20.1_wp, 10.1_wp, 8.2_wp, & + 25.05_wp, 19.97_wp], [2, 6]) + DO j = 1, SIZE(pts, 2) + CALL CD_Bathymetry_Floor_Gradient(bathy, pts(1, j), pts(2, j), z, g(1), g(2), es, em, crease_curvature=curv) + CALL floor_at(bathy, pts(1, j) + H, pts(2, j), zp, gp) + CALL floor_at(bathy, pts(1, j) - H, pts(2, j), zm, gm) + CALL require(ABS((zp - zm)/(2.0_wp*H) - g(1)) <= 1.0e-6_wp, 'crease:dz/dx') + ! the rounding's curvature: the bilinear part of z_xx is zero within a cell + CALL require(ABS((gp(1) - gm(1))/(2.0_wp*H) - curv(1)) <= 1.0e-4_wp*MAX(1.0_wp, ABS(curv(1))), & + 'crease:z_xx') + CALL floor_at(bathy, pts(1, j), pts(2, j) + H, zp, gp) + CALL floor_at(bathy, pts(1, j), pts(2, j) - H, zm, gm) + CALL require(ABS((zp - zm)/(2.0_wp*H) - g(2)) <= 1.0e-6_wp, 'crease:dz/dy') + CALL require(ABS((gp(2) - gm(2))/(2.0_wp*H) - curv(3)) <= 1.0e-4_wp*MAX(1.0_wp, ABS(curv(3))), & + 'crease:z_yy') + ! z_xy of the rounding: the y-derivative of z_x less the twist of the bilinear cell, + ! which the curvature leaves out (a four-point difference of the bilinear surface) + CALL CD_Bathymetry_Grid_Floor(bathy, pts(1, j) + H, pts(2, j) + H, zpp, es, em) + CALL CD_Bathymetry_Grid_Floor(bathy, pts(1, j) + H, pts(2, j) - H, zpm, es, em) + CALL CD_Bathymetry_Grid_Floor(bathy, pts(1, j) - H, pts(2, j) + H, zmp, es, em) + CALL CD_Bathymetry_Grid_Floor(bathy, pts(1, j) - H, pts(2, j) - H, zmm, es, em) + twist = (zpp - zpm - zmp + zmm)/(4.0_wp*H*H) + CALL require(ABS((gp(1) - gm(1))/(2.0_wp*H) - twist - curv(2)) <= 1.0e-4_wp*MAX(1.0_wp, ABS(curv(2))), & + 'crease:z_xy') + CALL CD_Bathymetry_Grid_Floor(bathy, pts(1, j), pts(2, j), zg, es, em) + dz = ABS(z - zg) + ! slope jumps below 1 here: a band of half-width <= 0.6 m moves the surface by < 0.1 m + CALL require(dz > 0.0_wp .AND. dz <= 0.1_wp, 'crease:bounded rounding inside a band') + END DO + ! the turned curvature is the Hessian in the turned frame (90 degrees: xx <-> yy) + curv = CD_Bathymetry_Rotate_Curvature([1.0_wp, 0.0_wp, 0.0_wp], [0.0_wp, 1.0_wp]) + CALL require(ABS(curv(1)) <= 1.0e-15_wp .AND. ABS(curv(2)) <= 1.0e-15_wp .AND. & + ABS(curv(3) - 1.0_wp) <= 1.0e-15_wp, 'crease:turned curvature') + CALL CD_End_Bathymetry(bathy) + END SUBROUTINE case_crease_rounding_c2 + + SUBROUTINE case_crease_rounding_planar_exact() + !! A planar grid has no crease: the surface and its gradient are the bilinear ones bit + !! for bit everywhere, inside the bands too, also for a plane written to six decimals. + TYPE(CD_BathymetryType) :: bathy + REAL(wp) :: x(4), y(3), depth(4, 3), z, zg, g(2), curv(3), xq, yq + INTEGER :: i, j, k, es + CHARACTER(160) :: em + x = [0.0_wp, 10.0_wp, 25.0_wp, 30.0_wp] + y = [-5.0_wp, 8.0_wp, 20.0_wp] + DO k = 1, 2 + DO j = 1, SIZE(y) + DO i = 1, SIZE(x) + depth(i, j) = 388.949782_wp + 0.0732_wp*x(i) - 0.0417_wp*y(j) + IF (k == 2) depth(i, j) = ANINT(depth(i, j)*1.0e6_wp)/1.0e6_wp + END DO + END DO + CALL CD_Init_Bathymetry(bathy, x, y, depth, es, em) + CALL expect_es(es, CD_BATHY_OK, 'planar:init') + DO j = 0, 40 + DO i = 0, 40 + xq = -1.0_wp + 32.0_wp*REAL(i, wp)/40.0_wp + 0.01_wp*REAL(MOD(j, 3), wp) + yq = -6.0_wp + 27.0_wp*REAL(j, wp)/40.0_wp + CALL CD_Bathymetry_Floor_Gradient(bathy, xq, yq, z, g(1), g(2), es, em, crease_curvature=curv) + CALL CD_Bathymetry_Grid_Floor(bathy, xq, yq, zg, es, em) + CALL require(z == zg .AND. ALL(curv == 0.0_wp), 'planar:bit-identical bilinear surface') + END DO + END DO + ! on the lines themselves (inside every band) + CALL CD_Bathymetry_Floor(bathy, 10.0_wp, 8.0_wp, z, es, em) + CALL CD_Bathymetry_Grid_Floor(bathy, 10.0_wp, 8.0_wp, zg, es, em) + CALL require(z == zg, 'planar:bit-identical at a crossing') + END DO + CALL CD_End_Bathymetry(bathy) + END SUBROUTINE case_crease_rounding_planar_exact + + SUBROUTINE case_crease_contact_tangent_fd() + !! In a band (at a crossing of two lines) the contact force is the gradient of the + !! penalty potential of the rounded surface, and its residual tangent the Hessian: + !! k_resid(:, j) = -d f/d q_j against central differences (to 1 % of the largest + !! entry: the tangent leaves out the third derivatives of the surface, a term of the + !! order of the force times the penetration times d(curvature)/dq), and symmetric. + TYPE(CD_BathymetryType) :: bathy + REAL(wp) :: nodes(3, 1), kn(1), f0(3), fp(3), fm(3), kres(3, 3), kbase(3, 3), fd_col(3), trial(3, 1), z + REAL(wp) :: h + INTEGER :: es, j + CHARACTER(160) :: em + CALL init_creased_bathy(bathy) + CALL CD_Bathymetry_Floor(bathy, 10.1_wp, 8.15_wp, z, es, em) + nodes(:, 1) = [10.1_wp, 8.15_wp, z - 0.05_wp] + kn = [2.0e4_wp] + h = 1.0e-6_wp + CALL CD_Bathymetry_Seabed_Load(bathy, nodes, kn, f0, kres, es, em) + CALL expect_es(es, CD_BATHY_OK, 'crease-fd:base') + kbase = kres + DO j = 1, 3 + trial = nodes + trial(j, 1) = trial(j, 1) + h + CALL CD_Bathymetry_Seabed_Load(bathy, trial, kn, fp, kres, es, em) + trial = nodes + trial(j, 1) = trial(j, 1) - h + CALL CD_Bathymetry_Seabed_Load(bathy, trial, kn, fm, kres, es, em) + fd_col = -(fp - fm)/(2.0_wp*h) + CALL require(MAXVAL(ABS(kbase(:, j) - fd_col)) <= 1.0e-2_wp*MAXVAL(ABS(kbase)), 'crease-fd:kcol') + END DO + ! the node is in contact (the tangent above is not trivially zero) + CALL require(ABS(f0(3)) > 0.0_wp, 'crease-fd:in contact') + CALL require(MAXVAL(ABS(kbase - TRANSPOSE(kbase))) <= 1.0e-9_wp*MAXVAL(ABS(kbase)), 'crease-fd:symmetric') + CALL CD_End_Bathymetry(bathy) + END SUBROUTINE case_crease_contact_tangent_fd + SUBROUTINE expect_vec_fd(got, want, label) REAL(wp), INTENT(IN) :: got(:), want(:) CHARACTER(*), INTENT(IN) :: label diff --git a/tests/test_cable_statics_matrix.py b/tests/test_cable_statics_matrix.py index 769be723..b1be2c32 100644 --- a/tests/test_cable_statics_matrix.py +++ b/tests/test_cable_statics_matrix.py @@ -6,7 +6,7 @@ A deterministic sample of finite-EI (cubic-Hermite) cable decks drawn from a seeded robustness study: lazy waves (single and modular buoyancy, some floating at the surface), steep and lazy-S waves, heavy catenaries, lines hung in mid-water, sloped -structured seabeds, azimuthal layouts, rotationally restrained hang-offs, current and +and rough structured seabeds, azimuthal layouts, rotationally restrained hang-offs, current and friction options, mixed mooring + cable decks, refined meshes, and metamorphic twins (translated, rotated, anchor-first, split sections, constant-depth grid). Every deck is run through the standalone driver and checked against its committed expectation: diff --git a/tests/test_statics_robustness.py b/tests/test_statics_robustness.py index 96a28e11..465a8ca1 100644 --- a/tests/test_statics_robustness.py +++ b/tests/test_statics_robustness.py @@ -5,11 +5,13 @@ A deterministic sample of the regimes a mooring designer meets -- grounded catenary, semi-taut, taut, fully suspended, multi-section composite, nearly taut, slack (the H -> 0 limit), vertical, -anchors just off the seabed, sloped seabed, fine meshes, soft seabed, steady current, one- and -two-segment lines, and Free/Connect points -- is written as cabledyn decks and solved by the -production executable. Every case must converge with no compressed element and an independent -nodal force balance (tensions, lumped weight, penalty seabed along the local normal, Morison -drag). Cases with a continuous elastic-catenary solution also match it (element tensions and the +anchors just off the seabed, sloped seabed, gridded seabeds with a trench or 2D roughness (their +creases rounded as in the solver), fine meshes, soft seabed, steady current, one- and two-segment +lines, and Free/Connect points -- is written as cabledyn decks and solved by the production +executable. Every case must converge with no compressed element and an independent nodal force +balance (tensions, lumped weight, penalty seabed along the local normal, or in a rounded crease +the gradient of its penalty potential, Morison drag); a trench deep enough to hold the excess +length slack at its bottom must show it, with the anchor tension of the run rising from there. Cases with a continuous elastic-catenary solution also match it (element tensions and the line-end forces FairTen/AnchTen); a subset is run through both the static-only and the dynamic (TMax = 0) route, which must report the same end tensions; an anchor genuinely below the seabed must be rejected with a clear message. @@ -239,7 +241,16 @@ def nodal_balance(case, root): s = math.sqrt(1 + gx * gx + gy * gy) pen = (zf - P[i, 2]) / s if pen > 0: - F[i] += kn[i] * pen * np.array([-gx, -gy, 1.0]) / s + hess = case["floor_hess"](P[i, 0], P[i, 1]) if "floor_hess" in case else None + if hess is None: + F[i] += kn[i] * pen * np.array([-gx, -gy, 1.0]) / s + else: + # in a rounded crease: the gradient of the penalty potential of the + # normal penetration g = (zf - z)/s, force = -k g dg/dq + fxx, fxy, fyy = hess + ds = np.array([gx * fxx + gy * fxy, gx * fxy + gy * fyy, 0.0]) / s + dg = np.array([gx, gy, -1.0]) / s - (zf - P[i, 2]) * ds / s**2 + F[i] -= kn[i] * pen * dg if "current" in case: # a depth profile is sampled at each node's own elevation (as the dynamics do) vel = [case["current"](z) for z in P[:, 2]] @@ -261,11 +272,67 @@ def nodal_balance(case, root): return worst +# ------------------------------------------------------------------ rounded bathymetry +class RoundedGrid: + """The solver's seabed of a structured grid, written independently in basis form. + + z(x, y) = sum_ij z_ij phi_i(x) psi_j(y), with phi_i the hat functions of the x grid whose + kinks at the interior grid lines are rounded by the cubic fillet J (d - |u|)^3 / (6 d^2) + (J the slope jump of the hat there, d = 5 % of the smaller spacing next to the line); + likewise psi_j. Gradient and curvature by central differences of z. Data creases that + would move the surface by less than 1 micrometre are not rounded in the solver; the + grids used here have none. + """ + + def __init__(self, xs, ys, z): + self.xs, self.ys, self.z = np.asarray(xs, float), np.asarray(ys, float), np.asarray(z, float) + + @staticmethod + def _basis(axis, q): + n = axis.size + q = min(max(q, axis[0]), axis[-1]) + phi = np.zeros(n) + i = min(max(int(np.searchsorted(axis, q, side="right")) - 1, 0), n - 2) + t = (q - axis[i]) / (axis[i + 1] - axis[i]) + phi[i], phi[i + 1] = 1.0 - t, t + for k in range(1, n - 1): + d = 0.05 * min(axis[k] - axis[k - 1], axis[k + 1] - axis[k]) + u = abs(q - axis[k]) + if u >= d: + continue + h = (d - u) ** 3 / (6.0 * d * d) + # slope jumps of the hats at line k: hat k-1, k and k+1 + phi[k - 1] += h * (1.0 / (axis[k] - axis[k - 1])) + phi[k] += h * (-1.0 / (axis[k] - axis[k - 1]) - 1.0 / (axis[k + 1] - axis[k])) + phi[k + 1] += h * (1.0 / (axis[k + 1] - axis[k])) + return phi + + def height(self, x, y): + return float(self._basis(self.xs, x) @ self.z @ self._basis(self.ys, y)) + + def floor(self, x, y, h=1.0e-5): + gx = (self.height(x + h, y) - self.height(x - h, y)) / (2 * h) + gy = (self.height(x, y + h) - self.height(x, y - h)) / (2 * h) + return self.height(x, y), gx, gy + + def hess(self, x, y, h=1.0e-4): + z0 = self.height(x, y) + fxx = (self.height(x + h, y) - 2 * z0 + self.height(x - h, y)) / h**2 + fyy = (self.height(x, y + h) - 2 * z0 + self.height(x, y - h)) / h**2 + fxy = (self.height(x + h, y + h) - self.height(x + h, y - h) - self.height(x - h, y + h) + + self.height(x - h, y - h)) / (4 * h * h) + # a bilinear cell has no z_xx or z_yy: the contact there is the normal force + return (fxx, fxy, fyy) if abs(fxx) > 1e-3 or abs(fyy) > 1e-3 else None + + def rows(self): + return [(float(x), float(y), float(-self.z[i, j])) for i, x in enumerate(self.xs) for j, y in enumerate(self.ys)] + + # ------------------------------------------------------------------ case builders CASES: list[dict] = [] # The matrix is seeded, so the designs the oracle can close are fixed: a change in the # oracle, the seed or the case table that drops cases must fail, not shrink the matrix. -EXPECTED_CASES = 71 +EXPECTED_CASES = 74 def single(name, t, L, nseg, fair, anch, depth=None, kbot=1.0e5, extra=(), oracle=True, slope=None, @@ -400,6 +467,28 @@ def floor(x, y, th=th): grid = [(x, y, 70.0 - math.tan(th) * x) for x in (-200.0, 900.0) for y in (-300.0, 300.0)] single("slope_fold_%+.1fdeg" % deg, chain12, length, nseg, (97.0, 0.0, -1.0), (0.0, 0.0, -70.0), bathy=grid, floor=floor, slope=th, oracle=False) + # --- a gridded seabed with valleys (the creases of the bilinear grid rounded by the + # solver): a 30 m Gaussian trench under the touchdown, and in the grounded run, deep + # enough that the frictionless run's tension T = T0 + w (z - z0) falls to zero inside it + # and the excess length rests slack at the bottom (the anchor tension is then w times the + # trench depth below the anchor); and a +-0.5 m random seabed on a 10 m grid in both + # directions, whose valleys the frictionless grounded run slides sideways into --- + xs = [-100.0 + 5.0 * k for k in range(141)] + for tag, xc, n_seg in (("touchdown", 200.0, 104), ("grounded_run", 350.0, 104)): + trench = RoundedGrid(xs, [-100.0, 100.0], + [[-100.0 - 30.0 * math.exp(-((x - xc) / 40.0) ** 2)] * 2 for x in xs]) + za = trench.height(450.0, 0.0) + c = single("trench_%s_pile" % tag, chain12, 520.0, n_seg, (0.0, 0.0, -10.0), (450.0, 0.0, za), + bathy=trench.rows(), floor=trench.floor, oracle=False) + c["floor_hess"] = trench.hess + c["pile_dz"] = za - trench.height(xc, 0.0) + rr = random.Random(20261015) + xs = [-100.0 + 10.0 * k for k in range(71)] + ys = [-100.0 + 10.0 * k for k in range(21)] + rough = RoundedGrid(xs, ys, [[-100.0 if x == 450.0 else -100.0 + rr.uniform(-0.5, 0.5) for _ in ys] for x in xs]) + c = single("rough2d_seabed", chain12, 520.0, 104, (0.0, 0.0, -10.0), (450.0, 0.0, -100.0), bathy=rough.rows(), + floor=rough.floor, oracle=False) + c["floor_hess"] = rough.hess # --- a soft seabed (kBot = 1e3): the grounded run sinks ~4 m, and the line only fits its # span because of that penetration --- wire_soft = line_type("wiresoft", "wire", 0.10) @@ -482,6 +571,14 @@ def evaluate(case, exe): check(bal < BALANCE_TOL, "%s: nodal force balance %.3g" % (name, bal)) if case.get("point_case"): check_points(case, row) + if case.get("pile_dz"): + # a slack element at the bottom of the trench, and the anchor tension of the grounded + # run that rises from a zero tension there: w times the trench depth below the anchor + T = read_tensions(os.path.join(d, "o.Line1.t.out")) + w = next(iter(case["types"].values()))["w"] + check(T.min() <= 0.0, "%s: the excess length rests slack at the bottom of the trench" % name) + check(abs(row["AnchTen1"] - w * case["pile_dz"]) < 0.02 * w * case["pile_dz"], + "%s: AnchTen %.6g vs w*depth %.6g" % (name, row["AnchTen1"], w * case["pile_dz"])) if case.get("fair_ref"): # slack line: the hanging leg carries about its own weight w*h (the discrete grounded # run keeps a small horizontal tension), never a compressed strut or zero From b32d3f42cdadc08ce7d0fd5ee9c40abb85ede771 Mon Sep 17 00:00:00 2001 From: Jae Hoon Seo Date: Fri, 16 Oct 2026 17:09:38 +0900 Subject: [PATCH 11/31] feat: OrcaFlex "as laid" seabed friction in statics (#17) Seabed friction in the static solve, following OrcaFlex's "As laid" policy, as the opt-in option staticsFriction asLaid. The default, staticsFriction none, keeps the previous behaviour (and MoorDyn's), which is conservative for anchor loads; every example and test deck is byte-identical under it. Seabed friction had no effect on the static solve: its springs were anchored to the frictionless still-water layout, so a grounded run on a slope with tan(theta) < mu, or laid with surplus length, still slid or folded (an EI = 0 line on a 5 deg slope with mu = 1 folded 24 m past its anchor, as with mu = 0). With asLaid, the line is assumed laid from its lower end along a lay azimuth (layAzimuth / layAzimuth, default from that end toward the other) at an as-laid tension (asLaidTension / asLaidTension, default 0, at most EA), and friction resists displacement from those positions with the regularised law of the dynamics, isotropic or anisotropic. On a bathymetry each reference node carries the normal sink of its nodal load (weight, discrete attachment loads, the turning load of the laid tension, with the surface metric), so the normal sink adds no friction deflection. The reference is laid on every mesh a static solve uses and on the final mesh for the dynamics, whose friction anchors continue the static springs (no jump at t = 0). A lay off the chord plane, or a seabed sloping across it, puts a finite-EI line in 3D. The EI = 0 and finite-EI routes, the coupled aggregate, the C API and the Python deck reader/writer/builder share it; routes that cannot apply it refuse it by name. Results with asLaid: the 5 deg line holds where laid (FairTen 714.2 -> 622.9 kN, friction within mu N at every grounded node), a 650 m finite-EI cable on a 10 deg slope solves and holds, a refined line equals its fine-mesh twin to 1e-12 m, and on a flat seabed laid at its run tension the result equals the frictionless one. Signed-off-by: Jae Hoon Seo --- CHANGELOG.md | 40 ++ CMakeLists.txt | 13 + doc/driver_format.md | 5 +- doc/modeling.rst | 8 + doc/options.rst | 53 +- doc/theory.rst | 114 +++- doc/troubleshooting.rst | 18 + examples/cabledyn_options_reference.dat | 7 + python/cabledyn/builder.py | 4 +- python/cabledyn/deck.py | 4 +- python/cabledyn/deck_file.py | 54 +- python/tests/test_builder.py | 25 + python/tests/test_deck_file.py | 86 +++ python/tests/test_deck_writer.py | 19 + src/CableDyn_DeckDriver.f90 | 550 +++++++++++++++++- src/CableDyn_HermiteCableStatic.f90 | 276 ++++++++- src/CableDyn_Model.f90 | 122 +++- src/CableDyn_Static.f90 | 365 +++++++++++- tests/test_bathymetry.f90 | 157 ++++++ tests/test_static_friction_as_laid.py | 716 ++++++++++++++++++++++++ 20 files changed, 2537 insertions(+), 99 deletions(-) create mode 100644 tests/test_static_friction_as_laid.py diff --git a/CHANGELOG.md b/CHANGELOG.md index d5d89754..7fd83771 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -10,6 +10,46 @@ All notable changes to CableDyn are recorded in this file. The format follows ### Added +- Seabed friction in the static solve, toward the as-laid position (OrcaFlex's *as laid* + statics seabed friction policy, opt-in): `asLaid staticsFriction`. Every grounded node is + held by a friction spring toward the position at which the line was laid from its lower end + (the anchor, or the fairlead when that is lower) along the lay azimuth on the seabed, with the regularised Coulomb law of the dynamics + (isotropic or axial/lateral, capped at `mu N`), in still water and in a current, on `EI = 0` + and finite-EI lines, standalone, coupled OpenFAST and through the C API; the march continues + the static springs, so a held run stays at rest. New OPTIONS `staticsFriction none|asLaid`, + `layAzimuth` and `layAzimuth` (default: the horizontal direction of each line's chord, + from its lower end), + `asLaidTension` and `asLaidTension` (default 0). The default stays `none`, as in MoorDyn: + frictionless statics in still water (friction from the still-water equilibrium in a current), + conservative for anchor loads, and every deck without the new rows runs as before. With + `asLaid`, a 700 m chain on a 5° slope with `frictionMu 1`, which the frictionless static + folds 24.0 m back past its anchor, holds where it was laid (friction up to 0.087 `mu N`, the + slope; FairTen 714.2 → 622.9 kN; held for 2 s to 1.5e-10 of FairTen), and a 650 m finite-EI + cable on a 10° slope, rejected as too long for its span, solves. As an illustration of the + effect on anchor loads, `asLaid` in `iea15mw_umaine_mixed_cabledyn.dat` lowers the chains' + AnchTen from 1351.6 to 368.2 kN (FairTen +0.16 %) and the laid cable's from 1230 N to 0.36 N: + runs laid slack and pulled taut are held back by friction. A run laid at the tension it + carries (`asLaidTension`) mobilises none: on a flat seabed FairTen equals the frictionless + one to 6e-6 and AnchTen to 0.4 %. A finite-EI line laid past the point under its fairlead has + no static solution yet (its touchdown hook is not reached); a lay azimuth across the span + solves it. A lay azimuth across the vertical plane of the chord, or a bathymetry sloping across + it under the laid run, solves a finite-EI line in 3D from the start (so a march from it stays + at rest), and a finite-EI line is laid from its lower end like an `EI = 0` one; a line whose + fairlead lies below its other end is laid, and seeded, from the fairlead. With discrete + `ATTACHMENTS` the reference sinks each node under its discrete load (its share of the line's + weight plus the attachment's net weight), so a module node rests on the laid path like the rest + of the run instead of taking its sink for a friction deflection. On a mesh the finite-EI + statics refines (adaptive refinement, the bending-length and stability refinements) or + coarsens, the reference is laid on that mesh itself, under its own lumped weights and nodal + seabed stiffnesses, and the march takes it on the final mesh: a run refined 16x on a seabed + curved along it and sloping across it, with a section change on the grounded run, rests where + its twin declared on the refined mesh does (to solver precision), where a reference + interpolated from the deck nodes moved it by up to 1 mm and reversed its lateral anchor force. The policy is rejected + where the statics carry no seabed friction: on decks with bodies, rods or dynamic + (`Connect`/`Free`) points (`frictionMu` itself is rejected on the latter and accepted on the + default monolithic body and rod march), and on a finite-EI deck whose line has a moving End B + (a line shared between two turbines, which takes the compatibility route). The Python `DeckFile`, `DeckWriter` and `DeckModel` take the new + rows. See the theory page (Friction in statics). - Run-time profile of the standalone driver. With the environment variable `CABLEDYN_PROFILE=1`, the driver prints at the end of the run how its wall time divides between input parsing, initialisation and statics, and the dynamic march. The march is split diff --git a/CMakeLists.txt b/CMakeLists.txt index 57752120..f3fbb945 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -1393,6 +1393,19 @@ if(Python3_Interpreter_FOUND) TIMEOUT 900 ENVIRONMENT "${_cabledyn_python_test_environment}") + # Static seabed friction toward the as-laid position: a run on a slope below the friction + # angle holds (EI = 0 and finite EI), the march continues the static springs at rest, a + # line laid at its run tension reproduces the frictionless statics, and the inputs are + # checked. + add_test(NAME static_friction_as_laid + COMMAND ${Python3_EXECUTABLE} ${CMAKE_CURRENT_SOURCE_DIR}/tests/test_static_friction_as_laid.py + --exe $ + --output ${CMAKE_BINARY_DIR}/static_friction_as_laid) + set_tests_properties(static_friction_as_laid PROPERTIES + LABELS "python;static;seabed" + TIMEOUT 600 + ENVIRONMENT "${_cabledyn_python_test_environment}") + # Finite-EI generalised-alpha blends: force-blend dtM convergence under prescribed surge. add_test(NAME hermite_force_blend_dt COMMAND ${Python3_EXECUTABLE} ${CMAKE_CURRENT_SOURCE_DIR}/tests/test_hermite_force_blend_dt.py diff --git a/doc/driver_format.md b/doc/driver_format.md index cb048610..5b39e369 100644 --- a/doc/driver_format.md +++ b/doc/driver_format.md @@ -992,8 +992,11 @@ syntax form. The most frequently edited keywords are: | `kBot` | seabed penalty stiffness base [Pa/m = N/m³], scaled per line node and rod contact station by diameter × tributary length, and by a fixed 1 m² reference area at a Rigid6 reference point (only with `WtrDpth`/`bathymetryFile`) | 1.0e5 | | `cBot` | seabed normal damping base [Pa·s/m = N·s/m³], scaled like `kBot`; active only on contacting nodes moving downward | 1.0e4 | | `bodyIC` | `static`: free `Rigid6` bodies and free rods, with `Free`/`Connect` points, start at their static equilibrium; `deck`: they start at their deck pose (for example a free-decay test) | `static` | -| `frictionMu` / `mu` | isotropic seabed friction coefficient: stick-slip springs on line nodes (held by the static solve too in a deck current, from the still-water laid shape), regularised kinetic friction on rods and bodies; requires `WtrDpth` or `bathymetryFile`, and `dtM`/`TMax` in the standalone driver. Rejected on some routes (decks with `Connect`/`Free` points, `Point3` buoys or `FAILURE` rows, and body or rod decks off the default monolithic march); see the [OPTIONS reference](options.rst) | 0 | +| `frictionMu` / `mu` | isotropic seabed friction coefficient: stick-slip springs on line nodes (held by the static solve too in a deck current, from the still-water laid shape, or toward the as-laid position with `staticsFriction asLaid`), regularised kinetic friction on rods and bodies; requires `WtrDpth` or `bathymetryFile`, and `dtM`/`TMax` in the standalone driver. Rejected on some routes (decks with `Connect`/`Free` points, `Point3` buoys or `FAILURE` rows, and body or rod decks off the default monolithic march); see the [OPTIONS reference](options.rst) | 0 | | `frictionMuAxial` / `frictionMuLateral` | anisotropic line friction: the coefficients along and across the local line axis (OrcaFlex axial/normal); an omitted one takes `frictionMu`; both positive or both zero; rods and bodies use the lateral one | `frictionMu` | +| `staticsFriction` | statics seabed friction policy (OrcaFlex): `none` solves frictionless statics (in a deck current, friction from the still-water equilibrium); `asLaid` holds every grounded node toward its as-laid position (laid from the line's lower end, the anchor or the fairlead when that is lower, along `layAzimuth` at `asLaidTension`) with the regularised Coulomb law; rejected where the statics solve the lines without seabed friction (decks with bodies, rods or `Connect`/`Free` points, and a finite-EI line whose End B is not `Fixed`, as a line shared between two turbines) | `none` | +| `layAzimuth`, `layAzimuth` | lay azimuth (deg, from +x toward +y) of every line, or of line `ID` | chord direction, from the lower end | +| `asLaidTension`, `asLaidTension` | as-laid effective tension (N, ≥ 0) of every line, or of line `ID` | 0 | | `dtM` | dynamic time step [s] | — | | `TMax` | dynamic end time [s]; an integer multiple of `dtM` | — | | `rhoInf` | generalised-α spectral radius | 0.4 | diff --git a/doc/modeling.rst b/doc/modeling.rst index ecaaf2d0..b68537c8 100644 --- a/doc/modeling.rst +++ b/doc/modeling.rst @@ -154,6 +154,14 @@ fallback) rather than by artificial drag-scaled relaxation. A converged solver is necessary but not sufficient: reject a result with the wrong touchdown side, impossible tension gradient, penetrated seabed, broken symmetry, or unresolved curvature peak. +With seabed friction (``frictionMu``) the static solve is frictionless in still water by +default, as in MoorDyn, which is conservative for anchor loads. ``asLaid staticsFriction`` +holds the grounded run toward the position in which the line was laid, as OrcaFlex's *as laid* +policy does: then decide how the line was laid (``layAzimuth``, by default along the chord +from its lower end, normally the anchor) and at what tension (``asLaidTension``, by default slack), because the +anchor tension depends on it: a run laid slack and pulled taut is held back by friction. See +:ref:`friction in statics `. + 7. Configure dynamics and forcing ---------------------------------- diff --git a/doc/options.rst b/doc/options.rst index 2794e0b2..ac834613 100644 --- a/doc/options.rst +++ b/doc/options.rst @@ -105,7 +105,8 @@ Environment and seabed - finite, ≥ 0, or ``none``. A positive value needs ``WtrDpth`` or ``bathymetryFile``, and ``dtM``/``TMax`` in the standalone driver. Line nodes carry stick-slip friction springs; in a current the static solve holds the line with friction springs from its still-water laid - shape, and the march continues them. The isotropic shorthand of + shape, and the march continues them (``staticsFriction asLaid`` holds it toward its + as-laid position instead, in still water too). The isotropic shorthand of ``frictionMuAxial``/``frictionMuLateral``. Not supported (the deck is rejected) with a ``FAILURE`` section, on a deck with ``Connect``/``Free`` points or ``Point3`` buoys, or on a deck whose lines attach to ``Rigid6`` bodies or rods unless it runs on the default @@ -126,6 +127,56 @@ Environment and seabed ``frictionMuNormal``, ``frictionMu_normal`` for the lateral one. See :doc:`theory` - both, within the limits of ``frictionMu`` - ``0.2 frictionMuAxial`` + * - ``staticsFriction`` / ``statics_friction`` / ``staticsSeabedFrictionPolicy`` / + ``seabedFrictionPolicy`` + - word + - ``none`` + - ``none`` or ``asLaid`` (also ``as_laid``, ``as-laid``), case-insensitive; OrcaFlex's + statics seabed friction policy. ``none``: the static solve is frictionless in still water + and the friction anchors of the march start at the static node positions; in a deck + current friction springs from the still-water equilibrium hold the line, and the anchors + continue their static forces. ``asLaid``: the + static solve resists the horizontal displacement of every grounded node from its as-laid + position (the line laid from its lower end, the anchor or the fairlead when that is lower, + along ``layAzimuth`` on the seabed at ``asLaidTension``, its top end then moved to its + position; on a mesh the finite-EI statics refines, laid on the refined mesh) with the + regularised Coulomb + law of the dynamics, capped at ``mu N``, in still water and in a current, so a run on a + slope with ``tan(slope) < mu`` holds and surplus length rests where it was laid; the + march continues the springs. ``none`` is the default, as in MoorDyn: a run laid slack + and pulled taut is held back by its friction, so the as-laid statics lowers anchor + tensions (by up to ``mu w`` times the grounded length), and the frictionless statics is + the conservative choice for anchor loads unless the as-laid layout and tension are + known. Used only with ``frictionMu > 0`` and a seabed; rejected where the static + equilibrium solves the lines without seabed friction: on decks with bodies, rods or + ``Connect``/``Free`` points (``frictionMu`` itself is accepted on the default monolithic + body and rod march), and on the finite-EI two-moving-end route (a line whose End B is + not ``Fixed``, as a line shared between two turbines). See + :ref:`friction in statics ` + - both + - ``asLaid staticsFriction`` + * - ``layAzimuth`` / ``lay_azimuth``, and ``layAzimuth`` + - real, deg + - absent: each line's chord direction, from its lower end (anchor → fairlead, or + fairlead → anchor when the fairlead is lower) + - finite. Horizontal direction, from global +x toward +y, in which the line was laid away + from its lower end (the anchor, or the fairlead when that is lower): the as-laid + reference of ``staticsFriction asLaid``. + ``layAzimuth`` sets every line; ``layAzimuth`` (the line ID appended, e.g. + ``layAzimuth2``) sets line ``ID`` and overrides it. A direction off the vertical plane of + the line ends puts the finite-EI static solve in 3D, as does a bathymetry sloping across + that plane under the laid run. An ID that names no line is rejected + - both + - ``225.0 layAzimuth2`` + * - ``asLaidTension`` / ``as_laid_tension``, and ``asLaidTension`` + - real, N + - ``0`` + - finite, ≥ 0. Effective tension with which the line was laid: the as-laid node spacing is + the unstretched one times ``1 + asLaidTension/EA``, so a run on a level seabed whose + static tension equals it carries no friction force. ``asLaidTension`` sets line ``ID`` alone, as for + ``layAzimuth`` + - both + - ``2.0e5 asLaidTension1`` Clock and initial condition --------------------------- diff --git a/doc/theory.rst b/doc/theory.rst index f8dee70b..46fbf879 100644 --- a/doc/theory.rst +++ b/doc/theory.rst @@ -751,24 +751,111 @@ failed or subdivided step, join the aggregate snapshot, and are part of the Open checkpoint. The force and its position and velocity Jacobians (through :math:`N`) are exact. Unlike a velocity-regularised Coulomb law, the spring holds its force at rest. -In statics without a current the anchors are the static node positions and carry no force. In -a deck current the static solve carries friction springs from a reference position, capped -smoothly at :math:`\mu N`, +.. _static-friction: + +**Friction in statics.** With seabed friction a static equilibrium is not unique: a grounded +run can rest anywhere its friction holds it. Like OrcaFlex, CableDyn resolves this by assuming +the position in which the line was originally laid and letting friction act toward it. +OrcaFlex (Orcina's documentation, *Line data: statics*, +https://www.orcina.com/webhelp/OrcaFlex/Content/html/Linedata,Statics.htm, and *Friction +theory*, https://www.orcina.com/webhelp/OrcaFlex/Content/html/Frictiontheory.htm) offers the +statics seabed friction policies *none*, *as laid* and *restart*. As laid, with a step 1 +statics method other than *prescribed*, the line is assumed laid starting with its bottom end +at its position, in the *lay azimuth* direction away from it, following the seabed profile, and +its top end then moved slowly to its position; the friction targets are spaced along the +seabed by the unstretched segment lengths and the *as laid tension*, so a line with every node +on its target carries that tension throughout. Friction applies in statics only to line-seabed +contact and only when the policy is not *none*; each node's force acts toward its target and +is capped at :math:`\mu R`, and dynamics then starts from the target positions of statics. +OrcaFlex warns that a lay azimuth far from the vertical plane through the line ends makes the +statics harder to converge. The documentation consulted does not state the defaults of these +three data items. + +CableDyn implements the *as laid* and *none* policies (``staticsFriction``; *restart* has no +counterpart, and there is no prescribed starting shape). *None* is the default, as in MoorDyn: +the static solve is frictionless in still water, and in a deck current the friction springs +below hold the line from its still-water equilibrium (the same line solved without the current +first). It is conservative for anchor loads, since an as-laid run pulled taut is held back by +its friction (below). With ``asLaid`` the reference of +node :math:`i` is the as-laid position: the line is laid from its lower end (the anchor, or the +fairlead when that is lower) along the azimuth :math:`\alpha` away from it (``layAzimuth``; by +default the horizontal direction of the chord from that end, the vertical plane through the +line ends) on the seabed at the tension :math:`T_\text{laid}` (``asLaidTension``, default 0), +so that the seabed path from that end to node :math:`i` is :math:`s_i = \sum_{e`) is tried first. Seed nodes deeper below the seabed than their static penetration are lifted onto it. 2. **Compression-capable Newton** at the full load (Armijo line search on :math:`\tfrac{1}{2}\lVert\mathbf{R}\rVert^2`, :ref:`Armijo, 1966 `). A converged diff --git a/doc/troubleshooting.rst b/doc/troubleshooting.rst index 9fd5209f..c2f34a07 100644 --- a/doc/troubleshooting.rst +++ b/doc/troubleshooting.rst @@ -464,6 +464,24 @@ but a few geometries are genuinely hard: turning angles; a finite-EI line carries compression there instead, which the driver notes. With 5 m elements on steep trench walls the end tensions of a pile still change by about 1 % on a mesh four times finer: refine the line over the trench when they matter. +- **A grounded run that slides down a slope, or anchor tension with as-laid friction.** By default + (``staticsFriction none``) the static solve is frictionless in still water, so a grounded run + on a slope slides down it whatever ``frictionMu`` is, and a line longer than its span folds or + is rejected. ``asLaid staticsFriction`` holds every grounded node toward its as-laid position + (see :ref:`friction in statics `), so the run rests where it was laid. A line laid slack + (``asLaidTension 0``) and pulled taut by its fairlead is then held back by friction along its + grounded run, and its anchor tension is lower than the frictionless static's by up to + ``mu w`` times the grounded length (an 850 m chain in 200 m of water with ``frictionMu 0.35``: + 1352 → 368 kN). If the run was laid at a known tension, give it as ``asLaidTension`` (or + ``asLaidTension``): a run laid at the tension it carries mobilises no friction. +- **A finite-EI line laid past the point under its fairlead** (``asLaid staticsFriction``). A line + longer than the seabed run + from its anchor to the point under its fairlead plus its hang is laid beyond that point, and + its suspended part turns back over the grounded run at the touchdown. On an ``EI = 0`` line + this fold solves; a finite-EI line must round it into a hook of its bending length, which the + static solve may not reach (it then fails with its route diagnostics, for example ``too long + for its span``). Lay the line across the span (``layAzimuth``, e.g. 90° from the + anchor → fairlead direction), shorten it, or move the anchor. - **A twisted finite-EI line.** ``torsion continuation stalled at Phi = ... (target ...)`` reports the imposed twist the static ramp reached: beyond it the line has no nearby static equilibrium on the path, typically because a loop is forming (hockling), which needs a diff --git a/examples/cabledyn_options_reference.dat b/examples/cabledyn_options_reference.dat index 5b931ff4..a4223f66 100644 --- a/examples/cabledyn_options_reference.dat +++ b/examples/cabledyn_options_reference.dat @@ -77,6 +77,11 @@ none waves - Wave model and parameters (m, s, deg) {none; airy; -- 3 WaterKin - MoorDyn-C WaveKin 3/7: wave_elevation.txt / wave_frequencies.txt in the deck folder -- 0.5 frictionMuAxial - Seabed friction along the line axis {>=0} [default: frictionMu] -- 0.5 frictionMuLateral - Seabed friction across the line axis {>=0} [default: frictionMu] +-- asLaid staticsFriction - Statics seabed friction policy {none; asLaid} [default: none] +-- 0.0 layAzimuth - Lay azimuth of every line from +x toward +y (deg) [default: anchor -> fairlead] +-- 225.0 layAzimuth2 - Lay azimuth of line 2 alone (deg) [default: layAzimuth] +-- 0.0 asLaidTension - As-laid effective tension of every line (N) [default: 0] +-- 2.0e5 asLaidTension2 - As-laid effective tension of line 2 alone (N) [default: asLaidTension] -- 0 nModes - Modal analysis: lowest natural modes per line {0=off; 1 to 1000} [default: 0] -- "WaterKin.dat" WaterKin - MoorDyn-F WaterKin file (standalone file modes or coupled host selectors) -- SEASTATE WaterKin - Full host SeaState field (OpenFAST aggregate only) @@ -92,6 +97,8 @@ none waves - Wave model and parameters (m, s, deg) {none; airy; -- Keyword aliases (equivalent spellings, case-insensitive): -- g = gravity; rhoW = WtrDnsty = water_density; WtrDpth = water_depth; kBot = kb; cBot = cb -- bathymetryFile = bathymetry_file = seafloorFile = seafloor_file; frictionMu = mu = frictionCoefficient +-- staticsFriction = statics_friction = staticsSeabedFrictionPolicy = seabedFrictionPolicy +-- layAzimuth = lay_azimuth; asLaidTension = as_laid_tension -- dtM = dt; rhoInf = rho_inf; modified_newton = modifiedNewton; adaptive_mesh = adaptiveMesh -- cable_statics = cableStatics; alpha_force_blend = alphaForceBlend -- maxStrain = max_strain; WaveSeed = wave_seed; rampTime = ramp_time = tRamp diff --git a/python/cabledyn/builder.py b/python/cabledyn/builder.py index 71666747..d2223602 100644 --- a/python/cabledyn/builder.py +++ b/python/cabledyn/builder.py @@ -39,7 +39,6 @@ _PINNED_END_CONNECTIONS, _RIGID_END_CONNECTIONS, _ROD_ATTACHMENT_ALIASES, - _SCALAR_OPTION_KEYWORDS, _WAVETRAIN_KEYWORDS, DeckFile, DeckRecord, @@ -47,6 +46,7 @@ _copy_companions, _end_connection_end, _is_csys_token, + _is_scalar_option_keyword, _is_turbine_point_type, _native_int, _option_key, @@ -970,7 +970,7 @@ def _make(keyword: str, values: tuple[object, ...], description: str | None) -> or lowered in _WAVETRAIN_KEYWORDS or _option_key(lowered) in _POSITIONAL_KEYS ) - if lowered not in _SCALAR_OPTION_KEYWORDS and not multi: + if not _is_scalar_option_keyword(lowered) and not multi: raise ValueError(f"unknown option keyword {keyword!r}") if not values: raise ValueError(f"option {keyword} needs a value") diff --git a/python/cabledyn/deck.py b/python/cabledyn/deck.py index 81b66ec5..0f9066c2 100644 --- a/python/cabledyn/deck.py +++ b/python/cabledyn/deck.py @@ -20,7 +20,7 @@ from dataclasses import dataclass, field from pathlib import Path -from cabledyn.deck_file import _SCALAR_OPTION_KEYWORDS, DeckFile +from cabledyn.deck_file import DeckFile, _is_scalar_option_keyword _POINT_TYPES = {"fixed", "coupled", "vessel", "free", "connect"} _END_CONNECTION_ENDS = { @@ -391,7 +391,7 @@ def set_option( f"option keyword must be a string, got {type(keyword).__name__}; " "the argument order is set_option(value, keyword, description)" ) - if keyword.lower() not in _SCALAR_OPTION_KEYWORDS: + if not _is_scalar_option_keyword(keyword): raise ValueError( f"unknown option keyword {keyword!r}; the argument order is " "set_option(value, keyword, description)" diff --git a/python/cabledyn/deck_file.py b/python/cabledyn/deck_file.py index 66341c0f..be7f0813 100644 --- a/python/cabledyn/deck_file.py +++ b/python/cabledyn/deck_file.py @@ -240,7 +240,20 @@ "alphaforceblend": "alpha_force_blend", "cable_statics": "cable_statics", "cablestatics": "cable_statics", + "staticsfriction": "statics_friction", + "statics_friction": "statics_friction", + "staticsseabedfrictionpolicy": "statics_friction", + "seabedfrictionpolicy": "statics_friction", + "layazimuth": "lay_azimuth", + "lay_azimuth": "lay_azimuth", + "aslaidtension": "as_laid_tension", + "as_laid_tension": "as_laid_tension", } +# Per-line static friction rows (native apply_option): ``layAzimuth`` and ``asLaidTension`` +# with the LINE id appended; the id is a plain decimal suffix, and leading zeros name the same line. +_LINE_OPTION_PATTERN = re.compile(r"(layazimuth|aslaidtension)([0-9]+)\Z") +_LINE_OPTION_FAMILIES = {"layazimuth": "lay_azimuth", "aslaidtension": "as_laid_tension"} +_STATICS_FRICTION_POLICIES = frozenset({"aslaid", "as_laid", "as-laid", "none"}) _SCALAR_OPTION_KEYWORDS = frozenset(_OPTION_ALIASES) | { "icmode", "bodyic", @@ -800,12 +813,34 @@ def _selector_int(text: object, what: str) -> int: raise ValueError(f"{what} must be an integer, got {text!r}") +def _line_option(keyword: str) -> tuple[str, int] | None: + """Return (family, line id) of a per-line static friction row, else ``None``. + + ``layAzimuth`` and ``asLaidTension`` (case-insensitive) set the lay azimuth and the + as-laid tension of the LINE ``ID`` alone, over the global ``layAzimuth`` / ``asLaidTension`` + row; the family is ``lay_azimuth`` or ``as_laid_tension``. + """ + match = _LINE_OPTION_PATTERN.match(keyword.lower()) + if match is None: + return None + return _LINE_OPTION_FAMILIES[match.group(1)], int(match.group(2)) + + +def _is_scalar_option_keyword(keyword: str) -> bool: + """Whether ``keyword`` (any case) is a two-token scalar OPTIONS keyword (per-line rows too).""" + return keyword.lower() in _SCALAR_OPTION_KEYWORDS or _line_option(keyword) is not None + + def _option_key(keyword: str) -> str: """Return the native identity of an option keyword (aliases collapse to one key).""" lowered = keyword.lower() if lowered in _WAVETRAIN_KEYWORDS: # native CD_Sea_Parse_Train takes both spellings of the one keyword return "wavetrain" + line_option = _line_option(lowered) + if line_option is not None: + # layAzimuth7 and layAzimuth07 set the same line natively: the last row wins + return f"{line_option[0]}:{line_option[1]}" return _OPTION_ALIASES.get(lowered, lowered) @@ -1029,7 +1064,7 @@ def _dynamic_solver_values_are_valid(values: list[str] | tuple[str, ...]) -> boo def _scalar_option_value_error(keyword: str, value: str) -> str | None: """Return why a two-token scalar row violates ``apply_option`` semantics.""" raw = keyword.lower() - key = _option_key(raw) + key = _option_key(raw).partition(":")[0] # a per-line row takes its family's rules defect = _real_token_defect(value) if defect is not None and "subnormal" in defect: return defect @@ -1051,6 +1086,7 @@ def _scalar_option_value_error(keyword: str, value: str) -> str | None: "friction", "friction_axial", "friction_lateral", + "as_laid_tension", "tensile_strain_tolerance", "ramp_time", "max_strain", @@ -1077,6 +1113,8 @@ def _scalar_option_value_error(keyword: str, value: str) -> str | None: "friction", "friction_axial", "friction_lateral", + "lay_azimuth", + "as_laid_tension", "rhoinf", "tensile_strain_tolerance", "ramp_time", @@ -1170,6 +1208,13 @@ def _scalar_option_value_error(keyword: str, value: str) -> str | None: if abs(numeric - round(numeric)) > integer_tolerance: return "must be an integer" return None + if key == "statics_friction": + # native: the policy is dequoted and compared case-insensitively + return ( + None + if _strip_quotes(value).lower() in _STATICS_FRICTION_POLICIES + else "must be asLaid or none" + ) if key == "cable_statics": return ( None @@ -2076,7 +2121,7 @@ def _option_row(self, index: int) -> OptionRecord | None: "Coulomb friction set by frictionMu, frictionMuLateral and frictionMuAxial; " "remove the row" ) - if keyword.lower() not in _SCALAR_OPTION_KEYWORDS: + if not _is_scalar_option_keyword(keyword): raise DeckFormatError(f"{where}: unknown OPTION keyword {keyword!r}") if error := _scalar_option_value_error(keyword, tokens[0]): raise DeckFormatError(f"{where}: OPTION {keyword} {error}") @@ -2660,6 +2705,11 @@ def end_key(token: str) -> str: for point_type in point_types.values() ) line_ids = unique(self.lines, "line", True) + for option in options: + line_option = _line_option(option.keyword) + if line_option is not None and str(line_option[1]) not in line_ids: + # native: layAzimuth / asLaidTension must name a LINE + raise DeckFormatError(f"{self._label}: OPTION {option.keyword} names no LINE") section_lines: set[str] = set() section_types_by_line: dict[str, list[str]] = {line_id: [] for line_id in line_ids} line_nelems: dict[str, int] = dict.fromkeys(line_ids, 0) diff --git a/python/tests/test_builder.py b/python/tests/test_builder.py index 3afee401..8ee00ec9 100644 --- a/python/tests/test_builder.py +++ b/python/tests/test_builder.py @@ -599,6 +599,31 @@ def test_collections_are_live_lookups() -> None: assert "DeckModel" in repr(model) +def test_option_set_static_friction_rows() -> None: + model = _chain_model() + options = model.options + options.set("staticsFriction", "asLaid") + options.set("layAzimuth", 45.0) + options.set("layAzimuth1", 180.0) + options.set("LAYAZIMUTH01", 90.0) # the same line as layAzimuth1: replaces it + options.set("asLaidTension1", 1.0e5) + assert [row.keyword for row in options if row.keyword.lower().startswith("layazimuth")] == [ + "layAzimuth", + "LAYAZIMUTH01", + ] + assert options.value("layAzimuth1") == "90.0" and options.value("asLaidTension1") == "100000.0" + assert options.value("layAzimuth2") is None + model.validate() + text = model.to_text() + assert "asLaid staticsFriction" in text and "90.0 LAYAZIMUTH01" in text + assert options.remove("layAzimuth1") == 1 and "layAzimuth" in options + with pytest.raises(ValueError, match="unknown option keyword"): + options.set("layAzimuth1x", 1.0) + options.set("layAzimuth3", 10.0) + with pytest.raises(Exception, match="names no LINE"): + model.validate() + + def test_option_set_semantics() -> None: model = _chain_model() options = model.options diff --git a/python/tests/test_deck_file.py b/python/tests/test_deck_file.py index 3141e498..74a5d40c 100644 --- a/python/tests/test_deck_file.py +++ b/python/tests/test_deck_file.py @@ -4093,6 +4093,92 @@ def test_anisotropic_friction_rows_fail_closed_like_native(rows, message): DeckFile.from_text(_wave_source(rows)) +@pytest.mark.parametrize( + "rows", + [ + "asLaid staticsFriction", + "none staticsFriction", + "ASLAID statics_friction", + "As_Laid staticsSeabedFrictionPolicy", + '"as-laid" seabedFrictionPolicy', + "45.0 layAzimuth", + "-30 lay_azimuth", + "180 layAzimuth1", + "2.0e5 asLaidTension", + "0 as_laid_tension", + "1e5 ASLAIDTENSION1", + "10 layAzimuth01\n20 layAzimuth1\n0.5 frictionMu\nasLaid staticsFriction", + ], +) +def test_static_friction_rows_are_native_compatible(rows): + deck = DeckFile.from_text(_wave_source(rows)) + deck.validate() + assert deck.options + + +@pytest.mark.parametrize( + ("rows", "message"), + [ + ("restart staticsFriction", "OPTION staticsFriction must be asLaid or none"), + ("1 seabedFrictionPolicy", "must be asLaid or none"), + ("inf layAzimuth", "must be finite"), + ("abc layAzimuth", "must be numeric"), + ("nan layAzimuth1", "must be finite"), + ("-1 asLaidTension", "must be >= 0"), + ("-1 asLaidTension1", "must be >= 0"), + ("inf as_laid_tension", "must be finite"), + ("30 layAzimuth2", "layAzimuth2 names no LINE"), + ("30 layAzimuth0", "layAzimuth0 names no LINE"), + ("30 asLaidTension7", "asLaidTension7 names no LINE"), + ("30 layAzimuth99999999999999999999", "names no LINE"), + ("1 asLaidTension99999999999999999999", "names no LINE"), + ("30 layAzimuth1x", "unknown OPTION keyword 'layAzimuth1x'"), + ("30 layAzimuth_1", "unknown OPTION keyword"), + ("30 layAzimuthx", "unknown OPTION keyword"), + ("30 asLaidTension-1", "unknown OPTION keyword"), + ], +) +def test_static_friction_rows_fail_closed_like_native(rows, message): + with pytest.raises(DeckFormatError, match=message): + DeckFile.from_text(_wave_source(rows)).validate() + + +def test_static_friction_option_identities_and_editing(): + deck = DeckFile.from_text( + _wave_source( + "90 layAzimuth\n45 LayAzimuth1\n30 layazimuth01\n0 asLaidTension\n" + "5e4 asLaidTension1\nasLaid STATICSFRICTION" + ) + ) + deck.validate() + assert deck.option("layAzimuth").values == ("90",) + assert deck.option("lay_azimuth").values == ("90",) + # layAzimuth1, LayAzimuth1 and layazimuth01 name one line: the last row wins + assert deck.option("layAzimuth1").values == ("30",) + assert deck.option("LAYAZIMUTH001").values == ("30",) + assert deck.option("asLaidTension1").values == ("5e4",) + assert deck.option("as_laid_tension").values == ("0",) + assert deck.option("staticsFriction").values == ("asLaid",) + assert deck.option("seabedFrictionPolicy").values == ("asLaid",) + with pytest.raises(KeyError): + deck.option("layAzimuth2") + deck.set_option("layAzimuth1", 120.0) + deck.set_option("lay_azimuth", -15) + deck.set_option("staticsFriction", "none") + assert deck.option("layAzimuth01").values == ("120",) + assert deck.option("layAzimuth").values == ("-15",) + assert deck.option("staticsFriction").values == ("none",) + with pytest.raises(DeckFormatError, match="asLaid or none"): + deck.set_option("staticsFriction", "restart") + with pytest.raises(DeckFormatError, match=">= 0"): + deck.set_option("asLaidTension1", -2.0) + with pytest.raises(DeckFormatError, match="must be finite"): + deck.set_option("layAzimuth1", float("inf")) + assert deck.option("staticsFriction").values == ("none",) + assert deck.option("asLaidTension1").values == ("5e4",) + assert DeckFile.from_text(deck.text()).option("layAzimuth1").values == ("120",) + + @pytest.mark.parametrize( ("row", "message"), [ diff --git a/python/tests/test_deck_writer.py b/python/tests/test_deck_writer.py index 3bffb6c2..b0e92a31 100644 --- a/python/tests/test_deck_writer.py +++ b/python/tests/test_deck_writer.py @@ -65,6 +65,25 @@ def test_writer_output_validates_and_round_trips(tmp_path): assert path.read_text(encoding="ascii") == deck.text() +def test_writer_accepts_static_friction_rows(tmp_path): + deck = _writer() + deck.set_option("asLaid", "staticsFriction", "Statics seabed friction policy") + deck.set_option(45.0, "layAzimuth") + deck.set_option(180.0, "layAzimuth1") + deck.set_option(2.0e5, "asLaidTension1") + parsed = DeckFile.read(deck.write(tmp_path / "friction.dat")) + assert parsed.option("staticsFriction").values == ("asLaid",) + assert parsed.option("layAzimuth").values == ("45.0",) + assert parsed.option("LAYAZIMUTH1").values == ("180.0",) + assert parsed.option("asLaidTension1").values == ("200000.0",) + with pytest.raises(ValueError, match="unknown option keyword 'layAzimuth1x'"): + deck.set_option(1.0, "layAzimuth1x") + bad = _writer() + bad.set_option(30.0, "layAzimuth7") + with pytest.raises(DeckFormatError, match="names no LINE"): + bad.text() + + def test_set_option_rejects_swapped_value_and_keyword(): deck = _writer() with pytest.raises(TypeError, match="set_option\\(value, keyword"): diff --git a/src/CableDyn_DeckDriver.f90 b/src/CableDyn_DeckDriver.f90 index b57ea388..dbc3a5a1 100644 --- a/src/CableDyn_DeckDriver.f90 +++ b/src/CableDyn_DeckDriver.f90 @@ -37,7 +37,8 @@ MODULE CableDyn_DeckDriver CD_Assemble_Cable_Tangent_Force_Banded_Free USE CableDyn_Static, ONLY: CableSolverConfig, CableCurrentLoad, CD_StaticLineReport, CD_Static_Line_Equilibrium, & CD_Static_Line_End_Forces, CD_Static_Anchor_Seabed_Tolerance, CD_Static_Cable_Solve, & - CD_STATIC_OK, CD_STATIC_BADINPUT + CD_STATIC_OK, CD_STATIC_BADINPUT, & + CD_STATIC_FRICTION_AS_LAID, CD_STATIC_FRICTION_NONE USE CableDyn_Bathymetry, ONLY: CD_BathymetryType, CD_Init_Bathymetry, CD_End_Bathymetry, & CD_Bathymetry_Is_Initialized, CD_Bathymetry_Floor, & CD_Bathymetry_Floor_Gradient, CD_Bathymetry_Grid_Floor, CD_BATHY_OK @@ -85,6 +86,7 @@ MODULE CableDyn_DeckDriver CD_HermiteResolutionType, CD_HC_HKAPPA_TARGET, CD_HC_REFINE_CAP, & CD_HermiteCable_Refine_Mesh, CD_HermiteStaticCurrentType, & CD_HermiteCable_Friction_Anchors, CD_HermiteCable_Mean_Axial_Extremes, & + CD_HermiteCable_Friction_Reference, CD_HermiteCable_As_Laid_Offsets, & CD_HC_KINK_LIMIT, CD_HermiteCable_Static_Solve_Continuation, & CD_HermiteCable_Branch_Audit, CD_HermiteBranchAuditType, & CD_HC_AUDIT_BACKTRACK, CD_HC_AUDIT_COMPRESSION, CD_HC_AUDIT_KINK, & @@ -537,6 +539,16 @@ MODULE CableDyn_DeckDriver ! the one along the line; -1 = isotropic (frictionMu alone). REAL(wp) :: friction_mu_axial = -1.0_wp REAL(wp) :: friction_mu_axial_row = -1.0_wp, friction_mu_lateral_row = -1.0_wp + ! Static seabed friction (staticsFriction, layAzimuth, asLaidTension rows): the policy + ! (CD_STATIC_FRICTION_NONE, the default, or _AS_LAID), the lay azimuth [deg] for every + ! line (has_lay_azimuth; otherwise each line's chord direction, from its lower end) and the + ! as-laid tension [N], with per-line overrides (layAzimuth, asLaidTension). + INTEGER :: static_friction = CD_STATIC_FRICTION_NONE + LOGICAL :: has_lay_azimuth = .FALSE. + REAL(wp) :: lay_azimuth_deg = CD_ZERO + REAL(wp) :: as_laid_tension = CD_ZERO + INTEGER, ALLOCATABLE :: lay_azimuth_line(:), as_laid_tension_line(:) + REAL(wp), ALLOCATABLE :: lay_azimuth_line_deg(:), as_laid_tension_line_value(:) LOGICAL :: has_wtrdpth = .FALSE. LOGICAL :: has_bathymetry_file = .FALSE. LOGICAL :: has_dtm = .FALSE., has_tmax = .FALSE. @@ -1318,6 +1330,15 @@ SUBROUTINE init_finite_deck_models(types, points, lines, sections, opts, models, CALL fail(ErrStat, ErrMsg, 'mixed EI=0 and finite-EI dynamic decks are not supported by this entry point') RETURN END IF + ! This compatibility route (a finite-EI deck with a line whose End B is not Fixed) solves + ! its statics without seabed friction: fail closed on the as-laid policy instead of + ! starting from a frictionless equilibrium reported as the as-laid one. + IF (opts%has_friction .AND. opts%static_friction == CD_STATIC_FRICTION_AS_LAID) THEN + CALL fail(ErrStat, ErrMsg, 'OPTION staticsFriction asLaid is not applied by the finite-EI route of a deck '// & + 'whose line has a moving End B (End B not Fixed); hold End B at a Fixed point or use '// & + 'staticsFriction none') + RETURN + END IF ALLOCATE (models(SIZE(lines))) DO i = 1, SIZE(lines) @@ -1558,11 +1579,11 @@ RECURSIVE SUBROUTINE build_one_hermite_cable(ln, sections, types, points, opts, LOGICAL :: tensile_error CHARACTER(400) :: note_text CHARACTER(512) :: limit_text - ! Steady deck current for the static solve (unallocated: no current). + ! Steady deck current for the static solve (unallocated: no current and no static friction). TYPE(CD_HermiteStaticCurrentType), ALLOCATABLE :: cur_obj, cur_exact - ! Seabed friction holding the line against the deck current (static springs to - ! the still-water laid shape, continued by elastic-plastic springs in the dynamics). - LOGICAL :: static_friction + ! Static seabed friction toward the as-laid position (static springs, continued by + ! elastic-plastic springs in the dynamics); a still-water deck carries it on cur_obj. + LOGICAL :: static_friction, as_laid REAL(wp), ALLOCATABLE :: fr_anchor(:, :), fr_force(:, :) INTEGER :: pass CHARACTER(1024) :: em, primary_msg, sequence_msg, planar_primary_msg, planar_sequence_msg, coarse_msg @@ -1735,10 +1756,17 @@ RECURSIVE SUBROUTINE build_one_hermite_cable(ln, sections, types, points, opts, require_3d_static = .TRUE. END IF END IF + ! A lay azimuth across the vertical plane of the chord puts the as-laid friction + ! reference, and the friction it holds, out of that plane: solved in 3D as well. This is + ! decided here, before the held (planar) DOFs below are chosen. + IF (as_laid_off_plane()) require_3d_static = .TRUE. CALL build_finite_section_mesh(ln, sections, types, conn, l0, ea, mpl, diam, ei, & gas_in, gj_in, i_rt_in, i_rn_in, ErrStat, ErrMsg) IF (ErrStat /= CD_DECKDRV_OK) RETURN + ! A seabed sloping across that plane under the as-laid run pushes the grounded nodes out + ! of it against their friction: solved in 3D as well, so the march starts at rest. + IF (.NOT. require_3d_static) require_3d_static = as_laid_cross_slope() ! Fine-mesh limit: an element shorter than the axial-bending length sqrt(EI/EA) has an ! axial stiffness EA/h that dwarfs every bending term; the static Newton system then ! loses the precision to converge and the solve stalls after minutes instead of @@ -1967,16 +1995,34 @@ RECURSIVE SUBROUTINE build_one_hermite_cable(ln, sections, types, points, opts, dry_b = opts%rhoW*opts%g*QUARTER_PI*diam**2 ! A deck current loads the line at rest: the static equilibrium includes its steady drag ! (the drag of the dynamic path at zero velocity), so a run starts at rest in the current. - static_friction = .FALSE. - IF (opts%has_current) THEN + ! Static seabed friction. With staticsFriction asLaid (the OrcaFlex "as laid" policy) + ! every grounded node is held by a friction spring toward its as-laid position -- the + ! line laid from its lower end along the lay azimuth on the seabed at the as-laid tension, + ! on the mesh of each static solve (as_laid_reference) -- capped at mu N, in still water + ! and in a current alike; the springs ride on the current object, whose drag is zero in + ! still water. With staticsFriction none (the default) a + ! frictional seabed resists only a deck current, from the still-water laid shape: the + ! line is first solved without the current, and that equilibrium is the reference of the + ! springs. Their forces then seed the stick-slip anchors of the march (standalone and + ! coupled alike). + as_laid = contact_enabled .AND. opts%has_friction .AND. opts%static_friction == CD_STATIC_FRICTION_AS_LAID + static_friction = contact_enabled .AND. opts%has_friction .AND. (opts%has_current .OR. as_laid) + IF (opts%has_current .OR. as_laid) THEN ALLOCATE (cur_obj) CALL hermite_static_current(ln, sections, types, opts, l0, frame_cs, cur_obj) - ! A frictional seabed resists the current from the still-water laid shape (the - ! OrcaFlex convention): the line is first solved without the current, and that - ! equilibrium is the reference of the friction springs, whose forces then seed the - ! stick-slip anchors of the march (standalone and coupled alike). - static_friction = contact_enabled .AND. opts%has_friction - IF (static_friction) THEN + IF (.NOT. opts%has_current) THEN + cur_obj%velocity = CD_ZERO + cur_obj%drag = .FALSE. + IF (ALLOCATED(cur_obj%profile_z)) DEALLOCATE (cur_obj%profile_z) + IF (ALLOCATED(cur_obj%profile_velocity)) DEALLOCATE (cur_obj%profile_velocity) + END IF + IF (as_laid) THEN + CALL as_laid_reference(es, em) + IF (es /= CD_DECKDRV_OK) THEN + CALL fail_solve(ErrStat, ErrMsg, 'finite-EI as-laid reference for the seabed friction: '// & + TRIM(em)); RETURN + END IF + ELSE IF (static_friction) THEN CALL still_water_reference(es, em) IF (es /= CD_DECKDRV_OK) THEN CALL fail_solve(ErrStat, ErrMsg, 'finite-EI still-water reference for the seabed friction: '// & @@ -2734,6 +2780,31 @@ RECURSIVE SUBROUTINE build_one_hermite_cable(ln, sections, types, points, opts, w_bare = w_bare_deck IF (SIZE(l0) /= SIZE(l0_deck_att)) CALL remap_elem_by_reference_arc(w_bare, l0_deck_att, l0) CALL attachment_nodes(l0, ln%att(1, :), att_node, att_offset) + ! As laid on a bathymetry, the friction reference moves with the sink of every node under + ! its load (as_laid_reference). The reference of the smeared solve sinks the nodes under + ! the smeared weights; the polish reaches the discrete loads, so the reference is rebuilt + ! on the final mesh for them (the bare weights plus each attachment's net weight at its + ! node), and held on that mesh for the polish and the dynamic hand-off: otherwise the + ! difference of a node's normal sink under its own load would show as a spurious + ! friction deflection along a slope, beyond the slope load its spring carries at rest. + IF (as_laid .AND. PRESENT(bathymetry)) THEN + BLOCK + REAL(wp), ALLOCATABLE :: node_load(:) + ALLOCATE (node_load(SIZE(l0) + 1)) + node_load = CD_ZERO + DO i = 1, SIZE(l0) + node_load(i:i + 1) = node_load(i:i + 1) + 0.5_wp*w_bare(i)*l0(i) + END DO + DO i = 1, SIZE(att_node) + node_load(att_node(i)) = node_load(att_node(i)) + (ln%att(2, i) - opts%rhoW*ln%att(3, i))*opts%g + END DO + CALL as_laid_reference(es, em, node_load) + END BLOCK + IF (es /= CD_DECKDRV_OK) THEN + CALL fail_solve(ErrStat, ErrMsg, 'finite-EI as-laid reference for the seabed friction with discrete '// & + 'ATTACHMENTS: '//TRIM(em)); RETURN + END IF + END IF CALL attachment_static_polish(l0, ea, ei, w_bare, w, diam, att_node, ln%att, q_static, fixed_dofs, & contact_enabled, contact_z, frame_cs, endconn_k, endconn_d0_local, & endconn_mode, opts, static_tol, ErrStat, ErrMsg, bathymetry, cur_obj) @@ -2816,10 +2887,10 @@ RECURSIVE SUBROUTINE build_one_hermite_cable(ln, sections, types, points, opts, IF (PRESENT(bathymetry) .AND. .NOT. bathymetry_flat) THEN CALL CD_HermiteCable_Friction_Anchors(l0, q_static, cur_obj%friction, contact_kn, contact_z, & fr_anchor, fr_force, es, em, bathymetry=bathymetry, & - contact_frame_cs=frame_cs) + contact_frame_cs=frame_cs, EA=ea, w=w) ELSE CALL CD_HermiteCable_Friction_Anchors(l0, q_static, cur_obj%friction, contact_kn, contact_z, & - fr_anchor, fr_force, es, em) + fr_anchor, fr_force, es, em, EA=ea, w=w) END IF IF (es == CD_HCSTAT_OK) CALL CD_HermiteCable_Dyn_Set_Friction_Anchors(cable%line, fr_anchor, es, em) IF (es /= CD_HCSTAT_OK) THEN @@ -3811,6 +3882,171 @@ SUBROUTINE still_water_reference(esr, emr) CALL CD_HFMF_End(sw_cable) END SUBROUTINE still_water_reference + LOGICAL FUNCTION as_laid_off_plane() RESULT(off) + !! Whether the as-laid seabed friction of this line has a lay azimuth across the + !! vertical plane of its chord (an explicit layAzimuth / layAzimuth; the default + !! azimuth is the chord's own heading and lies in that plane). Decided from the deck + !! options alone, so the static solve can be set up in 3D before its held DOFs are chosen. + REAL(wp), ALLOCATABLE :: lay_az_opt + REAL(wp) :: laid_t, dir_l(2) + off = .FALSE. + IF (.NOT. (contact_enabled .AND. opts%has_friction .AND. & + opts%static_friction == CD_STATIC_FRICTION_AS_LAID)) RETURN + CALL line_static_friction(opts, ln%id, lay_az_opt, laid_t) + IF (.NOT. ALLOCATED(lay_az_opt)) RETURN + dir_l = [frame_cs(1)*COS(lay_az_opt) + frame_cs(2)*SIN(lay_az_opt), & + -frame_cs(2)*COS(lay_az_opt) + frame_cs(1)*SIN(lay_az_opt)] + off = ABS(dir_l(2)) > 64.0_wp*EPSILON(CD_ONE) + END FUNCTION as_laid_off_plane + + SUBROUTINE as_laid_heading(from_top, az, laid_t) + !! Lay of the as-laid reference: from_top when the line is laid from its fairlead (the + !! last node, lower than the anchor), the lay azimuth az [rad, global] and the as-laid + !! tension laid_t [N]. The default azimuth is the chord's horizontal direction from the + !! line's lower end (+x from the anchor, and -x from the fairlead, for a vertical chord). + LOGICAL, INTENT(OUT) :: from_top + REAL(wp), INTENT(OUT) :: az, laid_t + REAL(wp), ALLOCATABLE :: lay_az_opt + REAL(wp) :: a_g(3), f_g(3) + CALL line_static_friction(opts, ln%id, lay_az_opt, laid_t) + a_g = points(pa)%pos + f_g = points(pb)%pos + from_top = f_g(3) < a_g(3) + az = CD_ZERO + IF (NORM2(f_g(1:2) - a_g(1:2)) > 1.0e-9_wp*MAX(CD_ONE, NORM2(f_g - a_g))) & + az = ATAN2(f_g(2) - a_g(2), f_g(1) - a_g(1)) + IF (ALLOCATED(lay_az_opt)) THEN + az = lay_az_opt + ELSE IF (from_top) THEN + az = ATAN2(-SIN(az), -COS(az)) + END IF + END SUBROUTINE as_laid_heading + + LOGICAL FUNCTION as_laid_cross_slope() RESULT(cross) + !! Whether the seabed under the as-laid path of this line slopes across the vertical + !! plane of its chord (a bathymetry whose gradient has a component across that plane + !! somewhere along the laid length, sampled at most 1 m apart; a laid length beyond the + !! sample cap counts as crossing). There the seabed normal + !! pushes every grounded node out of the plane and the friction holds it, so only a 3D + !! static solve is an equilibrium of the line with its end positions alone held, which + !! the dynamics start from at rest; a planar solve leaves the lateral loads unbalanced. + !! A failed bathymetry query answers .FALSE. (the reference build reports it). + INTEGER, PARAMETER :: MAX_SAMPLES = 100000 + REAL(wp) :: az, laid_t, o_xy(2), dir(2), e_cross(2), span, ds, zf, gx, gy + INTEGER :: k, n_s, es_c + LOGICAL :: from_top + CHARACTER(200) :: em_c + cross = .FALSE. + IF (.NOT. (contact_enabled .AND. opts%has_friction .AND. & + opts%static_friction == CD_STATIC_FRICTION_AS_LAID)) RETURN + IF (.NOT. PRESENT(bathymetry)) RETURN + IF (bathymetry_flat) RETURN + CALL as_laid_heading(from_top, az, laid_t) + IF (from_top) THEN + o_xy = points(pb)%pos(1:2) + ELSE + o_xy = points(pa)%pos(1:2) + END IF + dir = [COS(az), SIN(az)] + ! the global horizontal direction across the chord plane (frame_cs: the chord heading) + e_cross = [-frame_cs(2), frame_cs(1)] + ! the laid path is at most its stretched length long (asLaidTension <= EA) + span = SUM(l0)*(CD_ONE + MIN(laid_t/MINVAL(ea), CD_ONE)) + ! capped before the integer conversion (the reference build rejects an absurd length) + IF (.NOT. (span > CD_ZERO .AND. span <= HUGE(span))) RETURN + ! beyond MAX_SAMPLES m the samples would lie more than 1 m apart and could miss a local + ! cross slope: the 3D solve, an equilibrium in either case, is chosen conservatively + IF (span > REAL(MAX_SAMPLES, wp)) THEN + cross = .TRUE. + RETURN + END IF + n_s = MAX(1, CEILING(span)) + ds = span/REAL(n_s, wp) + DO k = 0, n_s + CALL CD_Bathymetry_Floor_Gradient(bathymetry, o_xy(1) + REAL(k, wp)*ds*dir(1), & + o_xy(2) + REAL(k, wp)*ds*dir(2), zf, gx, gy, es_c, em_c) + IF (es_c /= CD_BATHY_OK) RETURN + IF (ABS(gx*e_cross(1) + gy*e_cross(2)) > 64.0_wp*EPSILON(CD_ONE)*MAX(CD_ONE, ABS(gx) + ABS(gy))) THEN + cross = .TRUE. + RETURN + END IF + END DO + END FUNCTION as_laid_cross_slope + + SUBROUTINE as_laid_reference(esr, emr, node_load) + !! Friction reference of the static solve (CD_HermiteCable_As_Laid_Offsets): the line laid + !! on the seabed from its lower end (the anchor, node 1, unless the fairlead is lower, as in + !! the EI = 0 line model) along the lay azimuth at the as-laid tension, as (x, y) offsets + !! from node 1 in the solve frame along the unstretched arc length of the mesh l0. A lay + !! azimuth off the vertical plane of the chord puts the reference out of that plane (see + !! as_laid_off_plane): the static solve then runs in 3D. In the plane the reference is + !! held in it, but for the sink of its nodes along a cross slope, each under its nodal + !! load over its nodal seabed stiffness (kBot Diam l0 lumped to the nodes). The lay is + !! kept with the profile of the deck mesh, and every static solve lays the reference on + !! its own mesh (a refined or coarsened one too) under its own lumped weights, as the + !! dynamic hand-off does on the final mesh. node_load [N, downward positive, one entry per + !! node]: the discrete loads of an attachment polish on the final mesh l0, which hold on + !! that mesh alone; the reference is then this profile (default: the lumped weights w). + INTEGER, INTENT(OUT) :: esr + CHARACTER(*), INTENT(OUT) :: emr + REAL(wp), INTENT(IN), OPTIONAL :: node_load(:) + REAL(wp), ALLOCATABLE :: wn(:), kn_r(:), offsets(:, :) + REAL(wp) :: laid_t, az + INTEGER :: k, ne_r, es_r + LOGICAL :: from_top + esr = CD_DECKDRV_OK + emr = '' + ne_r = SIZE(l0) + CALL as_laid_heading(from_top, az, laid_t) + IF (ALLOCATED(cur_obj%friction)) DEALLOCATE (cur_obj%friction) + ALLOCATE (cur_obj%friction) + cur_obj%friction%mu = opts%friction_mu + cur_obj%friction%mu_axial = opts%friction_mu_axial + cur_obj%friction%as_laid = .TRUE. + cur_obj%friction%laid_from_top = from_top + cur_obj%friction%laid_in_plane = .NOT. as_laid_off_plane() + cur_obj%friction%laid_bathymetry = PRESENT(bathymetry) + IF (from_top) THEN + cur_obj%friction%laid_origin = points(pb)%pos(1:2) + ELSE + cur_obj%friction%laid_origin = points(pa)%pos(1:2) + END IF + cur_obj%friction%laid_node1 = points(pa)%pos(1:2) + cur_obj%friction%laid_azimuth = az + cur_obj%friction%laid_tension = laid_t + cur_obj%friction%laid_frame_cs = frame_cs + ! the nodal loads and seabed stiffnesses the nodes of mesh l0 sink under + ALLOCATE (wn(ne_r + 1), kn_r(ne_r + 1), offsets(2, ne_r + 1)) + wn = CD_ZERO + kn_r = CD_ZERO + DO k = 1, ne_r + kn_r(k:k + 1) = kn_r(k:k + 1) + 0.5_wp*opts%kbot*diam(k)*l0(k) + END DO + IF (PRESENT(node_load)) THEN + wn = node_load + ELSE + DO k = 1, ne_r + wn(k:k + 1) = wn(k:k + 1) + 0.5_wp*w(k)*l0(k) + END DO + END IF + IF (PRESENT(bathymetry)) THEN + CALL CD_HermiteCable_As_Laid_Offsets(cur_obj%friction, l0, ea, wn, kn_r, offsets, es_r, emr, bathymetry) + ELSE + CALL CD_HermiteCable_As_Laid_Offsets(cur_obj%friction, l0, ea, wn, kn_r, offsets, es_r, emr) + END IF + IF (es_r /= CD_HCSTAT_OK) THEN + esr = CD_DECKDRV_BADINPUT + RETURN + END IF + ALLOCATE (cur_obj%friction%ref_s(ne_r + 1)) + cur_obj%friction%ref_s(1) = CD_ZERO + DO k = 2, ne_r + 1 + cur_obj%friction%ref_s(k) = cur_obj%friction%ref_s(k - 1) + l0(k - 1) + END DO + CALL MOVE_ALLOC(offsets, cur_obj%friction%ref_xy) + cur_obj%friction%laid_on_mesh = .NOT. PRESENT(node_load) + END SUBROUTINE as_laid_reference + SUBROUTINE fine_mesh_note(note) !! Sets note when some element is shorter than sqrt(EI/EA) (see its call). CHARACTER(*), INTENT(OUT) :: note @@ -4202,7 +4438,7 @@ RECURSIVE SUBROUTINE hermite_static_primary(anchor, fairlead, l0, ea, ei, w, dia CHARACTER(400) :: walk_msg_c REAL(wp) :: walk_d, a_seed(3) CHARACTER(512) :: walk_msg - LOGICAL :: tensile, refine_all, planar_bed, walk_needed + LOGICAL :: tensile, refine_all, planar_bed, walk_needed, laid REAL(wp) :: h_target REAL(wp) :: origin(2), a_l(3), f_l(3), seabed_z, seabed_slope, horizontal_tension, grounded_length REAL(wp) :: lambda0, ratio, span(2), span_len, t, xg, yg, zf, sx, sz, sxx, sxz, xl, yl @@ -4312,10 +4548,30 @@ RECURSIVE SUBROUTINE hermite_static_primary(anchor, fairlead, l0, ea, ei, w, dia ErrMsg = 'the bow behind the fairlead is traced over a flat seabed only' RETURN END IF + ! Static seabed friction toward an as-laid position: the seed is the EI = 0 equilibrium + ! of the same mesh with that friction (laid_seed_positions), which rests the grounded run + ! where the friction holds it; no catenary seed, and no anchor walk, is needed. Without + ! that equilibrium the catenary seed below is used, as on a mesh finer than sqrt(EI/EA) + ! somewhere, which the route fails closed on by name (the seed is not built for it). + laid = .FALSE. + IF (contact_enabled .AND. .NOT. fold .AND. PRESENT(cur_obj)) THEN + IF (ALLOCATED(cur_obj%friction)) THEN + IF (cur_obj%friction%as_laid .AND. cur_obj%friction%mu > CD_ZERO) THEN + IF (.NOT. ANY(ei > CD_ZERO .AND. ea > CD_ZERO .AND. l0 < SQRT(MAX(ei, CD_ZERO)/MAX(ea, TINY(CD_ONE))))) & + CALL laid_seed_positions(laid) + END IF + END IF + END IF walk_d = CD_ZERO a_seed = a_l walk_msg = '' seed_walk: DO k_walk = 0, WALK_MAX_TRIES + IF (laid) THEN + ErrStat = CD_HCSTAT_OK + ErrMsg = '' + inadmissible = .FALSE. + EXIT seed_walk + END IF IF (k_walk > 0) THEN ! First retreat: the length the line exceeds its span plus rise by, and a tenth of ! the line; then half as far again each time. @@ -4599,12 +4855,92 @@ RECURSIVE SUBROUTINE hermite_static_primary(anchor, fairlead, l0, ea, ei, w, dia CONTAINS + SUBROUTINE laid_seed_positions(ok) + !! Seed positions pos (translated solve frame) of a line with static seabed friction + !! toward its as-laid position: the tension-only EI = 0 equilibrium of the same mesh, + !! weight and seabed with that friction (CD_Static_Line_Equilibrium, solved in global + !! coordinates, where the bathymetry is queried). ok = .FALSE. when it has none. + LOGICAL, INTENT(OUT) :: ok + TYPE(CableCurrentLoad) :: fr_ld + TYPE(CableSolverConfig) :: cfg_ld + TYPE(CD_StaticLineReport) :: rep_ld + INTEGER, ALLOCATABLE :: conn_ld(:, :) + REAL(wp), ALLOCATABLE :: f_ld(:), kn_ld(:), q_ld(:), ref_l(:, :) + REAL(wp) :: c, s, a_g(3), f_g(3), xl_, yl_ + INTEGER :: e_, k_, es_ld + LOGICAL :: conv_ld + CHARACTER(512) :: em_ld + ok = .FALSE. + c = frame_cs(1) + s = frame_cs(2) + a_g = [c*anchor(1) - s*anchor(2), s*anchor(1) + c*anchor(2), anchor(3)] + f_g = [c*fairlead(1) - s*fairlead(2), s*fairlead(1) + c*fairlead(2), fairlead(3)] + ALLOCATE (conn_ld(2, ne), f_ld(3*nnode), kn_ld(nnode), q_ld(3*nnode), ref_l(2, nnode)) + f_ld = CD_ZERO + kn_ld = CD_ZERO + DO e_ = 1, ne + conn_ld(:, e_) = [e_, e_ + 1] + f_ld(3*e_) = f_ld(3*e_) - 0.5_wp*w(e_)*l0(e_) + f_ld(3*e_ + 3) = f_ld(3*e_ + 3) - 0.5_wp*w(e_)*l0(e_) + kn_ld(e_) = kn_ld(e_) + 0.5_wp*opts%kbot*diam(e_)*l0(e_) + kn_ld(e_ + 1) = kn_ld(e_ + 1) + 0.5_wp*opts%kbot*diam(e_)*l0(e_) + END DO + IF (.NOT. ALL(kn_ld > CD_ZERO)) RETURN + ! the as-laid reference on this mesh (laid on it as the static solve lays it), from the + ! solve frame to global coordinates + CALL CD_HermiteCable_Friction_Reference(cur_obj%friction, l0, anchor(1:2), ref_l, es_ld, em_ld, EA=ea, w=w, & + node_kn=kn_ld, bathymetry=bathymetry) + IF (es_ld /= CD_HCSTAT_OK) RETURN + fr_ld%drag = .FALSE. + ! the static seabed friction of the as-laid policy: the laid-run seed order of + ! CD_Static_Line_Equilibrium (SEED_ORDER_LAID) applies + fr_ld%friction_as_laid = .TRUE. + fr_ld%friction_mu = cur_obj%friction%mu + fr_ld%friction_mu_axial = cur_obj%friction%mu_axial + ALLOCATE (fr_ld%friction_ref(2, nnode)) + DO k_ = 1, nnode + fr_ld%friction_ref(:, k_) = [c*ref_l(1, k_) - s*ref_l(2, k_), s*ref_l(1, k_) + c*ref_l(2, k_)] + END DO + IF (PRESENT(bathymetry)) THEN + CALL CD_Static_Line_Equilibrium(a_g, f_g, conn_ld, l0, ea, w, f_ld, cfg_ld, .TRUE., q_ld, conv_ld, rep_ld, & + es_ld, em_ld, seabed_kn=kn_ld, bathymetry=bathymetry, current=fr_ld) + ELSE + CALL CD_Static_Line_Equilibrium(a_g, f_g, conn_ld, l0, ea, w, f_ld, cfg_ld, .TRUE., q_ld, conv_ld, rep_ld, & + es_ld, em_ld, seabed_z_floor=contact_z, seabed_kn=kn_ld, current=fr_ld) + END IF + IF (es_ld /= CD_STATIC_OK .OR. .NOT. conv_ld) RETURN + IF (.NOT. ALL(IEEE_IS_FINITE(q_ld))) RETURN + ! An element collapsed well below its length is a fold of the tension-only line (the + ! line laid past the point under the fairlead turns back over its grounded run, and + ! the slack elements at the turn bunch up): no seed for the bending-stiffness + ! continuation, whose hook would start from a kink. The catenary seed is used then. + DO e_ = 1, ne + IF (NORM2(q_ld(3*e_ + 1:3*e_ + 3) - q_ld(3*e_ - 2:3*e_)) < 0.99_wp*l0(e_)) RETURN + END DO + DO k_ = 1, nnode + xl_ = c*q_ld(3*k_ - 2) + s*q_ld(3*k_ - 1) + yl_ = -s*q_ld(3*k_ - 2) + c*q_ld(3*k_ - 1) + pos(3*k_ - 2:3*k_) = [xl_ - origin(1), yl_ - origin(2), q_ld(3*k_)] + END DO + ! the held ends exactly where the solve holds them + pos(1:3) = a_l + pos(3*nnode - 2:3*nnode) = f_l + ok = .TRUE. + END SUBROUTINE laid_seed_positions + + LOGICAL FUNCTION in_current() RESULT(yes) + !! Whether the line is loaded by a real current: the current object carries drag. In + !! still water it may be present only as the carrier of the as-laid seabed friction. + yes = .FALSE. + IF (PRESENT(cur_obj)) yes = cur_obj%drag + END FUNCTION in_current + LOGICAL FUNCTION planar_run_diagnosed(msg) RESULT(yes) !! Whether msg carries the frictionless grounded-run diagnosis of a current (the !! current drives the run on the seabed into compression) for this line held in its !! vertical plane (every node's out-of-plane DOF held). CHARACTER(*), INTENT(IN) :: msg - yes = PRESENT(cur_obj) + yes = in_current() IF (yes) yes = COUNT(MOD(fixed_dofs - 1, 6) == 1) >= nnode IF (yes) yes = INDEX(msg, 'the run on the seabed is in axial compression') > 0 .OR. & INDEX(msg, 'the run on the seabed folds against its end') > 0 @@ -4713,7 +5049,7 @@ SUBROUTINE walk_anchor() DO k = 2, nnode sref(k) = sref(k - 1) + l0(k - 1) END DO - energy = .NOT. PRESENT(cur_obj) + energy = .NOT. in_current() tol_w = MAX(cont_tol, WALK_TOL) tw = CD_ZERO dt = WALK_DT0 @@ -7168,6 +7504,31 @@ END SUBROUTINE CD_Deck_Equilibrium_Jacobian_Check ! per-line static solve (multi-section) ! ! --------------------------------------------------------------------------- ! + SUBROUTINE line_static_friction(opts, line_id, lay_az, laid_t) + !! Static seabed friction settings of one deck line: the lay azimuth [rad] when the deck + !! sets one (layAzimuth, else layAzimuth; unallocated otherwise, the line's anchor + !! -> fairlead direction) and the as-laid tension [N] (asLaidTension, else + !! asLaidTension, default 0). + TYPE(DeckOptions), INTENT(IN) :: opts + INTEGER, INTENT(IN) :: line_id + REAL(wp), ALLOCATABLE, INTENT(OUT) :: lay_az + REAL(wp), INTENT(OUT) :: laid_t + REAL(wp), PARAMETER :: DEG2RAD = 3.14159265358979323846264338327950288_wp/180.0_wp + INTEGER :: k + IF (opts%has_lay_azimuth) lay_az = opts%lay_azimuth_deg*DEG2RAD + IF (ALLOCATED(opts%lay_azimuth_line)) THEN + DO k = 1, SIZE(opts%lay_azimuth_line) + IF (opts%lay_azimuth_line(k) == line_id) lay_az = opts%lay_azimuth_line_deg(k)*DEG2RAD + END DO + END IF + laid_t = opts%as_laid_tension + IF (ALLOCATED(opts%as_laid_tension_line)) THEN + DO k = 1, SIZE(opts%as_laid_tension_line) + IF (opts%as_laid_tension_line(k) == line_id) laid_t = opts%as_laid_tension_line_value(k) + END DO + END IF + END SUBROUTINE line_static_friction + SUBROUTINE init_one_model(ln, sections, types, points, opts, model, ErrStat, ErrMsg, bathymetry) !! Initialize one persistent model from a validated deck LINE. TYPE(DeckLine), INTENT(IN) :: ln @@ -7194,11 +7555,16 @@ SUBROUTINE init_one_model(ln, sections, types, points, opts, model, ErrStat, Err INTEGER :: j, i, e, es LOGICAL :: want_wave_cfg CHARACTER(200) :: em + ! static seabed friction of this line: lay azimuth override [rad] (unallocated: the + ! default, the chord direction from the line's lower end) and as-laid tension [N] + REAL(wp), ALLOCATABLE :: lay_az_opt + REAL(wp) :: laid_t ErrStat = CD_DECKDRV_OK ErrMsg = '' CALL gather_line_inputs(ln, sections, types, points, lts, secs, anchor, fairlead, ErrStat, ErrMsg) IF (ErrStat /= CD_DECKDRV_OK) RETURN + CALL line_static_friction(opts, ln%id, lay_az_opt, laid_t) dynamic_cfg%rho_inf = opts%rho_inf dynamic_cfg%rel_tol = opts%dynamic_rel_tol @@ -7328,6 +7694,8 @@ SUBROUTINE init_one_model(ln, sections, types, points, opts, model, ErrStat, Err seabed_kbot=opts%kbot, seabed_contact_diameter=diam, & seabed_cn_over_kn=opts%cbot/opts%kbot, & seabed_mu=opts%friction_mu, seabed_mu_axial=opts%friction_mu_axial, ba=ba, & + static_friction=opts%static_friction, lay_azimuth=lay_az_opt, & + as_laid_tension=laid_t, & ve_ea_d=ve_ead, ve_ba=ve_bas, ve_ba_d=ve_bad, ve_alpha_mbl=ve_ambl, ve_vbeta=ve_vbet, & current_profile_z=opts%current_profile_z, & current_profile_velocity=opts%current_profile_velocity, & @@ -7355,6 +7723,8 @@ SUBROUTINE init_one_model(ln, sections, types, points, opts, model, ErrStat, Err seabed_kbot=opts%kbot, seabed_contact_diameter=diam, & seabed_cn_over_kn=opts%cbot/opts%kbot, & seabed_mu=opts%friction_mu, seabed_mu_axial=opts%friction_mu_axial, ba=ba, & + static_friction=opts%static_friction, lay_azimuth=lay_az_opt, & + as_laid_tension=laid_t, & ve_ea_d=ve_ead, ve_ba=ve_bas, ve_ba_d=ve_bad, ve_alpha_mbl=ve_ambl, ve_vbeta=ve_vbet, & current_profile_z=opts%current_profile_z, & current_profile_velocity=opts%current_profile_velocity, & @@ -7380,6 +7750,8 @@ SUBROUTINE init_one_model(ln, sections, types, points, opts, model, ErrStat, Err seabed_kbot=opts%kbot, seabed_contact_diameter=diam, & seabed_cn_over_kn=opts%cbot/opts%kbot, & seabed_mu=opts%friction_mu, seabed_mu_axial=opts%friction_mu_axial, ba=ba, & + static_friction=opts%static_friction, lay_azimuth=lay_az_opt, & + as_laid_tension=laid_t, & ve_ea_d=ve_ead, ve_ba=ve_bas, ve_ba_d=ve_bad, ve_alpha_mbl=ve_ambl, ve_vbeta=ve_vbet, & current_profile_z=opts%current_profile_z, & current_profile_velocity=opts%current_profile_velocity, & @@ -7406,6 +7778,8 @@ SUBROUTINE init_one_model(ln, sections, types, points, opts, model, ErrStat, Err seabed_kbot=opts%kbot, seabed_contact_diameter=diam, & seabed_cn_over_kn=opts%cbot/opts%kbot, & seabed_mu=opts%friction_mu, seabed_mu_axial=opts%friction_mu_axial, ba=ba, & + static_friction=opts%static_friction, lay_azimuth=lay_az_opt, & + as_laid_tension=laid_t, & ve_ea_d=ve_ead, ve_ba=ve_bas, ve_ba_d=ve_bad, ve_alpha_mbl=ve_ambl, ve_vbeta=ve_vbet, & current_profile_z=opts%current_profile_z, & current_profile_velocity=opts%current_profile_velocity, & @@ -7434,6 +7808,8 @@ SUBROUTINE init_one_model(ln, sections, types, points, opts, model, ErrStat, Err seabed_kbot=opts%kbot, seabed_contact_diameter=diam, & seabed_cn_over_kn=opts%cbot/opts%kbot, & seabed_mu=opts%friction_mu, seabed_mu_axial=opts%friction_mu_axial, ba=ba, & + static_friction=opts%static_friction, lay_azimuth=lay_az_opt, & + as_laid_tension=laid_t, & ve_ea_d=ve_ead, ve_ba=ve_bas, ve_ba_d=ve_bad, ve_alpha_mbl=ve_ambl, ve_vbeta=ve_vbet, & current_profile_z=opts%current_profile_z, & current_profile_velocity=opts%current_profile_velocity, & @@ -7460,6 +7836,8 @@ SUBROUTINE init_one_model(ln, sections, types, points, opts, model, ErrStat, Err seabed_kbot=opts%kbot, seabed_contact_diameter=diam, & seabed_cn_over_kn=opts%cbot/opts%kbot, & seabed_mu=opts%friction_mu, seabed_mu_axial=opts%friction_mu_axial, ba=ba, & + static_friction=opts%static_friction, lay_azimuth=lay_az_opt, & + as_laid_tension=laid_t, & ve_ea_d=ve_ead, ve_ba=ve_bas, ve_ba_d=ve_bad, ve_alpha_mbl=ve_ambl, ve_vbeta=ve_vbet, & current_profile_z=opts%current_profile_z, & current_profile_velocity=opts%current_profile_velocity, & @@ -7523,9 +7901,13 @@ SUBROUTINE init_one_syrope_model(types, syt, ln, lts, secs, anchor, fairlead, l0 INTEGER :: ne, e, es, n_owc, iter CHARACTER(200) :: em CHARACTER(24) :: s_eps, s_lo, s_hi + ! static seabed friction of this line: lay azimuth override [rad] and as-laid tension + REAL(wp), ALLOCATABLE :: lay_az_opt + REAL(wp) :: laid_t ErrStat = CD_DECKDRV_OK ErrMsg = '' + CALL line_static_friction(opts, ln%id, lay_az_opt, laid_t) IF (SIZE(secs) /= 1) THEN CALL fail(ErrStat, ErrMsg, 'a Syrope line must be a single section (composite Syrope lines are '// & 'not supported yet)'); RETURN @@ -7705,6 +8087,8 @@ SUBROUTINE build_model(with_syrope) seabed_z_floor=-opts%wtrdpth, seabed_kn=kn, seabed_cn=cn, & seabed_cn_over_kn=opts%cbot/opts%kbot, seabed_mu=opts%friction_mu, & seabed_mu_axial=opts%friction_mu_axial, & + static_friction=opts%static_friction, lay_azimuth=lay_az_opt, & + as_laid_tension=laid_t, & seabed_kbot=opts%kbot, seabed_contact_diameter=diam, & syrope_is=sis, syrope_type=stype, syrope_slow0=sslow, syrope_tmax0=stmax) ELSE IF (opts%has_wtrdpth) THEN @@ -7714,6 +8098,8 @@ SUBROUTINE build_model(with_syrope) seabed_z_floor=-opts%wtrdpth, seabed_kn=kn, seabed_cn=cn, & seabed_cn_over_kn=opts%cbot/opts%kbot, seabed_mu=opts%friction_mu, & seabed_mu_axial=opts%friction_mu_axial, & + static_friction=opts%static_friction, lay_azimuth=lay_az_opt, & + as_laid_tension=laid_t, & seabed_kbot=opts%kbot, seabed_contact_diameter=diam) ELSE IF (with_syrope) THEN CALL CD_Init_Line_Model(model, anchor, fairlead, lts, secs, opts%g, opts%rhoW, .FALSE., & @@ -8919,6 +9305,15 @@ SUBROUTINE solve_one_line(ln, sections, types, points, opts, q, tension, converg IF (PRESENT(end_force)) end_force = CD_ZERO force_a = CD_ZERO force_b = CD_ZERO + ! This static-only EI = 0 solve carries no seabed friction (standalone, frictionMu needs + ! dtM and TMax, so the dynamic route owns it): fail closed on the as-laid policy instead of + ! reporting a frictionless equilibrium as the as-laid one. + IF (opts%has_friction .AND. opts%static_friction == CD_STATIC_FRICTION_AS_LAID .AND. & + (PRESENT(bathymetry) .OR. opts%has_wtrdpth)) THEN + CALL fail(ErrStat, ErrMsg, 'OPTION staticsFriction asLaid is not applied by the static-only line solve; '// & + 'run the deck with dtM and TMax (the dynamic route holds the line toward its as-laid '// & + 'position) or use staticsFriction none'); RETURN + END IF ! NodeA is deck End A/fairlead; NodeB is deck End B/anchor. Internally the ! catenary/static model remains anchor -> fairlead. anchor = points(find_point(points, ln%nodeB))%pos @@ -12687,6 +13082,21 @@ SUBROUTINE apply_option(line, opts, ErrStat, ErrMsg) CALL rd(val, opts%friction_mu, ErrStat, ErrMsg) opts%has_friction = (ErrStat == 0 .AND. opts%friction_mu > CD_ZERO) END IF + CASE ('staticsfriction', 'statics_friction', 'staticsseabedfrictionpolicy', 'seabedfrictionpolicy') + ! OrcaFlex's statics seabed friction policy: "as laid" or "none" (the default) + SELECT CASE (to_lower(TRIM(strip_quotes(val)))) + CASE ('aslaid', 'as_laid', 'as-laid') + opts%static_friction = CD_STATIC_FRICTION_AS_LAID + CASE ('none') + opts%static_friction = CD_STATIC_FRICTION_NONE + CASE DEFAULT + CALL fail(ErrStat, ErrMsg, 'OPTION '//TRIM(kw)//' must be asLaid or none (got "'//TRIM(val)//'")') + END SELECT + CASE ('layazimuth', 'lay_azimuth') + CALL rd(val, opts%lay_azimuth_deg, ErrStat, ErrMsg) + opts%has_lay_azimuth = ErrStat == 0 + CASE ('aslaidtension', 'as_laid_tension') + CALL rd(val, opts%as_laid_tension, ErrStat, ErrMsg) CASE ('mu_kt', 'mu_ka') ! MoorDyn-F seabed friction coefficients: named, so a stock deck is pointed at the ! CableDyn keywords rather than failing as an unknown keyword @@ -12812,9 +13222,64 @@ SUBROUTINE apply_option(line, opts, ErrStat, ErrMsg) 'supported; use Currents 1 or the "current" option') END SELECT CASE DEFAULT - CALL fail(ErrStat, ErrMsg, 'unknown OPTION keyword "'//TRIM(kw)//'"') + ! per-line static friction rows: layAzimuth, asLaidTension (line ID suffix) + BLOCK + CHARACTER(LEN(kw)) :: kl + INTEGER :: lid, ios_l, np + LOGICAL :: digits + REAL(wp) :: xv + kl = to_lower(TRIM(kw)) + np = 0 + IF (LEN_TRIM(kl) > 10) THEN + IF (kl(1:10) == 'layazimuth') np = 10 + END IF + IF (LEN_TRIM(kl) > 13) THEN + IF (kl(1:13) == 'aslaidtension') np = 13 + END IF + ios_l = 1 + digits = .FALSE. + IF (np > 0) THEN + digits = VERIFY(TRIM(kl(np + 1:)), '0123456789') == 0 + IF (digits) READ (kl(np + 1:), *, IOSTAT=ios_l) lid + END IF + IF (.NOT. digits) THEN + CALL fail(ErrStat, ErrMsg, 'unknown OPTION keyword "'//TRIM(kw)//'"') + ELSE IF (ios_l /= 0) THEN + ! an integer suffix too large for a line ID + CALL fail(ErrStat, ErrMsg, 'OPTION '//TRIM(kw)//' names no LINE') + ELSE + CALL rd(val, xv, ErrStat, ErrMsg) + IF (ErrStat == 0) THEN + IF (np == 10) THEN + CALL set_line_value(opts%lay_azimuth_line, opts%lay_azimuth_line_deg, lid, xv) + ELSE + CALL set_line_value(opts%as_laid_tension_line, opts%as_laid_tension_line_value, lid, xv) + END IF + END IF + END IF + END BLOCK END SELECT IF (ErrStat == 0) CALL check_option_row_value(kw, val, ErrStat, ErrMsg) + CONTAINS + SUBROUTINE set_line_value(ids, vals, lid, xv) + !! Record (or replace: the last row wins) the per-line value xv of line lid. + INTEGER, ALLOCATABLE, INTENT(INOUT) :: ids(:) + REAL(wp), ALLOCATABLE, INTENT(INOUT) :: vals(:) + INTEGER, INTENT(IN) :: lid + REAL(wp), INTENT(IN) :: xv + INTEGER :: k + IF (.NOT. ALLOCATED(ids)) THEN + ALLOCATE (ids(0), vals(0)) + END IF + DO k = 1, SIZE(ids) + IF (ids(k) == lid) THEN + vals(k) = xv + RETURN + END IF + END DO + ids = [ids, lid] + vals = [vals, xv] + END SUBROUTINE set_line_value END SUBROUTINE apply_option SUBROUTINE check_option_row_value(kw, val, ErrStat, ErrMsg) @@ -12828,9 +13293,18 @@ SUBROUTINE check_option_row_value(kw, val, ErrStat, ErrMsg) REAL(wp) :: x LOGICAL :: ok CHARACTER(16) :: rule + CHARACTER(LEN(kw)) :: key ErrStat = 0; ErrMsg = '' - SELECT CASE (to_lower(TRIM(kw))) + ! a per-line row (layAzimuth, asLaidTension) takes the rule of its family + key = to_lower(TRIM(kw)) + IF (LEN_TRIM(key) > 10) THEN + IF (key(1:10) == 'layazimuth' .AND. VERIFY(TRIM(key(11:)), '0123456789') == 0) key = 'layazimuth' + END IF + IF (LEN_TRIM(key) > 13) THEN + IF (key(1:13) == 'aslaidtension' .AND. VERIFY(TRIM(key(14:)), '0123456789') == 0) key = 'aslaidtension' + END IF + SELECT CASE (TRIM(key)) CASE ('g', 'gravity', 'rhow', 'wtrdnsty', 'water_density', 'wtrdpth', 'water_depth', 'dtm', 'dt', 'dtwave') rule = 'positive' CASE ('tmax', 'tensile_strain_tolerance', 'tensilestraintolerance', 'ramptime', 'ramp_time', 'tramp', & @@ -12842,6 +13316,10 @@ SUBROUTINE check_option_row_value(kw, val, ErrStat, ErrMsg) CASE ('frictionmuaxial', 'frictionmu_axial', 'mu_axial', 'muaxial', 'frictionmulateral', 'frictionmu_lateral', & 'mu_lateral', 'mulateral', 'frictionmunormal', 'frictionmu_normal') rule = 'non-negative' + CASE ('aslaidtension', 'as_laid_tension') + rule = 'non-negative' + CASE ('layazimuth', 'lay_azimuth') + rule = 'finite' CASE ('rhoinf', 'rho_inf') rule = 'unit' CASE ('kbot', 'kb', 'cbot', 'cb', 'dtic', 'tmaxic', 'cdscaleic', 'threshic', 'writelog', 'dtout') @@ -13447,6 +13925,32 @@ SUBROUTINE finalize_checks(types, bodies, rod_types, rods, points, lines, sectio CALL fail(ErrStat, ErrMsg, 'OPTION frictionMu requires WtrDpth or bathymetryFile'); RETURN END IF END IF + ! per-line static friction rows: a line that exists, a finite azimuth, a tension >= 0 + IF (ALLOCATED(opts%lay_azimuth_line)) THEN + DO i = 1, SIZE(opts%lay_azimuth_line) + IF (find_line(lines, opts%lay_azimuth_line(i)) < 1) THEN + CALL fail(ErrStat, ErrMsg, 'OPTION layAzimuth'//TRIM(int_to_str(opts%lay_azimuth_line(i)))// & + ' names no LINE'); RETURN + END IF + IF (.NOT. IEEE_IS_FINITE(opts%lay_azimuth_line_deg(i))) THEN + CALL fail(ErrStat, ErrMsg, 'OPTION layAzimuth'//TRIM(int_to_str(opts%lay_azimuth_line(i)))// & + ' must be finite'); RETURN + END IF + END DO + END IF + IF (ALLOCATED(opts%as_laid_tension_line)) THEN + DO i = 1, SIZE(opts%as_laid_tension_line) + IF (find_line(lines, opts%as_laid_tension_line(i)) < 1) THEN + CALL fail(ErrStat, ErrMsg, 'OPTION asLaidTension'//TRIM(int_to_str(opts%as_laid_tension_line(i)))// & + ' names no LINE'); RETURN + END IF + IF (.NOT. (IEEE_IS_FINITE(opts%as_laid_tension_line_value(i)) .AND. & + opts%as_laid_tension_line_value(i) >= CD_ZERO)) THEN + CALL fail(ErrStat, ErrMsg, 'OPTION asLaidTension'//TRIM(int_to_str(opts%as_laid_tension_line(i)))// & + ' must be finite and >= 0'); RETURN + END IF + END DO + END IF IF (.NOT. (IEEE_IS_FINITE(opts%rho_inf) .AND. opts%rho_inf >= CD_ZERO .AND. opts%rho_inf <= CD_ONE)) THEN CALL fail(ErrStat, ErrMsg, 'OPTIONS rhoInf must be finite and in [0, 1]'); RETURN END IF @@ -16955,6 +17459,12 @@ SUBROUTINE write_multibody_dynamic_out(deck_path, out_root, channels, types, bod first_miss_time = CD_ZERO last_miss_time = CD_ZERO ! ---- scope of the multibody march (fail closed by name) ---- + IF (opts%has_friction .AND. opts%static_friction == CD_STATIC_FRICTION_AS_LAID) THEN + CALL fail(ErrStat, ErrMsg, 'a deck with bodies, rods or dynamic points does not support OPTION '// & + 'staticsFriction asLaid (the '// & + 'static equilibrium of its bodies, rods and points solves the lines without seabed friction); '// & + 'use staticsFriction none'); RETURN + END IF IF (opts%has_motion_file) THEN CALL fail(ErrStat, ErrMsg, 'a mixed-topology deck (bodies, rods, dynamic points, EI=0 and finite-EI '// & 'lines together) does not support motionFile coupling'); RETURN diff --git a/src/CableDyn_HermiteCableStatic.f90 b/src/CableDyn_HermiteCableStatic.f90 index 72b20cdc..446ba6df 100644 --- a/src/CableDyn_HermiteCableStatic.f90 +++ b/src/CableDyn_HermiteCableStatic.f90 @@ -48,6 +48,7 @@ MODULE CableDyn_HermiteCableStatic CD_Bathymetry_Floor, CD_Bathymetry_Floor_Gradient, CD_BATHY_OK, & CD_Bathymetry_Rotate_Curvature USE CableDyn_HermiteCableDynamic, ONLY: CD_HermiteCable_Drag_Element, CD_HCDYN_OK + USE CableDyn_Static, ONLY: CD_Static_As_Laid_Reference, CD_STATIC_OK USE CableDyn_Hydro, ONLY: CD_Current_Profile_Velocity, CD_HYDRO_OK USE CableDyn_HermiteTorsion, ONLY: CD_HermiteTorsionType, CD_HermiteTorsion_Line, CD_HermiteTorsion_Unwrap, & CD_HermiteTorsion_Accept, CD_HermiteTorsion_Compliance, & @@ -70,7 +71,7 @@ MODULE CableDyn_HermiteCableStatic PUBLIC :: CD_HermiteCable_Prolong_Arc PUBLIC :: CD_HermiteCable_Static_Solve_AutoMesh PUBLIC :: CD_HermiteCable_Current_Load - PUBLIC :: CD_HermiteCable_Friction_Anchors + PUBLIC :: CD_HermiteCable_Friction_Anchors, CD_HermiteCable_Friction_Reference, CD_HermiteCable_As_Laid_Offsets PUBLIC :: CD_HermiteCable_Mean_Axial_Extremes PUBLIC :: CD_Arclength_Dot, CD_Arclength_Unit_Tangent, CD_Arclength_Bordered_Update INTEGER, PARAMETER, PUBLIC :: CD_HCSTAT_OK = 0, CD_HCSTAT_BADINPUT = 1, CD_HCSTAT_NOCONVERGE = 2 @@ -169,7 +170,8 @@ MODULE CableDyn_HermiteCableStatic ! position, capped at mu times the normal contact force. The reference is a profile ! along the unstretched arc length (ref_s ascending; ref_xy(1:2, :) the solve-frame ! offsets from node 1, the held first end), interpolated at each node, so it survives - ! mesh refinement and a translated solve origin: the still-water laid shape. + ! mesh refinement and a translated solve origin: the as-laid position of the line, which + ! is instead rebuilt on the mesh itself when its lay is given (laid_on_mesh, below). ! frozen_capacity (optional, one entry per node of the solved mesh) holds the capacities ! fixed: the springs are then conservative (the energy-minimising step applies), as the ! frozen drag of a fixed-point pass. @@ -181,6 +183,23 @@ MODULE CableDyn_HermiteCableStatic REAL(wp) :: mu_axial = -1.0_wp REAL(wp), ALLOCATABLE :: ref_s(:), ref_xy(:, :) REAL(wp), ALLOCATABLE :: frozen_capacity(:) + ! the reference is the as-laid position (staticsFriction asLaid; otherwise the still-water + ! equilibrium of a current deck) + LOGICAL :: as_laid = .FALSE. + ! The lay of an as-laid reference that is rebuilt on every mesh it is applied to + ! (laid_on_mesh, CD_HermiteCable_As_Laid_Offsets): the nodes of a refined or coarsened + ! mesh are laid and sink as the deck nodes are, under their own lumped weights and nodal + ! seabed stiffnesses, which no interpolation of the deck-mesh profile gives at a section + ! change or on a varying slope. The line is laid from laid_origin (global x, y of its + ! lower end, node 1 or, laid_from_top, the last node) along laid_azimuth [rad, global] at + ! laid_tension [N], over the bathymetry when laid_bathymetry; the offsets are taken from + ! laid_node1 (global x, y of node 1) in the solve frame laid_frame_cs = (cos, sin). With + ! laid_in_plane only the sink of the nodes leaves the vertical plane of the chord. + LOGICAL :: laid_on_mesh = .FALSE. + LOGICAL :: laid_from_top = .FALSE., laid_in_plane = .FALSE., laid_bathymetry = .FALSE. + REAL(wp) :: laid_origin(2) = 0.0_wp, laid_node1(2) = 0.0_wp + REAL(wp) :: laid_azimuth = 0.0_wp, laid_tension = 0.0_wp + REAL(wp) :: laid_frame_cs(2) = [1.0_wp, 0.0_wp] END TYPE CD_HermiteStaticFrictionType TYPE, PUBLIC :: CD_HermiteStaticCurrentType @@ -189,6 +208,8 @@ MODULE CableDyn_HermiteCableStatic REAL(wp) :: waterline_z = 0.0_wp REAL(wp) :: velocity(3) = 0.0_wp REAL(wp) :: frame_cs(2) = [1.0_wp, 0.0_wp] + ! drag = .FALSE.: a zero-velocity carrier of the as-laid seabed friction in still water + LOGICAL :: drag = .TRUE. REAL(wp), ALLOCATABLE :: profile_z(:), profile_velocity(:, :) REAL(wp), ALLOCATABLE :: arc_end(:), diam(:), cdn(:), cdt(:) ! Seabed friction held by the line against the current (allocated: active). @@ -2147,7 +2168,9 @@ SUBROUTINE setup_friction(fr, ecs, ecm) ELSE fr_k = kn*trib END IF - CALL CD_HermiteCable_Friction_Reference(fr, l0, q(1:2), fr_ref, ecs, ecm) + ! an as-laid reference is laid on this mesh, with its nodal loads and stiffnesses + CALL CD_HermiteCable_Friction_Reference(fr, l0, q(1:2), fr_ref, ecs, ecm, EA=EA, w=w, node_kn=fr_k, & + bathymetry=bathymetry) IF (ecs /= CD_HCSTAT_OK) RETURN IF (ALLOCATED(fr%frozen_capacity)) THEN IF (SIZE(fr%frozen_capacity) /= nn) THEN @@ -2601,20 +2624,140 @@ END SUBROUTINE fail END SUBROUTINE CD_HermiteCable_Static_Solve - SUBROUTINE CD_HermiteCable_Friction_Reference(fr, l0, origin, ref, ErrStat, ErrMsg) + SUBROUTINE CD_HermiteCable_As_Laid_Offsets(fr, l0, EA, node_load, node_kn, offsets, ErrStat, ErrMsg, bathymetry) + !! As-laid friction reference of the nodes of mesh l0 (the lay of fr, laid_* above; + !! CD_Static_As_Laid_Reference): node i at the stretched arc length of the elements + !! l0 (1 + laid_tension/EA) along the seabed from the lower end, and on a bathymetry + !! moved with its sink into the penalty seabed under its nodal load node_load(i) [N, + !! downward positive] over its nodal seabed stiffness node_kn(i) [N/m] (with the + !! turning force of the laid tension). offsets(1:2, i) is the reference of node i less + !! the global position laid_node1 of node 1, in the solve frame laid_frame_cs; with + !! laid_in_plane on a bathymetry only the sink offset across the chord leaves its plane. + TYPE(CD_HermiteStaticFrictionType), INTENT(IN) :: fr + REAL(wp), INTENT(IN) :: l0(:), EA(:), node_load(:), node_kn(:) + REAL(wp), INTENT(OUT) :: offsets(:, :) + INTEGER, INTENT(OUT) :: ErrStat + CHARACTER(*), INTENT(OUT) :: ErrMsg + TYPE(CD_BathymetryType), INTENT(IN), OPTIONAL :: bathymetry + REAL(wp), ALLOCATABLE :: ref_g(:, :), ref_0(:, :), wn(:), sn(:), kn_o(:), l0_r(:), ea_r(:) + REAL(wp) :: dg(2), dg0(2), cs(2) + INTEGER :: k, ne, es + CHARACTER(200) :: em + ErrStat = CD_HCSTAT_OK + ErrMsg = '' + ne = SIZE(l0) + IF (ne < 1 .OR. SIZE(EA) /= ne .OR. SIZE(node_load) /= ne + 1 .OR. SIZE(node_kn) /= ne + 1 .OR. & + SIZE(offsets, 1) /= 2 .OR. SIZE(offsets, 2) /= ne + 1) THEN + ErrStat = CD_HCSTAT_BADINPUT; ErrMsg = 'as-laid friction reference: inconsistent array sizes'; RETURN + END IF + IF (.NOT. CD_All_Finite(node_load) .OR. .NOT. CD_All_Finite(node_kn)) THEN + ErrStat = CD_HCSTAT_BADINPUT; ErrMsg = 'as-laid friction reference: nodal loads and stiffnesses must be finite' + RETURN + END IF + offsets = CD_ZERO + ALLOCATE (ref_g(2, ne + 1)) + IF (PRESENT(bathymetry)) THEN + ! the static penalty penetration factor w_i/k_i of every node + ALLOCATE (wn(ne + 1)) + WHERE (node_kn > CD_ZERO) + wn = MAX(node_load, CD_ZERO)/node_kn + ELSEWHERE + wn = CD_ZERO + END WHERE + IF (fr%laid_from_top) THEN + sn = wn(ne + 1:1:-1) + kn_o = node_kn(ne + 1:1:-1) + ELSE + sn = wn + kn_o = node_kn + END IF + END IF + IF (fr%laid_from_top) THEN + ! the line is laid from its bottom end, here the last node + l0_r = l0(ne:1:-1) + ea_r = EA(ne:1:-1) + ELSE + l0_r = l0 + ea_r = EA + END IF + ! sn and kn_o are unallocated (absent) without a bathymetry + CALL CD_Static_As_Laid_Reference(fr%laid_origin, fr%laid_azimuth, l0_r, ea_r, fr%laid_tension, ref_g, es, em, & + bathymetry=bathymetry, sink=sn, kn=kn_o) + IF (es /= CD_STATIC_OK) THEN + ErrStat = CD_HCSTAT_BADINPUT; ErrMsg = TRIM(em); RETURN + END IF + IF (fr%laid_from_top) ref_g = ref_g(:, ne + 1:1:-1) + ! the laid line without the sink of its nodes: its cross-plane offset is geometric + ref_0 = ref_g + IF (fr%laid_in_plane .AND. PRESENT(bathymetry)) THEN + CALL CD_Static_As_Laid_Reference(fr%laid_origin, fr%laid_azimuth, l0_r, ea_r, fr%laid_tension, ref_0, es, em, & + bathymetry=bathymetry) + IF (es /= CD_STATIC_OK) THEN + ErrStat = CD_HCSTAT_BADINPUT; ErrMsg = TRIM(em); RETURN + END IF + IF (fr%laid_from_top) ref_0 = ref_0(:, ne + 1:1:-1) + END IF + cs = fr%laid_frame_cs + DO k = 1, ne + 1 + dg = ref_g(:, k) - fr%laid_node1 + offsets(:, k) = [cs(1)*dg(1) + cs(2)*dg(2), -cs(2)*dg(1) + cs(1)*dg(2)] + IF (fr%laid_in_plane) THEN + ! the laid line lies in the vertical plane of the chord: only the sink offset of the + ! nodes on a cross slope (zero on a flat floor) leaves it + dg0 = ref_0(:, k) - fr%laid_node1 + offsets(2, k) = (-cs(2)*dg(1) + cs(1)*dg(2)) - (-cs(2)*dg0(1) + cs(1)*dg0(2)) + END IF + END DO + END SUBROUTINE CD_HermiteCable_As_Laid_Offsets + + SUBROUTINE CD_HermiteCable_Friction_Reference(fr, l0, origin, ref, ErrStat, ErrMsg, EA, w, node_kn, bathymetry) !! Reference position (x, y) of every node of mesh l0: origin (the position of node 1, !! the held first end, in the caller's frame) plus the friction reference offset !! profile interpolated linearly in unstretched arc length (constant past its ends). + !! An as-laid reference whose lay is given (fr%laid_on_mesh) is instead rebuilt on mesh + !! l0 itself (CD_HermiteCable_As_Laid_Offsets) when the mesh's axial stiffnesses EA, + !! submerged weights per length w (lumped to the nodes) and nodal seabed stiffnesses + !! node_kn are given, and the bathymetry it was laid on (fr%laid_bathymetry). TYPE(CD_HermiteStaticFrictionType), INTENT(IN) :: fr REAL(wp), INTENT(IN) :: l0(:), origin(2) REAL(wp), INTENT(OUT) :: ref(:, :) INTEGER, INTENT(OUT) :: ErrStat CHARACTER(*), INTENT(OUT) :: ErrMsg + REAL(wp), INTENT(IN), OPTIONAL :: EA(:), w(:), node_kn(:) + TYPE(CD_BathymetryType), INTENT(IN), OPTIONAL :: bathymetry + REAL(wp), ALLOCATABLE :: node_load(:) INTEGER :: node, k, np REAL(wp) :: s, t + LOGICAL :: on_mesh ErrStat = CD_HCSTAT_OK ErrMsg = '' ref = CD_ZERO + on_mesh = fr%as_laid .AND. fr%laid_on_mesh .AND. PRESENT(EA) .AND. PRESENT(w) .AND. PRESENT(node_kn) + IF (on_mesh .AND. fr%laid_bathymetry) on_mesh = PRESENT(bathymetry) + IF (on_mesh) THEN + IF (SIZE(w) /= SIZE(l0) .OR. SIZE(ref, 1) /= 2 .OR. SIZE(ref, 2) /= SIZE(l0) + 1 .OR. & + .NOT. CD_Is_Finite(fr%mu) .OR. .NOT. CD_All_Finite(w)) THEN + ErrStat = CD_HCSTAT_BADINPUT; ErrMsg = 'friction: as-laid reference inputs inconsistent or non-finite'; RETURN + END IF + ! the element weights lumped to the nodes + ALLOCATE (node_load(SIZE(l0) + 1)) + node_load = CD_ZERO + DO k = 1, SIZE(l0) + node_load(k:k + 1) = node_load(k:k + 1) + 0.5_wp*w(k)*l0(k) + END DO + IF (fr%laid_bathymetry) THEN + CALL CD_HermiteCable_As_Laid_Offsets(fr, l0, EA, node_load, node_kn, ref, ErrStat, ErrMsg, bathymetry) + ELSE + CALL CD_HermiteCable_As_Laid_Offsets(fr, l0, EA, node_load, node_kn, ref, ErrStat, ErrMsg) + END IF + IF (ErrStat /= CD_HCSTAT_OK) THEN + ErrMsg = 'friction: '//TRIM(ErrMsg); RETURN + END IF + DO node = 1, SIZE(l0) + 1 + ref(:, node) = origin + ref(:, node) + END DO + RETURN + END IF IF (.NOT. (ALLOCATED(fr%ref_s) .AND. ALLOCATED(fr%ref_xy))) THEN ErrStat = CD_HCSTAT_BADINPUT; ErrMsg = 'friction: reference profile required'; RETURN END IF @@ -2642,19 +2785,22 @@ SUBROUTINE CD_HermiteCable_Friction_Reference(fr, l0, origin, ref, ErrStat, ErrM END SUBROUTINE CD_HermiteCable_Friction_Reference SUBROUTINE CD_HermiteCable_Friction_Anchors(l0, q, fr, contact_kn, seabed_z, anchors, force, & - ErrStat, ErrMsg, bathymetry, contact_frame_cs) + ErrStat, ErrMsg, bathymetry, contact_frame_cs, EA, w) !! Elastic-plastic friction anchors that continue a static equilibrium solved with !! seabed friction fr into the dynamics: the static spring force f_s of every node !! (CD_Seabed_Friction_Spring at its normal force in state q) and the anchor !! x - f_s/k at which a linear spring of the same stiffness k (contact_kn) gives f_s. !! force(1:2, node) returns f_s (the force the seabed exerts is -f_s). + !! EA, w (optional, per element): the axial stiffnesses and submerged weights per length + !! of the static solve, with which an as-laid reference is laid on mesh l0 as it was + !! there (CD_HermiteCable_Friction_Reference). REAL(wp), INTENT(IN) :: l0(:), q(:), contact_kn(:), seabed_z TYPE(CD_HermiteStaticFrictionType), INTENT(IN) :: fr REAL(wp), INTENT(OUT) :: anchors(:, :), force(:, :) INTEGER, INTENT(OUT) :: ErrStat CHARACTER(*), INTENT(OUT) :: ErrMsg TYPE(CD_BathymetryType), INTENT(IN), OPTIONAL :: bathymetry - REAL(wp), INTENT(IN), OPTIONAL :: contact_frame_cs(2) + REAL(wp), INTENT(IN), OPTIONAL :: contact_frame_cs(2), EA(:), w(:) REAL(wp), ALLOCATABLE :: ref(:, :) REAL(wp) :: z_floor, gxg, gyg, xg, yg, normal, normal_gap, dfd(2, 2), dfc(2), cs(2) INTEGER :: node, ix, nn, es @@ -2681,7 +2827,8 @@ SUBROUTINE CD_HermiteCable_Friction_Anchors(l0, q, fr, contact_kn, seabed_z, anc END IF END IF ALLOCATE (ref(2, nn)) - CALL CD_HermiteCable_Friction_Reference(fr, l0, q(1:2), ref, ErrStat, ErrMsg) + CALL CD_HermiteCable_Friction_Reference(fr, l0, q(1:2), ref, ErrStat, ErrMsg, EA=EA, w=w, node_kn=contact_kn, & + bathymetry=bathymetry) IF (ErrStat /= CD_HCSTAT_OK) THEN ErrMsg = 'CD_HermiteCable_Friction_Anchors: '//TRIM(ErrMsg); RETURN END IF @@ -2728,6 +2875,14 @@ SUBROUTINE current_element_props(current, l0, d, cn, ct, ErrStat, ErrMsg) REAL(wp) :: arc, smid ErrStat = CD_HCSTAT_OK ErrMsg = '' + ! a carrier without drag (drag = .FALSE.: the static seabed friction alone) loads no + ! element, whatever its velocity, and needs no drag properties + IF (.NOT. current%drag) THEN + d = CD_ZERO + cn = CD_ZERO + ct = CD_ZERO + RETURN + END IF IF (.NOT. (current%rho > CD_ZERO) .OR. .NOT. CD_Is_Finite(current%rho) .OR. & .NOT. (current%load_factor >= CD_ZERO) .OR. .NOT. CD_Is_Finite(current%load_factor) .OR. & .NOT. CD_All_Finite(current%velocity) .OR. .NOT. CD_Is_Finite(current%waterline_z) .OR. & @@ -2781,6 +2936,8 @@ SUBROUTINE current_element_load(current, qe, l0e, d, cn, ct, want_jac, fd, djq, fd = CD_ZERO djq = CD_ZERO ve = CD_ZERO + ! no drag on a friction-only carrier (current_element_props) + IF (.NOT. current%drag) RETURN IF (ALLOCATED(current%profile_z)) THEN CALL CD_Current_Profile_Velocity(qe(3), current%profile_z, current%profile_velocity, ua, es, em) IF (es == CD_HYDRO_OK) CALL CD_Current_Profile_Velocity(qe(9), current%profile_z, current%profile_velocity, & @@ -2874,6 +3031,13 @@ SUBROUTINE CD_HermiteCable_Mean_Axial_Extremes(l0, EA, q, t_min, t_max, e_min, s END DO END SUBROUTINE CD_HermiteCable_Mean_Axial_Extremes + PURE LOGICAL FUNCTION current_has_drag(cur) RESULT(has) + !! Whether a static current object carries a flow (a zero-velocity one only carries the + !! static seabed friction of a line in still water): the current diagnoses apply then only. + TYPE(CD_HermiteStaticCurrentType), INTENT(IN) :: cur + has = cur%drag + END FUNCTION current_has_drag + FUNCTION current_compression_note(l0, EA, qx, seabed_z, flat, frictional, frictionless_run) RESULT(note) !! Diagnosis of a current that has no tension-only equilibrium on the traced branch: !! empty unless the state qx (the last one reached) carries an element-mean axial force @@ -3044,11 +3208,11 @@ SUBROUTINE CD_HermiteCable_Static_Solve_Continuation(l0, EA, EI, w, seed, fixed_ ! A current rides along the stiffness homotopy as the drag frozen at the last accepted ! configuration (drag_homotopy); if that path fails, the still-water homotopy is traced ! and the drag is then brought in by load steps at full stiffness. - ! Seabed friction holds the line against the current relative to its still-water laid - ! shape (the reference of its springs). The springs are memoryless, so the equilibrium - ! does not depend on the path that reaches it: they ride along the homotopy with the - ! drag, their capacities frozen at the same configuration (fric_stage). The still-water - ! homotopy of the fallback path runs without them. + ! Seabed friction holds the line relative to its as-laid position (the reference of its + ! springs; in still water a zero-velocity current carries it). The springs are + ! memoryless, so the equilibrium does not depend on the path that reaches it: they ride + ! along the homotopy with the drag, their capacities frozen at the same configuration + ! (fric_stage). The frictionless homotopy of the fallback path runs without them. use_fric = .FALSE. IF (PRESENT(current)) THEN IF (ALLOCATED(current%friction)) use_fric = current%friction%mu > CD_ZERO @@ -3066,7 +3230,7 @@ SUBROUTINE CD_HermiteCable_Static_Solve_Continuation(l0, EA, EI, w, seed, fixed_ picard_ok = ErrStat == CD_HCSTAT_OK IF (picard_ok) THEN CALL full_fixed_point(picard_ok) - IF (.NOT. picard_ok) first_msg = 'current drag fixed point not reached: '// & + IF (.NOT. picard_ok) first_msg = TRIM(fixed_point_name())//' not reached: '// & TRIM(compression_note(q))//TRIM(em) ELSE first_msg = ErrMsg @@ -3117,15 +3281,21 @@ SUBROUTINE CD_HermiteCable_Static_Solve_Continuation(l0, EA, EI, w, seed, fixed_ ! Formatted into a short buffer: the assembled message may exceed ErrMsg and is ! truncated by the assignment (an internal WRITE past the record length aborts). WRITE (frac_txt, '(F6.3)') cur_frac - ErrMsg = 'CD_HermiteCable_Static_Solve_Continuation: current load stepping stopped at drag '// & - 'fraction '//TRIM(ADJUSTL(frac_txt))//': '//TRIM(compression_note(q))//TRIM(em)// & - ' (with the current along the homotopy: '//TRIM(first_msg)//')' + IF (current_has_drag(current)) THEN + ErrMsg = 'CD_HermiteCable_Static_Solve_Continuation: current load stepping stopped at drag '// & + 'fraction '//TRIM(ADJUSTL(frac_txt))//': '//TRIM(compression_note(q))//TRIM(em)// & + ' (with the current along the homotopy: '//TRIM(first_msg)//')' + ELSE + ErrMsg = 'CD_HermiteCable_Static_Solve_Continuation: seabed friction load stepping stopped at '// & + 'load fraction '//TRIM(ADJUSTL(frac_txt))//': '//TRIM(em)// & + ' (with the friction along the homotopy: '//TRIM(first_msg)//')' + END IF q_out = q; RETURN END IF CALL full_fixed_point(picard_ok) IF (.NOT. picard_ok) THEN ErrStat = CD_HCSTAT_NOCONVERGE - ErrMsg = 'CD_HermiteCable_Static_Solve_Continuation: current drag fixed point not reached: '// & + ErrMsg = 'CD_HermiteCable_Static_Solve_Continuation: '//TRIM(fixed_point_name())//' not reached: '// & TRIM(compression_note(q))//TRIM(em) q_out = q; RETURN END IF @@ -3312,6 +3482,9 @@ LOGICAL FUNCTION frictionless_run_limit(qx) RESULT(run_limit) CHARACTER(512) :: note LOGICAL :: flat flat = .NOT. PRESENT(bathymetry) + run_limit = .FALSE. + IF (.NOT. PRESENT(current)) RETURN + IF (.NOT. current_has_drag(current)) RETURN note = current_compression_note(l0, EA, qx, seabed_z, flat, use_fric, run_limit) END FUNCTION frictionless_run_limit @@ -3321,9 +3494,31 @@ FUNCTION compression_note(qx) RESULT(note) CHARACTER(512) :: note LOGICAL :: flat flat = .NOT. PRESENT(bathymetry) + note = '' + IF (.NOT. PRESENT(current)) RETURN + IF (.NOT. current_has_drag(current)) RETURN note = current_compression_note(l0, EA, qx, seabed_z, flat, use_fric) END FUNCTION compression_note + FUNCTION fixed_point_name() RESULT(name) + !! The frozen-load fixed point of this solve in its messages: the current drag, or the + !! seabed friction a zero-velocity carrier holds in still water. + CHARACTER(40) :: name + name = 'seabed friction fixed point' + IF (PRESENT(current)) THEN + IF (current_has_drag(current)) name = 'current drag fixed point' + END IF + END FUNCTION fixed_point_name + + FUNCTION fraction_name() RESULT(name) + !! The continuation parameter of the load steps in messages (see fixed_point_name). + CHARACTER(16) :: name + name = 'load fraction' + IF (PRESENT(current)) THEN + IF (current_has_drag(current)) name = 'drag fraction' + END IF + END FUNCTION fraction_name + SUBROUTINE drag_arclength(ok) !! Pseudo-arclength continuation of F(q, lambda) = R(q; lambda * drag) = 0 in the drag !! fraction lambda, from the last converged state (q, cur_frac) to lambda = 1, passing @@ -3398,7 +3593,8 @@ SUBROUTINE drag_arclength(ok) IF (.NOT. conv) THEN ds = 0.5_wp*ds IF (ds < DS_MIN .OR. iters_out >= iteration_budget) THEN - WRITE (em, '(A,F6.3,A)') 'stalled at drag fraction ', lam, ' (arclength step below its minimum)' + WRITE (em, '(A,F6.3,A)') 'stalled at '//TRIM(fraction_name())//' ', lam, & + ' (arclength step below its minimum)' RETURN END IF CYCLE @@ -3440,11 +3636,11 @@ SUBROUTINE drag_arclength(ok) tl = tl_new IF (n_corr <= 4) ds = MIN(DS_MAX, 1.5_wp*ds) IF (iters_out >= iteration_budget) THEN - WRITE (em, '(A,F6.3)') 'iteration budget exhausted at drag fraction ', lam + WRITE (em, '(A,F6.3)') 'iteration budget exhausted at '//TRIM(fraction_name())//' ', lam RETURN END IF END DO - WRITE (em, '(A,F6.3)') 'step limit reached at drag fraction ', lam + WRITE (em, '(A,F6.3)') 'step limit reached at '//TRIM(fraction_name())//' ', lam END SUBROUTINE drag_arclength SUBROUTINE arc_assemble(qx, lamx, resx, esx) @@ -3605,14 +3801,27 @@ SUBROUTINE friction_capacity(qx, cap) REAL(wp), INTENT(IN) :: qx(:) REAL(wp), INTENT(OUT) :: cap(:) REAL(wp) :: z_floor, gxg, gyg, xg, yg, normal, normal_gap, trib_k, cs(2), mu_c, q_c, gq_c(2) - REAL(wp), ALLOCATABLE :: fr_ref_c(:, :) + REAL(wp), ALLOCATABLE :: fr_ref_c(:, :), kn_c(:) INTEGER :: k, es_c CHARACTER(200) :: em_c cs = [CD_ONE, CD_ZERO] IF (PRESENT(contact_frame_cs)) cs = contact_frame_cs IF (current%friction%mu_axial > CD_ZERO .AND. ABS(current%friction%mu_axial - current%friction%mu) > CD_ZERO) THEN ALLOCATE (fr_ref_c(2, nn)) - CALL CD_HermiteCable_Friction_Reference(current%friction, l0, qx(1:2), fr_ref_c, es_c, em_c) + ! an as-laid reference laid on this mesh, as the solve lays it (with its nodal + ! seabed stiffnesses: contact_kn, or kn times the tributary length) + ALLOCATE (kn_c(nn)) + IF (PRESENT(contact_kn)) THEN + kn_c = contact_kn + ELSE + kn_c = CD_ZERO + DO k = 1, ne + kn_c(k:k + 1) = kn_c(k:k + 1) + 0.5_wp*l0(k) + END DO + kn_c = kn*kn_c + END IF + CALL CD_HermiteCable_Friction_Reference(current%friction, l0, qx(1:2), fr_ref_c, es_c, em_c, EA=EA, w=w, & + node_kn=kn_c, bathymetry=bathymetry) IF (es_c /= CD_HCSTAT_OK) DEALLOCATE (fr_ref_c) END IF DO k = 1, nn @@ -5989,7 +6198,7 @@ SUBROUTINE CD_HermiteCable_Static_Solve_AutoMesh(l0, EA, EI, w, seed, fixed_dofs LOGICAL, ALLOCATABLE :: axial_marks(:) CHARACTER(LEN(ErrMsg)) :: emloc LOGICAL :: contact_active, polish_initial, must_resolve, must_be_tensile, refine_other - LOGICAL :: needs_refinement, local_axial + LOGICAL :: needs_refinement, local_axial, in_drag REAL(wp) :: contact_cs(2) ! Local axial refinement guards: an element budget and a no-progress stop, so a ! genuinely compressive equilibrium cannot grow the mesh geometrically. @@ -6210,7 +6419,10 @@ SUBROUTINE CD_HermiteCable_Static_Solve_AutoMesh(l0, EA, EI, w, seed, fixed_dofs CALL solve_level(l0r, EAr, EIr, wr, qr, fixedr, contact_diam_r, dry_r, & qnew, curvnew, res_out, it, es, emloc, .TRUE.) iters_out = iters_out + it - IF (es /= CD_HCSTAT_OK .AND. local_axial .AND. .NOT. PRESENT(current)) THEN + ! (a still-water carrier of the as-laid friction is no current here) + in_drag = .FALSE. + IF (PRESENT(current)) in_drag = current_has_drag(current) + IF (es /= CD_HCSTAT_OK .AND. local_axial .AND. .NOT. in_drag) THEN ! The tensile refinement of a compressive state could not be carried further: the ! last converged (parent-mesh) state keeps its compression, which is what the ! tensile contract rejects below (or returns, when advisory). @@ -6219,9 +6431,11 @@ SUBROUTINE CD_HermiteCable_Static_Solve_AutoMesh(l0, EA, EI, w, seed, fixed_dofs END IF IF (es /= CD_HCSTAT_OK) THEN ! Diagnosed on the last converged (parent-mesh) state, not on the unconverged iterate. - IF (PRESENT(current)) emloc = TRIM(current_compression_note(l0_out, EA_out, q_out, seabed_z, & - .NOT. PRESENT(bathymetry), & - ALLOCATED(current%friction)))//TRIM(emloc) + IF (PRESENT(current)) THEN + IF (current_has_drag(current)) & + emloc = TRIM(current_compression_note(l0_out, EA_out, q_out, seabed_z,.NOT. PRESENT(bathymetry), & + ALLOCATED(current%friction)))//TRIM(emloc) + END IF ErrStat = es; ErrMsg = 'CD_HermiteCable_Static_Solve_AutoMesh: refined-mesh polish failed: '//TRIM(emloc) RETURN END IF @@ -6330,9 +6544,11 @@ SUBROUTINE CD_HermiteCable_Static_Solve_AutoMesh(l0, EA, EI, w, seed, fixed_dofs ! In a current, name the limit the compression of this state shows (the grounded run ! pushed into its end, or into a friction-held touchdown): the driver's out-of-plane ! retry of a planar current needs it, as for the other routes' failures. - IF (PRESENT(current)) wbuf = TRIM(current_compression_note(l0_out, EA_out, q_out, seabed_z, & - .NOT. PRESENT(bathymetry), & - ALLOCATED(current%friction)))//TRIM(wbuf) + IF (PRESENT(current)) THEN + IF (current_has_drag(current)) & + wbuf = TRIM(current_compression_note(l0_out, EA_out, q_out, seabed_z,.NOT. PRESENT(bathymetry), & + ALLOCATED(current%friction)))//TRIM(wbuf) + END IF ErrMsg = wbuf RETURN END IF diff --git a/src/CableDyn_Model.f90 b/src/CableDyn_Model.f90 index 4d2855c9..7bd66c1f 100644 --- a/src/CableDyn_Model.f90 +++ b/src/CableDyn_Model.f90 @@ -31,7 +31,8 @@ MODULE CableDyn_Model CD_Bathymetry_Floor, CD_Bathymetry_Floor_Gradient, & CD_Bathymetry_Seabed_Load, CD_End_Bathymetry, CD_BATHY_OK USE CableDyn_Static, ONLY: CableSolverConfig, CableCurrentLoad, CD_StaticLineReport, CD_Static_Line_Equilibrium, & - CD_Static_Friction_Anchors, & + CD_Static_Friction_Anchors, CD_Static_As_Laid_Reference, & + CD_STATIC_FRICTION_AS_LAID, CD_STATIC_FRICTION_NONE, & CD_STATIC_OK USE CableDyn_Assemble, ONLY: CD_Assemble_Cable_Internal_Force, CD_Assemble_Cable_Mass, & CD_Assemble_Cable_Tangent_Force, CD_Compute_Cable_Tension @@ -1269,7 +1270,8 @@ SUBROUTINE CD_Init_Line_Model(model, anchor, fairlead, line_types, sections, gra seabed_kbot, seabed_contact_diameter, seabed_cn_over_kn, & ve_ea_d, ve_ba, ve_ba_d, ve_alpha_mbl, ve_vbeta, & syrope_is, syrope_type, syrope_slow0, syrope_tmax0, & - current_profile_z, current_profile_velocity) + current_profile_z, current_profile_velocity, & + static_friction, lay_azimuth, as_laid_tension) !! Initialise a persistent EI=0 dynamic model from an OrcaFlex-style line object: !! line types + sections + end points. This routine builds the mesh, assembles !! submerged-weight loads, obtains a static initial condition by load continuation, @@ -1342,12 +1344,27 @@ SUBROUTINE CD_Init_Line_Model(model, anchor, fairlead, line_types, sections, gra ! then samples the current at each node's own elevation, as the dynamic march does, so the ! march starts from rest. Without it the static drag uses fluid_velocity as given. REAL(wp), INTENT(IN), OPTIONAL :: current_profile_z(:), current_profile_velocity(:, :) + ! Static seabed friction (with seabed_mu > 0 on a seabed): the policy + ! (CD_STATIC_FRICTION_AS_LAID or CD_STATIC_FRICTION_NONE, the default), the lay azimuth + ! [rad, from global +x toward +y; default: the horizontal direction of the chord from + ! the line's lower end (anchor -> fairlead, or fairlead -> anchor when the fairlead is + ! lower), +x from the anchor for a vertical chord] and the as-laid effective tension + ! [N, default 0] of + ! CD_Static_As_Laid_Reference. As laid, the static solve resists every grounded node's + ! horizontal displacement from its as-laid position with the friction springs, and the + ! stick-slip anchors of the dynamics continue their forces; with none the static solve + ! is frictionless in still water and the anchors start at the static node positions, + ! while in a current the friction springs hold the line from its still-water equilibrium + ! and the anchors continue their forces likewise. + INTEGER, INTENT(IN), OPTIONAL :: static_friction + REAL(wp), INTENT(IN), OPTIONAL :: lay_azimuth, as_laid_tension INTEGER, ALLOCATABLE :: elem_conn(:, :), fixed_dofs(:) REAL(wp), ALLOCATABLE :: l0(:), ea(:), mass_per_length(:), diameter(:) REAL(wp), ALLOCATABLE :: weight(:), elem_load(:, :), f_ext(:), q_static(:), v0(:) - INTEGER :: n_elem, n_dof, e, es, istat - LOGICAL :: dyn_to + INTEGER :: n_elem, n_dof, e, es, istat, fr_policy + LOGICAL :: dyn_to, friction_static + REAL(wp) :: laid_az, laid_t LOGICAL :: reverse_line, converged, use_current LOGICAL :: use_seabed, use_seabed_damping, use_seabed_friction, use_damping CHARACTER(200) :: em @@ -1471,6 +1488,34 @@ SUBROUTINE CD_Init_Line_Model(model, anchor, fairlead, line_types, sections, gra dyn_to = tension_only IF (PRESENT(dynamic_tension_only)) dyn_to = dynamic_tension_only + ! Static seabed friction policy, lay azimuth and as-laid tension (validated even when + ! the line has no friction, so a bad value never passes silently). + fr_policy = CD_STATIC_FRICTION_NONE + IF (PRESENT(static_friction)) fr_policy = static_friction + IF (fr_policy /= CD_STATIC_FRICTION_AS_LAID .AND. fr_policy /= CD_STATIC_FRICTION_NONE) THEN + CALL fail(ErrStat, ErrMsg, 'line model static_friction must be CD_STATIC_FRICTION_AS_LAID or _NONE') + RETURN + END IF + laid_t = CD_ZERO + IF (PRESENT(as_laid_tension)) laid_t = as_laid_tension + IF (.NOT. CD_Is_Finite(laid_t) .OR. laid_t < CD_ZERO) THEN + CALL fail(ErrStat, ErrMsg, 'line model as_laid_tension must be finite and non-negative') + RETURN + END IF + ! default lay azimuth: the vertical plane through the line ends, from the anchor toward + ! the fairlead (negated below when the line is laid from its fairlead, the lower end) + laid_az = CD_ZERO + IF (NORM2(fairlead(1:2) - anchor(1:2)) > 1.0e-9_wp*MAX(CD_ONE, NORM2(fairlead - anchor))) & + laid_az = ATAN2(fairlead(2) - anchor(2), fairlead(1) - anchor(1)) + IF (PRESENT(lay_azimuth)) laid_az = lay_azimuth + IF (.NOT. CD_Is_Finite(laid_az)) THEN + CALL fail(ErrStat, ErrMsg, 'line model lay_azimuth must be finite') + RETURN + END IF + friction_static = .FALSE. + IF (use_seabed .AND. use_seabed_friction) friction_static = seabed_mu > CD_ZERO .AND. & + fr_policy == CD_STATIC_FRICTION_AS_LAID + ! Static initial condition: the shared robust line initializer (the same one the ! static-only deck route uses). The equilibrium obeys the committed model's constitutive ! law (dyn_to): a tension-only line gets its tension-only equilibrium, never a compressed @@ -1503,10 +1548,11 @@ SUBROUTINE CD_Init_Line_Model(model, anchor, fairlead, line_types, sections, gra cur%profile_velocity = current_profile_velocity END IF IF (PRESENT(drag_waterline_z)) cur%node_waterline = drag_waterline_z - ! A frictional seabed holds the line against the current from its still-water laid - ! shape: solve the line without the current first; that equilibrium is the reference - ! of the static friction springs, and their forces seed the stick-slip anchors below. - IF (use_seabed .AND. use_seabed_friction) THEN + ! Without the as-laid policy a frictional seabed holds the line against the current + ! from its still-water laid shape: solve the line without the current first; that + ! equilibrium is the reference of the static friction springs, and their forces seed + ! the stick-slip anchors below. + IF (use_seabed .AND. use_seabed_friction .AND. .NOT. friction_static) THEN IF (seabed_mu > CD_ZERO) THEN CALL CD_Static_Line_Equilibrium(anchor, fairlead, elem_conn, l0, ea, weight, f_ext, static_cfg, dyn_to, & q_static, converged, report, es, em, seabed_z_floor=seabed_z_floor, & @@ -1525,6 +1571,45 @@ SUBROUTINE CD_Init_Line_Model(model, anchor, fairlead, line_types, sections, gra END DO END IF END IF + ELSE + ! still water: the object carries only the static seabed friction (if any) + cur%drag = .FALSE. + END IF + ! Static seabed friction (the OrcaFlex "as laid" policy): every grounded node is held + ! by a friction spring toward its as-laid position -- the line laid from its lower end + ! (the anchor, or the fairlead when that is lower) along the lay azimuth on the seabed at + ! the as-laid tension -- capped at mu N; the spring forces then seed the stick-slip + ! anchors of the march below. + IF (friction_static) THEN + cur%friction_mu = seabed_mu + cur%friction_as_laid = .TRUE. + IF (PRESENT(seabed_mu_axial)) cur%friction_mu_axial = seabed_mu_axial + ALLOCATE (cur%friction_ref(2, n_elem + 1)) + BLOCK + ! static penalty penetration factor w_i/k_i of every node (see the routine) + REAL(wp) :: sink(n_elem + 1) + DO istat = 1, n_elem + 1 + sink(istat) = MAX(-f_ext(3*istat), CD_ZERO)/seabed_kn(istat) + END DO + IF (fairlead(3) < anchor(3)) THEN + ! the line is laid from its bottom end, here the last node (the default azimuth + ! then points from it toward node 1) + IF (.NOT. PRESENT(lay_azimuth)) laid_az = ATAN2(-SIN(laid_az), -COS(laid_az)) + CALL CD_Static_As_Laid_Reference(fairlead(1:2), laid_az, l0(n_elem:1:-1), ea(n_elem:1:-1), laid_t, & + cur%friction_ref, es, em, bathymetry=bathymetry, & + sink=sink(n_elem + 1:1:-1), kn=seabed_kn(n_elem + 1:1:-1)) + cur%friction_ref = cur%friction_ref(:, n_elem + 1:1:-1) + ELSE + CALL CD_Static_As_Laid_Reference(anchor(1:2), laid_az, l0, ea, laid_t, cur%friction_ref, es, em, & + bathymetry=bathymetry, sink=sink, kn=seabed_kn) + END IF + END BLOCK + IF (es /= CD_STATIC_OK) THEN + CALL fail(ErrStat, ErrMsg, 'line model seabed friction: '//TRIM(em)) + RETURN + END IF + END IF + IF (use_current .OR. friction_static) THEN CALL CD_Static_Line_Equilibrium(anchor, fairlead, elem_conn, l0, ea, weight, f_ext, static_cfg, dyn_to, & q_static, converged, report, es, em, seabed_z_floor=seabed_z_floor, & seabed_kn=seabed_kn, bathymetry=bathymetry, current=cur, & @@ -1547,11 +1632,26 @@ SUBROUTINE CD_Init_Line_Model(model, anchor, fairlead, line_types, sections, gra BLOCK REAL(wp), ALLOCATABLE :: q_sw(:) TYPE(CD_StaticLineReport) :: report_sw + TYPE(CableCurrentLoad) :: cur_sw LOGICAL :: conv_sw ALLOCATE (q_sw(SIZE(q_static))) - CALL CD_Static_Line_Equilibrium(anchor, fairlead, elem_conn, l0, ea, weight, f_ext, static_cfg, dyn_to, & - q_sw, conv_sw, report_sw, es, em, seabed_z_floor=seabed_z_floor, & - seabed_kn=seabed_kn, bathymetry=bathymetry, load_factors=load_factors) + IF (friction_static) THEN + ! still water with the same as-laid seabed friction + cur_sw%drag = .FALSE. + cur_sw%friction_mu = cur%friction_mu + cur_sw%friction_mu_axial = cur%friction_mu_axial + cur_sw%friction_ref = cur%friction_ref + cur_sw%friction_as_laid = .TRUE. + CALL CD_Static_Line_Equilibrium(anchor, fairlead, elem_conn, l0, ea, weight, f_ext, static_cfg, & + dyn_to, q_sw, conv_sw, report_sw, es, em, & + seabed_z_floor=seabed_z_floor, seabed_kn=seabed_kn, & + bathymetry=bathymetry, current=cur_sw, load_factors=load_factors) + ELSE + CALL CD_Static_Line_Equilibrium(anchor, fairlead, elem_conn, l0, ea, weight, f_ext, static_cfg, & + dyn_to, q_sw, conv_sw, report_sw, es, em, & + seabed_z_floor=seabed_z_floor, seabed_kn=seabed_kn, & + bathymetry=bathymetry, load_factors=load_factors) + END IF IF (es == CD_STATIC_OK .AND. conv_sw) THEN IF (ALLOCATED(cur%friction_ref)) THEN ErrMsg = 'CableDyn_Model: the line has a still-water equilibrium but none in the current: '// & diff --git a/src/CableDyn_Static.f90 b/src/CableDyn_Static.f90 index 19aa16c8..50b1140e 100644 --- a/src/CableDyn_Static.f90 +++ b/src/CableDyn_Static.f90 @@ -16,9 +16,10 @@ MODULE CableDyn_Static !! penalty contact force + its residual-Jacobian term are recomputed inside every !! residual/tangent evaluation (grounded catenary / mooring equilibrium); when !! absent it is the constant-f_ext solve, bit-for-bit unchanged. An OPTIONAL - !! steady current adds configuration-dependent Morison drag (CableCurrentLoad), and with - !! it the seabed friction that holds the line against the current (friction springs from - !! the still-water laid shape). Damping and wave loads belong to the dynamic path. + !! steady current adds configuration-dependent Morison drag (CableCurrentLoad), and the + !! same object carries the static seabed friction (friction springs from the as-laid + !! position, CD_Static_As_Laid_Reference), with or without the drag. Damping and wave + !! loads belong to the dynamic path. !! !! Conventions match the other modules: q is the flat (3 n_nodes) positions-only !! state [x1,y1,z1, x2,y2,z2, ...]; node nd owns DOFs 3*nd-2:3*nd; fixed_dofs are @@ -48,6 +49,7 @@ MODULE CableDyn_Static PUBLIC :: CD_Static_Line_End_Forces PUBLIC :: CD_Static_Anchor_Seabed_Tolerance PUBLIC :: CD_Static_Friction_Anchors + PUBLIC :: CD_Static_As_Laid_Reference TYPE :: CableSolverConfig !! Newton / Armijo policy and its default tolerances. @@ -88,13 +90,19 @@ MODULE CableDyn_Static ! residual evaluation (the dynamic march samples it at the actual node depths too), so the ! static state is an equilibrium of the marched model. It replaces node_velocity/velocity. REAL(wp), ALLOCATABLE :: profile_z(:), profile_velocity(:, :) - ! Seabed friction held against the current (friction_mu > 0 with friction_ref - ! allocated, on a line with seabed contact): each node in contact carries a horizontal - ! spring of its seabed stiffness from its reference position friction_ref(1:2, node), - ! capped smoothly at friction_mu times its normal reaction (CD_Seabed_Friction_Spring). - ! The reference is the still-water laid shape of the same line. + ! drag = .FALSE.: the object carries only the static seabed friction below (a line in + ! still water); the drag fields are then ignored and need not be set. + LOGICAL :: drag = .TRUE. + ! Static seabed friction (friction_mu > 0 with friction_ref allocated, on a line with + ! seabed contact): each node in contact carries a horizontal spring of its seabed + ! stiffness from its reference position friction_ref(1:2, node), capped smoothly at + ! friction_mu times its normal reaction (CD_Seabed_Friction_Spring). The reference is the + ! still-water equilibrium in a current (staticsFriction none), or the as-laid position of + ! the line (friction_as_laid, CD_Static_As_Laid_Reference), which also selects the + ! as-laid seed. REAL(wp) :: friction_mu = CD_ZERO REAL(wp), ALLOCATABLE :: friction_ref(:, :) + LOGICAL :: friction_as_laid = .FALSE. ! friction_mu_axial > 0 and different from friction_mu: anisotropic friction, with ! friction_mu the lateral coefficient (CD_Seabed_Friction_Aniso, line axis = chord ! through the neighbouring nodes). @@ -116,6 +124,10 @@ MODULE CableDyn_Static INTEGER, PARAMETER, PUBLIC :: CD_STATIC_OK = 0 INTEGER, PARAMETER, PUBLIC :: CD_STATIC_BADINPUT = 1 INTEGER, PARAMETER, PUBLIC :: CD_STATIC_SINGULAR = 2 + ! Static seabed friction policies (OrcaFlex "statics seabed friction policy"): none, or + ! friction toward the as-laid position (CD_Static_As_Laid_Reference). + INTEGER, PARAMETER, PUBLIC :: CD_STATIC_FRICTION_NONE = 0 + INTEGER, PARAMETER, PUBLIC :: CD_STATIC_FRICTION_AS_LAID = 1 CONTAINS @@ -312,12 +324,14 @@ SUBROUTINE CD_Static_Cable_Solve(q0, elem_conn, l0, ea, tension_only, f_ext, fix END IF ! --- optional steady-current Morison drag (configuration-dependent, ramp-scaled) --- + ! (a friction-only object, drag = .FALSE., carries no drag) current_active = PRESENT(current) + IF (current_active) current_active = current%drag profile_active = .FALSE. cf = CD_ONE IF (PRESENT(current_load_factor)) THEN ! A ramp factor without a current is a caller error: it would silently do nothing. - IF (.NOT. current_active) THEN + IF (.NOT. PRESENT(current)) THEN CALL fail(ErrStat, ErrMsg, 'current_load_factor given without a current load') RETURN END IF @@ -415,7 +429,7 @@ SUBROUTINE CD_Static_Cable_Solve(q0, elem_conn, l0, ea, tension_only, f_ext, fix ALLOCATE (drag_f(n_dof), drag_fz(n_dof), source=CD_ZERO) END IF friction_active = .FALSE. - IF (current_active .AND. seabed_active) THEN + IF (PRESENT(current) .AND. seabed_active) THEN ! Check finiteness before the mu > 0 gate: a NaN coefficient must fail closed, not ! silently disable (or make isotropic) the friction. IF (.NOT. (CD_Is_Finite(current%friction_mu) .AND. CD_Is_Finite(current%friction_mu_axial))) THEN @@ -1300,6 +1314,259 @@ SUBROUTINE CD_Static_Friction_Anchors(q, current, seabed_kn, anchors, ErrStat, E END DO END SUBROUTINE CD_Static_Friction_Anchors + SUBROUTINE CD_Static_As_Laid_Reference(origin, azimuth, l0, ea, laid_tension, ref, ErrStat, ErrMsg, bathymetry, & + sink, kn) + !! As-laid position of a line on the seabed, the reference of its static seabed friction + !! (OrcaFlex's "as laid" statics seabed friction policy): the line is laid from its + !! bottom end (node 1, horizontal position origin) in the horizontal direction azimuth + !! [rad, from global +x toward +y], following the seabed profile, at the effective + !! tension laid_tension [N]. Node i then lies at the stretched arc length + !! s_i = sum_{e < i} l0_e (1 + laid_tension/ea_e) from node 1 along the seabed, so + !! ref(1:2, i) = origin + d_i (cos, sin)(azimuth), where the seabed path over the + !! horizontal distance d_i is s_i long: d_i = s_i on a level floor (no bathymetry), + !! and on a bathymetry the path is integrated in sub-steps of at most 1 m with the + !! midpoint slope along the azimuth. If every node rested at its reference, the line + !! would carry laid_tension throughout. + !! sink (optional, per node, on a bathymetry): the static penalty penetration factor + !! w_i/k_i of each node (its submerged weight over its seabed stiffness). A laid node + !! sinks into the penalty seabed along the surface normal, which on a slope moves it + !! horizontally by w_i (z_x, z_y)/k_i; its reference moves with it, so the normal sink + !! adds no spurious friction deflection (a deflection normal to the seabed is not a + !! friction deflection, as in OrcaFlex's in-plane friction): the spring of a node laid at + !! rest on a slope carries only the slope load that friction holds there. + !! kn (optional, per node, with sink): the nodal seabed stiffness. With a positive + !! laid_tension on a bathymetry whose slope varies, the tension turns at every node of + !! the laid path and presses it into the seabed (over a crest) or lifts it (in a hollow); + !! the normal component of that turning force over kn is added to the node's sink, so + !! the line laid at its as-laid tension rests on its laid path, its springs carrying + !! only the slope and turning loads along the seabed. + REAL(wp), INTENT(IN) :: origin(2), azimuth, l0(:), ea(:), laid_tension + REAL(wp), INTENT(OUT) :: ref(:, :) + INTEGER, INTENT(OUT) :: ErrStat + CHARACTER(*), INTENT(OUT) :: ErrMsg + TYPE(CD_BathymetryType), INTENT(IN), OPTIONAL :: bathymetry + REAL(wp), INTENT(IN), OPTIONAL :: sink(:), kn(:) + INTEGER :: n_elem, e, j, nsub, es + REAL(wp) :: dir(2), d, ds, step, x, y, zf, gx, gy, g, dshort, sink_j, p(3, 3), t_in(3), t_out(3), nrm(3) + REAL(wp), ALLOCATABLE :: ref0(:, :) + CHARACTER(120) :: em + + ErrStat = CD_STATIC_OK + ErrMsg = '' + n_elem = SIZE(l0) + IF (n_elem < 1 .OR. SIZE(ea) /= n_elem .OR. SIZE(ref, 1) /= 2 .OR. SIZE(ref, 2) /= n_elem + 1) THEN + CALL fail(ErrStat, ErrMsg, 'as-laid reference: inconsistent shapes') + RETURN + END IF + IF (.NOT. (CD_All_Finite(origin) .AND. CD_Is_Finite(azimuth) .AND. CD_Is_Finite(laid_tension) .AND. & + CD_All_Finite(l0) .AND. CD_All_Finite(ea))) THEN + CALL fail(ErrStat, ErrMsg, 'as-laid reference: inputs must be finite') + RETURN + END IF + IF (ANY(l0 <= CD_ZERO) .OR. ANY(ea <= CD_ZERO) .OR. laid_tension < CD_ZERO) THEN + CALL fail(ErrStat, ErrMsg, 'as-laid reference: l0 and ea must be positive and laid_tension non-negative') + RETURN + END IF + ! A laid tension that stretches an element beyond its length is no laid state (and would + ! make the seabed path integration below unbounded): fail closed. + IF (ANY(laid_tension > ea)) THEN + CALL fail(ErrStat, ErrMsg, 'as-laid reference: asLaidTension stretches an element by more than 100 % '// & + '(asLaidTension > EA); give the tension the line was laid with') + RETURN + END IF + IF (PRESENT(bathymetry) .AND. SUM(l0)*2.0_wp > 1.0e7_wp) THEN + CALL fail(ErrStat, ErrMsg, 'as-laid reference: the laid length exceeds the 1e7 m the seabed path '// & + 'integration supports') + RETURN + END IF + dir = [COS(azimuth), SIN(azimuth)] + ref(:, 1) = origin + d = CD_ZERO + DO e = 1, n_elem + ds = l0(e)*(CD_ONE + laid_tension/ea(e)) + IF (PRESENT(bathymetry)) THEN + ! the horizontal advance is ds less the shortening of the sloped sub-steps, so a + ! level patch advances by exactly ds, bit-for-bit as on a flat floor + nsub = MAX(1, CEILING(ds)) + step = ds/REAL(nsub, wp) + dshort = CD_ZERO + DO j = 1, nsub + ! midpoint slope along the azimuth (at the level-floor midpoint of the sub-step) + x = origin(1) + (d + REAL(j - 1, wp)*step - dshort + 0.5_wp*step)*dir(1) + y = origin(2) + (d + REAL(j - 1, wp)*step - dshort + 0.5_wp*step)*dir(2) + CALL CD_Bathymetry_Floor_Gradient(bathymetry, x, y, zf, gx, gy, es, em) + IF (es /= CD_BATHY_OK) THEN + CALL fail(ErrStat, ErrMsg, 'as-laid reference: bathymetry query failed: '//TRIM(em)) + RETURN + END IF + g = gx*dir(1) + gy*dir(2) + dshort = dshort + step*(CD_ONE - CD_ONE/SQRT(CD_ONE + g*g)) + END DO + d = d + (ds - dshort) + ELSE + d = d + ds + END IF + ref(:, e + 1) = origin + d*dir + END DO + IF (PRESENT(sink) .AND. PRESENT(bathymetry)) THEN + IF (SIZE(sink) /= n_elem + 1 .OR. .NOT. CD_All_Finite(sink)) THEN + CALL fail(ErrStat, ErrMsg, 'as-laid reference: sink must be finite, one entry per node') + RETURN + END IF + IF (PRESENT(kn)) THEN + IF (SIZE(kn) /= n_elem + 1 .OR. .NOT. CD_All_Finite(kn)) THEN + CALL fail(ErrStat, ErrMsg, 'as-laid reference: kn must be finite, one entry per node') + RETURN + END IF + END IF + ! node 1 is held: its reference stays at origin. The turning force of the laid tension + ! is evaluated on the path before the sink (a second-order correction). + ref0 = ref + DO j = 2, n_elem + 1 + sink_j = sink(j) + IF (PRESENT(kn) .AND. laid_tension > CD_ZERO .AND. j <= n_elem) THEN + IF (kn(j) > CD_ZERO) THEN + DO e = 1, 3 + CALL CD_Bathymetry_Floor_Gradient(bathymetry, ref0(1, j + e - 2), ref0(2, j + e - 2), p(3, e), gx, gy, & + es, em) + IF (es /= CD_BATHY_OK) THEN + CALL fail(ErrStat, ErrMsg, 'as-laid reference: bathymetry query failed: '//TRIM(em)) + RETURN + END IF + p(1:2, e) = ref0(:, j + e - 2) + IF (e == 2) nrm = [-gx, -gy, CD_ONE]/SQRT(CD_ONE + gx*gx + gy*gy) + END DO + t_in = p(:, 2) - p(:, 1) + t_out = p(:, 3) - p(:, 2) + IF (NORM2(t_in) > CD_ZERO .AND. NORM2(t_out) > CD_ZERO) THEN + ! the tension's force on node j is T (t_out - t_in); its component P into the + ! seabed (against the upward normal) deepens the normal penetration by P/kn, + ! which moves the node horizontally by (P/kn) (z_x, z_y)/s: in units of the + ! sink (the factor of the gradient, w/kn for the weight) that is P/(kn s), with + ! 1/s = nrm(3) the vertical component of the unit normal + sink_j = MAX(CD_ZERO, sink_j - laid_tension*DOT_PRODUCT(t_out/NORM2(t_out) - t_in/NORM2(t_in), nrm)* & + nrm(3)/kn(j)) + END IF + END IF + END IF + IF (.NOT. (sink_j > CD_ZERO)) CYCLE + CALL CD_Bathymetry_Floor_Gradient(bathymetry, ref(1, j), ref(2, j), zf, gx, gy, es, em) + IF (es /= CD_BATHY_OK) THEN + CALL fail(ErrStat, ErrMsg, 'as-laid reference: bathymetry query failed: '//TRIM(em)) + RETURN + END IF + ref(:, j) = ref(:, j) + sink_j*[gx, gy] + END DO + END IF + END SUBROUTINE CD_Static_As_Laid_Reference + + SUBROUTINE CD_Static_As_Laid_Seed(anchor, fairlead, l0, ea, weight, ref, q, ok, seabed_z_floor, bathymetry) + !! As-laid seed of a line with static seabed friction (OrcaFlex's picture: the line laid + !! from its anchor, node 1, and its top end then moved to the fairlead, node n): nodes + !! 1..k rest on the seabed at their as-laid positions ref(1:2, :) (the friction + !! reference, CD_Static_As_Laid_Reference), and nodes k..n form the fully suspended + !! elastic catenary from node k to the fairlead. k is the first node at which the + !! suspended span leaves the seabed at or above the local seabed angle along its own + !! heading (tangent lift-off), found by bisection; a line laid past the point under its + !! fairlead turns back there, over its grounded run. q holds the positions (3 n_nodes); + !! ok = .FALSE. when no node qualifies. One of seabed_z_floor or bathymetry is given. + REAL(wp), INTENT(IN) :: anchor(3), fairlead(3), l0(:), ea(:), weight(:), ref(:, :) + REAL(wp), INTENT(OUT) :: q(:) + LOGICAL, INTENT(OUT) :: ok + REAL(wp), INTENT(IN), OPTIONAL :: seabed_z_floor + TYPE(CD_BathymetryType), INTENT(IN), OPTIONAL :: bathymetry + INTEGER :: n_nodes, k_lo, k_hi, k_mid, it + REAL(wp) :: f_lo, f_hi, f_mid + LOGICAL :: v_lo, v_hi, v_mid + + ok = .FALSE. + q = CD_ZERO + n_nodes = SIZE(l0) + 1 + IF (SIZE(q) /= 3*n_nodes .OR. SIZE(ref, 1) /= 2 .OR. SIZE(ref, 2) /= n_nodes .OR. SIZE(ea) /= n_nodes - 1 & + .OR. SIZE(weight) /= n_nodes - 1) RETURN + IF (.NOT. (PRESENT(seabed_z_floor) .OR. PRESENT(bathymetry))) RETURN + k_lo = 1 + CALL laid_at(k_lo, f_lo, v_lo) + IF (v_lo .AND. f_lo >= CD_ZERO) THEN + ok = .TRUE. + RETURN + END IF + k_hi = n_nodes - 1 + CALL laid_at(k_hi, f_hi, v_hi) + IF (.NOT. (v_hi .AND. f_hi >= CD_ZERO)) RETURN + DO it = 1, 64 + IF (k_hi - k_lo <= 1) EXIT + k_mid = (k_lo + k_hi)/2 + CALL laid_at(k_mid, f_mid, v_mid) + IF (v_mid .AND. f_mid >= CD_ZERO) THEN + k_hi = k_mid + ELSE + k_lo = k_mid + END IF + END DO + CALL laid_at(k_hi, f_hi, v_hi) + ok = v_hi + + CONTAINS + + SUBROUTINE laid_at(k, mismatch, valid) + !! The seed with lift-off node k into q; mismatch is the elevation angle of the first + !! suspended element minus the seabed angle along its horizontal heading at the + !! lift-off point (>= 0: the span leaves the seabed tangent or steeper). + INTEGER, INTENT(IN) :: k + REAL(wp), INTENT(OUT) :: mismatch + LOGICAL, INTENT(OUT) :: valid + INTEGER :: i, es_d + REAL(wp) :: zf, gx, gy, g, p(3), h_s, g_s, u(3), uh + REAL(wp), ALLOCATABLE :: q_sus(:) + CHARACTER(200) :: em_d + + valid = .FALSE. + mismatch = -HUGE(CD_ONE) + q(1:3) = anchor + DO i = 2, k + CALL floor_at(ref(1, i), ref(2, i), zf, gx, gy, es_d) + IF (es_d /= 0) RETURN + q(3*i - 2:3*i) = [ref(1, i), ref(2, i), zf] + END DO + p = q(3*k - 2:3*k) + IF (fairlead(3) <= p(3)) RETURN + ALLOCATE (q_sus(3*(n_nodes - k + 1))) + CALL CD_Catenary_Seed(p, fairlead, l0(k:), ea(k:), weight(k:), q_sus, h_s, g_s, es_d, em_d, & + suspended=.TRUE.) + IF (es_d /= CD_CAT_OK) RETURN + IF (.NOT. CD_All_Finite(q_sus)) RETURN + q(3*k - 2:) = q_sus + u = q_sus(4:6) - q_sus(1:3) + IF (NORM2(u) <= CD_ZERO) RETURN + uh = NORM2(u(1:2)) + g = CD_ZERO + IF (uh > CD_ZERO) THEN + CALL floor_at(p(1), p(2), zf, gx, gy, es_d) + IF (es_d /= 0) RETURN + g = (gx*u(1) + gy*u(2))/uh + END IF + mismatch = ATAN2(u(3), MAX(uh, TINY(CD_ONE))) - ATAN(g) + valid = .TRUE. + END SUBROUTINE laid_at + + SUBROUTINE floor_at(x, y, zf, gx, gy, es_f) + !! Seabed elevation and gradient under (x, y): the flat floor or the bathymetry. + REAL(wp), INTENT(IN) :: x, y + REAL(wp), INTENT(OUT) :: zf, gx, gy + INTEGER, INTENT(OUT) :: es_f + CHARACTER(120) :: em_f + es_f = 0 + gx = CD_ZERO + gy = CD_ZERO + IF (PRESENT(bathymetry)) THEN + CALL CD_Bathymetry_Floor_Gradient(bathymetry, x, y, zf, gx, gy, es_f, em_f) + ELSE + zf = seabed_z_floor + END IF + END SUBROUTINE floor_at + END SUBROUTINE CD_Static_As_Laid_Seed + PURE FUNCTION friction_chord(q, node) RESULT(axis) !! Horizontal line axis at a node for anisotropic friction: the chord through its !! neighbours (one-sided at the ends), the axis of CableDyn_Model's dynamics. @@ -1340,7 +1607,13 @@ SUBROUTINE CD_Static_Line_Equilibrium(anchor, fairlead, elem_conn, l0, ea, weigh !! H -> 0 limit (a straight hanging leg with the excess on the seabed, folded back where !! the seabed keeps falling); the other catenary variant; and a two-leg polyline of the !! right length that never compresses the line. Seed nodes deeper below the seabed than - !! their static penetration are lifted onto it. + !! their static penetration are lifted onto it. With static seabed friction (current + !! carrying friction_ref, CD_Static_As_Laid_Reference) the as-laid seed is tried first: + !! the nodes up to a lift-off node rest at their as-laid positions, and the rest hang as + !! the suspended catenary to the fairlead (the line laid, then its top end moved). The + !! reference is laid from the lower end of the line: node 1, or node n when it lies below + !! node 1 (a line without a Fixed anchor at node 1), whose seed is the mirror image, laid + !! from node n and hanging to node 1. !! For each seed: !! A. Newton (plain, then Levenberg-Marquardt) with the compression-capable law, first at !! the full load, then by load continuation. Accepted when it converges and (for a @@ -1378,7 +1651,10 @@ SUBROUTINE CD_Static_Line_Equilibrium(anchor, fairlead, elem_conn, l0, ea, weigh REAL(wp), ALLOCATABLE :: ramp(:) INTEGER :: n_dof, n_elem, n_nodes, iseed, iorder, n_it, n_st, es INTEGER, PARAMETER :: SEED_ORDER(6) = [1, 5, 6, 2, 3, 4] - INTEGER, ALLOCATABLE :: fixed(:) + ! with static seabed friction, the as-laid seed (7) first + INTEGER, PARAMETER :: SEED_ORDER_LAID(7) = [7, 1, 5, 6, 2, 3, 4] + INTEGER, ALLOCATABLE :: fixed(:), order(:) + LOGICAL :: as_laid REAL(wp), ALLOCATABLE :: q_seed(:), q_try(:), q_mid(:), q_best(:), ten(:) REAL(wp) :: f_node, t_min, t_max, r_soft, r_firm, floor_a, slope_a, h_cat, g_cat LOGICAL :: has_seabed, anchor_grounded, conv, stalled, at_floor, have_seed, done, have_best @@ -1477,13 +1753,25 @@ SUBROUTINE CD_Static_Line_Equilibrium(anchor, fairlead, elem_conn, l0, ea, weigh END IF END IF + ! static seabed friction from an as-laid reference: the as-laid seed leads + as_laid = .FALSE. + IF (has_seabed .AND. PRESENT(current)) THEN + IF (ALLOCATED(current%friction_ref) .AND. current%friction_mu > CD_ZERO .AND. current%friction_as_laid) & + as_laid = SIZE(current%friction_ref, 1) == 2 .AND. SIZE(current%friction_ref, 2) == n_nodes + END IF + IF (as_laid) THEN + order = SEED_ORDER_LAID + ELSE + order = SEED_ORDER + END IF + notes = '' q_best = CD_ZERO have_best = .FALSE. - DO iorder = 1, SIZE(SEED_ORDER) - ! seed order: catenary, bathymetry drape, catenary on the penetrated seabed, slack - ! run, other catenary, polyline - iseed = SEED_ORDER(iorder) + DO iorder = 1, SIZE(order) + ! seed order: (as laid,) catenary, bathymetry drape, catenary on the penetrated seabed, + ! slack run, other catenary, polyline + iseed = order(iorder) CALL build_seed(iseed, have_seed) IF (.NOT. have_seed) CYCLE report%seed = seed_name @@ -1792,6 +2080,21 @@ SUBROUTINE build_seed(which, ok) IF (.NOT. (anchor_grounded .AND. PRESENT(bathymetry))) RETURN CALL drape_seed(ok) IF (ok) ok = CD_All_Finite(q_seed) + CASE (7) + ! the as-laid line with its top end moved to the fairlead: a grounded run at the + ! friction reference positions lifting off into a suspended catenary. The reference + ! is laid from the lower end of the line (CD_Static_As_Laid_Reference): node 1, or + ! node n when it lies below node 1, whose seed is built on the reversed line + seed_name = 'as-laid run' + IF (.NOT. as_laid) RETURN + IF (fairlead(3) < anchor(3)) THEN + CALL laid_seed_from_last(ok) + ELSE + IF (.NOT. anchor_grounded) RETURN + CALL CD_Static_As_Laid_Seed(anchor, fairlead, l0, ea, weight, current%friction_ref, q_seed, ok, & + seabed_z_floor=seabed_z_floor, bathymetry=bathymetry) + END IF + IF (ok) ok = CD_All_Finite(q_seed) CASE DEFAULT seed_name = 'two-leg polyline' CALL polyline_seed(anchor, fairlead, l0, has_seabed, floor_a, q_seed) @@ -1799,6 +2102,31 @@ SUBROUTINE build_seed(which, ok) END SELECT END SUBROUTINE build_seed + SUBROUTINE laid_seed_from_last(ok) + !! As-laid seed of a line laid from its last node (node n below node 1, the reference + !! laid from node n): CD_Static_As_Laid_Seed on the reversed line (node n first, with + !! the element and reference arrays reversed), its node order then reversed back into + !! q_seed. ok = .FALSE. when node n does not rest on the seabed or the seed has no + !! lift-off node. + LOGICAL, INTENT(OUT) :: ok + INTEGER :: es_r, i_r + REAL(wp) :: floor_n + REAL(wp), ALLOCATABLE :: q_rev(:) + CHARACTER(200) :: em_r + ok = .FALSE. + floor_n = seabed_floor_at(fairlead(1), fairlead(2), es_r, em_r) + IF (es_r /= 0) RETURN + IF (fairlead(3) > floor_n + CD_Static_Anchor_Seabed_Tolerance(floor_n)) RETURN + ALLOCATE (q_rev(n_dof)) + CALL CD_Static_As_Laid_Seed(fairlead, anchor, l0(n_elem:1:-1), ea(n_elem:1:-1), weight(n_elem:1:-1), & + current%friction_ref(:, n_nodes:1:-1), q_rev, ok, & + seabed_z_floor=seabed_z_floor, bathymetry=bathymetry) + IF (.NOT. ok) RETURN + DO i_r = 1, n_nodes + q_seed(3*i_r - 2:3*i_r) = q_rev(3*(n_nodes - i_r) + 1:3*(n_nodes - i_r) + 3) + END DO + END SUBROUTINE laid_seed_from_last + SUBROUTINE drape_seed(ok) !! Seed for a grounded line on a non-planar or sloped seabed: nodes 1..k lie on the !! seabed along the horizontal anchor -> fairlead direction (each at the arc length of @@ -2129,6 +2457,7 @@ SUBROUTINE CD_Static_Line_End_Forces(q, elem_conn, l0, ea, f_ext, tension_only, REAL(wp) :: zf, gx, gy, fvec(3), jac(3, 3), curv(3), f2(6), jq2(6, 6), jv2(6, 6), va(3), vb(3), de, cn, ct, wla, wlb CHARACTER(200) :: em INTEGER :: ends(2) + LOGICAL :: drag_ends ErrStat = CD_STATIC_OK ErrMsg = '' @@ -2176,7 +2505,9 @@ SUBROUTINE CD_Static_Line_End_Forces(q, elem_conn, l0, ea, f_ext, tension_only, fint(3*node - 2:3*node) = fint(3*node - 2:3*node) + fvec END DO END IF - IF (PRESENT(current)) THEN + drag_ends = PRESENT(current) + IF (drag_ends) drag_ends = current%drag + IF (drag_ends) THEN DO e = 1, n_elem a = elem_conn(1, e) b = elem_conn(2, e) diff --git a/tests/test_bathymetry.f90 b/tests/test_bathymetry.f90 index b3a0b2cf..f539d032 100644 --- a/tests/test_bathymetry.f90 +++ b/tests/test_bathymetry.f90 @@ -14,6 +14,8 @@ PROGRAM test_bathymetry CD_Bathymetry_Grid_Floor, CD_Bathymetry_Rotate_Curvature, & CD_BATHY_CREASE_FRACTION USE CableDyn_SeabedContact, ONLY: CD_SEABED_CONTACT_BLEND + USE CableDyn_Static, ONLY: CD_Static_As_Laid_Reference, CD_STATIC_OK, CD_Static_Line_Equilibrium, & + CableSolverConfig, CableCurrentLoad, CD_StaticLineReport USE, INTRINSIC :: IEEE_ARITHMETIC, ONLY: IEEE_VALUE, IEEE_QUIET_NAN IMPLICIT NONE @@ -27,6 +29,8 @@ PROGRAM test_bathymetry CALL case_crease_rounding_c2() CALL case_crease_rounding_planar_exact() CALL case_crease_contact_tangent_fd() + CALL case_as_laid_tension_sink() + CALL case_as_laid_seed_from_last() IF (nfail > 0) THEN WRITE (*, '(A,I0,A)') 'FAIL: ', nfail, ' assertion(s) failed' @@ -469,4 +473,157 @@ SUBROUTINE expect_vec_fd(got, want, label) END DO END SUBROUTINE expect_vec_fd + SUBROUTINE case_as_laid_tension_sink() + !! The as-laid friction reference on a curved bathymetry (a Gaussian crest along x): + !! with kn and no laid tension it is bit-identical to the reference without kn; with a + !! laid tension T each interior node's normal penetration deepens by the load + !! -T (t_out - t_in).n / kn (n the upward normal), which moves its reference horizontally + !! by that over s = sqrt(1 + |grad z|^2) times the local gradient (checked against an independent evaluation on the unsunk path). + TYPE(CD_BathymetryType) :: bathy + INTEGER, PARAMETER :: NE = 20 + REAL(wp), PARAMETER :: T = 2.0e4_wp, KN = 1.0e4_wp, SINK = 0.01_wp + REAL(wp) :: x(41), y(2), depth(41, 2), l0(NE), ea(NE), sk(NE + 1), kv(NE + 1) + REAL(wp) :: r_nokn(2, NE + 1), r_kn(2, NE + 1), r_t(2, NE + 1), r_t0(2, NE + 1), r_t_nokn(2, NE + 1) + REAL(wp) :: p(3, 3), g(2), nrm(3), tin(3), tout(3), extra, expect(2), worst + INTEGER :: i, j, k, es + CHARACTER(160) :: em + + DO i = 1, SIZE(x) + x(i) = 5.0_wp*REAL(i - 1, wp) + depth(i, :) = 100.0_wp - 10.0_wp*EXP(-((x(i) - 100.0_wp)/30.0_wp)**2) + END DO + y = [-20.0_wp, 20.0_wp] + CALL CD_Init_Bathymetry(bathy, x, y, depth, es, em) + CALL expect_es(es, CD_BATHY_OK, 'aslaid:init') + l0 = 9.0_wp + ea = 1.0e9_wp + sk = SINK + kv = KN + CALL CD_Static_As_Laid_Reference([0.0_wp, 0.0_wp], 0.0_wp, l0, ea, 0.0_wp, r_nokn, es, em, bathymetry=bathy, & + sink=sk) + CALL expect_es(es, CD_STATIC_OK, 'aslaid:ref') + CALL CD_Static_As_Laid_Reference([0.0_wp, 0.0_wp], 0.0_wp, l0, ea, 0.0_wp, r_kn, es, em, bathymetry=bathy, & + sink=sk, kn=kv) + CALL require(ALL(r_kn == r_nokn), 'aslaid:no tension, kn changes nothing') + CALL CD_Static_As_Laid_Reference([0.0_wp, 0.0_wp], 0.0_wp, l0, ea, T, r_t, es, em, bathymetry=bathy, & + sink=sk, kn=kv) + CALL CD_Static_As_Laid_Reference([0.0_wp, 0.0_wp], 0.0_wp, l0, ea, T, r_t_nokn, es, em, bathymetry=bathy, & + sink=sk) + sk = 0.0_wp + CALL CD_Static_As_Laid_Reference([0.0_wp, 0.0_wp], 0.0_wp, l0, ea, T, r_t0, es, em, bathymetry=bathy) + worst = 0.0_wp + DO j = 2, NE + DO k = 1, 3 + CALL floor_at(bathy, r_t0(1, j + k - 2), r_t0(2, j + k - 2), p(3, k), g) + p(1:2, k) = r_t0(:, j + k - 2) + IF (k == 2) nrm = [-g(1), -g(2), 1.0_wp]/SQRT(1.0_wp + g(1)**2 + g(2)**2) + END DO + tin = (p(:, 2) - p(:, 1))/NORM2(p(:, 2) - p(:, 1)) + tout = (p(:, 3) - p(:, 2))/NORM2(p(:, 3) - p(:, 2)) + CALL floor_at(bathy, r_t0(1, j), r_t0(2, j), p(3, 2), g) + extra = MAX(0.0_wp, SINK - T*DOT_PRODUCT(tout - tin, nrm)/(KN*SQRT(1.0_wp + g(1)**2 + g(2)**2))) + expect = r_t0(:, j) + extra*g + worst = MAX(worst, MAXVAL(ABS(r_t(:, j) - expect))) + END DO + CALL require(worst <= 1.0e-12_wp, 'aslaid:tension sink matches the turning force') + ! the crest presses the laid line into the seabed: the references differ with tension + CALL require(MAXVAL(ABS(r_t - r_t_nokn)) > 1.0e-6_wp, 'aslaid:tension sink active on a crest') + CALL CD_End_Bathymetry(bathy) + END SUBROUTINE case_as_laid_tension_sink + + SUBROUTINE case_as_laid_seed_from_last() + !! The as-laid seed of the EI = 0 static equilibrium for a line whose last node is its lower + !! end (a line without a Fixed anchor at node 1, e.g. a FAST.Farm shared line): its friction + !! reference is laid from node n (as CD_Init_Line_Model lays it), and the seed must be laid + !! from node n too, the mirror image of the seed of the same line numbered from its lower + !! end. A grounded line (300 m, laid slack, mu = 0.5) is solved both ways, on a level floor + !! and on a bathymetry rising toward the upper end: both take the as-laid seed and reach the + !! same equilibrium, node for node mirrored. + INTEGER, PARAMETER :: NE = 60, NN = NE + 1 + REAL(wp), PARAMETER :: L0E = 5.0_wp, EA = 1.0e9_wp, WPL = 1.0e3_wp, KNE = 5.0e4_wp, Z0 = -100.0_wp + REAL(wp), PARAMETER :: SLOPE = 0.05_wp, MU = 0.5_wp + TYPE(CD_BathymetryType) :: bathy + TYPE(CableSolverConfig) :: cfg + TYPE(CableCurrentLoad) :: fr_a, fr_b + TYPE(CD_StaticLineReport) :: rep_a, rep_b + INTEGER :: conn(2, NE), i, j, es, icase + REAL(wp) :: l0(NE), ea_e(NE), w(NE), f_ext(3*NN), kn(NN), sink(NN), lo(3), up(3) + REAL(wp) :: ref(2, NN), q_a(3*NN), q_b(3*NN), gx(21), gy(2), depth(21, 2), worst + LOGICAL :: conv_a, conv_b + CHARACTER(160) :: em + CHARACTER(32) :: tag + + DO i = 1, NE + conn(:, i) = [i, i + 1] + END DO + l0 = L0E + ea_e = EA + w = WPL + f_ext = 0.0_wp + kn = KNE + DO i = 1, NE + f_ext(3*i) = f_ext(3*i) - 0.5_wp*WPL*L0E + f_ext(3*i + 3) = f_ext(3*i + 3) - 0.5_wp*WPL*L0E + END DO + kn(1) = 0.5_wp*KNE + kn(NN) = 0.5_wp*KNE + sink = MAX(-f_ext(3:3*NN:3), 0.0_wp)/kn + DO i = 1, SIZE(gx) + gx(i) = -50.0_wp + 20.0_wp*REAL(i - 1, wp) + depth(i, :) = -(Z0 + SLOPE*gx(i)) + END DO + gy = [-50.0_wp, 50.0_wp] + CALL CD_Init_Bathymetry(bathy, gx, gy, depth, es, em) + CALL expect_es(es, CD_BATHY_OK, 'laid-last:init') + lo = [0.0_wp, 0.0_wp, Z0] + up = [250.0_wp, 0.0_wp, -10.0_wp] + DO icase = 1, 2 + tag = MERGE('laid-last:flat ', 'laid-last:slope', icase == 1) + ! the reference laid from the lower end along +x (the default azimuth of either numbering) + IF (icase == 1) THEN + CALL CD_Static_As_Laid_Reference(lo(1:2), 0.0_wp, l0, ea_e, 0.0_wp, ref, es, em) + ELSE + CALL CD_Static_As_Laid_Reference(lo(1:2), 0.0_wp, l0, ea_e, 0.0_wp, ref, es, em, bathymetry=bathy, & + sink=sink, kn=kn) + END IF + CALL expect_es(es, CD_STATIC_OK, TRIM(tag)//' reference') + fr_a%drag = .FALSE. + fr_a%friction_mu = MU + fr_a%friction_as_laid = .TRUE. + fr_a%friction_ref = ref + fr_b = fr_a + fr_b%friction_ref = ref(:, NN:1:-1) + IF (icase == 1) THEN + CALL CD_Static_Line_Equilibrium(lo, up, conn, l0, ea_e, w, f_ext, cfg, .TRUE., q_a, conv_a, rep_a, es, em, & + seabed_z_floor=Z0, seabed_kn=kn, current=fr_a) + CALL expect_es(es, CD_STATIC_OK, TRIM(tag)//' from node 1') + CALL CD_Static_Line_Equilibrium(up, lo, conn, l0, ea_e, w, f_ext, cfg, .TRUE., q_b, conv_b, rep_b, es, em, & + seabed_z_floor=Z0, seabed_kn=kn, current=fr_b) + ELSE + CALL CD_Static_Line_Equilibrium(lo, up, conn, l0, ea_e, w, f_ext, cfg, .TRUE., q_a, conv_a, rep_a, es, em, & + seabed_kn=kn, bathymetry=bathy, current=fr_a) + CALL expect_es(es, CD_STATIC_OK, TRIM(tag)//' from node 1') + CALL CD_Static_Line_Equilibrium(up, lo, conn, l0, ea_e, w, f_ext, cfg, .TRUE., q_b, conv_b, rep_b, es, em, & + seabed_kn=kn, bathymetry=bathy, current=fr_b) + END IF + CALL expect_es(es, CD_STATIC_OK, TRIM(tag)//' from node n') + CALL require(conv_a .AND. conv_b, TRIM(tag)//' both numberings converge') + CALL require(TRIM(rep_a%seed) == 'as-laid run', TRIM(tag)//' node 1 lower: as-laid seed ('// & + TRIM(rep_a%seed)//')') + CALL require(TRIM(rep_b%seed) == 'as-laid run', TRIM(tag)//' node n lower: as-laid seed ('// & + TRIM(rep_b%seed)//')') + worst = 0.0_wp + DO i = 1, NN + j = NN + 1 - i + worst = MAX(worst, MAXVAL(ABS(q_b(3*i - 2:3*i) - q_a(3*j - 2:3*j)))) + END DO + IF (.NOT. (worst <= 1.0e-6_wp)) WRITE (*, '(A,ES10.3,A)') ' '//TRIM(tag)//': mirror mismatch ', worst, ' m' + CALL require(worst <= 1.0e-6_wp, TRIM(tag)//' the two numberings give the mirrored equilibrium') + ! the run rests on the seabed where it was laid (its friction holds it there) + CALL require(ABS(q_a(3*11) - (Z0 + MERGE(0.0_wp, SLOPE*q_a(3*11 - 2), icase == 1))) < 0.2_wp, & + TRIM(tag)//' node 11 rests on the seabed') + END DO + CALL CD_End_Bathymetry(bathy) + END SUBROUTINE case_as_laid_seed_from_last + END PROGRAM test_bathymetry diff --git a/tests/test_static_friction_as_laid.py b/tests/test_static_friction_as_laid.py new file mode 100644 index 00000000..aacf39be --- /dev/null +++ b/tests/test_static_friction_as_laid.py @@ -0,0 +1,716 @@ +#!/usr/bin/env python3 +# SPDX-License-Identifier: Apache-2.0 +# Copyright (c) 2026 Jae Hoon Seo, SMI Lab, Inha University +"""Static seabed friction toward the as-laid position (OPTIONS staticsFriction asLaid, set in +every deck below; the default is none). + +A grounded run on a seabed sloping down toward its anchor, with friction mu = 1 well above the +slope, must hold in statics where it was laid; with the default frictionless statics (none) the +run slides down the slope and folds back past its anchor (EI = 0), or is rejected as too long +for its span (finite EI). Every deck runs through the standalone +driver: + +* ``slope_ei0`` (EI = 0 chain, 5 degree slope, 700 m line over a 450 m span): converges with + the grounded run on its side of the anchor, and an independent nodal force balance (element + tensions, lumped weight, seabed normal along the local normal) leaves at every grounded node + a horizontal friction force within mu N, mobilised against the slope; its twin with + ``none staticsFriction`` still folds past the anchor (the frictionless static of before); +* ``slope_ei0_rest``: the same deck marched for 2 s from the static state stays at rest (every + output row reproduces the static end forces to 1e-5 of the fairlead tension): the friction + anchors of the march continue the static springs, with no jump at t = 0; +* ``slope_fei`` (finite-EI cable on a 10 degree slope, too long for its span) converges, and + marched for 1 s stays at rest likewise; +* ``flat_*`` (a grounded chain on a flat seabed): laid at the tension its run carries + (``asLaidTension``), the friction is not mobilised and the end tensions equal the + frictionless ones (FairTen to 1e-4, AnchTen to 0.5 %, see the check); laid slack (the + default), friction holds the run back and the anchor tension falls by at most mu w times the + grounded length; +* ``fei_flat_*`` (finite-EI cable on a flat seabed, laid slack): a lay azimuth across the vertical + plane of the chord (45 degrees) is solved in 3D from the start, so the state is consistent + (friction within mu N, a march from it stays at rest), while 180 degrees keeps the planar solve + and flips the reference (the anchor tension falls below the default one); +* ``fei_cross`` (a cable on a cross slope, EI = 0 and finite EI): the lateral anchor force stays a + small fraction of the one a reference without the sink offset of the laid nodes would give, and + the finite-EI line, solved in 3D because the seabed slopes across its chord, stays at rest when + marched; +* ``att_cross`` (a finite-EI line with discrete buoyancy modules on a cross slope): the reference + sinks each node under its discrete load, so the module nodes rest on the laid path (no lateral + kink, as in the smeared twin) and a march from the static state stays at rest; +* ``pl_*``: per-line rows win over the global ones (``layAzimuth`` over ``layAzimuth``, + ``asLaidTension`` over ``asLaidTension``, in either order), and a row for line 2 leaves + line 1 alone; ``aniso_*``: the axial coefficient rules the friction along a laid run; + ``multi``: a three-section line of different weights keeps every grounded node within mu N; +* ``refined`` (a finite-EI line of two sections laid at a tension on a seabed curved along it and + sloping across it, on a deck mesh the adaptive refinement takes 16x finer): the reference is laid + on the refined mesh, so the run rests where its twin declared on that mesh does (positions to + 1e-6 m, end forces) and a march from it stays at rest; +* input checks: ``layAzimuth`` of a line that does not exist (also one too large for an + integer), an unknown suffix and an unknown policy are rejected, and the ```` rows take + effect; a finite-EI line shared between two turbines (End B not Fixed, the compatibility route, + whose statics have no seabed friction) rejects asLaid by name and runs with none. + +usage: test_static_friction_as_laid.py --exe --output +""" + +from __future__ import annotations + +import argparse +import math +import os +import subprocess +import sys +from pathlib import Path + +G, RHO = 9.80665, 1025.0 +CHAIN = (0.216, 286.56, 1.22976e9) # diameter [m], mass [kg/m], EA [N] +REST_TOL = 1.0e-5 +FAILURES: list[str] = [] + + +def check(cond: bool, msg: str) -> None: + print(("ok " if cond else "FAIL ") + msg) + if not cond: + FAILURES.append(msg) + + +def slope_grid(path: Path, depth0: float, slope_deg: float) -> None: + """A seabed z = -(depth0 + tan(slope) x): planar in x, falling toward +x.""" + t = math.tan(math.radians(slope_deg)) + rows = [] + for x in range(-300, 1000, 100): + for y in (-300.0, 300.0): + rows.append("%.1f %.1f %.12g" % (x, y, depth0 + t * x)) + path.write_text("\n".join(rows) + "\n", encoding="utf-8", newline="\n") + + +def deck(title: str, ei: float, length: float, nseg: int, fair: tuple, anch: tuple, seabed: str, + extra: str = "", tmax: float = 0.0, mu: float = 1.0, types: str | None = None, + sections: str | None = None, attachments: str | None = None) -> str: + d, m, ea = CHAIN + if types is None: + types = f"chain {d} {m} {ea} -1 {ei} 1.37 0.64 1 0\n" + if sections is None: + sections = f"1 chain {length} {nseg}\n" + if attachments is not None: + sections += ("--------------------- ATTACHMENTS ---\n" + "LineID ArcLength Mass Volume CdA Ca CdAx\n(-) (m) (kg) (m^3) (m^2) (-) (m^2)\n" + f"{attachments}") + return ( + "--------------------- CableDyn Input File ---\n" + f"{title}\n" + "--------------------- LINE TYPES ---\n" + "TypeName Diam MassDenInAir EA BA EI Cd_n Cd_t Ca_n Ca_t\n" + "(-) (m) (kg/m) (N) (-) (Nm2) (-) (-) (-) (-)\n" + f"{types}" + "--------------------- POINTS ---\n" + "ID Type X Y Z Mass Vol CdA Ca\n(-) (-) (m) (m) (m) (kg) (m3) (m2) (-)\n" + f"1 Coupled {fair[0]} {fair[1]} {fair[2]} 0 0 0 0\n" + f"2 Fixed {anch[0]} {anch[1]} {anch[2]} 0 0 0 0\n" + "--------------------- LINES ---\n" + "ID NodeA NodeB Outputs\n(-) (-) (-) (-)\n1 1 2 pt\n" + "--------------------- SECTIONS ---\n" + "LineID LineType Length NumSegs\n(-) (-) (m) (-)\n" + f"{sections}" + "--------------------- OPTIONS ---\n" + f"{G} g\n{RHO} rhoW\n{seabed}\n100000.0 kBot\n1.0e4 cBot\n0.05 dtM\n{tmax} TMax\n" + f"{mu} frictionMu\nasLaid staticsFriction\n{extra}" + "--------------------- OUTPUTS ---\n" + '"FairTen1"\n"AnchTen1"\n"Point1Fx"\n"Point1Fy"\n"Point1Fz"\n"Point2Fx"\n"Point2Fy"\n"Point2Fz"\n' + "--------------------- need this line ---\n" + ) + + +def run(exe: str, cdir: Path, name: str, text: str) -> tuple: + cdir.mkdir(parents=True, exist_ok=True) + (cdir / (name + ".dat")).write_text(text, encoding="utf-8", newline="\n") + env = dict(os.environ) + env.setdefault("OPENBLAS_NUM_THREADS", "1") + env.setdefault("OMP_NUM_THREADS", "1") + p = subprocess.run([exe, name + ".dat", name], cwd=cdir, env=env, capture_output=True, text=True, + timeout=600) + return p.returncode, p.stdout + p.stderr + + +def table(path: Path) -> list: + rows = [r for r in path.read_text(encoding="utf-8").splitlines() if r.strip() and not r.startswith("#")] + names = rows[0].split() + return [dict(zip(names, map(float, r.split()))) for r in rows[1:]] + + +def first_row(path: Path) -> list: + rows = [r for r in path.read_text(encoding="utf-8").splitlines() if r.strip() and not r.startswith("#")] + return [float(v) for v in rows[1].split()[1:]] + + +def grounded_balance(cdir: Path, name: str, length: float, nseg: int, mu: float, depth0: float, + slope_deg: float, band: float | None = None, end_trim: int = 0) -> tuple: + """Largest friction utilisation |f|/(mu N) over grounded nodes and the total friction. + + band: only the nodes whose three neighbours on either side lie within band [m] of the + seabed are taken (a finite-EI cable bends at its touchdown, which the tension-only balance + does not carry), and not the last end_trim nodes before the anchor.""" + d, m, _ = CHAIN + w = (m - RHO * math.pi / 4.0 * d * d) * G + l0 = length / nseg + p = first_row(cdir / (name + ".Line1.p.out")) + pos = [p[3 * i:3 * i + 3] for i in range(len(p) // 3)] + ten = first_row(cdir / (name + ".Line1.t.out")) + gx = -math.tan(math.radians(slope_deg)) + nrm = [-gx / math.hypot(1.0, gx), 0.0, 1.0 / math.hypot(1.0, gx)] + worst, total = 0.0, 0.0 + for i in range(1, len(pos) - 1): + f = [0.0, 0.0, -w * l0] + for e, j in ((i - 1, i - 1), (i, i + 1)): + u = [pos[j][k] - pos[i][k] for k in range(3)] + n = math.sqrt(sum(x * x for x in u)) + for k in range(3): + f[k] += ten[e] * u[k] / n + zf = -(depth0 + math.tan(math.radians(slope_deg)) * pos[i][0]) + normal = -f[2] / nrm[2] + if pos[i][2] > zf + 0.5 or not normal > 1.0e-6 * w * l0: + continue + if i >= len(pos) - 1 - end_trim: + continue + if band is not None and not all( + abs(pos[j][2] + depth0 + math.tan(math.radians(slope_deg)) * pos[j][0]) < band + for j in range(max(i - 3, 0), min(i + 4, len(pos)))): + continue + fr = math.hypot(f[0] + normal * nrm[0], f[1]) + total += fr + worst = max(worst, fr / (mu * normal)) + past = max(p_[0] for p_ in pos) - pos[-1][0] # beyond the anchor (+x) along the span + return worst, total, past + + +def at_rest(cdir: Path, static_name: str, rest_name: str) -> float: + s0 = table(cdir / (static_name + ".out"))[0] + scale = max(abs(s0["FairTen1"]), 1.0) + drift = 0.0 + for row in table(cdir / (rest_name + ".out")): + drift = max(drift, max(abs(row[n] - s0[n]) for n in s0 if n != "Time(s)")) + return drift / scale + + +def deck_two(title: str, extra: str = "", mu: float = 0.5) -> str: + """Two identical EI = 0 chains on a flat seabed, 1000 m apart (lines 1 and 2).""" + d, m, ea = CHAIN + return ( + "--------------------- CableDyn Input File ---\n" + f"{title}\n" + "--------------------- LINE TYPES ---\n" + "TypeName Diam MassDenInAir EA BA EI Cd_n Cd_t Ca_n Ca_t\n" + "(-) (m) (kg/m) (N) (-) (Nm2) (-) (-) (-) (-)\n" + f"chain {d} {m} {ea} -1 0 1.37 0.64 1 0\n" + "--------------------- POINTS ---\n" + "ID Type X Y Z Mass Vol CdA Ca\n(-) (-) (m) (m) (m) (kg) (m3) (m2) (-)\n" + "1 Coupled -58 0 -14 0 0 0 0\n2 Fixed -837.6 0 -200 0 0 0 0\n" + "3 Coupled -58 1000 -14 0 0 0 0\n4 Fixed -837.6 1000 -200 0 0 0 0\n" + "--------------------- LINES ---\n" + "ID NodeA NodeB Outputs\n(-) (-) (-) (-)\n1 1 2 pt\n2 3 4 pt\n" + "--------------------- SECTIONS ---\n" + "LineID LineType Length NumSegs\n(-) (-) (m) (-)\n1 chain 850 85\n2 chain 850 85\n" + "--------------------- OPTIONS ---\n" + f"{G} g\n{RHO} rhoW\n200.0 WtrDpth\n100000.0 kBot\n1.0e4 cBot\n0.05 dtM\n0 TMax\n" + f"{mu} frictionMu\nasLaid staticsFriction\n{extra}" + "--------------------- OUTPUTS ---\n" + '"FairTen1"\n"AnchTen1"\n"FairTen2"\n"AnchTen2"\n' + "--------------------- need this line ---\n" + ) + + +def same(a: dict, b: dict, keys: tuple, tol: float = 1.0e-9) -> bool: + """Whether the channels ``keys`` of two output rows agree to the relative tolerance tol.""" + return all(abs(a[k] - b[k]) <= tol * max(abs(a[k]), 1.0) for k in keys) + + +def chain_weight() -> float: + """Submerged weight per length [N/m] of the test chain.""" + d, m, _ = CHAIN + return (m - RHO * math.pi / 4.0 * d * d) * G + + +def plateau_utilisation(cdir: Path, name: str, mu: float, zfloor: float, kbot: float, sections: tuple, + trim: int = 2) -> tuple: + """Largest |f|/(mu N) over the nodes resting on a flat seabed, from the nodal balance. + + The horizontal force that tensions and weight leave at a grounded node is what friction + carries (EI = 0, or a straight run of a finite-EI cable). The nodes are the ones at the + penetration depth of the penalty seabed, less ``trim`` at each end of the run (the bending + of a finite-EI cable acts at the touchdown and at the anchor). ``sections``: (diameter, + submerged weight per length, element length, number of elements) from End A. Returns + (utilisation, number of nodes, largest |y| of the line, the utilisation and the number of + nodes of each section, a node counted with the section of its End A element). + """ + p = first_row(cdir / (name + ".Line1.p.out")) + pos = [p[3 * i:3 * i + 3] for i in range(len(p) // 3)] + ten = first_row(cdir / (name + ".Line1.t.out")) + elem = [] # per element: diameter, weight per length, length + owner = [] # per element: its section + for k, (dia, wt, l0, ne) in enumerate(sections): + elem += [(dia, wt, l0)] * ne + owner += [k] * ne + grounded = [] + for i in range(1, len(pos) - 1): + # a node is grounded when it sits below the floor by (nearly) the penetration of the + # lighter of its two elements + pen = min(elem[i - 1][1] / (kbot * elem[i - 1][0]), elem[i][1] / (kbot * elem[i][0])) + if pos[i][2] < zfloor - 0.95 * pen: + grounded.append(i) + grounded = grounded[trim:len(grounded) - trim] + worst = 0.0 + by_section = [[0.0, 0] for _ in sections] + for i in grounded: + f = [0.0, 0.0, -0.5 * (elem[i - 1][1] * elem[i - 1][2] + elem[i][1] * elem[i][2])] + for e, j in ((i - 1, i - 1), (i, i + 1)): + u = [pos[j][k] - pos[i][k] for k in range(3)] + n = math.sqrt(sum(x * x for x in u)) + for k in range(3): + f[k] += ten[e] * u[k] / n + util = math.hypot(f[0], f[1]) / (mu * -f[2]) + worst = max(worst, util) + by_section[owner[i - 1]][0] = max(by_section[owner[i - 1]][0], util) + by_section[owner[i - 1]][1] += 1 + return worst, len(grounded), max(abs(q[1]) for q in pos), by_section + + +def cross_grid(path: Path, depth0: float, slope_deg: float) -> None: + """A seabed z = -(depth0 + tan(slope) y): planar in y, falling toward +y (across the line).""" + t = math.tan(math.radians(slope_deg)) + rows = [] + for x in range(-300, 1000, 100): + for y in (-300.0, 300.0): + rows.append("%.1f %.1f %.12g" % (x, y, depth0 + t * y)) + path.write_text("\n".join(rows) + "\n", encoding="utf-8", newline="\n") + + +def main() -> int: + ap = argparse.ArgumentParser() + ap.add_argument("--exe", required=True) + ap.add_argument("--output", required=True) + a = ap.parse_args() + root = Path(a.output).resolve() + root.mkdir(parents=True, exist_ok=True) + d, m, ea = CHAIN + w = (m - RHO * math.pi / 4.0 * d * d) * G + + # --- EI = 0 run on a 5 degree slope (the R3 reproducer) --- + cdir = root / "slope_ei0" + cdir.mkdir(parents=True, exist_ok=True) + depth0, slope = 260.6301014133342, 5.0 + slope_grid(cdir / "bathy.txt", depth0, slope) + sb = "bathy.txt bathymetryFile" + base = dict(ei=0.0, length=700.0, nseg=70, fair=(0, 0, -10), anch=(450, 0, -300), seabed=sb) + rc, log = run(a.exe, cdir, "laid", deck("slope_ei0", **base)) + check(rc == 0, "slope_ei0 converges (rc %d)" % rc) + if rc == 0: + worst, total, past = grounded_balance(cdir, "laid", 700.0, 70, 1.0, depth0, slope) + check(past < 0.5, "slope_ei0: the grounded run stays on its side of the anchor (%.3f m past it)" % past) + check(worst <= 1.0 + 1.0e-3, "slope_ei0: friction within mu N at every grounded node (max %.4f)" % worst) + check(worst > 0.5 * math.tan(math.radians(slope)), + "slope_ei0: friction holds the slope load (max utilisation %.4f)" % worst) + rc, log = run(a.exe, cdir, "none", deck("slope_ei0 none", **base, extra="none staticsFriction\n")) + check(rc == 0, "slope_ei0 with staticsFriction none converges (rc %d)" % rc) + if rc == 0: + _, total, past = grounded_balance(cdir, "none", 700.0, 70, 1.0, depth0, slope) + check(past > 10.0, "slope_ei0 frictionless static still folds past the anchor (%.2f m)" % past) + rc, log = run(a.exe, cdir, "rest", deck("slope_ei0 rest", **base, tmax=2.0)) + check(rc == 0, "slope_ei0 at-rest march runs (rc %d)" % rc) + if rc == 0: + drift = at_rest(cdir, "laid", "rest") + check(drift <= REST_TOL, "slope_ei0 stays at rest from the static state (drift %.2e of FairTen)" % drift) + + # --- finite-EI cable on a 10 degree slope, too long for its span --- + cdir = root / "slope_fei" + cdir.mkdir(parents=True, exist_ok=True) + depth0, slope = 220.65285868119076, 10.0 + slope_grid(cdir / "bathy.txt", depth0, slope) + fei = dict(ei=1.0e4, length=650.0, nseg=140, fair=(0, 0, -10), anch=(450, 0, -300), seabed=sb) + rc, log = run(a.exe, cdir, "laid", deck("slope_fei", **fei)) + check(rc == 0, "slope_fei converges (rc %d)%s" % (rc, "" if rc == 0 else ": " + log.strip()[-300:])) + if rc == 0: + # the straight grounded run (away from the touchdown and the anchor, where the cable + # bends) carries its slope load by friction: mobilised well above zero, within mu N + worst, total, past = grounded_balance(cdir, "laid", 650.0, 140, 1.0, depth0, slope, band=0.35, + end_trim=10) + check(worst <= 1.0 + 1.0e-2, "slope_fei: friction within mu N along the straight run (max %.4f)" % worst) + check(worst > 0.5 * math.tan(math.radians(slope)), + "slope_fei: friction holds the slope load (max utilisation %.4f, tan(slope) %.4f)" + % (worst, math.tan(math.radians(slope)))) + rc, log = run(a.exe, cdir, "rest", deck("slope_fei rest", **fei, tmax=1.0)) + check(rc == 0, "slope_fei at-rest march runs (rc %d)" % rc) + if rc == 0: + drift = at_rest(cdir, "laid", "rest") + check(drift <= REST_TOL, "slope_fei stays at rest from the static state (drift %.2e)" % drift) + + # --- flat seabed: friction not mobilised when laid at the run's tension --- + cdir = root / "flat" + h_run = None # the horizontal tension of the frictionless grounded run + flat = dict(ei=0.0, length=850.0, nseg=85, fair=(-58, 0, -14), anch=(-837.6, 0, -200), + seabed="200.0 WtrDpth", mu=0.5) + rc0, _ = run(a.exe, cdir, "none", deck("flat none", **flat, extra="none staticsFriction\n")) + check(rc0 == 0, "flat frictionless static converges") + if rc0 == 0: + r0 = table(cdir / "none.out")[0] + h = abs(r0["Point2Fx"]) # the grounded run carries the anchor's horizontal tension + h_run = h + rc, _ = run(a.exe, cdir, "taut", deck("flat taut", **flat, extra="%.9g asLaidTension\n" % h)) + check(rc == 0, "flat laid at the run tension converges") + if rc == 0: + r1 = table(cdir / "taut.out")[0] + # FairTen to 1e-4. AnchTen to 0.5 %: the anchor rests on the seabed surface and the + # laid run one static penetration below it, so the run is drawn a fraction of a + # millimetre toward the anchor and its friction springs add a small tension there + # (the anchor-level effect Orcina's "OrcaFlex Friction Effects" note describes). + for k, tol in (("FairTen1", 1.0e-4), ("AnchTen1", 5.0e-3)): + rel = abs(r1[k] - r0[k]) / r0[k] + check(rel < tol, "flat laid at the run tension: %s equals the frictionless %.6g N (rel %.1e)" + % (k, r0[k], rel)) + rc, _ = run(a.exe, cdir, "slack", deck("flat slack", **flat)) + check(rc == 0, "flat laid slack converges") + if rc == 0: + r2 = table(cdir / "slack.out")[0] + drop = r0["AnchTen1"] - r2["AnchTen1"] + check(0.0 < drop <= 0.5 * w * 850.0, + "flat laid slack: friction lowers AnchTen by %.4g N (within mu w L)" % drop) + + # --- finite-EI cable on a flat seabed, laid slack: lay azimuth across the chord --- + # A lay azimuth off the vertical plane of the chord puts the reference (and its friction) + # out of that plane, so the static solve is 3D from the start: the state is then an + # equilibrium of the line (friction within mu N, a march from it stays at rest). At 180 + # degrees the reference lies in the plane, on the far side of the anchor: the planar solve + # holds, and the friction saturates along the whole run, below the default's anchor tension. + cdir = root / "fei_flat" + kbot = 1.0e5 + fl = dict(ei=1.0e4, length=400.0, nseg=80, fair=(300, 0, -10), anch=(0, 0, -200), + seabed="200.0 WtrDpth", mu=0.5) + fsec = ((d, w, 400.0 / 80, 80),) + fres = {} + for tag, extra in (("def", ""), ("az45", "45.0 layAzimuth\n"), ("az180", "180.0 layAzimuth\n")): + rc, log = run(a.exe, cdir, tag, deck("fei flat " + tag, **fl, extra=extra)) + check(rc == 0, "fei_flat %s converges (rc %d)%s" % (tag, rc, "" if rc == 0 else ": " + log.strip()[-300:])) + if rc != 0: + continue + fres[tag] = table(cdir / (tag + ".out"))[0] + util, ngr, maxy, _ = plateau_utilisation(cdir, tag, 0.5, -200.0, kbot, fsec) + check(ngr > 10 and 0.1 < util <= 1.05, + "fei_flat %s: friction within mu N over %d grounded nodes (max %.4f)" % (tag, ngr, util)) + if tag == "az45": + check(maxy > 1.0, "fei_flat az45: the line leaves the chord plane (max |y| %.3f m)" % maxy) + else: + check(maxy < 1.0e-6, "fei_flat %s: the line stays in the chord plane (max |y| %.1e m)" % (tag, maxy)) + rc, _ = run(a.exe, cdir, tag + "_rest", deck("fei flat rest " + tag, **fl, extra=extra, tmax=1.0)) + check(rc == 0, "fei_flat %s at-rest march runs (rc %d)" % (tag, rc)) + if rc == 0: + drift = at_rest(cdir, tag, tag + "_rest") + check(drift <= REST_TOL, "fei_flat %s stays at rest from the static state (drift %.2e)" % (tag, drift)) + if "def" in fres and "az180" in fres: + check(fres["az180"]["AnchTen1"] < 0.8 * fres["def"]["AnchTen1"], + "fei_flat: the 180 degree reference flips (AnchTen %.4g below the default %.4g N)" + % (fres["az180"]["AnchTen1"], fres["def"]["AnchTen1"])) + + # --- finite-EI cable on a cross slope, default lay azimuth --- + # The nodes laid at rest sink into the penalty seabed along its normal, across the slope too; + # the friction reference keeps that offset. A reference without it would leave the run shifted + # down the slope by the sink, about w tan(slope)/(kBot d) = 1 cm, which the anchor would carry + # as a lateral force of AnchTen times that shift over an element (about +0.4 kN, down the slope). + # With it the lateral anchor force is a small fraction of that, up the slope, for the EI = 0 + # line and for the finite-EI one (whose end force follows the cable's end tangent where the + # EI = 0 line's follows the chord of its first element). The seabed slope across the chord + # pushes the run out of its vertical plane against its friction, so the finite-EI line is solved + # in 3D and a march from its static state stays at rest. + cdir = root / "fei_cross" + cdir.mkdir(parents=True, exist_ok=True) + cross_grid(cdir / "bathy.txt", 200.0, 5.0) + fy = {} + for tag, ei in (("ei0", 0.0), ("fei", 1.0e4)): + cd = dict(ei=ei, length=400.0, nseg=80, fair=(300, 0, -10), anch=(0, 0, -200), seabed=sb) + rc, log = run(a.exe, cdir, tag, deck("fei cross " + tag, **cd)) + check(rc == 0, "fei_cross %s converges (rc %d)%s" % (tag, rc, "" if rc == 0 else ": " + log.strip()[-300:])) + if rc == 0: + r0 = table(cdir / (tag + ".out"))[0] + # the anchor force of a run shifted down the slope by its sink, half of it + bound = 0.5 * r0["AnchTen1"] * w / (1.0e5 * d) * math.tan(math.radians(5.0)) / 5.0 + fy[tag] = r0["Point2Fy"] + check(-bound < fy[tag] < 0.0, + "fei_cross %s: lateral anchor force %.4g N up the slope, within half the %.4g N of a reference " + "without the sink" % (tag, fy[tag], 2.0 * bound)) + if rc == 0 and tag == "fei": + rc, _ = run(a.exe, cdir, "fei_rest", deck("fei cross rest", **cd, tmax=1.0)) + check(rc == 0, "fei_cross fei at-rest march runs (rc %d)" % rc) + if rc == 0: + drift = at_rest(cdir, "fei", "fei_rest") + check(drift <= REST_TOL, "fei_cross fei stays at rest from the static state (drift %.2e)" % drift) + + # --- finite-EI line with discrete buoyancy modules on a cross slope --- + # Three modules (net buoyancy 8.09 kN, two thirds of a node's weight) on the grounded run of a + # soft rope (EA 2e7 N: its laid slack run beyond the touchdown is held by friction at a small + # tension, so it rests as laid). The static solve smears each module over its node's two + # elements, then polishes to the discrete loads; the friction reference sinks every node under + # those discrete loads, so a module node rests on the laid path as its neighbours do. A + # reference built from the smeared weights would deflect each module node across the slope by + # about half its net weight times tan(slope) over the nodal seabed stiffness (3.3 mm) and hold + # that with a spurious friction force (the seabed stiffness times that kink). Checked: the + # lateral kink of the line at the module nodes stays within a tenth of that and no larger than + # in its smeared twin (each module spread over its node's two elements as a section), and a + # march from the static state stays at rest. + cdir = root / "att_cross" + cdir.mkdir(parents=True, exist_ok=True) + cross_grid(cdir / "bathy.txt", 200.0, 5.0) + ea_soft, l_att, n_att, mods = 2.0e7, 600.0, 120, (450.0, 500.0, 550.0) + m_mod, v_mod = 200.0, 1.0 + d_m = 0.5 * (m_mod - RHO * v_mod) / 5.0 # smeared mass per length over each of the two elements + soft = f"chain {d} {m} {ea_soft} -1 1.0e4 1.37 0.64 1 0\n" + ac = dict(ei=1.0e4, length=l_att, nseg=n_att, fair=(500, 0, -10), anch=(0, 0, -200), seabed=sb) + att_rows = "".join("1 %.1f %.1f %.1f 0.0 0.0 0.0\n" % (s, m_mod, v_mod) for s in mods) + secs, s0 = "", 0.0 + for s in mods: + secs += "1 chain %.1f %d\n1 mod %.1f 2\n" % (s - 5.0 - s0, round((s - 5.0 - s0) / 5.0), 10.0) + s0 = s + 5.0 + secs += "1 chain %.1f %d\n" % (l_att - s0, round((l_att - s0) / 5.0)) + twin_types = soft + f"mod {d} {m + d_m} {ea_soft} -1 1.0e4 1.37 0.64 1 0\n" + ys = {} + for tag, kw in (("discrete", dict(types=soft, attachments=att_rows)), + ("smeared", dict(types=twin_types, sections=secs))): + rc, log = run(a.exe, cdir, tag, deck("att cross " + tag, **ac, **kw)) + check(rc == 0, "att_cross %s converges (rc %d)%s" % (tag, rc, "" if rc == 0 else ": " + log.strip()[-300:])) + if rc != 0: + continue + p = first_row(cdir / (tag + ".Line1.p.out")) + ys[tag] = [p[3 * i + 1] for i in range(len(p) // 3)] + if tag == "discrete": + rc, _ = run(a.exe, cdir, tag + "_rest", deck("att cross rest", **ac, **kw, tmax=1.0)) + check(rc == 0, "att_cross at-rest march runs (rc %d)" % rc) + if rc == 0: + drift = at_rest(cdir, tag, tag + "_rest") + check(drift <= REST_TOL, "att_cross stays at rest from the static state (drift %.2e)" % drift) + if len(ys) == 2: + spurious = 0.5 * abs(m_mod - RHO * v_mod) * G * math.tan(math.radians(5.0)) / (1.0e5 * d * 5.0) + + def kink(y: list) -> float: + """Largest lateral offset of a module node from the chord of its two neighbours [m].""" + return max(abs(y[k] - 0.5 * (y[k - 1] + y[k + 1])) for k in (round(s / 5.0) for s in mods)) + + kd, ks = kink(ys["discrete"]), kink(ys["smeared"]) + check(kd < 0.1 * spurious, + "att_cross: no lateral kink at the module nodes (%.2e m, the smeared reference's %.2e m)" % (kd, spurious)) + check(kd <= ks, + "att_cross: the module nodes rest on the laid path as closely as in the smeared twin (%.2e <= %.2e m)" + % (kd, ks)) + + # --- per-line rows, non-default azimuth and tension, anisotropic friction (EI = 0) --- + cdir = root / "perline" + keys = ("FairTen1", "AnchTen1", "Point1Fx", "Point2Fx", "Point1Fz") + pl = {} + cases = { + "def": "", + "g180": "180.0 layAzimuth\n", + "g90": "90.0 layAzimuth\n", + "p180": "90.0 layAzimuth\n180.0 layAzimuth1\n", + "p180b": "180.0 layAzimuth1\n90.0 layAzimuth\n", + "p90": "180.0 layAzimuth\n90.0 layAzimuth1\n", + } + if h_run is not None: + cases.update({ + "gt": "%.9g asLaidTension\n" % h_run, + "pt": "0.0 asLaidTension\n%.9g asLaidTension1\n" % h_run, + "ptb": "%.9g asLaidTension1\n0.0 asLaidTension\n" % h_run, + "pt0": "%.9g asLaidTension\n0.0 asLaidTension1\n" % h_run, + "lay1": "180.0 layAzimuth1\n", + }) + for tag, extra in cases.items(): + rc, log = run(a.exe, cdir, tag, deck("perline " + tag, **flat, extra=extra)) + check(rc == 0, "perline %s converges (rc %d)%s" % (tag, rc, "" if rc == 0 else ": " + log.strip()[-300:])) + if rc == 0: + pl[tag] = table(cdir / (tag + ".out"))[0] + if {"def", "g180", "g90"} <= pl.keys(): + check(not same(pl["g180"], pl["def"], keys, 1.0e-3), + "layAzimuth 180 changes the statics (AnchTen %.5g vs %.5g N)" % (pl["g180"]["AnchTen1"], pl["def"]["AnchTen1"])) + check(not same(pl["g90"], pl["def"], keys, 1.0e-3) and not same(pl["g90"], pl["g180"], keys, 1.0e-3), + "layAzimuth 90 gives its own statics (AnchTen %.5g N)" % pl["g90"]["AnchTen1"]) + if {"g180", "p180", "p180b", "g90"} <= pl.keys(): + check(same(pl["p180"], pl["g180"], keys) and same(pl["p180b"], pl["g180"], keys), + "layAzimuth1 wins over layAzimuth, in either order (as the global 180)") + check(not same(pl["p180"], pl["g90"], keys, 1.0e-3), "layAzimuth1 differs from the global value it overrides") + if {"g180", "p90", "g90"} <= pl.keys(): + check(same(pl["p90"], pl["g90"], keys), "layAzimuth1 wins over layAzimuth (90 over 180)") + if {"def", "gt", "pt", "ptb", "pt0", "lay1"} <= pl.keys(): + check(not same(pl["gt"], pl["def"], keys, 1.0e-3), + "asLaidTension changes the statics (AnchTen %.5g vs %.5g N)" % (pl["gt"]["AnchTen1"], pl["def"]["AnchTen1"])) + check(same(pl["pt"], pl["gt"], keys) and same(pl["ptb"], pl["gt"], keys), + "asLaidTension1 wins over asLaidTension, in either order (as the global value)") + check(same(pl["pt0"], pl["def"], keys), "asLaidTension1 0 wins over a global tension (as the default)") + check(not same(pl["lay1"], pl["def"], keys, 1.0e-3), "layAzimuth1 alone takes effect") + + # two lines: a row for line 2 leaves line 1 alone + two = {} + for tag, extra in (("def", ""), ("g180", "180.0 layAzimuth\n"), ("l2", "180.0 layAzimuth2\n")) + ( + (("gt", "%.9g asLaidTension\n" % h_run), ("t2", "%.9g asLaidTension2\n" % h_run)) if h_run else ()): + rc, log = run(a.exe, cdir, "two_" + tag, deck_two("two lines " + tag, extra=extra)) + check(rc == 0, "two lines %s converge (rc %d)" % (tag, rc)) + if rc == 0: + two[tag] = table(cdir / ("two_" + tag + ".out"))[0] + + def of_line(row: dict, i: int) -> dict: + return {"FairTen1": row["FairTen%d" % i], "AnchTen1": row["AnchTen%d" % i]} + + if {"def", "g180", "l2"} <= two.keys(): + k2 = ("FairTen1", "AnchTen1") + check(same(of_line(two["def"], 1), of_line(two["def"], 2), k2), "two lines: identical lines give identical statics") + check(same(of_line(two["l2"], 1), of_line(two["def"], 1), k2), + "two lines: layAzimuth2 leaves line 1 at the default") + check(same(of_line(two["l2"], 2), of_line(two["g180"], 2), k2) and + not same(of_line(two["l2"], 2), of_line(two["def"], 2), k2, 1.0e-3), + "two lines: layAzimuth2 sets line 2 alone (AnchTen2 %.5g N)" % two["l2"]["AnchTen2"]) + if {"def", "gt", "t2"} <= two.keys(): + k2 = ("FairTen1", "AnchTen1") + check(same(of_line(two["t2"], 1), of_line(two["def"], 1), k2), "two lines: asLaidTension2 leaves line 1 alone") + check(same(of_line(two["t2"], 2), of_line(two["gt"], 2), k2) and + not same(of_line(two["t2"], 2), of_line(two["def"], 2), k2, 1.0e-3), + "two lines: asLaidTension2 sets line 2 alone (AnchTen2 %.5g N)" % two["t2"]["AnchTen2"]) + + # anisotropic friction: along a run laid and pulled along the chord the axial coefficient rules + cdir = root / "aniso" + an = {} + for tag, mu_iso, extra in (("iso05", 0.5, ""), ("iso02", 0.2, ""), + ("ax05_lat02", 0.5, "0.2 frictionMuLateral\n"), + ("ax02_lat05", 0.2, "0.5 frictionMuLateral\n")): + fa = dict(flat, mu=mu_iso) + rc, log = run(a.exe, cdir, tag, deck("aniso " + tag, **fa, extra=extra)) + check(rc == 0, "aniso %s converges (rc %d)%s" % (tag, rc, "" if rc == 0 else ": " + log.strip()[-300:])) + if rc == 0: + an[tag] = table(cdir / (tag + ".out"))[0] + if len(an) == 4: + k1 = ("FairTen1", "AnchTen1") + check(not same(an["iso05"], an["iso02"], k1, 1.0e-2), "aniso: the coefficient changes the anchor tension") + check(same(an["ax05_lat02"], an["iso05"], k1, 2.0e-3), + "aniso: axial 0.5 / lateral 0.2 acts as the isotropic 0.5 along the chord (AnchTen %.5g vs %.5g N)" + % (an["ax05_lat02"]["AnchTen1"], an["iso05"]["AnchTen1"])) + check(same(an["ax02_lat05"], an["iso02"], k1, 2.0e-3), + "aniso: axial 0.2 / lateral 0.5 acts as the isotropic 0.2 along the chord (AnchTen %.5g vs %.5g N)" + % (an["ax02_lat05"]["AnchTen1"], an["iso02"]["AnchTen1"])) + + # --- a line of three sections of different weights: friction within mu N everywhere --- + cdir = root / "multi" + light = (0.1, 40.0, 5.0e8) # diameter [m], mass [kg/m], EA [N] + wl = (light[1] - RHO * math.pi / 4.0 * light[0] ** 2) * G + mtypes = (f"chain {d} {m} {ea} -1 0 1.37 0.64 1 0\n" + f"light {light[0]} {light[1]} {light[2]} -1 0 1.2 0.6 1 0\n") + msecs = "1 chain 300 60\n1 light 300 60\n1 chain 250 50\n" + rc, log = run(a.exe, cdir, "multi", deck("multi", ei=0.0, length=850.0, nseg=170, fair=(-58, 0, -14), + anch=(-837.6, 0, -200), seabed="200.0 WtrDpth", mu=0.5, + types=mtypes, sections=msecs)) + check(rc == 0, "multi converges (rc %d)%s" % (rc, "" if rc == 0 else ": " + log.strip()[-300:])) + if rc == 0: + msec = ((d, w, 5.0, 60), (light[0], wl, 5.0, 60), (d, w, 5.0, 50)) + util, ngr, _, by_sec = plateau_utilisation(cdir, "multi", 0.5, -200.0, kbot, msec) + check(by_sec[1][1] > 5 and by_sec[2][1] > 5, + "multi: the grounded run spans the light (%d nodes) and the heavy (%d) section" % (by_sec[1][1], by_sec[2][1])) + check(util <= 1.01, "multi: friction within mu N at every grounded node (max %.4f)" % util) + check(by_sec[1][0] > 0.9 and by_sec[2][0] > 0.5, + "multi: friction mobilised to mu N in the light section and beyond in the heavy (%.3f, %.3f)" + % (by_sec[1][0], by_sec[2][0])) + + # --- a refined mesh is laid as its own deck would be --- + # A finite-EI line of two sections (the light one grounded at the anchor end) laid at a + # tension on a seabed curved along the line and sloping across it, on a 20 m deck mesh that + # the adaptive refinement takes to 1.25 m (16x). The friction reference of the refined solve + # is laid on the refined mesh itself (path, sink under each node's lumped weight over its + # seabed stiffness, turning force of the laid tension), so the run reaches the equilibrium + # of its twin declared on that 1.25 m mesh to solver precision. A reference interpolated + # from the 20 m deck nodes misplaces the sink of the refined nodes next to the section + # change (about 1 mm across the slope) and the turning force along the curved floor, which + # moves the run (the lateral anchor force changes sign, AnchTen moves by about 8 N). The + # refined run marched for 1 s stays at rest. + cdir = root / "refined" + cdir.mkdir(parents=True, exist_ok=True) + rows = ["%.1f %.1f %.12g" % (x, y, 200.0 + 1.0e-4 * x * x + 0.05 * y) + for x in range(-300, 1000, 10) for y in (-300.0, 300.0)] + (cdir / "bathy.txt").write_text("\n".join(rows) + "\n", encoding="utf-8", newline="\n") + rtypes = (f"chain {d} {m} {ea} -1 1.0e4 1.37 0.64 1 0\n" + f"light {light[0]} {light[1]} {light[2]} -1 1.0e4 1.2 0.6 1 0\n") + rpos = {} + for tag, nseg, extra in (("coarse", 20, "True adaptive_mesh\n"), ("fine", 320, "")): + rd = dict(ei=1.0e4, length=400.0, nseg=nseg, fair=(300, 0, -10), anch=(0, 0, -200), seabed=sb, mu=0.5, + types=rtypes, sections="1 chain 300 %d\n1 light 100 %d\n" % (nseg * 3 // 4, nseg // 4)) + ex = extra + "50000 asLaidTension\n" + rc, log = run(a.exe, cdir, tag, deck("refined " + tag, **rd, extra=ex)) + check(rc == 0, "refined %s converges (rc %d)%s" % (tag, rc, "" if rc == 0 else ": " + log.strip()[-300:])) + if rc != 0: + continue + p = first_row(cdir / (tag + ".Line1.p.out")) + rpos[tag] = ([p[3 * i:3 * i + 3] for i in range(len(p) // 3)], table(cdir / (tag + ".out"))[0]) + if tag == "coarse": + check(len(rpos[tag][0]) == 321, "refined: the 20-element deck mesh is refined to 320 elements (%d nodes)" + % len(rpos[tag][0])) + rc, _ = run(a.exe, cdir, "coarse_rest", deck("refined rest", **rd, extra=ex, tmax=1.0)) + check(rc == 0, "refined at-rest march runs (rc %d)" % rc) + if rc == 0: + drift = at_rest(cdir, "coarse", "coarse_rest") + check(drift <= REST_TOL, "refined stays at rest from the static state (drift %.2e)" % drift) + if len(rpos) == 2 and len(rpos["coarse"][0]) == len(rpos["fine"][0]): + dpos = max(abs(u[k] - v[k]) for u, v in zip(rpos["coarse"][0], rpos["fine"][0]) for k in range(3)) + check(dpos < 1.0e-6, "refined: the refined run rests where its twin on the refined mesh does (%.1e m)" % dpos) + rc_, rf_ = rpos["coarse"][1], rpos["fine"][1] + check(same(rc_, rf_, ("FairTen1", "AnchTen1", "Point2Fx"), 1.0e-7) and abs(rc_["Point2Fy"] - rf_["Point2Fy"]) < 0.1, + "refined: end forces as on the refined mesh (AnchTen %.6g / %.6g N, anchor Fy %.4g / %.4g N)" + % (rc_["AnchTen1"], rf_["AnchTen1"], rc_["Point2Fy"], rf_["Point2Fy"])) + + # --- input checks --- + cdir = root / "inputs" + rc, log = run(a.exe, cdir, "badid", deck("bad id", **flat, extra="30.0 layAzimuth9\n")) + check(rc != 0 and "names no LINE" in log, "layAzimuth9 without a line 9 is rejected") + rc, log = run(a.exe, cdir, "badpolicy", deck("bad policy", **flat, extra="restart staticsFriction\n")) + check(rc != 0 and "asLaid or none" in log, "an unknown staticsFriction policy is rejected") + rc, log = run(a.exe, cdir, "goodid", deck("good id", **flat, extra="180.0 layAzimuth1\n0 asLaidTension1\n")) + check(rc == 0, "layAzimuth1 / asLaidTension1 rows are accepted") + if rc == 0 and "g180" in pl: + # the rows are not only accepted: line 1 is laid at 180 degrees (as the global row does) + check(same(table(cdir / "goodid.out")[0], pl["g180"], keys), + "layAzimuth1 180 / asLaidTension1 0 act as the global 180 degree lay") + if h_run is not None: + rc, log = run(a.exe, cdir, "goodid_t", deck("good id t", **flat, extra="%.9g asLaidTension1\n" % h_run)) + check(rc == 0, "asLaidTension1 row is accepted") + if rc == 0 and "gt" in pl and "def" in pl: + row = table(cdir / "goodid_t.out")[0] + check(same(row, pl["gt"], keys) and not same(row, pl["def"], keys, 1.0e-3), + "asLaidTension1 takes effect (AnchTen %.5g vs %.5g N laid slack)" % (row["AnchTen1"], pl["def"]["AnchTen1"])) + rc, log = run(a.exe, cdir, "hugeid", deck("huge id", **flat, extra="30.0 layAzimuth99999999999\n")) + check(rc != 0 and "names no LINE" in log, "layAzimuth with an integer suffix too large for a line ID is rejected") + rc, log = run(a.exe, cdir, "hugeidt", deck("huge id t", **flat, extra="1.0 asLaidTension99999999999999999999\n")) + check(rc != 0 and "names no LINE" in log, "asLaidTension with an integer suffix too large for a line ID is rejected") + rc, log = run(a.exe, cdir, "badsuffix", deck("bad suffix", **flat, extra="30.0 layAzimuth1x\n")) + check(rc != 0 and "unknown OPTION keyword" in log, "layAzimuth1x is an unknown keyword") + rc, log = run(a.exe, cdir, "badtension", deck("bad tension", **flat, extra="-1.0 asLaidTension1\n")) + check(rc != 0 and "asLaidTension1" in log, "a negative asLaidTension1 is rejected") + rc, log = run(a.exe, cdir, "hugetension", deck("huge tension", **flat, extra="1.0e30 asLaidTension\n")) + check(rc != 0 and "more than 100 %" in log, "an asLaidTension above EA fails closed instead of overflowing") + # every row is validated, also one a later row for the same line overrides + rc, log = run(a.exe, cdir, "shadowt", deck("shadowed tension", **flat, + extra="-1.0 asLaidTension1\n0.0 asLaidTension1\n")) + check(rc != 0 and "asLaidTension1" in log, "a negative asLaidTension1 shadowed by a valid row is rejected") + rc, log = run(a.exe, cdir, "shadowaz", deck("shadowed azimuth", **flat, + extra="nan layAzimuth1\n30.0 layAzimuth1\n")) + check(rc != 0 and "layAzimuth1" in log, "a NaN layAzimuth1 shadowed by a valid row is rejected") + + # a finite-EI line shared between two turbines (End B not Fixed) runs the compatibility route, + # whose statics carry no seabed friction: asLaid fails closed there by name, none runs + shared = dict(ei=1.0e4, length=600.0, nseg=60, fair=(0, 0, -10), anch=(0, 0, -10), seabed="200.0 WtrDpth", mu=0.5) + for tag, extra in (("shared", ""), ("shared_none", "none staticsFriction\n")): + txt = deck("shared " + tag, **shared, extra=extra, tmax=0.2) + txt = txt.replace("1 Coupled", "1 Turbine1").replace("2 Fixed", "2 Turbine2") + txt = txt.replace("--------------------- LINES ---", + "--------------------- TURBINES ---\nJ X0 Y0 Z0\n(-) (m) (m) (m)\n1 0 0 0\n2 300 0 0\n" + "--------------------- LINES ---") + txt = txt.replace('"Point1Fx"\n"Point1Fy"\n"Point1Fz"\n"Point2Fx"\n"Point2Fy"\n"Point2Fz"\n', "") + rc, log = run(a.exe, cdir, tag, txt) + if tag == "shared": + check(rc != 0 and "moving End B" in log, "asLaid on a line with a moving End B (shared line) is rejected") + else: + check(rc == 0, "the shared line runs with staticsFriction none (rc %d)" % rc) + + print("static friction as laid: %d failure(s)" % len(FAILURES)) + return 1 if FAILURES else 0 + + +if __name__ == "__main__": + sys.exit(main()) From f2caf1fe129850c88e1e517b730cc4d3cbe6492d Mon Sep 17 00:00:00 2001 From: Jae Hoon Seo Date: Fri, 16 Oct 2026 18:45:04 +0900 Subject: [PATCH 12/31] feat(capi): host-coupling calls for CFD hosts (ABI 1.2) (#18) C ABI 1, minor extension 2: calls for hosts that drive the Coupled points of a deck, CFD solvers in particular. Every existing function is unchanged. - CableDyn_InitDeckAt solves the statics with every line-bound Coupled/Vessel point at its entry of q0 (the host blocks alone, like MoorDyn's X, or the full coupled vector), on the point and the aggregate route, and checks that every host block starts at q0. A body starting away from its deck position no longer starts the lines with a transient: for foamMooring's EsfLOWC box, line 4's fairlead load moved by up to 0.38 N of 0.52 N under InitDeck; under InitDeckAt it equals the deck moved to the host positions bit for bit. - CableDyn_SaveState / CableDyn_RestoreState keep one in-memory deep copy of the model (and the aggregate's committed time) for the outer correctors of a host step; restore then step is bit-identical to stepping from the saved state on both routes, including viscoelastic, Syrope, seabed friction, point fluid fields, bodies and rods. - CableDyn_GetCoupledLayout returns the deck point id and type of every block of the coupled vector. Python: init_deck_at, save_state, restore_state, coupled_layout, host_dofs. doc/capi.rst gains "Coupling a host (CFD) solver", which compares the call sequence with MoorDyn's C API step by step. Tests: c_api_host_coupling (C, shared library), save/restore in test_c_api and test_c_api_stack (1 MiB stack), and python/tests/test_host_coupling.py. Signed-off-by: Jae Hoon Seo --- ARCHITECTURE.md | 7 +- CHANGELOG.md | 17 + CMakeLists.txt | 28 +- doc/api_python.rst | 73 +- doc/capi.rst | 420 ++++++++++- doc/coupling_boundary.md | 15 +- doc/python.rst | 33 + python/cabledyn/_lib.py | 35 + python/cabledyn/model.py | 160 ++++- python/tests/test_host_coupling.py | 210 ++++++ python/tests/test_objects.py | 3 +- release/check_release_metadata.py | 2 +- src/CableDyn_CAPI.f90 | 448 +++++++++++- src/CableDyn_CAPI.h | 59 +- src/CableDyn_DeckDriver.f90 | 78 +- src/cabledyn.def | 4 + src/cabledyn.exp | 4 + src/cabledyn.map | 4 + tests/data/foam_esflowc_box_points.dat | 41 ++ tests/data/host_coupling_chain_cable.dat | 35 + tests/test_c_api.f90 | 21 +- tests/test_c_api_host_coupling.c | 862 +++++++++++++++++++++++ tests/test_c_api_shared.c | 3 +- tests/test_c_api_stack.c | 44 +- 24 files changed, 2512 insertions(+), 94 deletions(-) create mode 100644 python/tests/test_host_coupling.py create mode 100644 tests/data/foam_esflowc_box_points.dat create mode 100644 tests/data/host_coupling_chain_cable.dat create mode 100644 tests/test_c_api_host_coupling.c diff --git a/ARCHITECTURE.md b/ARCHITECTURE.md index 71582bd4..e7e2c77a 100644 --- a/ARCHITECTURE.md +++ b/ARCHITECTURE.md @@ -500,8 +500,11 @@ import only Windows system DLLs. minor extension 1 (`CableDyn_GetAbiMinor() ≥ 1`) adds in-process object queries (object counts and ids, line node and segment values, point, body, and rod states, and any output channel through `CableDyn_EvalChannel`), which return - what the matching output channel reports for the same state (see - [doc/capi.rst](doc/capi.rst)). + what the matching output channel reports for the same state. Minor extension 2 + (`≥ 2`) adds the host-coupling calls: `CableDyn_InitDeckAt` (the statics solved + at the host's coupled-point positions), `CableDyn_SaveState` / + `CableDyn_RestoreState` (a one-slot deep copy of the model object for outer + correctors) and `CableDyn_GetCoupledLayout` (see [doc/capi.rst](doc/capi.rst)). - **Python** (`python/cabledyn`): runs the driver, reads and post-processes outputs, edits decks, runs studies, and binds the C interface through ctypes with a pinned ABI version. With its object views and snapshots it is designed diff --git a/CHANGELOG.md b/CHANGELOG.md index 7fd83771..0d160eb7 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -76,6 +76,23 @@ All notable changes to CableDyn are recorded in this file. The format follows body, which move the line ends by translation only, still refuse torsion columns by name, and so does OpenFAST linearisation of a line restrained in torsion. See the manual's OpenFAST page (Line torsion). +- C ABI 1 minor extension 2 (`CableDyn_GetAbiMinor() == 2`) for hosts that drive the + `Coupled` points of a deck, such as CFD solvers. Every existing function is unchanged. + `CableDyn_InitDeckAt` solves the statics with the `Coupled`/`Vessel` points at the host's + positions, the counterpart of `MoorDyn_Init(X, XD)` (the statics start at rest), so a body + that starts away from the deck coordinates starts without a transient: for foamMooring's + `EsfLOWC` box, whose fairleads start 15 mm below the deck, the fairlead load of + `CableDyn_InitDeck` followed by held fairleads deviates by up to 0.38 N of 0.52 N, and stays + constant to round-off after `CableDyn_InitDeckAt`. `CableDyn_SaveState` and + `CableDyn_RestoreState` keep one in-memory copy of the whole model for outer correctors + (PIMPLE); a restore followed by a step is bit-identical to stepping from the saved state, on + both routes and across any number of steps. `CableDyn_GetCoupledLayout` returns the deck point + id and type of every block of the coupled vector, which on the point route includes the + `Fixed` anchors. The Python `CableDyn` class gains `init_deck_at`, `save_state`, + `restore_state`, `coupled_layout` and `host_dofs`. The manual's C API page has a new section, + Coupling a host (CFD) solver, that compares the call sequence step by step with MoorDyn's C + API: initialisation, vector layout, end-of-step motion, outer correctors, load summation, + the fixed step of the aggregate route, and units. ### Changed diff --git a/CMakeLists.txt b/CMakeLists.txt index f3fbb945..e0006d2e 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -1081,6 +1081,25 @@ add_test(NAME c_api_shared ${CMAKE_CURRENT_SOURCE_DIR}/examples/dynamic_chain_waves.dat) set_tests_properties(c_api_shared PROPERTIES LABELS "c;unit;capi;shared") +# The host-coupling calls of ABI 1.2 through the public header and the shared library: +# initialization at the host's positions (the foamMooring EsfLOWC box, whose fairleads start +# below their deck coordinates), state save/restore on both routes, on a raw-array handle and +# with viscoelastic, Syrope, seabed-friction and point fluid-field state, the save-slot +# lifetime across failed initializations, and the layout query. +add_executable(test_c_api_host_coupling tests/test_c_api_host_coupling.c) +target_include_directories(test_c_api_host_coupling PRIVATE "${CMAKE_CURRENT_SOURCE_DIR}/src") +target_link_libraries(test_c_api_host_coupling PRIVATE cabledyn_shared) +if(NOT WIN32) + target_link_libraries(test_c_api_host_coupling PRIVATE m) +endif() +add_test(NAME c_api_host_coupling + COMMAND test_c_api_host_coupling ${CMAKE_CURRENT_SOURCE_DIR}/tests/data/foam_esflowc_box_points.dat + ${CMAKE_CURRENT_SOURCE_DIR}/tests/data/host_coupling_chain_cable.dat + ${CMAKE_CURRENT_SOURCE_DIR}/examples/ve_polyester_catenary_mooring.dat + ${CMAKE_CURRENT_SOURCE_DIR}/examples/syrope_polyester_mooring.dat + ${CMAKE_CURRENT_SOURCE_DIR}/examples/clump_weight_free_point.dat) +set_tests_properties(c_api_host_coupling PROPERTIES LABELS "c;unit;capi;shared;dynamic") + find_package(Threads QUIET) if(Threads_FOUND AND CMAKE_USE_PTHREADS_INIT) add_executable(test_c_api_concurrency tests/test_c_api_concurrency.c) @@ -1094,10 +1113,11 @@ else() endif() # Portable (Win32 or POSIX threads) stack bound of the shared library: each deck is -# initialised, stepped, and evaluated on a thread with a 1 MiB stack (a host program, not -# CableDyn, chooses the stack of the threads that call the library). The decks are a -# 2048-element finite-EI cable (12294 DOFs), an EI=0 + finite-EI aggregate, and an EI=0 -# mooring; a stack need that grew with the model would overflow here. +# initialised, stepped, saved and restored, evaluated, and initialised again at its coupled +# positions (CableDyn_InitDeckAt) on a thread with a 1 MiB stack (a host program, not +# CableDyn, chooses the stack of the threads that call the library). The +# decks are a 2048-element finite-EI cable (12294 DOFs), an EI=0 + finite-EI aggregate, and an +# EI=0 mooring; a stack need that grew with the model would overflow here. add_executable(test_c_api_stack tests/test_c_api_stack.c) target_include_directories(test_c_api_stack PRIVATE "${CMAKE_CURRENT_SOURCE_DIR}/src") target_link_libraries(test_c_api_stack PRIVATE $) diff --git a/doc/api_python.rst b/doc/api_python.rst index bc98e41d..671d10b6 100644 --- a/doc/api_python.rst +++ b/doc/api_python.rst @@ -513,6 +513,70 @@ library is located. Array ordering, frames, and units at the coupling boundary f :raises ValueError: if the path contains a NUL character or, on Windows, cannot be represented in the active ANSI code page. + .. py:method:: init_deck_at(deck, q0) + + Initialise from a deck file with the static initial condition solved at the host's + positions of the coupled points (``CableDyn_InitDeckAt``). Every line-bound + ``Coupled``/``Vessel`` point starts at its entry of ``q0`` instead of its deck coordinates; + the lines, ``Free``/``Connect`` points, bodies and rods are solved in equilibrium with those + points held there, at rest. A host whose body starts away from the deck coordinates then + starts without a transient (:ref:`capi-host-coupling`). + + :param deck: Path of the ``.dat`` deck, as for :meth:`init_deck`. + :type deck: str | os.PathLike + :param q0: Either the full coupled vector of the deck (``n_coupled_dof`` values, the layout + :meth:`step` uses; the ``Fixed``, ``Free`` and ``Connect`` blocks are not read), or the + ``Coupled``/``Vessel`` blocks alone, in coupled-vector order (the ``MoorDyn_Init`` + layout of a deck whose coupled objects are points that are all attached to lines: a + ``Coupled`` point attached to no line has no block here). Flat, or column-per-point + ``(3, n)`` with ``n`` ≠ 3; positions in m. + :type q0: array_like + :raises CableDynError: if the deck fails to initialise, or ``q0`` does not match its + coupled points. A failed initialisation keeps any previously initialised model and its + saved state. + :raises ValueError: if the path is rejected as by :meth:`init_deck`; if ``q0`` is a ``(3, 3)`` + array, which is ambiguous (column-per-point or row-per-point: pass three points flat); + if ``q0`` has any other shape than flat or ``(3, n)``, or a length that is not a + multiple of 3; or if ``q0`` is not finite. + :raises RuntimeError: if the loaded library predates ABI 1 minor extension 2. + + .. py:method:: save_state() + restore_state() + + Save the whole model, and :attr:`time`, into the instance's single save slot; return to + it (``CableDyn_SaveState``, ``CableDyn_RestoreState``). The slot is a copy of every line, + point, body and rod state with its solver history. A restore keeps the slot, so one save + serves every outer corrector of a host time step, and a restore followed by a step is + bit-identical to taking that step from the saved state directly. Save when a host time + step starts after the previous one was accepted, and restore on every repeated pass from + the same start time, whatever its ``dt`` (:ref:`capi-host-coupling`). A successful + initialisation discards the slot; a failed one keeps it with the model. + + :raises CableDynError: on an uninitialised model, or from :meth:`restore_state` when + nothing was saved since the model was initialised. + :raises RuntimeError: if the loaded library predates ABI 1 minor extension 2. + + .. py:method:: coupled_layout() + + Return the owner of each 3-DOF block of the coupled vector (``CableDyn_GetCoupledLayout``): + a tuple of ``(point_id, kind)`` pairs, block ``k`` holding the degrees of freedom + ``3k .. 3k+2``. ``kind`` is ``"fixed"``, ``"coupled"`` (``Coupled`` or ``Vessel``), + ``"free"`` or ``"connect"``. On a point-system deck every line-bound point has a block, in + deck ``POINTS`` order; on the coupled aggregate (finite-EI lines, bodies or rods) only the + ``Coupled`` points do. + + :rtype: tuple[tuple[int, str], ...] + :raises CableDynError: on an uninitialised model or one built from raw arrays. + + .. py:method:: host_dofs() + + Return the indices of the coupled degrees of freedom the host drives, those of the + ``"coupled"`` blocks of :meth:`coupled_layout`, as an integer array. With ``x`` the + ``(3, n)`` host positions of those points in layout order, + ``q[model.host_dofs()] = x.reshape(-1, order="F")`` fills them in a full coupled vector. + + :rtype: numpy.ndarray + .. py:property:: initialized :type: bool @@ -666,7 +730,8 @@ library is located. Array ordering, frames, and units at the coupling boundary f .. py:property:: time :type: float - Simulation time (s): 0 after initialisation, advanced by every completed step. + Simulation time (s): 0 after initialisation, advanced by every completed step, and set back + by :meth:`restore_state`. .. py:property:: deck :type: pathlib.Path | None @@ -711,8 +776,10 @@ imports without the shared library. .. py:function:: abi_minor() - Return the extension level of ABI 1 of the loaded library: 1 when it has the object queries - behind :attr:`CableDyn.lines` and :meth:`CableDyn.channel`, 0 for an older library. + Return the extension level of ABI 1 of the loaded library: 2 when it also has the + host-coupling calls behind :meth:`CableDyn.init_deck_at`, :meth:`CableDyn.save_state` and + :meth:`CableDyn.coupled_layout`, 1 when it has the object queries behind + :attr:`CableDyn.lines` and :meth:`CableDyn.channel`, 0 for an older library. :rtype: int diff --git a/doc/capi.rst b/doc/capi.rst index 2c6bf44c..3bdcab8d 100644 --- a/doc/capi.rst +++ b/doc/capi.rst @@ -29,13 +29,19 @@ A model lives behind an opaque handle. The lifecycle is: .. code-block:: text CableDyn_Create - -> CableDyn_InitDeck | CableDyn_InitLine | CableDyn_InitLines (initialize; may repeat) + -> CableDyn_InitDeck | CableDyn_InitDeckAt (initialize; may repeat) + | CableDyn_InitLine | CableDyn_InitLines -> CableDyn_GetCoupledMotion (read the initial state) - -> loop: [CableDyn_UpdatePointFluidFields] + -> loop: [CableDyn_SaveState | CableDyn_RestoreState] (host outer correctors) + [CableDyn_UpdatePointFluidFields] CableDyn_Step(dt, motion at t+dt) CableDyn_CalcOutput (loads at t+dt) -> CableDyn_Close +A host solver that drives the ``Coupled`` points of a deck, a CFD code in particular, should +read `Coupling a host (CFD) solver`_ first: it gives the call sequence and how it differs from +MoorDyn's C API. + .. list-table:: Function summary :header-rows: 1 :widths: 38 62 @@ -72,6 +78,11 @@ A model lives behind an opaque handle. The lifecycle is: ``CableDyn_GetRodState``, ``CableDyn_EvalChannel`` - object queries (ABI 1.1): the objects of the model, their committed state, and any ``OUTPUTS`` channel (`Object queries`_) + * - ``CableDyn_InitDeckAt``, ``CableDyn_SaveState``, ``CableDyn_RestoreState``, + ``CableDyn_GetCoupledLayout`` + - host coupling (ABI 1.2): initialization with the statics at the host's positions, a + one-slot state save and restore for outer correctors, and the owner of each block of + the coupled vector (`Host coupling calls`_) Building and linking -------------------- @@ -125,7 +136,7 @@ a work buffer of about 128 MB at once (about 4 GB on a 32-CPU machine). The Wind therefore does not import ``openblas.dll``: the first ``CableDyn_Create`` (or, in an executable, the first solve) loads the ``openblas.dll`` next to the CableDyn library or executable with a one-thread pool, falling back to the standard DLL search order. If it cannot be loaded, -``InitDeck``, ``InitLine`` and ``InitLines`` return ``CD_C_ALLOC_FAIL`` and +``InitDeck``, ``InitDeckAt``, ``InitLine`` and ``InitLines`` return ``CD_C_ALLOC_FAIL`` and ``CableDyn_GetLastError`` names the library, each location tried and the Windows load error; the standalone driver prints the same diagnostic and exits with status 2. Other builds that link OpenBLAS call ``openblas_set_num_threads(1)`` at the first ``Create``; the Intel @@ -226,8 +237,9 @@ ABI and versioning - 1 - the C ABI revision the header describes * - ``CABLEDYN_CAPI_ABI_MINOR`` / ``CableDyn_GetAbiMinor()`` - - 1 - - additive extensions of ABI 1: 1 adds the `Object queries`_ + - 2 + - additive extensions of ABI 1: 1 adds the `Object queries`_, 2 the + `Host coupling calls`_ * - ``CableDyn_GetVersion(&major, &minor, &patch, &abi)`` - runtime - the same four numbers, reported by the loaded library @@ -258,7 +270,8 @@ The Python package does this check at import and rejects a library that speaks a A minor extension only adds functions: every ABI 1 prototype and its semantics are unchanged, so a caller built against an older header keeps working. A caller that uses the additions checks -``CableDyn_GetAbiMinor() >= 1`` before calling them. +``CableDyn_GetAbiMinor() >= 1`` before calling the object queries, and +``CableDyn_GetAbiMinor() >= 2`` before calling the host-coupling functions. Calling conventions ------------------- @@ -301,10 +314,10 @@ These rules apply to every entry point. The Python package uses the same array o water at :math:`z = 0` (:doc:`conventions`). See `State, units, and load sign`_. * **Threads.** ``Create`` and ``Close`` are thread-safe; a process-wide mutex guards the handle registry, independently of OpenMP. Separate handles may run concurrently on separate threads. - ``InitDeck``, ``InitLine``, and ``InitLines`` are serialised by a second process-wide lock: - they open and parse files through the Fortran runtime, which cannot open one file on two units - at once (two threads reading the same deck, or decks sharing a Syrope OWC table) and whose - formatted I/O is not safe to run concurrently. Concurrent initialisations therefore succeed but + ``InitDeck``, ``InitDeckAt``, ``InitLine``, and ``InitLines`` are serialised by a second + process-wide lock: they open and parse files through the Fortran runtime, which cannot open + one file on two units at once (two threads reading the same deck, or decks sharing a Syrope + OWC table) and whose formatted I/O is not safe to run concurrently. Concurrent initialisations therefore succeed but run one after another; a thread blocks while another thread initialises. ``Step``, ``UpdateStates``, ``CalcOutput``, and the other per-handle calls do no file or formatted I/O when they succeed and run concurrently on separate handles. A single handle must not be used @@ -320,9 +333,14 @@ These rules apply to every entry point. The Python package uses the same array o ``CD_C_BAD_HANDLE`` and is never dereferenced. One limitation is inherent to a pointer ABI: if a stale copy's address has been reused by a new ``Create``, the copy cannot be told apart from the new handle. -* **Re-initialisation is atomic.** Calling any ``Init*`` function on an initialised handle - replaces the model only on success. If the new initialisation fails, the previous model is - kept unchanged. +* **Re-initialisation is atomic for decks.** Calling ``CableDyn_InitDeck`` or + ``CableDyn_InitDeckAt`` on an initialised handle replaces the model only on success. If the + new initialisation fails, the previous model is kept unchanged, and so is the state saved by + ``CableDyn_SaveState``; a successful one discards that save. ``CableDyn_InitLine`` and + ``CableDyn_InitLines`` build the point model in place: after a failure the handle must be + initialised again, and the saved state is discarded. The one exception is a handle whose + deck model runs on the coupled aggregate (finite-EI lines, bodies or rods): a failed + ``InitLine``/``InitLines`` leaves that model live, and its saved state with it. * **Time.** The library keeps no clock. Only ``dt`` enters ``CableDyn_Step``, and the host owns the time line. @@ -378,13 +396,20 @@ Coupled DOF layout so do the rows and columns of every Jacobian. The layout is fixed when the handle is initialised. -``CableDyn_InitDeck`` +``CableDyn_InitDeck`` or ``CableDyn_InitDeckAt``, point route (``EI = 0`` lines only) One ``x, y, z`` block for every deck point that is attached to at least one line end, in ``POINTS`` table order. This includes points of every type: ``Fixed`` anchors, ``Coupled``/``Vessel`` points, and ``Free``/``Connect`` points. ``n_coupled_dof`` is three times the number of attached points. A point referenced by no line gets no block, but it is still counted by ``CableDyn_NPoints``. +``CableDyn_InitDeck`` or ``CableDyn_InitDeckAt``, aggregate route (finite-EI lines, bodies, rods) + One ``x, y, z`` block for every host-driven point and nothing else: first the + ``Coupled``/``Vessel`` points attached to an ``EI = 0`` line, in ``POINTS`` table order, + then the fairlead (End A, which must be ``Coupled``/``Vessel``) of each finite-EI line, in + ``LINES`` table order. ``Fixed`` anchors, ``Free``/``Connect`` points, bodies and rods have + no block. + ``CableDyn_InitLine`` ``n_fixed`` entries. Entry ``k`` is the DOF ``fixed_dofs[k]``, in the order the caller listed them. @@ -404,6 +429,11 @@ anchor blocks of a deck. Fill the vectors once from ``CableDyn_GetCoupledMotion` overwrite only the blocks the host drives. Deck ``Free`` and ``Connect`` points are the exception, described under ``CableDyn_Step``. +On a deck model, ``CableDyn_GetCoupledLayout`` (ABI 1.2) returns the deck point id and type +of every block, so a host does not have to derive the layout from the deck: the host drives +the blocks of type ``CD_C_POINT_COUPLED``. `Coupling a host (CFD) solver`_ works through an +example. + State, units, and load sign --------------------------- @@ -448,6 +478,222 @@ their loads at that point are summed. **Jacobians.** For the tight Newton loop of a monolithic host, the linear load model is :math:`L(q+\delta q, v+\delta v, a+\delta a) \approx L + J_q\,\delta q + J_v\,\delta v - M_a\,\delta a`. +.. _capi-host-coupling: + +Coupling a host (CFD) solver +---------------------------- + +This section is for a host that moves a body with its own equations of motion, typically a CFD +solver with a rigid-body solver, and drives the deck's ``Coupled`` points as fairleads on that +body. It goes through the coupling step by step and compares each step with MoorDyn's C API +(``MoorDyn_Create``, ``MoorDyn_Init``, ``MoorDyn_Step``, ``MoorDyn_Serialize``), because a host +written for MoorDyn needs the differences below, not only renamed calls. The functions are +those of ABI 1.2: check ``CableDyn_GetAbiMinor() >= 2``. + +The example is the floating box of foamMooring's ``EsfLOWC`` tutorial, +``tests/data/foam_esflowc_box_points.dat``: four slack ``EI = 0`` lines from ``Fixed`` anchors +1 to 4 to ``Coupled`` fairleads 5 to 8. The deck places the fairleads at +:math:`z = -0.062` m; the CFD box starts with them at :math:`z = -0.077` m. + +Step 1: initialise at the host's positions +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + +*MoorDyn.* ``MoorDyn_Create`` parses the input file; ``MoorDyn_Init(X, XD)`` then moves the +coupled points to the host's ``X`` and computes the initial condition there. + +*CableDyn.* ``CableDyn_InitDeckAt(h, deck, deck_len, q0, n_q0, &err)`` does both in one call: it +parses the deck and solves the statics with every line-bound ``Coupled``/``Vessel`` point held at +its entry of ``q0``. ``CableDyn_InitDeck`` solves them at the deck coordinates instead, and a +host whose body starts elsewhere then gives the lines a start-up transient on its first steps. +For the box, the deck statics followed by fairleads held 15 mm lower move line 4's fairlead load +by up to 0.38 N, 74 % of its 0.52 N static value, and it is still 0.04 N off after 1 s +(:math:`\Delta t = 10^{-3}` s). After ``CableDyn_InitDeckAt`` the held fairleads keep their +load to round-off (:math:`2 \times 10^{-16}` N over the same second), and line 4's fairlead load +is the standalone value of the deck moved to the CFD positions, (0.3026, -0.0761, -0.4114) N +(MoorDyn: (0.3034, -0.0763, -0.4136) N). + +``q0`` is one of two vectors; its length selects which: + +* the ``Coupled``/``Vessel`` blocks alone, in coupled-vector order: 3 values per host point. + This is the layout of MoorDyn's ``X`` for a deck whose coupled objects are points that are + all attached to lines (MoorDyn's ``X`` also holds a ``Coupled`` point attached to no line, + which has no block here), and the one a host that knows only its fairleads can build before + any handle exists; +* the full coupled vector, ``CableDyn_NCoupledDOF`` values. Its ``Fixed``, ``Free`` and + ``Connect`` blocks are not read. + +The statics start at rest: there is no counterpart of MoorDyn's ``XD``. A host whose body is +already moving imposes the velocities on the coupled blocks with ``CableDyn_UpdateStates`` +after the initialisation; the line interiors stay at rest. + +Step 2: build the coupled vector from the layout +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + +*MoorDyn.* The coupled vector holds the coupled objects and nothing else: 6 values per coupled +body or cantilevered rod, 3 per pinned rod or coupled point. + +*CableDyn.* On the point route (decks of ``EI = 0`` lines) the vector has a block for every +line-bound point, ``Fixed`` anchors included, in ``POINTS`` order. On the aggregate route +(finite-EI lines, bodies or rods) only the host-driven points have blocks (`Coupled DOF +layout`_). Ask the handle rather than deriving the layout from the deck: + +.. code-block:: c + + int n = CableDyn_NCoupledDOF(h, &err); /* 24 for the box */ + int ids[8], types[8]; /* n / 3 blocks */ + CableDyn_GetCoupledLayout(h, ids, types, n / 3, &err); + +.. list-table:: Coupled vector of the box (point route) + :header-rows: 1 + :widths: 14 18 18 50 + + * - Block ``k`` + - DOFs + - ``point_id[k]`` + - ``point_type[k]`` + * - 0 to 3 + - 0 to 11 + - 1 to 4 + - ``CD_C_POINT_FIXED``: the anchors + * - 4 to 7 + - 12 to 23 + - 5 to 8 + - ``CD_C_POINT_COUPLED``: the fairleads, driven by the host + +Seed ``q``, ``v`` and ``a`` once from ``CableDyn_GetCoupledMotion`` after the initialisation, +and before each step overwrite only the ``CD_C_POINT_COUPLED`` blocks. Every block is +prescribed on every step, so the anchor blocks must keep the values ``GetCoupledMotion`` +returned: zeros there would move the anchors to the origin. ``CableDyn_CalcOutput`` returns a +load for every block, and the anchor blocks carry the anchor reactions, which are not loads on +the host. + +Step 3: step with the motion at the end of the step +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + +*MoorDyn.* ``MoorDyn_Step(X, XD, F, &t, &dt)`` takes the coupled state at the start of the +step, :math:`t`, extrapolates it over the step with ``XD``, and returns the forces at +:math:`t + \Delta t`. + +*CableDyn.* ``CableDyn_Step(h, dt, q, v, a, ...)`` takes the prescribed position, velocity and +acceleration at the end of the step, :math:`t + \Delta t`, and ``CableDyn_CalcOutput`` then +returns the loads at :math:`t + \Delta t`. Pass the host's motion for the new time level (in a +CFD time step, the body's current iterate for it) with a consistent acceleration: the +integrator uses ``v`` and ``a``, not only ``q``. A host without body accelerations can use the +backward difference :math:`a = (v(t + \Delta t) - v(t)) / \Delta t`. + +Step 4: outer correctors save and restore +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + +A host that iterates its time step (PIMPLE outer correctors, predictor-corrector schemes) +advances the mooring once per pass and must rewind it between passes, or the mooring advances +by several steps per host step. + +*MoorDyn.* The host serialises the system at the start of the time step +(``MoorDyn_Serialize``) and deserialises it before every repeated pass. + +*CableDyn.* ``CableDyn_SaveState`` copies the whole model into the handle's single save slot +(every line, point, body and rod state with its solver history); ``CableDyn_RestoreState`` +returns to it. A restore keeps the slot, so one save at the first pass of a time step serves +every later pass. A restore followed by a step is bit-identical to taking that step from the +saved state directly, and any number of steps may lie between the save and the restore (the +sub-steps of Step 6). A successful ``Init*`` call discards the save. + +Key the save on the start time of the pass, :math:`t_{prev} = t - \Delta t`, not on its end +time :math:`t`. Save when a pass starts later than the saved state, which happens once the +previous step has been accepted and the model stands at :math:`t_{prev}`; restore before +every other pass, which starts from the same :math:`t_{prev}` whatever its :math:`\Delta t`. +A host that rejects a step and retries it with a smaller :math:`\Delta t` thus restores: keyed +on :math:`t`, the retry would look like a new step and save a model that the rejected pass has +already advanced. Compare the start times with a tolerance, as foamMooring's +``sixDoFMooringRestraints`` ``moorDynR2`` does (a new step when +:math:`t_{prev} - t_{saved} \ge 10^{-3}\,\Delta t`), since :math:`t - \Delta t` is subject to +round-off. + +The names differ from MoorDyn's file calls: ``MoorDyn_SaveState`` writes the state to a file, +``CableDyn_SaveState`` keeps it in memory. Serialising the state to a caller buffer or a +restart file (``MoorDyn_Serialize``, ``MoorDyn_Save``/``MoorDyn_Load``) is not supported. A +restarted host re-initialises with ``CableDyn_InitDeckAt`` at its restart positions, which +gives the statics there rather than the dynamic state. + +Step 5: sum the loads into a rigid-body force and moment +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + +The sign convention is MoorDyn's: each block of ``coupled_loads`` is the force the lines exert +on that point, in newtons, in global axes (`State, units, and load sign`_). For a rigid body +with reference point :math:`r`, sum the ``CD_C_POINT_COUPLED`` blocks only: + +.. math:: + + F = \sum_k f_k, \qquad M_r = \sum_k (x_k - r) \times f_k + +where :math:`x_k` is the fairlead position the step was taken with. The reference point +depends on the host's restraint: foamMooring's ``moorDynR2`` of ``rigidBodyMooringRestraints`` +in point mode accumulates :math:`x_k \times f_k`, the moment about the global origin +(:math:`r = 0`), while its ``moorDynR2`` of ``sixDoFMooringRestraints`` accumulates +:math:`(x_k - x_{CoR}) \times f_k` about the body's centre of rotation +(:math:`r = x_{CoR}`). Do not add the anchor blocks. + +Step 6: fixed step on the aggregate route +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + +On the point route each ``CableDyn_Step`` takes any :math:`\Delta t > 0`. On the aggregate route +every step must use the deck's ``dtM``: a host step of :math:`m` times ``dtM`` is taken as +:math:`m` calls of ``CableDyn_Step``, with the host-driven motion interpolated linearly between +the start and the end of the host step. One ``CableDyn_SaveState`` before the first sub-step +and one ``CableDyn_RestoreState`` undo all of them. MoorDyn sub-steps internally with its own +``dtM``. + +Step 7: units and frame +~~~~~~~~~~~~~~~~~~~~~~~ + +SI units in the global right-handed frame with z up and still water at :math:`z = 0` +(:doc:`conventions`), as in MoorDyn. A host in another frame or unit system converts the +motion it passes and the loads it receives. + +Call sequence +~~~~~~~~~~~~~ + +The calls a restraint of a CFD rigid-body solver makes, with ``n_fair`` fairleads on one body +whose positions ``x_fair`` (``3 * n_fair`` values in coupled-vector order: on the point route +the deck's ``POINTS`` order of the ``Coupled`` points) the host computes from the body pose: + +.. code-block:: c + + /* First call, the body at its initial pose. */ + CableDyn_Create(&h, &err); + CableDyn_InitDeckAt(h, deck, (int)strlen(deck), x_fair, 3 * n_fair, &err); + n = CableDyn_NCoupledDOF(h, &err); + CableDyn_GetCoupledLayout(h, ids, types, n / 3, &err); /* host blocks: CD_C_POINT_COUPLED */ + CableDyn_GetCoupledMotion(h, q, v, a, n, &err); /* seed every block */ + t_saved = -HUGE_VAL; /* nothing saved yet */ + + /* Every call: a pass of the host time step from t_prev = t - dt to t. */ + if (t_prev - t_saved >= 1.0e-3 * dt) { /* a new step: the model is at t_prev */ + CableDyn_SaveState(h, &err); + t_saved = t_prev; + } else { /* a repeated pass from t_saved, any dt */ + CableDyn_RestoreState(h, &err); + } + /* the fairlead motion at t (the END of the step) into the host blocks, in layout order */ + for (j = 0, k = 0; k < n / 3; ++k) { + if (types[k] != CD_C_POINT_COUPLED) continue; + for (c = 0; c < 3; ++c) { + q[3 * k + c] = x_fair[3 * j + c]; + v[3 * k + c] = v_fair[3 * j + c]; + a[3 * k + c] = a_fair[3 * j + c]; + } + ++j; + } + CableDyn_Step(h, dt, q, v, a, n, &converged, &stalled, &n_iter, &err); + CableDyn_CalcOutput(h, f, n, &err); + /* F = sum of f over the host blocks; M = sum of (x - r) x f over the same blocks */ + + /* End of the run. */ + CableDyn_Close(&h, &err); + +Check ``err`` after every call. On the aggregate route, replace the single ``CableDyn_Step`` +by the sub-steps of Step 6. + Function reference ------------------ @@ -620,8 +866,9 @@ but the C ABI writes no output files. rods, with their lines) runs on the same coupled aggregate as the OpenFAST module, with these differences from the point-system decks: -* the coupled DOFs are the ``x, y, z`` of the deck's ``Coupled``/``Vessel`` points only, in deck - order (anchors are not part of the vector); the bodies and rods are integrated internally; +* the coupled DOFs are the ``x, y, z`` of the deck's ``Coupled``/``Vessel`` points only, in + the order of `Coupled DOF layout`_ (anchors are not part of the vector); the bodies and + rods are integrated internally; * the deck must declare ``dtM``, and every ``CableDyn_Step`` must use that ``dt``; * the run is in still water: deck waves or currents are rejected, and ``CableDyn_UpdatePointFluidFields`` and ``CableDyn_CalcOutputDerivatives`` return @@ -1393,6 +1640,7 @@ them all zero. Copies the current coupled motion. Right after ``CableDyn_InitDeck`` this is the static solution: the deck coordinates of every attached point, with zero velocity and acceleration. +After ``CableDyn_InitDeckAt`` the host-driven blocks hold their entries of ``q0`` instead. Use it to seed the host's coupled vectors before the first step. The buffers are set to zero before the copy and stay zero if the call fails. The model is not changed. @@ -1546,6 +1794,146 @@ capacity of a larger buffer, as for the other string arguments. ``token_len`` mu and a token longer than 64 characters (the longest channel name) is rejected with ``CD_C_BAD_INPUT``. +Host coupling calls +~~~~~~~~~~~~~~~~~~~ + +ABI 1 minor extension 2: check ``CableDyn_GetAbiMinor() >= 2`` before calling these. +`Coupling a host (CFD) solver`_ shows how they fit together. + +.. code-block:: c + + #define CD_C_POINT_FIXED 1 + #define CD_C_POINT_COUPLED 2 /* Coupled or Vessel */ + #define CD_C_POINT_FREE 3 + #define CD_C_POINT_CONNECT 4 + + void CableDyn_InitDeckAt(void *handle, const char *deck_path, int deck_path_len, + const double *q0, int n_q0, int *err_stat); + void CableDyn_SaveState(void *handle, int *err_stat); + void CableDyn_RestoreState(void *handle, int *err_stat); + void CableDyn_GetCoupledLayout(void *handle, int *point_id, int *point_type, + int n_block, int *err_stat); + +The ``CD_C_POINT_*`` codes are also the point ``subtype`` of ``CableDyn_GetObjectInfo``. + +**CableDyn_InitDeckAt.** ``CableDyn_InitDeck`` with the static solve at the host's positions of +the coupled points. ``handle``, ``deck_path`` and ``deck_path_len`` are as for +``CableDyn_InitDeck``, and the call takes the same routes, rejects the same decks, and is +serialised and transactional in the same way. + +.. list-table:: + :header-rows: 1 + :widths: 18 8 12 12 12 38 + + * - Argument + - Dir + - C type + - Length + - NULL + - Meaning + * - ``q0`` + - in + - ``const double *`` + - ``n_q0`` + - only if ``n_q0 == 0`` + - host positions [m], interleaved ``x, y, z``: either the ``Coupled``/``Vessel`` blocks + alone, in coupled-vector order, or the full coupled vector (whose ``Fixed``, ``Free`` and + ``Connect`` blocks are not read) + * - ``n_q0`` + - in + - ``int`` + - -- + - -- + - 3 times the number of line-bound ``Coupled``/``Vessel`` points, or + ``CableDyn_NCoupledDOF`` of the new model; 0 for a deck without line-bound + ``Coupled``/``Vessel`` points + +Every line-bound ``Coupled``/``Vessel`` point is placed at its entry of ``q0`` before the static +solve, and the lines, ``Free``/``Connect`` points, bodies and rods are solved in equilibrium with +those points held there. The result equals ``CableDyn_InitDeck`` of the deck with those points +moved to ``q0``. The statics start at rest: every coupled velocity and acceleration is zero, +and ``CableDyn_GetCoupledMotion`` returns ``q0`` in the host-driven blocks. A +``Coupled``/``Vessel`` point referenced by no line has no block and keeps its deck coordinates. +On the aggregate route the two forms of ``q0`` coincide; a point that has two blocks there (a +fairlead shared by an ``EI = 0`` and a finite-EI line) needs the same position in both. + +An ``n_q0`` that is negative, not a multiple of 3, or fits neither form, a ``NULL`` or +non-finite ``q0``, a line's End A moved below its ``Fixed`` End B anchor (on a deck without +``Free`` or ``Connect`` points), and the deck rejections of ``CableDyn_InitDeck`` return +``CD_C_BAD_INPUT``; the diagnostics of a ``q0`` that does not fit the deck call it +``coupled_positions``. A static-solve failure returns ``CD_C_SOLVE_FAIL``. + +**CableDyn_SaveState, CableDyn_RestoreState.** One save slot per handle, for a host's outer +correctors. + +.. list-table:: + :header-rows: 1 + :widths: 26 74 + + * - Function + - Effect + * - ``CableDyn_SaveState`` + - copies the whole model into the slot, replacing any earlier save: every line, point, + body and rod state with its solver history (viscoelastic, Syrope and seabed-friction + states), the point fluid fields of ``CableDyn_UpdatePointFluidFields``, and the + aggregate route's step time + * - ``CableDyn_RestoreState`` + - returns the model to the slot and keeps the slot, so one save serves any number of + restores + +A restore followed by a step is bit-identical to taking that step from the saved state +directly, whatever ran between the save and the restore: the slot is a copy of the model +object, independent of the rollback buffers the steps use internally. The slot follows the +model it was taken from: a successful ``Init*`` call discards it; a failed ``CableDyn_InitDeck`` +or ``CableDyn_InitDeckAt`` keeps it with the model; a failed ``CableDyn_InitLine`` or +``CableDyn_InitLines`` discards it, except on a handle whose model runs on the coupled +aggregate, which stays live with its save (`Calling conventions`_). Both calls return +``CD_C_NOT_INITIALIZED`` before an initialisation, and ``RestoreState`` returns +``CD_C_BAD_INPUT`` when nothing has been saved since the model was initialised. Each call copies +the model, so it allocates memory of the size of the model and costs about as much as copying +it; it does no file I/O and follows the threading rules of the other per-handle calls. On the +aggregate route ``SaveState`` returns ``CD_C_ALLOC_FAIL`` when the slot itself cannot be +allocated, and the handle then holds no save; running out of memory during the copy of the +model, on either route and in either call, aborts the process, as any Fortran assignment of +allocatable data does. There is no serialisation of the state to a caller buffer. + +**CableDyn_GetCoupledLayout.** The owner of each 3-DOF block of the coupled vector. + +.. list-table:: + :header-rows: 1 + :widths: 18 8 12 12 12 38 + + * - Argument + - Dir + - C type + - Length + - NULL + - Meaning + * - ``point_id`` + - out + - ``int *`` + - ``n_block`` + - yes: skipped + - deck point id of block ``k`` (DOFs ``3k`` to ``3k+2``, 0-based) + * - ``point_type`` + - out + - ``int *`` + - ``n_block`` + - yes: skipped + - ``CD_C_POINT_FIXED``, ``_COUPLED``, ``_FREE`` or ``_CONNECT`` + * - ``n_block`` + - in + - ``int`` + - -- + - -- + - must equal ``CableDyn_NCoupledDOF / 3`` + +The host drives the ``CD_C_POINT_COUPLED`` blocks. On the point route the blocks are the +line-bound points of every type in ``POINTS`` order; on the aggregate route they are the +``Coupled``/``Vessel`` points only (`Coupled DOF layout`_). A handle initialised from raw arrays +has no deck points, and the call returns ``CD_C_BAD_INPUT``: its coupled vector is the caller's +own ``fixed_dofs`` list. A wrong ``n_block`` returns ``CD_C_BAD_INPUT``. + Examples -------- diff --git a/doc/coupling_boundary.md b/doc/coupling_boundary.md index 2132e632..15205cb8 100644 --- a/doc/coupling_boundary.md +++ b/doc/coupling_boundary.md @@ -75,7 +75,9 @@ on `t + dt` and the host time grid is unchanged. In OpenFAST the module may adva The public header declares the complete interface of C ABI version 1, including the object queries of its minor extension 1 (ABI 1.1; check `CableDyn_GetAbiMinor() >= 1` before calling -them). Signatures and examples are in the [C API guide](capi.rst). +them) and the host-coupling calls of its minor extension 2 (ABI 1.2; check +`CableDyn_GetAbiMinor() >= 2`). Signatures and examples are in the [C API guide](capi.rst), +whose section "Coupling a host (CFD) solver" gives the call sequence of a CFD host. | Group | Functions | | --- | --- | @@ -86,6 +88,7 @@ them). Signatures and examples are in the [C API guide](capi.rst). | Output | `CableDyn_CalcOutput`, `CableDyn_CalcOutputDerivatives`, `CableDyn_GetCoupledMotion` | | Queries | `CableDyn_NCoupledDOF`, `CableDyn_NPoints`, `CableDyn_NLines`, `CableDyn_GetLastError` | | Object queries (ABI 1.1) | `CableDyn_GetAbiMinor`, `CableDyn_NObjects`, `CableDyn_GetObjectInfo`, `CableDyn_GetLineValues`, `CableDyn_GetPointState`, `CableDyn_GetBodyState`, `CableDyn_GetRodState`, `CableDyn_EvalChannel`: the model's lines, points, bodies and rods, their committed state, and any `OUTPUTS` channel | +| Host coupling (ABI 1.2) | `CableDyn_InitDeckAt` (`CableDyn_InitDeck` with the statics solved at the host's positions of the `Coupled` points), `CableDyn_SaveState`, `CableDyn_RestoreState` (a one-slot in-memory save of the whole model for outer correctors), `CableDyn_GetCoupledLayout` (the deck point id and type of every block of the coupled vector) | Rules shared by every entry point: @@ -96,12 +99,16 @@ Rules shared by every entry point: (up to 1024 characters) and copied by `CableDyn_GetLastError`. - `CableDyn_NPoints` returns the column count expected by `CableDyn_UpdatePointFluidFields`; it can exceed `NCoupledDOF/3` when a deck has output-only fixed or coupled points. -- Initialisation is transactional: a failed call leaves the handle as it was (uninitialised, - or holding its previous model). +- Deck initialisation is transactional: a failed `CableDyn_InitDeck` or `CableDyn_InitDeckAt` + leaves the handle as it was (uninitialised, or holding its previous model and the state + saved for it by `CableDyn_SaveState`). `CableDyn_InitLine` and `CableDyn_InitLines` build the + point model in place: after a failure the handle must be initialised again and its saved + state is discarded, except on a handle whose deck model runs on the coupled aggregate, which + stays live with its saved state. A successful initialisation discards the saved state. The interface ships as the versioned shared library `libcabledyn` (`cabledyn.dll` in an Intel Fortran and MSVC build; CMake target `cabledyn_shared`) with the installed header; it reports -CableDyn 0.1.1 and C ABI version 1, minor extension 1. The Python package uses the same library. +CableDyn 0.1.1 and C ABI version 1, minor extension 2. The Python package uses the same library. ### Concurrency diff --git a/doc/python.rst b/doc/python.rst index 403d56cc..c6def699 100644 --- a/doc/python.rst +++ b/doc/python.rst @@ -772,6 +772,39 @@ motion are rejected in-process (they run in the standalone driver): time-varying kinematics enter through :meth:`~cabledyn.CableDyn.update_point_fluid_fields`, and motion through the coupled kinematics of every step. +A host that moves the ``Coupled`` points from its own body solver starts the model at its +positions and rewinds it between the passes of an iterated time step. The save is keyed on the +start time of the pass, so a pass retried with a smaller ``dt`` restores as well +(:ref:`capi-host-coupling` explains each call and how it differs from MoorDyn): + +.. code-block:: python + + import math + + from cabledyn import CableDyn + + + class Mooring: + def __init__(self, deck, fairleads): + # fairleads: the Coupled points in layout order, flat or (3, n) with n != 3 + self.model = CableDyn() + self.model.init_deck_at(deck, fairleads) + self.q, self.v, self.a = self.model.get_coupled_motion() + self.host = self.model.host_dofs() # the "coupled" blocks of coupled_layout() + self.t_saved = -math.inf # nothing saved yet + + def solve(self, t, dt, x_end, v_end, a_end): + """One pass of the host time step from t - dt to t (flat host motion at t).""" + t_prev = t - dt + if t_prev - self.t_saved >= 1e-3 * dt: # a new step: the model is at t_prev + self.model.save_state() + self.t_saved = t_prev + else: # a repeated pass from the same start time, whatever its dt + self.model.restore_state() + self.q[self.host], self.v[self.host], self.a[self.host] = x_end, v_end, a_end + self.model.step(dt, self.q, self.v, self.a) + return self.model.calc_output()[self.host].reshape(3, -1, order="F") + Objects and output channels ~~~~~~~~~~~~~~~~~~~~~~~~~~~ diff --git a/python/cabledyn/_lib.py b/python/cabledyn/_lib.py index 72a159b8..5495a4b8 100644 --- a/python/cabledyn/_lib.py +++ b/python/cabledyn/_lib.py @@ -175,6 +175,41 @@ def _bind_object_queries() -> bool: _has_object_queries = _bind_object_queries() +# --- ABI 1, minor extension 2: host coupling --------------------------------- +# Initialization at the host's coupled positions, the one-slot state save and +# restore of outer correctors, and the coupled layout query. A library built +# before the extension lacks these symbols and reports ``abi_minor() < 2``. + +#: Minor extension level of ABI 1 this binding uses for the host-coupling calls +#: (the newest extension the binding knows). +HOST_COUPLING_ABI_MINOR = 2 + + +def _bind_host_coupling() -> bool: + try: + init_at = _lib.CableDyn_InitDeckAt + except AttributeError: + return False + init_at.argtypes = [c_void_p, c_char_p, c_int, _DBL, c_int, POINTER(c_int)] + init_at.restype = None + _lib.CableDyn_SaveState.argtypes = [c_void_p, POINTER(c_int)] + _lib.CableDyn_SaveState.restype = None + _lib.CableDyn_RestoreState.argtypes = [c_void_p, POINTER(c_int)] + _lib.CableDyn_RestoreState.restype = None + _lib.CableDyn_GetCoupledLayout.argtypes = [ + c_void_p, + POINTER(c_int), + POINTER(c_int), + c_int, + POINTER(c_int), + ] + _lib.CableDyn_GetCoupledLayout.restype = None + return True + + +_has_host_coupling = _bind_host_coupling() + + def abi_minor() -> int: """The loaded library's ABI 1 extension level (0 before the object queries).""" if not _has_object_queries: diff --git a/python/cabledyn/model.py b/python/cabledyn/model.py index b9a1ee1b..e05e8b24 100644 --- a/python/cabledyn/model.py +++ b/python/cabledyn/model.py @@ -21,7 +21,16 @@ from cabledyn import _lib as _lib_module from cabledyn._lib import _lib from cabledyn.errors import CableDynError, ConvergenceError -from cabledyn.objects import Body, Line, Point, Rod, build_views, eval_channel +from cabledyn.objects import ( + _POINT_KINDS, + Body, + Line, + Point, + PointKind, + Rod, + build_views, + eval_channel, +) __all__ = ["Body", "CableDyn", "CableDynError", "ConvergenceError", "Line", "Point", "Rod"] @@ -138,6 +147,8 @@ def __init__(self, deck: str | os.PathLike[str] | None = None) -> None: self._views = ((), (), (), ()) self._views_valid = False self._time = 0.0 + # the time of the state in the save slot (None: nothing saved since the initialization) + self._saved_time: float | None = None self._deck: Path | None = None status = c_int() _lib.CableDyn_Create(byref(self._handle), byref(status)) @@ -206,10 +217,68 @@ def init_deck(self, deck: str | os.PathLike[str]) -> None: status = c_int() _lib.CableDyn_InitDeck(self._handle, path, len(path), byref(status)) self._check("CableDyn_InitDeck", status.value) - self._generation += 1 - self._views_valid = False - self._time = 0.0 - self._deck = resolved + self._initialized_from(resolved) + + def init_deck_at(self, deck: str | os.PathLike[str], q0: ArrayInput) -> None: + """Initialize from a deck with the statics solved at the host's coupled positions. + + Every line-bound Coupled/Vessel point starts at its entry of ``q0`` instead + of its deck coordinates, and the static equilibrium (lines, Free/Connect + points, bodies, rods) is solved with those points held there, at rest; a + host whose body starts away from the deck coordinates then starts without + a transient. ``q0`` is either the full coupled vector of the deck + (``n_coupled_dof`` values, the layout of :meth:`step`; the Fixed, Free and + Connect blocks are not read) or the Coupled/Vessel blocks alone, in + coupled-vector order (the ``MoorDyn_Init`` layout of a deck whose coupled + objects are points that are all attached to lines: a Coupled point attached + to no line has no block here), flat or column-per-point ``(3, n)`` with + ``n != 3`` (a ``(3, 3)`` array is rejected as ambiguous: pass three points + flat). See :meth:`coupled_layout`. A failed initialization keeps any + previously initialized model and its saved state. + """ + _encode_path(deck) # rejects a NUL before any file-system call + resolved = Path(deck).expanduser().resolve() + path = _encode_path(resolved) + q = _as_real_array(q0, "q0") + if q.ndim == 2 and q.shape == (3, 3): + # three points: column-per-point and row-per-point look alike + raise ValueError( + "q0 of shape (3, 3) is ambiguous (column-per-point or row-per-point); " + "pass it flat, x1 y1 z1 x2 y2 z2 ..." + ) + if q.ndim == 2 and q.shape[0] == 3: + q = np.ascontiguousarray(q.reshape(-1, order="F")) + if q.ndim != 1 or q.size % 3 != 0: + raise ValueError( + f"q0 must be flat (3 * n,) or column-per-point (3, n); got shape {np.shape(q0)}" + ) + if not np.all(np.isfinite(q)): + raise ValueError("q0 must be finite (no NaN or Inf)") + with self._lock: + self._require_host_coupling() + status = c_int() + _lib.CableDyn_InitDeckAt( + self._handle, path, len(path), _dbl_ptr(q), int(q.size), byref(status) + ) + self._check("CableDyn_InitDeckAt", status.value) + self._initialized_from(resolved) + + def _initialized_from(self, deck: Path) -> None: + """Book-keeping after a successful deck initialization (the caller holds the lock).""" + self._generation += 1 + self._views_valid = False + self._time = 0.0 + self._saved_time = None + self._deck = deck + + @staticmethod + def _require_host_coupling() -> None: + if _lib_module.abi_minor() < _lib_module.HOST_COUPLING_ABI_MINOR: + # not a C status: the loaded library lacks the entry points + raise RuntimeError( + "the loaded CableDyn library predates the host-coupling calls " + "(ABI 1 minor extension 2); rebuild it from this checkout" + ) @property def initialized(self) -> bool: @@ -249,7 +318,10 @@ def deck(self) -> Path | None: @property def time(self) -> float: - """Simulation time [s]: 0 after initialization, advanced by every completed step.""" + """Simulation time [s]: 0 after initialization, advanced by every completed step. + + :meth:`restore_state` sets it back to the time of the saved state. + """ with self._lock: return self._time @@ -428,6 +500,82 @@ def calc_output(self) -> FloatArray: self._check("CableDyn_CalcOutput", status.value) return loads + # -- host coupling: outer correctors and the coupled layout ------------------- + + def save_state(self) -> None: + """Save the whole model and :attr:`time` into the handle's single save slot. + + The slot is a deep copy of the model (every line, point, body and rod + state with its solver history), replacing any earlier save. A successful + initialization discards it and a failed one keeps it with the model, so one + save serves every outer corrector of a host time step (see + :meth:`restore_state`). Save when a host time step starts after the + previous one was accepted, and restore on every repeated pass from the + same start time, whatever its ``dt``. + """ + with self._lock: + self._require_host_coupling() + status = c_int() + _lib.CableDyn_SaveState(self._handle, byref(status)) + if status.value != 0: + self._saved_time = None # a failed save leaves no save in the slot + self._check("CableDyn_SaveState", status.value) + self._saved_time = self._time + + def restore_state(self) -> None: + """Return the model and :attr:`time` to the last :meth:`save_state`. + + The save is kept, so the call can be repeated. A restore followed by a + step is bit-identical to taking that step from the saved state directly. + Raises :class:`CableDynError` when nothing was saved since the model was + initialized. + """ + with self._lock: + self._require_host_coupling() + status = c_int() + _lib.CableDyn_RestoreState(self._handle, byref(status)) + self._check("CableDyn_RestoreState", status.value) + if self._saved_time is not None: + self._time = self._saved_time + + def coupled_layout(self) -> tuple[tuple[int, PointKind], ...]: + """The owner of each 3-DOF block of the coupled vector, as ``(point_id, kind)``. + + Block ``k`` holds DOFs ``3k .. 3k+2`` of the vectors :meth:`step`, + :meth:`get_coupled_motion` and :meth:`calc_output` use; ``kind`` is + ``"fixed"``, ``"coupled"`` (Coupled or Vessel), ``"free"`` or + ``"connect"``. On a point-system deck every line-bound point has a block, + in deck POINTS order; on the coupled aggregate (finite-EI lines, bodies or + rods) only the Coupled points do. The host drives the ``"coupled"`` + blocks (:meth:`host_dofs`). + """ + with self._lock: + self._require_host_coupling() + nb = self.n_coupled_dof // 3 + ids = np.zeros(max(nb, 1), dtype=np.intc) + kinds = np.zeros(max(nb, 1), dtype=np.intc) + status = c_int() + _lib.CableDyn_GetCoupledLayout( + self._handle, + ids.ctypes.data_as(POINTER(c_int)), + kinds.ctypes.data_as(POINTER(c_int)), + nb, + byref(status), + ) + self._check("CableDyn_GetCoupledLayout", status.value) + return tuple((int(ids[k]), _POINT_KINDS.get(int(kinds[k]), "fixed")) for k in range(nb)) + + def host_dofs(self) -> npt.NDArray[np.intp]: + """Indices of the coupled DOFs the host drives (the ``"coupled"`` blocks). + + With ``x`` the ``(3, n)`` host positions of those points in layout order, + ``q[model.host_dofs()] = x.reshape(-1, order="F")`` fills them in a full + coupled vector ``q`` taken from :meth:`get_coupled_motion`. + """ + layout = self.coupled_layout() + blocks = [k for k, (_, kind) in enumerate(layout) if kind == "coupled"] + return np.array([3 * k + c for k in blocks for c in range(3)], dtype=np.intp) + def update_point_fluid_fields( self, fluid_velocity: ArrayInput, diff --git a/python/tests/test_host_coupling.py b/python/tests/test_host_coupling.py new file mode 100644 index 00000000..1c104f57 --- /dev/null +++ b/python/tests/test_host_coupling.py @@ -0,0 +1,210 @@ +# SPDX-License-Identifier: Apache-2.0 +"""Host coupling (C ABI 1 minor extension 2): init at host positions, save/restore, layout. + +The point-route deck is the foamMooring EsfLOWC box (four slack EI=0 lines), whose +fairleads sit at z = -0.062 m in the deck while the CFD box starts with them at +z = -0.077 m. The aggregate-route deck is an EI=0 chain plus a finite-EI cable. +""" + +from __future__ import annotations + +from pathlib import Path + +import numpy as np +import pytest + +try: + import cabledyn._lib # loads the shared library +except (ImportError, OSError) as exc: # a missing library raises OSError + pytest.skip(f"CableDyn shared library not available: {exc}", allow_module_level=True) + +import cabledyn +from cabledyn import _lib +from cabledyn.errors import CableDynError +from cabledyn.model import CableDyn + +DATA = Path(__file__).resolve().parents[2] / "tests" / "data" +BOX = DATA / "foam_esflowc_box_points.dat" +MIXED = DATA / "host_coupling_chain_cable.dat" + +#: The box fairleads (points 5-8) at the CFD start height, column per point. +BOX_FAIRLEADS = np.array( + [[-0.1, 0.1, -0.077], [-0.1, -0.1, -0.077], [0.1, 0.1, -0.077], [0.1, -0.1, -0.077]] +).T + + +def _motion(model: CableDyn, q0: np.ndarray, amp: float, t: float): + """A smooth surge/heave of the host-driven blocks about q0 at time t.""" + w = 2.0 * np.pi + q, v, a = q0.copy(), np.zeros_like(q0), np.zeros_like(q0) + dofs = model.host_dofs().reshape(-1, 3) + q[dofs[:, 0]] += amp * np.sin(w * t) + v[dofs[:, 0]] = amp * w * np.cos(w * t) + a[dofs[:, 0]] = -amp * w * w * np.sin(w * t) + q[dofs[:, 2]] += 0.5 * amp * (1.0 - np.cos(w * t)) + v[dofs[:, 2]] = 0.5 * amp * w * np.sin(w * t) + a[dofs[:, 2]] = 0.5 * amp * w * w * np.cos(w * t) + return q, v, a + + +def test_abi_minor_reports_the_host_coupling_extension(): + assert _lib.HOST_COUPLING_ABI_MINOR == 2 + assert _lib.abi_minor() == cabledyn.abi_minor() == _lib.HOST_COUPLING_ABI_MINOR + + +def test_point_route_layout(): + with CableDyn(BOX) as model: + layout = model.coupled_layout() + assert layout == tuple((p, "fixed") for p in (1, 2, 3, 4)) + tuple( + (p, "coupled") for p in (5, 6, 7, 8) + ) + assert model.host_dofs().tolist() == list(range(12, 24)) + + +def test_init_deck_at_host_positions_has_no_transient(): + with CableDyn() as model: + model.init_deck_at(BOX, BOX_FAIRLEADS) + assert model.n_coupled_dof == 24 + q, v, a = model.get_coupled_motion() + assert np.array_equal(q[model.host_dofs()], BOX_FAIRLEADS.reshape(-1, order="F")) + assert not v.any() and not a.any() + f0 = model.calc_output() + # line 4's fairlead: the standalone statics of the deck moved to z = -0.077 + np.testing.assert_allclose(f0[21:24], [0.3026, -0.0761, -0.4114], atol=1.0e-4) + for _ in range(200): + model.step(1.0e-3, q, v, a) + assert np.max(np.abs(model.calc_output() - f0)) < 1.0e-9 + assert model.time == pytest.approx(0.2) + + # the same statics from the full coupled vector (the Fixed blocks are not read) + full = q.copy() + full[:12] = 1.0e3 + with CableDyn() as other: + other.init_deck_at(BOX, full) + assert np.array_equal(other.calc_output(), f0) + + # InitDeck at the deck positions rings when the host holds the fairleads lower + with CableDyn(BOX) as plain: + peak = 0.0 + for _ in range(200): + plain.step(1.0e-3, q, v, a) + peak = max(peak, float(np.max(np.abs(plain.calc_output() - f0)))) + assert peak > 1.0e-2 + + +def test_point_route_order_follows_the_points_table(tmp_path): + """Coupled rows listed before the Fixed ones: the blocks follow the POINTS table order.""" + lines = BOX.read_text(encoding="utf-8").splitlines() + rows = [i for i, ln in enumerate(lines) if ln.split()[:2] in (["1", "Fixed"], ["5", "Coupled"])] + fixed_at, coupled_at = rows[0], rows[1] + reordered = ( + lines[:fixed_at] + + lines[coupled_at : coupled_at + 4] + + lines[fixed_at : fixed_at + 4] + + lines[coupled_at + 4 :] + ) + deck = tmp_path / "box_reordered.dat" + deck.write_text("\n".join(reordered) + "\n", encoding="utf-8") + with CableDyn() as model: + model.init_deck_at(deck, BOX_FAIRLEADS) + assert model.coupled_layout() == tuple((p, "coupled") for p in (5, 6, 7, 8)) + tuple( + (p, "fixed") for p in (1, 2, 3, 4) + ) + assert model.host_dofs().tolist() == list(range(12)) + f = model.calc_output() + # line 4's fairlead (point 8) is block 3 now + np.testing.assert_allclose(f[9:12], [0.3026, -0.0761, -0.4114], atol=1.0e-4) + + +def test_init_deck_at_rejections_keep_the_model(): + with CableDyn(BOX) as model: + before = model.calc_output() + with pytest.raises(CableDynError, match="coupled_positions"): + model.init_deck_at(BOX, BOX_FAIRLEADS[:, :3].reshape(-1, order="F")) + with pytest.raises(ValueError, match="ambiguous"): + model.init_deck_at(BOX, BOX_FAIRLEADS[:, :3]) + with pytest.raises(ValueError, match="finite"): + model.init_deck_at(BOX, np.full(12, np.nan)) + with pytest.raises(ValueError, match="3 \\* n"): + model.init_deck_at(BOX, np.zeros(13)) + assert np.array_equal(model.calc_output(), before) + + +@pytest.mark.parametrize( + ("deck", "q_host", "dt", "amp"), + [(BOX, BOX_FAIRLEADS, 1.0e-3, 0.005), (MIXED, None, 0.01, 0.2)], + ids=["point-route", "aggregate-route"], +) +def test_save_restore_is_bit_identical(deck, q_host, dt, amp): + with CableDyn(deck) as model, CableDyn(deck) as ref: + if q_host is not None: + model.init_deck_at(deck, q_host) + ref.init_deck_at(deck, q_host) + q0, _, _ = model.get_coupled_motion() + with pytest.raises(CableDynError, match="no state has been saved"): + model.restore_state() + model.save_state() + for corrector in (1, 2): # two outer correctors that try other motions + for s in range(1, 6): + model.step(dt, *_motion(model, q0, 2.0 * corrector * amp, s * dt)) + model.restore_state() + assert model.time == 0.0 + for s in range(1, 8): + motion = _motion(model, q0, amp, s * dt) + model.step(dt, *motion) + ref.step(dt, *motion) + assert np.array_equal(model.calc_output(), ref.calc_output()) + for x, y in zip(model.get_coupled_motion(), ref.get_coupled_motion(), strict=True): + assert np.array_equal(x, y) + for line, line_ref in zip(model.lines, ref.lines, strict=True): + assert np.array_equal(line.node_positions(), line_ref.node_positions()) + assert model.time == pytest.approx(ref.time) + # a new initialization discards the save + model.init_deck(deck) + with pytest.raises(CableDynError, match="no state has been saved"): + model.restore_state() + + +def test_a_failed_initialization_keeps_the_save(tmp_path): + """A failed init_deck/init_deck_at keeps the model and its save; restore still works.""" + dt = 1.0e-3 + with CableDyn() as model, CableDyn() as ref: + model.init_deck_at(BOX, BOX_FAIRLEADS) + ref.init_deck_at(BOX, BOX_FAIRLEADS) + q0, _, _ = model.get_coupled_motion() + model.save_state() + model.step(dt, *_motion(model, q0, 0.02, dt)) + with pytest.raises(CableDynError): + model.init_deck(tmp_path / "missing.dat") + with pytest.raises(CableDynError, match="coupled_positions"): + model.init_deck_at(BOX, BOX_FAIRLEADS[:, :2]) + with pytest.raises(ValueError, match="column-per-point"): + model.init_deck_at(BOX, BOX_FAIRLEADS.T) # (4, 3): row per point + model.restore_state() + assert model.time == 0.0 + for s in range(1, 4): + motion = _motion(model, q0, 0.005, s * dt) + model.step(dt, *motion) + ref.step(dt, *motion) + assert np.array_equal(model.calc_output(), ref.calc_output()) + + +def test_aggregate_layout_holds_only_the_coupled_points(): + with CableDyn(MIXED) as model: + assert model.coupled_layout() == ((2, "coupled"), (4, "coupled")) + assert model.host_dofs().tolist() == list(range(6)) + + +def test_an_uninitialized_handle_has_nothing_to_save(): + with CableDyn() as model: + with pytest.raises(CableDynError, match="NOT_INITIALIZED"): + model.save_state() + + +def test_an_old_library_fails_clearly(monkeypatch): + monkeypatch.setattr(_lib, "abi_minor", lambda: 1) + with CableDyn(BOX) as model: + with pytest.raises(RuntimeError, match="predates the host-coupling calls"): + model.save_state() + with pytest.raises(RuntimeError, match="predates the host-coupling calls"): + model.init_deck_at(BOX, BOX_FAIRLEADS) diff --git a/python/tests/test_objects.py b/python/tests/test_objects.py index acb791b0..1eadb457 100644 --- a/python/tests/test_objects.py +++ b/python/tests/test_objects.py @@ -431,7 +431,8 @@ def test_unbound_handle_and_raw_lines(monkeypatch, tmp_path): def test_abi_minor_is_reported(): - assert _lib.abi_minor() == _lib.OBJECT_QUERY_ABI_MINOR == cabledyn.abi_minor() == 1 + assert _lib.OBJECT_QUERY_ABI_MINOR == 1 + assert _lib.abi_minor() == cabledyn.abi_minor() == _lib.HOST_COUPLING_ABI_MINOR == 2 assert objects_module.OBJ_ROD == 4 diff --git a/release/check_release_metadata.py b/release/check_release_metadata.py index 208ebfe0..919255ce 100644 --- a/release/check_release_metadata.py +++ b/release/check_release_metadata.py @@ -139,7 +139,7 @@ def main() -> int: "C header ABI minor level": f"CABLEDYN_CAPI_ABI_MINOR {abi_minor}" in read( "src/CableDyn_CAPI.h" ), - "Python ABI minor level": f"OBJECT_QUERY_ABI_MINOR = {abi_minor}" in read( + "Python ABI minor level": f"HOST_COUPLING_ABI_MINOR = {abi_minor}" in read( "python/cabledyn/_lib.py" ), "C header ABI version": f"CABLEDYN_CAPI_ABI_VERSION {abi_version}" in read( diff --git a/src/CableDyn_CAPI.f90 b/src/CableDyn_CAPI.f90 index 2bdec470..7f50c96f 100644 --- a/src/CableDyn_CAPI.f90 +++ b/src/CableDyn_CAPI.f90 @@ -32,7 +32,8 @@ MODULE CableDyn_CAPI CD_FAST_NOT_INITIALIZED, CD_FAST_ALLOCFAIL, CD_FAST_UpdatePointFluidFields USE CableDyn_OpenFAST_HermiteFMF, ONLY: CD_HFMF_ModuleType USE CableDyn_Precision, ONLY: wp, CD_ZERO - USE CableDyn_System, ONLY: CD_SystemType, CD_System_Line_NDOF + USE CableDyn_System, ONLY: CD_SystemType, CD_System_Line_NDOF, CD_Get_System_PointBlocks, CD_SYSTEM_OK, & + CD_POINT_COUPLED IMPLICIT NONE PRIVATE @@ -62,6 +63,10 @@ MODULE CableDyn_CAPI PUBLIC :: CableDyn_GetBodyState PUBLIC :: CableDyn_GetRodState PUBLIC :: CableDyn_EvalChannel + PUBLIC :: CableDyn_InitDeckAt + PUBLIC :: CableDyn_SaveState + PUBLIC :: CableDyn_RestoreState + PUBLIC :: CableDyn_GetCoupledLayout INTEGER(C_INT), PARAMETER :: CD_C_OK = 0_C_INT INTEGER(C_INT), PARAMETER :: CD_C_BAD_HANDLE = 1_C_INT @@ -74,8 +79,9 @@ MODULE CableDyn_CAPI INTEGER(C_INT), PARAMETER :: CD_C_VERSION_PATCH = 1_C_INT INTEGER(C_INT), PARAMETER :: CD_C_ABI_VERSION = 1_C_INT CHARACTER(*), PARAMETER :: CD_C_VERSION_STRING = 'CableDyn 0.1.1 C-ABI 1' - !> Minor extension level of ABI 1: 1 adds the in-process object queries. - INTEGER(C_INT), PARAMETER :: CD_C_ABI_MINOR = 1_C_INT + !> Minor extension level of ABI 1: 1 adds the in-process object queries, 2 the host-coupling + !> calls (initialization at host positions, state save/restore, the coupled layout query). + INTEGER(C_INT), PARAMETER :: CD_C_ABI_MINOR = 2_C_INT !> Object kinds of CableDyn_NObjects / CableDyn_GetObjectInfo. INTEGER(C_INT), PARAMETER :: CD_C_OBJ_LINE = 1_C_INT, CD_C_OBJ_POINT = 2_C_INT, CD_C_OBJ_BODY = 3_C_INT, & CD_C_OBJ_ROD = 4_C_INT @@ -156,6 +162,15 @@ END FUNCTION cabledyn_blas_threads_once LOGICAL, ALLOCATABLE :: pt_is_cable(:) INTEGER, ALLOCATABLE :: pt_obj(:) TYPE(CD_HFMF_ModuleType), ALLOCATABLE :: no_cables(:) + ! The single save slot of CableDyn_SaveState/RestoreState: a deep copy of the route's model + ! object (the point system, or the aggregate on the heap) and the aggregate's committed time, + ! valid (has_saved) from a SaveState until a successful initialization or a failed + ! InitLine/InitLines on a handle whose live model is a point system (drop_point_save_on_failure); + ! a failed InitDeck/InitDeckAt, or a failed InitLine/InitLines on an aggregate handle, keeps it. + LOGICAL :: has_saved = .FALSE. + TYPE(CD_FAST_ModuleType) :: saved_fast + TYPE(CD_AGG_ModuleType), ALLOCATABLE :: saved_agg + REAL(wp) :: saved_agg_t = CD_ZERO CHARACTER(CD_C_MSG_LEN) :: last_error = '' END TYPE CD_C_Handle @@ -225,15 +240,66 @@ SUBROUTINE CableDyn_InitDeck(handle, deck_path_ptr, deck_path_len, err_stat) BIN IF (.NOT. blas_runtime_ready(handle, 'CableDyn_InitDeck', err_stat)) RETURN CALL cabledyn_input_lock() - CALL init_deck_serialised(handle, deck_path_ptr, deck_path_len, err_stat) + CALL init_deck_serialised(handle, deck_path_ptr, deck_path_len, 'CableDyn_InitDeck', err_stat) CALL cabledyn_input_unlock() END SUBROUTINE CableDyn_InitDeck - SUBROUTINE init_deck_serialised(handle, deck_path_ptr, deck_path_len, err_stat) - !! CableDyn_InitDeck body; the caller holds the process-wide input lock. + SUBROUTINE CableDyn_InitDeckAt(handle, deck_path_ptr, deck_path_len, q0_ptr, n_q0, err_stat) & + BIND(C, NAME='CableDyn_InitDeckAt') + !! CableDyn_InitDeck with the static solve at the host's positions of the coupled points: + !! every line-bound Coupled/Vessel point starts at its entry of q0 instead of its deck + !! coordinates, and the statics (lines, Free/Connect points, bodies and rods) are solved + !! with those points held there, at rest. q0 is either the full coupled vector of the + !! deck's route (n_q0 = CableDyn_NCoupledDOF after the call; the Fixed, Free and Connect + !! blocks are not read) or the Coupled/Vessel blocks alone, in coupled-vector order. A + !! deck without line-bound Coupled/Vessel points takes n_q0 = 0 (q0 may then be null). + !! Serialised process-wide and transactional like CableDyn_InitDeck. + TYPE(C_PTR), VALUE :: handle, deck_path_ptr, q0_ptr + INTEGER(C_INT), VALUE :: deck_path_len, n_q0 + INTEGER(C_INT), INTENT(OUT) :: err_stat + TYPE(CD_C_Handle), POINTER :: h + REAL(C_DOUBLE), POINTER :: q0_c(:) + REAL(wp), ALLOCATABLE :: positions(:, :) + INTEGER :: stat + + IF (.NOT. blas_runtime_ready(handle, 'CableDyn_InitDeckAt', err_stat)) RETURN + err_stat = validate_handle(handle, h) + IF (err_stat /= CD_C_OK) RETURN + IF (n_q0 < 0_C_INT .OR. MOD(n_q0, 3_C_INT) /= 0_C_INT) THEN + CALL set_status(h, CD_C_BAD_INPUT, 'CableDyn_InitDeckAt: n_q0 must be a non-negative multiple of 3', & + err_stat) + RETURN + END IF + IF (n_q0 > 0_C_INT .AND. .NOT. C_ASSOCIATED(q0_ptr)) THEN + CALL set_status(h, CD_C_BAD_INPUT, 'CableDyn_InitDeckAt: q0 pointer is null', err_stat) + RETURN + END IF + ALLOCATE (positions(3, INT(n_q0)/3), STAT=stat) + IF (stat /= 0) THEN + CALL set_status(h, CD_C_ALLOC_FAIL, 'CableDyn_InitDeckAt: q0 allocation failed', err_stat) + RETURN + END IF + IF (n_q0 > 0_C_INT) THEN + CALL C_F_POINTER(q0_ptr, q0_c, [INT(n_q0)]) + IF (.NOT. ALL(IEEE_IS_FINITE(q0_c))) THEN + CALL set_status(h, CD_C_BAD_INPUT, 'CableDyn_InitDeckAt: q0 must be finite', err_stat) + RETURN + END IF + positions = RESHAPE(REAL(q0_c, wp), SHAPE(positions)) + END IF + CALL cabledyn_input_lock() + CALL init_deck_serialised(handle, deck_path_ptr, deck_path_len, 'CableDyn_InitDeckAt', err_stat, positions) + CALL cabledyn_input_unlock() + END SUBROUTINE CableDyn_InitDeckAt + + SUBROUTINE init_deck_serialised(handle, deck_path_ptr, deck_path_len, caller, err_stat, positions) + !! CableDyn_InitDeck / CableDyn_InitDeckAt body; the caller holds the process-wide input + !! lock. positions (3, n): the host positions of CableDyn_InitDeckAt. TYPE(C_PTR), VALUE :: handle, deck_path_ptr INTEGER(C_INT), VALUE :: deck_path_len + CHARACTER(*), INTENT(IN) :: caller INTEGER(C_INT), INTENT(OUT) :: err_stat + REAL(wp), INTENT(IN), OPTIONAL :: positions(:, :) TYPE(CD_C_Handle), POINTER :: h TYPE(CD_FAST_ModuleType) :: new_fast @@ -248,20 +314,19 @@ SUBROUTINE init_deck_serialised(handle, deck_path_ptr, deck_path_len, err_stat) err_stat = validate_handle(handle, h) IF (err_stat /= CD_C_OK) RETURN IF (deck_path_len < 1_C_INT .OR. .NOT. C_ASSOCIATED(deck_path_ptr)) THEN - CALL set_status(h, CD_C_BAD_INPUT, 'CableDyn_InitDeck: deck path pointer is null or length is non-positive', & - err_stat) + CALL set_status(h, CD_C_BAD_INPUT, caller//': deck path pointer is null or length is non-positive', err_stat) RETURN END IF CALL C_F_POINTER(deck_path_ptr, path_c, [INT(deck_path_len)]) ALLOCATE (CHARACTER(LEN=INT(deck_path_len)) :: deck_path, STAT=stat) IF (stat /= 0) THEN - CALL set_status(h, CD_C_ALLOC_FAIL, 'CableDyn_InitDeck: deck path allocation failed', err_stat) + CALL set_status(h, CD_C_ALLOC_FAIL, caller//': deck path allocation failed', err_stat) RETURN END IF DO i = 1, INT(deck_path_len) IF (path_c(i) == C_NULL_CHAR) THEN IF (i == 1) THEN - CALL set_status(h, CD_C_BAD_INPUT, 'CableDyn_InitDeck: deck path is empty', err_stat) + CALL set_status(h, CD_C_BAD_INPUT, caller//': deck path is empty', err_stat) RETURN END IF deck_path = deck_path(:i - 1) @@ -275,55 +340,124 @@ SUBROUTINE init_deck_serialised(handle, deck_path_ptr, deck_path_len, err_stat) CALL CD_Deck_Query_dtM(TRIM(deck_path), dtm, has_dtm, es, em, standalone_scan=.TRUE., n_bodies_rods=n_objects, & n_finite_ei=n_finite) IF (es == CD_DECKDRV_OK .AND. (n_objects > 0 .OR. n_finite > 0)) THEN - CALL init_deck_aggregate(h, TRIM(deck_path), has_dtm, dtm, err_stat) + CALL init_deck_aggregate(h, TRIM(deck_path), has_dtm, dtm, caller, err_stat, positions) RETURN END IF - CALL CD_Init_Deck_System(TRIM(deck_path), new_fast%system, dtm, gravity, rho_water, es, em, line_ids=line_ids) + ! An absent positions argument stays absent through the optional coupled_positions. + CALL CD_Init_Deck_System(TRIM(deck_path), new_fast%system, dtm, gravity, rho_water, es, em, line_ids=line_ids, & + coupled_positions=positions) IF (es /= CD_DECKDRV_OK) THEN CALL map_deck_status(es, err_stat) - CALL store_status(h, err_stat, 'CableDyn_InitDeck: '//TRIM(em)) + CALL store_status(h, err_stat, caller//': '//TRIM(em)) CALL CD_FAST_End(new_fast, end_es, end_em) RETURN END IF + IF (PRESENT(positions)) THEN + CALL check_point_start(new_fast, positions, em) + IF (LEN_TRIM(em) > 0) THEN + CALL set_status(h, CD_C_BAD_INPUT, caller//': '//TRIM(em), err_stat) + CALL CD_FAST_End(new_fast, end_es, end_em) + RETURN + END IF + END IF CALL CD_FAST_End(h%fast, end_es, end_em) h%fast = new_fast CALL CD_FAST_End(new_fast, end_es, end_em) CALL drop_aggregate(h) + CALL drop_saved_state(h) CALL set_point_line_map(h, line_ids) CALL store_status(h, CD_C_OK, '') err_stat = CD_C_OK END SUBROUTINE init_deck_serialised - SUBROUTINE init_deck_aggregate(h, deck_path, has_dtm, dtm, err_stat) + SUBROUTINE check_point_start(fast, positions, msg) + !! Post-condition of CableDyn_InitDeckAt on the point route: every Coupled block of the new + !! system starts at its host position (msg is blank when it does). positions holds either + !! one column per coupled block or one per Coupled block (apply_point_system_positions). + TYPE(CD_FAST_ModuleType), INTENT(IN) :: fast + REAL(wp), INTENT(IN) :: positions(:, :) + CHARACTER(*), INTENT(OUT) :: msg + INTEGER, ALLOCATABLE :: blocks(:) + REAL(wp), ALLOCATABLE :: q(:), v(:), a(:) + INTEGER :: k, col, n, es, stat + LOGICAL :: full + CHARACTER(CD_C_MSG_LEN) :: em + + msg = '' + n = CD_FAST_NCoupledDOF(fast, es, em) + IF (es /= CD_FAST_OK) THEN + msg = 'the coupled vector of the new model is unavailable: '//TRIM(em) + RETURN + END IF + CALL CD_Get_System_PointBlocks(fast%system, blocks, es, em) + IF (es /= CD_SYSTEM_OK .OR. .NOT. ALLOCATED(blocks)) THEN + msg = 'the coupled layout of the new model is unavailable' + RETURN + END IF + ALLOCATE (q(n), v(n), a(n), STAT=stat) + IF (stat /= 0) THEN + msg = 'workspace allocation failed' + RETURN + END IF + CALL CD_FAST_GetCoupledMotion(fast, q, v, a, es, em) + IF (es /= CD_FAST_OK) THEN + msg = 'the coupled motion of the new model is unavailable: '//TRIM(em) + RETURN + END IF + full = SIZE(positions, 2) == SIZE(blocks) + col = 0 + DO k = 1, SIZE(blocks) + IF (full) col = col + 1 + IF (fast%system%points(blocks(k))%point_type /= CD_POINT_COUPLED) CYCLE + IF (.NOT. full) col = col + 1 + IF (.NOT. same_position(q(3*k - 2:3*k), positions(:, col))) THEN + msg = 'coupled point '//TRIM(int_text(fast%system%points(blocks(k))%id))//' did not start at its '// & + 'position in q0' + RETURN + END IF + END DO + END SUBROUTINE check_point_start + + PURE LOGICAL FUNCTION same_position(x, y) RESULT(same) + !! Two coupled-point positions agree to 1e-9 relative (1e-9 m below 1 m). + REAL(wp), INTENT(IN) :: x(3), y(3) + same = ALL(ABS(x - y) <= 1.0e-9_wp*MAX(1.0_wp, ABS(y))) + END FUNCTION same_position + + SUBROUTINE init_deck_aggregate(h, deck_path, has_dtm, dtm, caller, err_stat, positions) !! Build a BODIES/RODS deck on the coupled aggregate (transactional: the handle keeps its !! previous model on failure). Coupled/Vessel rods and bodies are 6-DOF host nodes, which the !! translational C ABI cannot drive; the standalone deck rules already reject them without a - !! motionFile, and the aggregate rejects a motionFile. + !! motionFile, and the aggregate rejects a motionFile. positions (3, n_moving): the host + !! positions of CableDyn_InitDeckAt, in the aggregate's coupled order. TYPE(CD_C_Handle), POINTER, INTENT(INOUT) :: h CHARACTER(*), INTENT(IN) :: deck_path LOGICAL, INTENT(IN) :: has_dtm REAL(wp), INTENT(IN) :: dtm + CHARACTER(*), INTENT(IN) :: caller INTEGER(C_INT), INTENT(OUT) :: err_stat + REAL(wp), INTENT(IN), OPTIONAL :: positions(:, :) ! On the heap: InitDeck runs on the host's thread, whose stack size the host chooses. TYPE(CD_AGG_ModuleType), ALLOCATABLE :: new_agg - INTEGER :: es, nm, stat + INTEGER :: es, nm, stat, k REAL(wp), ALLOCATABLE :: pos(:, :), vel(:, :), acc(:, :), load(:, :) CHARACTER(CD_C_MSG_LEN) :: em IF (.NOT. (has_dtm .AND. dtm > CD_ZERO)) THEN - CALL set_status(h, CD_C_BAD_INPUT, 'CableDyn_InitDeck: a deck with finite-EI lines, BODIES or RODS '// & + CALL set_status(h, CD_C_BAD_INPUT, caller//': a deck with finite-EI lines, BODIES or RODS '// & 'needs dtM, the fixed step of CableDyn_Step', err_stat) RETURN END IF ALLOCATE (new_agg, STAT=stat) IF (stat /= 0) THEN - CALL set_status(h, CD_C_ALLOC_FAIL, 'CableDyn_InitDeck: aggregate allocation failed', err_stat) + CALL set_status(h, CD_C_ALLOC_FAIL, caller//': aggregate allocation failed', err_stat) RETURN END IF - CALL CD_AGG_Init_From_Deck(new_agg, deck_path, dtm, es, em) + ! An absent positions argument stays absent through the optional coupled_positions. + CALL CD_AGG_Init_From_Deck(new_agg, deck_path, dtm, es, em, coupled_positions=positions) IF (es /= CD_AGG_OK) THEN CALL map_agg_status(es, err_stat) - CALL store_status(h, err_stat, 'CableDyn_InitDeck: '//TRIM(em)) + CALL store_status(h, err_stat, caller//': '//TRIM(em)) CALL CD_AGG_End(new_agg, es, em) RETURN END IF @@ -333,11 +467,37 @@ SUBROUTINE init_deck_aggregate(h, deck_path, has_dtm, dtm, err_stat) ALLOCATE (pos(3, nm), vel(3, nm), acc(3, nm), load(3, nm), STAT=stat) IF (stat /= 0) THEN CALL CD_AGG_End(new_agg, es, em) - CALL set_status(h, CD_C_ALLOC_FAIL, 'CableDyn_InitDeck: aggregate workspace allocation failed', err_stat) + CALL set_status(h, CD_C_ALLOC_FAIL, caller//': aggregate workspace allocation failed', err_stat) RETURN END IF + IF (PRESENT(positions)) THEN + ! Post-condition: every moving point starts at its host position. A point that appears + ! in two blocks (a fairlead shared by an EI=0 line and a finite-EI line) takes the + ! position of its last block, so two different entries for it are rejected here. + CALL CD_AGG_GetMovingPointMesh(new_agg, pos, vel, acc, load, es, em) + IF (es == CD_AGG_OK .AND. SIZE(positions, 2) == nm) THEN + DO k = 1, nm + IF (.NOT. same_position(pos(:, k), positions(:, k))) THEN + es = CD_AGG_BADINPUT + em = 'coupled block '//TRIM(int_text(k - 1))//' did not start at its position in q0 (a point '// & + 'listed in two blocks needs the same position in both)' + EXIT + END IF + END DO + ELSE IF (es == CD_AGG_OK) THEN + es = CD_AGG_BADINPUT + em = 'q0 does not match the coupled vector of the new model' + END IF + IF (es /= CD_AGG_OK) THEN + CALL map_agg_status(es, err_stat) + CALL store_status(h, err_stat, caller//': '//TRIM(em)) + CALL CD_AGG_End(new_agg, es, em) + RETURN + END IF + END IF CALL CD_FAST_End(h%fast, es, em) CALL drop_aggregate(h) + CALL drop_saved_state(h) CALL clear_c_workspace(h) CALL MOVE_ALLOC(pos, h%agg_pos) CALL MOVE_ALLOC(vel, h%agg_vel) @@ -357,11 +517,46 @@ SUBROUTINE move_aggregate(src, dst) TYPE(CD_AGG_ModuleType), INTENT(INOUT) :: src, dst INTEGER :: es CHARACTER(CD_C_MSG_LEN) :: em - CALL CD_AGG_End(dst, es, em) - dst = src + CALL copy_aggregate(src, dst) CALL CD_AGG_End(src, es, em) END SUBROUTINE move_aggregate + SUBROUTINE copy_aggregate(src, dst) + !! Replace dst by a deep copy of src: every allocatable component (each sub-model's state, + !! histories, snapshot buffers and solver workspace) is copied, so the copy evolves + !! exactly as src would. Dummy arguments, so the assignment needs no temporary. + TYPE(CD_AGG_ModuleType), INTENT(IN) :: src + TYPE(CD_AGG_ModuleType), INTENT(INOUT) :: dst + INTEGER :: es + CHARACTER(CD_C_MSG_LEN) :: em + CALL CD_AGG_End(dst, es, em) + dst = src + END SUBROUTINE copy_aggregate + + SUBROUTINE copy_point_system(src, dst) + !! The point-route twin of copy_aggregate. + TYPE(CD_FAST_ModuleType), INTENT(IN) :: src + TYPE(CD_FAST_ModuleType), INTENT(INOUT) :: dst + INTEGER :: es + CHARACTER(CD_C_MSG_LEN) :: em + CALL CD_FAST_End(dst, es, em) + dst = src + END SUBROUTINE copy_point_system + + SUBROUTINE drop_saved_state(h) + !! Discard the save slot (a new initialization replaces the model it belongs to). + TYPE(CD_C_Handle), POINTER, INTENT(INOUT) :: h + INTEGER :: es + CHARACTER(CD_C_MSG_LEN) :: em + IF (ALLOCATED(h%saved_agg)) THEN + CALL CD_AGG_End(h%saved_agg, es, em) + DEALLOCATE (h%saved_agg) + END IF + CALL CD_FAST_End(h%saved_fast, es, em) + h%saved_agg_t = CD_ZERO + h%has_saved = .FALSE. + END SUBROUTINE drop_saved_state + SUBROUTINE drop_aggregate(h) !! Release the aggregate route of a handle (another initialization replaces it). TYPE(CD_C_Handle), POINTER, INTENT(INOUT) :: h @@ -402,13 +597,29 @@ SUBROUTINE CableDyn_InitLine(handle, n_nodes, n_elem, q0_ptr, v0_ptr, elem_conn_ REAL(C_DOUBLE), VALUE :: rho_inf INTEGER(C_INT), INTENT(OUT) :: err_stat - IF (.NOT. blas_runtime_ready(handle, 'CableDyn_InitLine', err_stat)) RETURN - CALL cabledyn_input_lock() - CALL init_line_serialised(handle, n_nodes, n_elem, q0_ptr, v0_ptr, elem_conn_ptr, l0_ptr, ea_ptr, rho_a_ptr, & - fixed_dofs_ptr, n_fixed, tension_only, rho_inf, err_stat) - CALL cabledyn_input_unlock() + IF (blas_runtime_ready(handle, 'CableDyn_InitLine', err_stat)) THEN + CALL cabledyn_input_lock() + CALL init_line_serialised(handle, n_nodes, n_elem, q0_ptr, v0_ptr, elem_conn_ptr, l0_ptr, ea_ptr, rho_a_ptr, & + fixed_dofs_ptr, n_fixed, tension_only, rho_inf, err_stat) + CALL cabledyn_input_unlock() + END IF + CALL drop_point_save_on_failure(handle, err_stat) END SUBROUTINE CableDyn_InitLine + SUBROUTINE drop_point_save_on_failure(handle, err_stat) + !! After a failed CableDyn_InitLine/InitLines the save slot follows the live model. These + !! calls rebuild the point system in place, so a handle whose live model is that point + !! system must be initialized again and loses the state saved for it. On a handle whose live + !! model is an aggregate (a deck with finite-EI lines, bodies or rods), the failure leaves + !! the aggregate live (use_agg is cleared only on success) and the save with it. + TYPE(C_PTR), VALUE :: handle + INTEGER(C_INT), INTENT(IN) :: err_stat + TYPE(CD_C_Handle), POINTER :: h + IF (err_stat == CD_C_OK) RETURN + IF (validate_handle(handle, h) /= CD_C_OK) RETURN + IF (.NOT. h%use_agg) CALL drop_saved_state(h) + END SUBROUTINE drop_point_save_on_failure + SUBROUTINE init_line_serialised(handle, n_nodes, n_elem, q0_ptr, v0_ptr, elem_conn_ptr, l0_ptr, ea_ptr, & rho_a_ptr, fixed_dofs_ptr, n_fixed, tension_only, rho_inf, err_stat) !! CableDyn_InitLine body; the caller holds the process-wide input lock. @@ -497,6 +708,7 @@ SUBROUTINE init_line_serialised(handle, n_nodes, n_elem, q0_ptr, v0_ptr, elem_co CALL map_fast_status(es, err_stat) IF (err_stat == CD_C_OK) THEN CALL drop_aggregate(h) + CALL drop_saved_state(h) CALL set_point_line_map(h, [1]) CALL store_status(h, err_stat, '') ELSE @@ -519,12 +731,14 @@ SUBROUTINE CableDyn_InitLines(handle, n_lines, n_nodes_ptr, n_elem_ptr, n_fixed_ REAL(C_DOUBLE), VALUE :: rho_inf INTEGER(C_INT), INTENT(OUT) :: err_stat - IF (.NOT. blas_runtime_ready(handle, 'CableDyn_InitLines', err_stat)) RETURN - CALL cabledyn_input_lock() - CALL init_lines_serialised(handle, n_lines, n_nodes_ptr, n_elem_ptr, n_fixed_ptr, q0_ptr, v0_ptr, & - elem_conn_ptr, l0_ptr, ea_ptr, rho_a_ptr, fixed_dofs_ptr, & - coupled_map_ptr, n_coupled_map, tension_only, rho_inf, err_stat) - CALL cabledyn_input_unlock() + IF (blas_runtime_ready(handle, 'CableDyn_InitLines', err_stat)) THEN + CALL cabledyn_input_lock() + CALL init_lines_serialised(handle, n_lines, n_nodes_ptr, n_elem_ptr, n_fixed_ptr, q0_ptr, v0_ptr, & + elem_conn_ptr, l0_ptr, ea_ptr, rho_a_ptr, fixed_dofs_ptr, & + coupled_map_ptr, n_coupled_map, tension_only, rho_inf, err_stat) + CALL cabledyn_input_unlock() + END IF + CALL drop_point_save_on_failure(handle, err_stat) END SUBROUTINE CableDyn_InitLines SUBROUTINE init_lines_serialised(handle, n_lines, n_nodes_ptr, n_elem_ptr, n_fixed_ptr, q0_ptr, v0_ptr, & @@ -692,6 +906,7 @@ SUBROUTINE init_lines_serialised(handle, n_lines, n_nodes_ptr, n_elem_ptr, n_fix CALL map_fast_status(es, err_stat) IF (err_stat == CD_C_OK) THEN CALL drop_aggregate(h) + CALL drop_saved_state(h) CALL set_point_line_map(h, [(i, i=1, INT(n_lines))]) CALL store_status(h, err_stat, '') ELSE @@ -1092,6 +1307,7 @@ SUBROUTINE CableDyn_Close(handle, err_stat) BIND(C, NAME='CableDyn_Close') h%magic = 0_INT64 CALL CD_FAST_End(h%fast, es, em) CALL drop_aggregate(h) + CALL drop_saved_state(h) CALL clear_c_workspace(h) DEALLOCATE (h) handle = C_NULL_PTR @@ -1527,6 +1743,170 @@ SUBROUTINE CableDyn_EvalChannel(handle, token_ptr, token_len, value, err_stat) B CALL store_status(h, CD_C_OK, '') END SUBROUTINE CableDyn_EvalChannel + ! --------------------------------------------------------------------------------------- + ! Host coupling (C ABI 1, minor extension 2): CableDyn_InitDeckAt (above, with InitDeck), + ! the one-slot state save/restore a host's outer correctors (PIMPLE, predictor-corrector) + ! rewind with, and the owner of each block of the coupled vector. + ! --------------------------------------------------------------------------------------- + + SUBROUTINE CableDyn_SaveState(handle, err_stat) BIND(C, NAME='CableDyn_SaveState') + !! Save the whole model into the handle's single save slot, replacing any earlier save: + !! every line, point, body and rod state with its solver history (viscoelastic, Syrope and + !! friction states, the last converged step), the point fluid fields, and on the aggregate + !! route the committed time. The slot holds a deep copy of the model object, independent of + !! the step's own rollback buffers, so any number of steps may follow before the restore. + !! A successful Init* call discards the slot; a failed InitDeck/InitDeckAt keeps it with the + !! model, and a failed InitLine/InitLines discards it unless the handle's live model is an + !! aggregate (drop_point_save_on_failure). Only the allocation of the aggregate slot itself + !! returns CD_C_ALLOC_FAIL (the handle then holds no save); running out of memory inside + !! the copy, an intrinsic assignment of allocatable components, aborts the process. + TYPE(C_PTR), VALUE :: handle + INTEGER(C_INT), INTENT(OUT) :: err_stat + TYPE(CD_C_Handle), POINTER :: h + INTEGER :: stat + + IF (.NOT. query_ready(handle, h, 'CableDyn_SaveState', err_stat)) RETURN + ! the slot is invalid while it is overwritten, and stays so if its allocation fails + h%has_saved = .FALSE. + IF (h%use_agg) THEN + IF (.NOT. ALLOCATED(h%saved_agg)) THEN + ! On the heap, as the live aggregate: the host chooses this thread's stack size. + ALLOCATE (h%saved_agg, STAT=stat) + IF (stat /= 0) THEN + CALL set_status(h, CD_C_ALLOC_FAIL, 'CableDyn_SaveState: save slot allocation failed', err_stat) + RETURN + END IF + END IF + CALL copy_aggregate(h%agg, h%saved_agg) + h%saved_agg_t = h%agg_t + ELSE + CALL copy_point_system(h%fast, h%saved_fast) + END IF + h%has_saved = .TRUE. + CALL store_status(h, CD_C_OK, '') + err_stat = CD_C_OK + END SUBROUTINE CableDyn_SaveState + + SUBROUTINE CableDyn_RestoreState(handle, err_stat) BIND(C, NAME='CableDyn_RestoreState') + !! Return the model to the last CableDyn_SaveState. The slot is kept, so one save serves any + !! number of restores (one per outer corrector). A restore followed by a step is + !! bit-identical to taking that step from the saved state without the intervening steps. + TYPE(C_PTR), VALUE :: handle + INTEGER(C_INT), INTENT(OUT) :: err_stat + TYPE(CD_C_Handle), POINTER :: h + + IF (.NOT. query_ready(handle, h, 'CableDyn_RestoreState', err_stat)) RETURN + IF (.NOT. h%has_saved) THEN + CALL set_status(h, CD_C_BAD_INPUT, 'CableDyn_RestoreState: no state has been saved since the model was '// & + 'initialized', err_stat) + RETURN + END IF + IF (h%use_agg) THEN + CALL copy_aggregate(h%saved_agg, h%agg) + h%agg_t = h%saved_agg_t + ELSE + CALL copy_point_system(h%saved_fast, h%fast) + END IF + CALL store_status(h, CD_C_OK, '') + err_stat = CD_C_OK + END SUBROUTINE CableDyn_RestoreState + + SUBROUTINE CableDyn_GetCoupledLayout(handle, point_id_ptr, point_type_ptr, n_block, err_stat) & + BIND(C, NAME='CableDyn_GetCoupledLayout') + !! The owner of each 3-DOF block of the coupled vector: block k (0-based, DOFs 3k .. 3k+2) + !! moves deck point point_id[k], of type point_type[k] (1 Fixed, 2 Coupled/Vessel, 3 Free, + !! 4 Connect). The host drives the type-2 blocks; the others take the values last returned + !! by CableDyn_GetCoupledMotion. n_block must equal CableDyn_NCoupledDOF / 3; a null pointer + !! skips that output. A raw-array handle has no deck points (its coupled vector is the + !! caller's own fixed-DOF list) and is rejected with CD_C_BAD_INPUT. + TYPE(C_PTR), VALUE :: handle, point_id_ptr, point_type_ptr + INTEGER(C_INT), VALUE :: n_block + INTEGER(C_INT), INTENT(OUT) :: err_stat + TYPE(CD_C_Handle), POINTER :: h + INTEGER(C_INT), POINTER :: out_c(:) + INTEGER, ALLOCATABLE :: ids(:), types(:) + + IF (.NOT. query_ready(handle, h, 'CableDyn_GetCoupledLayout', err_stat)) RETURN + CALL coupled_layout(h, ids, types, err_stat) + IF (err_stat /= CD_C_OK) RETURN + IF (INT(n_block) /= SIZE(ids)) THEN + CALL set_status(h, CD_C_BAD_INPUT, 'CableDyn_GetCoupledLayout: n_block does not match '// & + 'CableDyn_NCoupledDOF / 3', err_stat) + RETURN + END IF + IF (SIZE(ids) > 0 .AND. C_ASSOCIATED(point_id_ptr)) THEN + CALL C_F_POINTER(point_id_ptr, out_c, [SIZE(ids)]) + out_c = INT(ids, C_INT) + END IF + IF (SIZE(ids) > 0 .AND. C_ASSOCIATED(point_type_ptr)) THEN + CALL C_F_POINTER(point_type_ptr, out_c, [SIZE(types)]) + out_c = INT(types, C_INT) + END IF + CALL store_status(h, CD_C_OK, '') + END SUBROUTINE CableDyn_GetCoupledLayout + + SUBROUTINE coupled_layout(h, ids, types, err_stat) + !! Deck point id and point type (the CD_POINT_* codes) of each coupled block. Point route: + !! the line-bound points of every type in deck POINT order. Aggregate route: the moving + !! points, i.e. the EI=0-bound Coupled/Vessel points in deck POINT order, then the fairlead + !! (End A, which the coupled cable builder requires to be Coupled/Vessel) of each finite-EI + !! line in deck LINE order. + TYPE(CD_C_Handle), POINTER, INTENT(INOUT) :: h + INTEGER, ALLOCATABLE, INTENT(OUT) :: ids(:), types(:) + INTEGER(C_INT), INTENT(OUT) :: err_stat + INTEGER, ALLOCATABLE :: blocks(:) + INTEGER :: es, i, k, nm, nsys + CHARACTER(CD_C_MSG_LEN) :: em + + err_stat = CD_C_OK + IF (.NOT. h%use_agg) THEN + CALL CD_Get_System_PointBlocks(h%fast%system, blocks, es, em) + IF (es /= CD_SYSTEM_OK) THEN + CALL set_status(h, CD_C_SOLVE_FAIL, 'CableDyn_GetCoupledLayout: '//TRIM(em), err_stat) + RETURN + END IF + IF (.NOT. ALLOCATED(blocks)) THEN + CALL set_status(h, CD_C_BAD_INPUT, 'CableDyn_GetCoupledLayout: a handle initialized from raw arrays '// & + 'has no deck points; its coupled vector is the caller''s fixed-DOF list', err_stat) + RETURN + END IF + IF (ANY(blocks < 1)) THEN + CALL set_status(h, CD_C_SOLVE_FAIL, 'CableDyn_GetCoupledLayout: a coupled block has no owning point', & + err_stat) + RETURN + END IF + ALLOCATE (ids(SIZE(blocks)), types(SIZE(blocks))) + ids = h%fast%system%points(blocks)%id + types = h%fast%system%points(blocks)%point_type + RETURN + END IF + nm = CD_AGG_NMovingPoints(h%agg, es, em) + nsys = 0 + IF (h%agg%has_sys) nsys = h%agg%ncp_sys + IF (es /= CD_AGG_OK .OR. nm /= nsys + h%agg%ncable) THEN + CALL set_status(h, CD_C_SOLVE_FAIL, 'CableDyn_GetCoupledLayout: the moving points of the model are not '// & + 'its Coupled points and cable fairleads', err_stat) + RETURN + END IF + ALLOCATE (ids(nm), types(nm)) + IF (nsys > 0) THEN + CALL CD_Get_System_PointBlocks(h%agg%sys%fast%system, blocks, es, em) + IF (es /= CD_SYSTEM_OK .OR. .NOT. ALLOCATED(blocks)) THEN + CALL set_status(h, CD_C_SOLVE_FAIL, 'CableDyn_GetCoupledLayout: the system layout is unavailable', err_stat) + RETURN + END IF + DO i = 1, nsys + k = blocks(h%agg%sys%moving_blocks(i)) + ids(i) = h%agg%sys%fast%system%points(k)%id + types(i) = h%agg%sys%fast%system%points(k)%point_type + END DO + END IF + DO i = 1, h%agg%ncable + ids(nsys + i) = h%agg%cable_points(1, i) + types(nsys + i) = CD_POINT_COUPLED + END DO + END SUBROUTINE coupled_layout + LOGICAL FUNCTION query_ready(handle, h, caller, err_stat) RESULT(ready) !! Validate the handle of an object query and require an initialized model. TYPE(C_PTR), VALUE :: handle diff --git a/src/CableDyn_CAPI.h b/src/CableDyn_CAPI.h index bc504883..31253a3a 100644 --- a/src/CableDyn_CAPI.h +++ b/src/CableDyn_CAPI.h @@ -18,17 +18,18 @@ * J[i + j*n] = d(load_i)/d(q_j). * - Diagnostics are retained per handle (up to 1024 characters) and copied by * CableDyn_GetLastError, truncated to message_len - 1 and NUL-terminated. - * - Create and Close are thread-safe. InitDeck, InitLine, and InitLines are - * serialised process-wide (they parse files through the Fortran runtime), so - * concurrent initialisations of distinct handles succeed one after another. - * The remaining per-handle calls run concurrently on distinct handles. A - * handle must not be used by two threads at once, and must not be used while - * another thread closes it. + * - Create and Close are thread-safe. InitDeck, InitDeckAt, InitLine, and + * InitLines are serialised process-wide (they parse files through the Fortran + * runtime), so concurrent initialisations of distinct handles succeed one + * after another. The remaining per-handle calls run concurrently on distinct + * handles. A handle must not be used by two threads at once, and must not be + * used while another thread closes it. * - The first Create applies the BLAS thread policy (one OpenBLAS thread unless * the environment variable CABLEDYN_BLAS_THREADS says otherwise) and, in the * Windows GNU build, loads openblas.dll. When that runtime cannot be loaded, - * InitDeck, InitLine and InitLines return CD_C_ALLOC_FAIL and GetLastError names - * the library, the locations tried and the Windows load error. + * InitDeck, InitDeckAt, InitLine and InitLines return CD_C_ALLOC_FAIL and + * GetLastError names the library, the locations tried and the Windows load + * error. */ #ifndef CABLEDYN_CAPI_H #define CABLEDYN_CAPI_H @@ -125,8 +126,9 @@ int CableDyn_NLines(void *handle, int *err_stat); * output. A deck with finite-EI lines, BODIES or RODS runs on the coupled * aggregate (it needs dtM); other decks keep the point route. Check * CableDyn_GetAbiMinor() >= 1 before using these on a library of unknown - * vintage. */ -#define CABLEDYN_CAPI_ABI_MINOR 1 + * vintage. CABLEDYN_CAPI_ABI_MINOR is the extension level this header + * declares (2: the host-coupling calls below are present too). */ +#define CABLEDYN_CAPI_ABI_MINOR 2 #define CD_C_OBJ_LINE 1 #define CD_C_OBJ_POINT 2 @@ -173,6 +175,43 @@ void CableDyn_GetRodState(void *handle, int index, double *nodes, int n_nodes, void CableDyn_EvalChannel(void *handle, const char *token, int token_len, double *value, int *err_stat); +/* ---- ABI 1, minor extension 2: host coupling -------------------------------- + * + * For a host (a CFD solver) that drives the Coupled points of a deck. Check + * CableDyn_GetAbiMinor() >= 2 before using these on a library of unknown + * vintage. doc/capi.rst, "Coupling a host (CFD) solver", gives the call + * sequence. */ + +/* Point types of CableDyn_GetCoupledLayout (and of the point subtype of + * CableDyn_GetObjectInfo). The host drives the CD_C_POINT_COUPLED blocks. */ +#define CD_C_POINT_FIXED 1 +#define CD_C_POINT_COUPLED 2 /* Coupled or Vessel */ +#define CD_C_POINT_FREE 3 +#define CD_C_POINT_CONNECT 4 + +/* CableDyn_InitDeck with the static solve at the host's positions: every + * line-bound Coupled/Vessel point starts at its entry of q0 (statics at rest). + * q0 is either the full coupled vector of the deck's route (n_q0 = + * CableDyn_NCoupledDOF after the call; Fixed, Free and Connect blocks are not + * read) or the Coupled/Vessel blocks alone, in coupled-vector order. n_q0 = 0 + * (q0 may be NULL) for a deck without line-bound Coupled/Vessel points. */ +void CableDyn_InitDeckAt(void *handle, const char *deck_path, int deck_path_len, + const double *q0, int n_q0, int *err_stat); +/* One save slot per handle: SaveState copies the whole model (replacing an + * earlier save); RestoreState returns to it and keeps it, so one save serves + * every outer corrector of a host time step. A restore followed by a step is + * bit-identical to stepping from the saved state. A successful Init* call + * discards the save; a failed InitDeck/InitDeckAt keeps it with the model; a + * failed InitLine/InitLines discards it, except on a handle whose deck model + * runs on the coupled aggregate, which stays live with its save. */ +void CableDyn_SaveState(void *handle, int *err_stat); +void CableDyn_RestoreState(void *handle, int *err_stat); +/* Owner of each 3-DOF block k of the coupled vector (DOFs 3k..3k+2): deck + * point id and CD_C_POINT_* type. n_block = CableDyn_NCoupledDOF / 3; NULL + * skips an output. Not available on a raw-array (InitLine/InitLines) handle. */ +void CableDyn_GetCoupledLayout(void *handle, int *point_id, int *point_type, + int n_block, int *err_stat); + #ifdef __cplusplus } #endif diff --git a/src/CableDyn_DeckDriver.f90 b/src/CableDyn_DeckDriver.f90 index dbc3a5a1..ce5edfed 100644 --- a/src/CableDyn_DeckDriver.f90 +++ b/src/CableDyn_DeckDriver.f90 @@ -1073,7 +1073,7 @@ SUBROUTINE CD_Init_Deck_Models(deck_path, models, ErrStat, ErrMsg) END SUBROUTINE CD_Init_Deck_Models SUBROUTINE CD_Init_Deck_System(deck_path, system, dtM, gravity, rho_water, ErrStat, ErrMsg, caller_driven, & - env_gravity, env_rho_water, env_wtrdpth, line_ids) + env_gravity, env_rho_water, env_wtrdpth, line_ids, coupled_positions) !! Parse a supported EI=0 deck and initialize one persistent multi-line !! CableDyn system with product-facing points and endpoint bindings. !! caller_driven (default .FALSE.): the host marches the system, so the deck's @@ -1084,6 +1084,8 @@ SUBROUTINE CD_Init_Deck_System(deck_path, system, dtM, gravity, rho_water, ErrSt !! host values override deck-declared ones); a deck-declared bathymetryFile !! keeps its structured seabed over the host's flat depth. !! line_ids: the deck id of each system line (system line order = deck order). + !! coupled_positions (3, n): the host's positions of the line-bound Coupled/Vessel + !! points, placed before the static solve (layout: apply_point_system_positions). CHARACTER(*), INTENT(IN) :: deck_path TYPE(CD_SystemType), INTENT(INOUT) :: system REAL(wp), INTENT(OUT) :: dtM, gravity, rho_water @@ -1092,6 +1094,7 @@ SUBROUTINE CD_Init_Deck_System(deck_path, system, dtM, gravity, rho_water, ErrSt LOGICAL, INTENT(IN), OPTIONAL :: caller_driven REAL(wp), INTENT(IN), OPTIONAL :: env_gravity, env_rho_water, env_wtrdpth INTEGER, ALLOCATABLE, INTENT(OUT), OPTIONAL :: line_ids(:) + REAL(wp), INTENT(IN), OPTIONAL :: coupled_positions(:, :) TYPE(DeckLineType), ALLOCATABLE :: types(:) TYPE(DeckBody), ALLOCATABLE :: bodies(:) @@ -1150,6 +1153,12 @@ SUBROUTINE CD_Init_Deck_System(deck_path, system, dtM, gravity, rho_water, ErrSt CALL fail(ErrStat, ErrMsg, 'CD_Init_Deck_System does not support motionFile point-system initialization') RETURN END IF + IF (PRESENT(coupled_positions)) THEN + CALL apply_point_system_positions(points, lines, coupled_positions, ErrStat, ErrMsg) + IF (ErrStat /= CD_DECKDRV_OK) RETURN + CALL revalidate_ptfm_points(points, lines, ErrStat, ErrMsg, origin='coupled_positions') + IF (ErrStat /= CD_DECKDRV_OK) RETURN + END IF IF (opts%has_bathymetry_file) THEN CALL load_bathymetry_file(path_join(deck_dir(deck_path), opts%bathymetry_file), bathymetry, ErrStat, ErrMsg, & points=points) @@ -6429,7 +6438,7 @@ SUBROUTINE CD_Init_Deck_Aggregate(deck_path, dt, agg, ErrStat, ErrMsg, env_gravi IF (PRESENT(coupled_positions)) THEN CALL apply_coupled_positions(points, lines, is_fin, coupled_positions, ptfm_init, ErrStat, ErrMsg) IF (ErrStat /= CD_DECKDRV_OK) RETURN - CALL revalidate_ptfm_points(points, lines, ErrStat, ErrMsg) + CALL revalidate_ptfm_points(points, lines, ErrStat, ErrMsg, origin='coupled_positions') IF (ErrStat /= CD_DECKDRV_OK) RETURN END IF @@ -31840,23 +31849,80 @@ SUBROUTINE apply_coupled_positions(points, lines, is_fin, coupled_positions, ptf END IF END SUBROUTINE apply_coupled_positions - SUBROUTINE revalidate_ptfm_points(points, lines, ErrStat, ErrMsg) + SUBROUTINE apply_point_system_positions(points, lines, coupled_positions, ErrStat, ErrMsg) + !! Place the host-driven points of a point-system deck at the host's positions before + !! the static solve. The columns follow the point-system coupled vector, whose blocks are + !! the line-bound points of every type in deck POINT order. coupled_positions holds either + !! one column per line-bound point (the full coupled vector; only the Coupled/Vessel + !! columns are read, the Fixed, Free and Connect columns are not) or one column per + !! line-bound Coupled/Vessel point (those columns only, in the same order). The column + !! count selects the form; when every line-bound point is Coupled/Vessel the two agree. + !! Fails closed on a shape or count mismatch and on non-finite input. + TYPE(DeckPoint), INTENT(INOUT) :: points(:) + TYPE(DeckLine), INTENT(IN) :: lines(:) + REAL(wp), INTENT(IN) :: coupled_positions(:, :) + INTEGER, INTENT(OUT) :: ErrStat + CHARACTER(*), INTENT(OUT) :: ErrMsg + + INTEGER :: i, icol, n_bound, n_host + LOGICAL :: full + LOGICAL, ALLOCATABLE :: bound(:), host(:) + CHARACTER(12) :: t1, t2, t3 + + ErrStat = CD_DECKDRV_OK + ErrMsg = '' + IF (SIZE(coupled_positions, 1) /= 3) THEN + CALL fail(ErrStat, ErrMsg, 'coupled_positions must be shaped (3, n)'); RETURN + END IF + IF (.NOT. ALL(IEEE_IS_FINITE(coupled_positions))) THEN + CALL fail(ErrStat, ErrMsg, 'coupled_positions must be finite'); RETURN + END IF + ALLOCATE (bound(SIZE(points)), host(SIZE(points))) + DO i = 1, SIZE(points) + bound(i) = ANY(lines(:)%nodeA == points(i)%id) .OR. ANY(lines(:)%nodeB == points(i)%id) + host(i) = bound(i) .AND. (TRIM(points(i)%ptype) == 'coupled' .OR. TRIM(points(i)%ptype) == 'vessel') + END DO + n_bound = COUNT(bound) + n_host = COUNT(host) + full = SIZE(coupled_positions, 2) == n_bound + IF (.NOT. full .AND. SIZE(coupled_positions, 2) /= n_host) THEN + WRITE (t1, '(I0)') SIZE(coupled_positions, 2) + WRITE (t2, '(I0)') n_bound + WRITE (t3, '(I0)') n_host + CALL fail(ErrStat, ErrMsg, 'coupled_positions has '//TRIM(t1)//' points; the deck has '//TRIM(t2)// & + ' line-bound points (the coupled vector), '//TRIM(t3)//' of them Coupled/Vessel'); RETURN + END IF + icol = 0 + DO i = 1, SIZE(points) + IF (full .AND. bound(i)) icol = icol + 1 + IF (.NOT. host(i)) CYCLE + IF (.NOT. full) icol = icol + 1 + points(i)%pos = coupled_positions(:, icol) + END DO + END SUBROUTINE apply_point_system_positions + + SUBROUTINE revalidate_ptfm_points(points, lines, ErrStat, ErrMsg, origin) !! Re-establish the parse's position-dependent contracts on ptfm_init-displaced !! geometry (the transform runs after finalize_and_validate, so without this a !! displaced deck could hand the static builders geometry the undisplaced deck !! would have failed closed on): every point position stays finite, and on a !! static deck no LINE's fairlead-side End A ends up below its Fixed End B anchor - !! (the ordering contract the catenary seeding relies on). + !! (the ordering contract the catenary seeding relies on). origin names the input + !! that moved the points in the diagnostics (default 'ptfm_init'). TYPE(DeckPoint), INTENT(IN) :: points(:) TYPE(DeckLine), INTENT(IN) :: lines(:) INTEGER, INTENT(OUT) :: ErrStat CHARACTER(*), INTENT(OUT) :: ErrMsg + CHARACTER(*), INTENT(IN), OPTIONAL :: origin INTEGER :: i, ia, ib + CHARACTER(32) :: what ErrStat = CD_DECKDRV_OK ErrMsg = '' + what = 'ptfm_init' + IF (PRESENT(origin)) what = origin DO i = 1, SIZE(points) IF (.NOT. ALL(IEEE_IS_FINITE(points(i)%pos))) THEN - CALL fail(ErrStat, ErrMsg, 'ptfm_init produced a non-finite point position'); RETURN + CALL fail(ErrStat, ErrMsg, TRIM(what)//' produced a non-finite point position'); RETURN END IF END DO IF (deck_has_dynamic_points(points)) RETURN @@ -31866,7 +31932,7 @@ SUBROUTINE revalidate_ptfm_points(points, lines, ErrStat, ErrMsg) IF (ia == 0 .OR. ib == 0) CYCLE ! endpoint resolution already validated by the parse IF (TRIM(points(ib)%ptype) == 'fixed') THEN IF (points(ia)%pos(3) < points(ib)%pos(3)) THEN - CALL fail(ErrStat, ErrMsg, 'ptfm_init displaces a LINE End A fairlead (NodeA) below its '// & + CALL fail(ErrStat, ErrMsg, TRIM(what)//' displaces a LINE End A fairlead (NodeA) below its '// & 'Fixed End B anchor (NodeB)'); RETURN END IF END IF diff --git a/src/cabledyn.def b/src/cabledyn.def index 34764f5a..9d2679d4 100644 --- a/src/cabledyn.def +++ b/src/cabledyn.def @@ -8,6 +8,7 @@ EXPORTS CableDyn_EvalChannel CableDyn_GetAbiMinor CableDyn_GetBodyState + CableDyn_GetCoupledLayout CableDyn_GetCoupledMotion CableDyn_GetLastError CableDyn_GetLineValues @@ -17,6 +18,7 @@ EXPORTS CableDyn_GetVersion CableDyn_GetVersionString CableDyn_InitDeck + CableDyn_InitDeckAt CableDyn_InitLine CableDyn_InitLines CableDyn_IsInitialized @@ -24,6 +26,8 @@ EXPORTS CableDyn_NLines CableDyn_NObjects CableDyn_NPoints + CableDyn_RestoreState + CableDyn_SaveState CableDyn_Step CableDyn_UpdatePointFluidFields CableDyn_UpdateStates diff --git a/src/cabledyn.exp b/src/cabledyn.exp index 275e4c6e..945fcb2f 100644 --- a/src/cabledyn.exp +++ b/src/cabledyn.exp @@ -7,6 +7,7 @@ _CableDyn_Create _CableDyn_EvalChannel _CableDyn_GetAbiMinor _CableDyn_GetBodyState +_CableDyn_GetCoupledLayout _CableDyn_GetCoupledMotion _CableDyn_GetLastError _CableDyn_GetLineValues @@ -16,6 +17,7 @@ _CableDyn_GetRodState _CableDyn_GetVersion _CableDyn_GetVersionString _CableDyn_InitDeck +_CableDyn_InitDeckAt _CableDyn_InitLine _CableDyn_InitLines _CableDyn_IsInitialized @@ -23,6 +25,8 @@ _CableDyn_NCoupledDOF _CableDyn_NLines _CableDyn_NObjects _CableDyn_NPoints +_CableDyn_RestoreState +_CableDyn_SaveState _CableDyn_Step _CableDyn_UpdatePointFluidFields _CableDyn_UpdateStates diff --git a/src/cabledyn.map b/src/cabledyn.map index 08a9fe06..125f69b0 100644 --- a/src/cabledyn.map +++ b/src/cabledyn.map @@ -10,6 +10,7 @@ CableDyn_EvalChannel; CableDyn_GetAbiMinor; CableDyn_GetBodyState; + CableDyn_GetCoupledLayout; CableDyn_GetCoupledMotion; CableDyn_GetLastError; CableDyn_GetLineValues; @@ -19,6 +20,7 @@ CableDyn_GetVersion; CableDyn_GetVersionString; CableDyn_InitDeck; + CableDyn_InitDeckAt; CableDyn_InitLine; CableDyn_InitLines; CableDyn_IsInitialized; @@ -26,6 +28,8 @@ CableDyn_NLines; CableDyn_NObjects; CableDyn_NPoints; + CableDyn_RestoreState; + CableDyn_SaveState; CableDyn_Step; CableDyn_UpdatePointFluidFields; CableDyn_UpdateStates; diff --git a/tests/data/foam_esflowc_box_points.dat b/tests/data/foam_esflowc_box_points.dat new file mode 100644 index 00000000..d671462c --- /dev/null +++ b/tests/data/foam_esflowc_box_points.dat @@ -0,0 +1,41 @@ +--------------------- CableDyn Input File ------------------------------------ +foamMooring EsfLOWC floating box (Wu et al., 2018): four slack EI=0 lines, 4 Fixed anchors, 4 Coupled fairleads +Source: the MoorDyn v2 input lines_v2.txt of foamMooring's EsfLOWC tutorial, with the points renumbered +sequentially (anchors 1-4, fairleads 5-8). The fairleads sit at the deck z = -0.062 m; the tutorial's box +starts with them at z = -0.077 m (the C API host-coupling test, tests/test_c_api_host_coupling.c). +--------------------- LINE TYPES --------------------------------------------- +TypeName Diam MassDenInAir EA BA/-zeta EI Cd Ca CdAx CaAx +(name) (m) (kg/m) (N) (N-s/-) (N-m^2) (-) (-) (-) (-) +main 0.003656 0.0607 29 -0.8 0 1.6 1.0 0.05 0.0 +--------------------- POINTS ------------------------------------------------- +ID Type X Y Z Mass Vol CdA Ca +(#) (-) (m) (m) (m) (kg) (m3) (m2) (-) +1 Fixed -1.385 0.423 -0.5 0 0 0 0 +2 Fixed -1.385 -0.423 -0.5 0 0 0 0 +3 Fixed 1.385 0.423 -0.5 0 0 0 0 +4 Fixed 1.385 -0.423 -0.5 0 0 0 0 +5 Coupled -0.1 0.1 -0.062 0 0 0 0 +6 Coupled -0.1 -0.1 -0.062 0 0 0 0 +7 Coupled 0.1 0.1 -0.062 0 0 0 0 +8 Coupled 0.1 -0.1 -0.062 0 0 0 0 +--------------------- LINES -------------------------------------------------- +ID LineType AttachA AttachB UnstrLen NumSegs Outputs +(#) (name) (#) (#) (m) (-) (-) +1 main 1 5 1.455 40 - +2 main 2 6 1.455 40 - +3 main 3 7 1.455 40 - +4 main 4 8 1.455 40 - +--------------------- OPTIONS ------------------------------------------------ +9.81 g +1025.0 rhoW +0.5 WtrDpth +3.0e6 kBot +3.0e5 cBot +--------------------- OUTPUTS ------------------------------------------------ +FairTen4 +AnchTen4 +Point8Fx +Point8Fy +Point8Fz +TDP4s +--------------------- need this line ----------------------------------------- diff --git a/tests/data/host_coupling_chain_cable.dat b/tests/data/host_coupling_chain_cable.dat new file mode 100644 index 00000000..be53a5b8 --- /dev/null +++ b/tests/data/host_coupling_chain_cable.dat @@ -0,0 +1,35 @@ +--------------------- CableDyn Input File ------------------------------------ +C API host-coupling test deck: one EI=0 chain and one finite-EI cable, each from its own +Coupled fairlead to a Fixed anchor on a 50 m flat seabed. The finite-EI line puts the deck on +the coupled aggregate (fixed step dtM); the two sub-objects make every step a staged step. +--------------------------- LINE TYPES ---------------------------------------- +Name Diam Mass EA BA EI Cdn Cdt Can Cat +(-) (m) (kg/m) (N) (-) (Nm2) (-) (-) (-) (-) +chain 0.10 50.0 5.0e8 -1.0 0.0 2.0 0.4 0.82 0.27 +cable 0.16 36.7 4.69e8 0.0 1.99e4 1.2 0.1 1.0 0.0 +--------------------------- POINTS -------------------------------------------- +ID Type X Y Z +(-) (-) (m) (m) (m) +1 Fixed -110.0 0.0 -50.0 +2 Coupled -5.0 0.0 -5.0 +3 Fixed 95.0 0.0 -50.0 +4 Coupled 5.0 0.0 -5.0 +--------------------------- LINES --------------------------------------------- +ID NodeA NodeB Outputs +(-) (-) (-) (-) +1 2 1 - +2 4 3 - +--------------------------- SECTIONS ------------------------------------------ +LineID LineType Length NumSegs +(-) (-) (m) (-) +1 chain 120.0 20 +2 cable 110.0 22 +--------------------------- OPTIONS ------------------------------------------- +9.80665 g +1025.0 rhoW +3.0e6 kBot +3.0e5 cBot +50.0 WtrDpth +0.01 dtM +0.0 TMax +--------------------------- need this line ------------------------------------ diff --git a/tests/test_c_api.f90 b/tests/test_c_api.f90 index dd090160..ea8aa269 100644 --- a/tests/test_c_api.f90 +++ b/tests/test_c_api.f90 @@ -12,7 +12,8 @@ PROGRAM test_c_api CableDyn_UpdatePointFluidFields, CableDyn_Step, CableDyn_CalcOutput, & CableDyn_CalcOutputDerivatives, CableDyn_GetCoupledMotion, CableDyn_GetLastError, & CableDyn_GetVersion, & - CableDyn_GetVersionString, CableDyn_NCoupledDOF, CableDyn_NPoints, CableDyn_NLines + CableDyn_GetVersionString, CableDyn_NCoupledDOF, CableDyn_NPoints, CableDyn_NLines, & + CableDyn_SaveState, CableDyn_RestoreState USE CableDyn_Precision, ONLY: wp USE CableDyn_OpenFAST_Aggregate, ONLY: CD_AGG_ModuleType, CD_AGG_Init_From_Deck, CD_AGG_Step_Moving, & CD_AGG_CalcOutput, CD_AGG_GetMovingPointMesh, CD_AGG_End, CD_AGG_OK @@ -539,7 +540,8 @@ END SUBROUTINE case_stale_double_close_copied_handle SUBROUTINE case_deck_bodies_rods() !! A deck with a free rod (and one with a free Rigid6 body) initializes through the aggregate: !! the coupled DOFs are its Coupled points, the step is the deck dtM, and 20 driven steps - !! reproduce CD_AGG driven directly bit-for-bit (loads and coupled motion). A mismatched dt, + !! reproduce CD_AGG driven directly bit-for-bit (loads and coupled motion), also across a + !! SaveState / three trial steps / RestoreState rewind half way. A mismatched dt, !! load derivatives and point fluid fields fail closed by name; a Coupled rod (a 6-DOF host !! node) is rejected by the standalone deck rules. CHARACTER(*), PARAMETER :: ROD_DECK = 'capi_rod_deck.dat', BODY_DECK = 'capi_body_deck.dat', & @@ -590,6 +592,21 @@ SUBROUTINE case_deck_bodies_rods() a = 0.0_C_DOUBLE maxdiff = 0.0_wp DO s = 1, 20 + IF (s == 11) THEN + ! An outer-corrector rewind half way: save, take three trial steps with another motion, + ! restore. The march must go on bit for bit with the directly driven aggregate. + CALL CableDyn_SaveState(handle, es) + CALL require(es == 0_C_INT, 'c-api-objects:save') + DO i = 1, 3 + q(1) = qo(1) - 0.1_C_DOUBLE*REAL(i, C_DOUBLE) + v(1) = -0.2_C_DOUBLE + CALL CableDyn_Step(handle, 0.005_C_DOUBLE, C_LOC(q), C_LOC(v), C_LOC(a), 3_C_INT, converged, & + stalled, n_iter, es) + CALL require(es == 0_C_INT, 'c-api-objects:trial-step') + END DO + CALL CableDyn_RestoreState(handle, es) + CALL require(es == 0_C_INT, 'c-api-objects:restore') + END IF q(1) = qo(1) + 0.05_C_DOUBLE*SIN(0.5_C_DOUBLE*REAL(s, C_DOUBLE)) v(1) = 0.025_C_DOUBLE*COS(0.5_C_DOUBLE*REAL(s, C_DOUBLE)) CALL CableDyn_Step(handle, 0.005_C_DOUBLE, C_LOC(q), C_LOC(v), C_LOC(a), 3_C_INT, converged, stalled, & diff --git a/tests/test_c_api_host_coupling.c b/tests/test_c_api_host_coupling.c new file mode 100644 index 00000000..d85fbec6 --- /dev/null +++ b/tests/test_c_api_host_coupling.c @@ -0,0 +1,862 @@ +/* File: tests/test_c_api_host_coupling.c + * SPDX-License-Identifier: Apache-2.0 + * Host-coupling gate of C ABI 1 minor extension 2, through the public header + * and the shared library. + * + * Usage: test_c_api_host_coupling + * + * + * box_points.dat is the foamMooring EsfLOWC box (four slack EI=0 lines, point + * route) whose fairleads sit at z = -0.062 m in the deck while the CFD box + * starts with them at z = -0.077 m. mixed_chain_cable.dat is an EI=0 chain + * plus a finite-EI cable (aggregate route, staged steps). viscoelastic.dat is a + * grounded viscoelastic (ElasticMod 2) catenary, run with seabed friction + * switched on in a copy; syrope.dat is a taut Syrope line; free_point.dat is a + * chain with a Free clump weight. The test checks: + * - CableDyn_InitDeckAt solves the statics at the host positions: on both + * routes the result equals CableDyn_InitDeck of the deck moved there bit for + * bit; for the box, line 4's fairlead load is the standalone value and held + * fairleads stay at rest, while InitDeck at the deck positions followed by + * steps at the host positions rings; the full-vector form ignores the Fixed + * and Free blocks; + * - CableDyn_SaveState/RestoreState: a restore followed by steps reproduces a + * fresh model taking the same steps bit for bit, on both routes, on a raw-array + * (InitLine) handle, with viscoelastic, Syrope and seabed-friction states, and + * with point fluid fields changed between the save and the restore; also + * after several steps between save and restore and after repeated restores; + * - the save slot follows the live model: a failed InitDeck/InitDeckAt keeps + * it, a failed InitLine/InitLines drops it on a point-route handle and keeps + * it on an aggregate handle, and a successful initialization drops it; + * - CableDyn_GetCoupledLayout reports anchors and fairleads on the point route + * and only the Coupled points on the aggregate route; + * - the fail-closed rejections of the new calls, including a point shared by an + * EI=0 and a finite-EI line given two positions and a line End A moved below + * its Fixed anchor. + * The decks this test writes are removed on every exit path. + */ +#include "CableDyn_CAPI.h" + +#include +#include +#include +#include + +#define CHECK(condition, message) \ + do { \ + if (!(condition)) { \ + fprintf(stderr, "FAIL: %s\n", (message)); \ + return 1; \ + } \ + } while (0) + +/* CHECK for functions that release resources at their label done. */ +#define REQUIRE(condition, message) \ + do { \ + if (!(condition)) { \ + fprintf(stderr, "FAIL: %s\n", (message)); \ + goto done; \ + } \ + } while (0) + +#define BOX_NDOF 24 /* 8 line-bound points: 4 Fixed anchors, 4 Coupled fairleads */ +#define BOX_NHOST 12 /* the 4 Coupled fairleads */ +#define BOX_DT 1.0e-3 +#define BOX_NSTEP 1000 /* 1 s */ +#define DECK_Z (-0.062) +#define HOST_Z (-0.077) + +#define MIX_NDOF 6 /* the chain and the cable fairleads; the anchors are not coupled */ +#define MIX_DT 0.01 + +#define RAW_NODES 6 +#define RAW_ELEM 5 + +static const char *g_box; +static const char *g_mixed; +static const char *g_visco; +static const char *g_syrope; +static const char *g_free; + +/* Every deck the test writes (into the working directory); removed on every exit path. */ +#define BOX_MOVED "capi_host_box_moved.dat" +#define MIXED_HALF "capi_host_mixed_half.dat" +#define MIXED_MOVED "capi_host_mixed_moved.dat" +#define MIXED_SHARED_HALF "capi_host_mixed_shared_half.dat" +#define MIXED_SHARED "capi_host_mixed_shared.dat" +#define VISCO_FRICTION "capi_host_visco_friction.dat" +static const char *const g_written[] = {BOX_MOVED, MIXED_HALF, MIXED_MOVED, + MIXED_SHARED_HALF, MIXED_SHARED, VISCO_FRICTION}; + +static void remove_written_decks(void) +{ + for (size_t i = 0; i < sizeof g_written / sizeof g_written[0]; ++i) remove(g_written[i]); +} + +static void report(void *h, const char *where, int err) +{ + char msg[1025]; + CableDyn_GetLastError(h, msg, (int)sizeof msg); + fprintf(stderr, "FAIL: %s (status %d): %s\n", where, err, msg); +} + +static int init_deck(void **h, const char *deck) +{ + int err = -1; + CableDyn_Create(h, &err); + CHECK(err == CD_C_OK, "create"); + CableDyn_InitDeck(*h, deck, (int)strlen(deck), &err); + if (err != CD_C_OK) { + report(*h, "InitDeck", err); + return 1; + } + return 0; +} + +static int init_deck_at(void **h, const char *deck, const double *q0, int n_q0) +{ + int err = -1; + CableDyn_Create(h, &err); + CHECK(err == CD_C_OK, "create"); + CableDyn_InitDeckAt(*h, deck, (int)strlen(deck), q0, n_q0, &err); + if (err != CD_C_OK) { + report(*h, "InitDeckAt", err); + return 1; + } + return 0; +} + +static int step(void *h, double dt, const double *q, const double *v, const double *a, int n) +{ + bool converged = false, stalled = true; + int n_iter = 0, err = -1; + CableDyn_Step(h, dt, q, v, a, n, &converged, &stalled, &n_iter, &err); + if (err != CD_C_OK || !converged) { + report(h, "Step", err); + return 1; + } + return 0; +} + +static int loads(void *h, double *f, int n) +{ + int err = -1; + CableDyn_CalcOutput(h, f, n, &err); + if (err != CD_C_OK) { + report(h, "CalcOutput", err); + return 1; + } + return 0; +} + +static int last_error_has(void *h, const char *text) +{ + char msg[1025]; + CableDyn_GetLastError(h, msg, (int)sizeof msg); + return strstr(msg, text) != NULL; +} + +/* The box fairlead positions (deck x, y) at height z, as the 4 Coupled blocks. */ +static void box_fairleads(double z, double *q_host) +{ + static const double xy[4][2] = {{-0.1, 0.1}, {-0.1, -0.1}, {0.1, 0.1}, {0.1, -0.1}}; + for (int p = 0; p < 4; ++p) { + q_host[3 * p + 0] = xy[p][0]; + q_host[3 * p + 1] = xy[p][1]; + q_host[3 * p + 2] = z; + } +} + +/* Copy a deck with one text replaced: on every line that contains old_text (and row_key, unless + * row_key is NULL), the first old_text becomes new_text; n_expected such lines must be found. */ +static int edit_deck(const char *in_path, const char *out_path, const char *old_text, const char *new_text, + const char *row_key, int n_expected) +{ + FILE *in = fopen(in_path, "r"), *out = NULL; + char line[512], edited[1024]; + int n = 0; + + if (in == NULL) { + fprintf(stderr, "FAIL: open the deck %s\n", in_path); + return 1; + } + out = fopen(out_path, "w"); + if (out == NULL) { + fclose(in); + fprintf(stderr, "FAIL: write the deck %s\n", out_path); + return 1; + } + while (fgets(line, (int)sizeof line, in) != NULL) { + char *at = strstr(line, old_text); + if (at != NULL && (row_key == NULL || strstr(line, row_key) != NULL)) { + snprintf(edited, sizeof edited, "%.*s%s%s", (int)(at - line), line, new_text, at + strlen(old_text)); + fputs(edited, out); + ++n; + } else { + fputs(line, out); + } + } + fclose(in); + fclose(out); + if (n != n_expected) { + fprintf(stderr, "FAIL: %s: %d lines with \"%s\", expected %d\n", in_path, n, old_text, n_expected); + return 1; + } + return 0; +} + +static int check_version(void) +{ + CHECK(CABLEDYN_CAPI_ABI_MINOR == 2 && CableDyn_GetAbiMinor() == CABLEDYN_CAPI_ABI_MINOR, + "ABI minor level 2"); + return 0; +} + +static int check_point_layout(void) +{ + void *h = NULL; + int err = -1, ids[8], types[8], n; + if (init_deck(&h, g_box)) return 1; + n = CableDyn_NCoupledDOF(h, &err); + CHECK(err == CD_C_OK && n == BOX_NDOF, "the box coupled vector has 8 blocks"); + CableDyn_GetCoupledLayout(h, ids, types, n / 3, &err); + CHECK(err == CD_C_OK, "layout query"); + for (int k = 0; k < 8; ++k) { + CHECK(ids[k] == k + 1, "point-route blocks follow the POINTS table"); + CHECK(types[k] == (k < 4 ? CD_C_POINT_FIXED : CD_C_POINT_COUPLED), + "point-route blocks: 4 Fixed anchors, then 4 Coupled fairleads"); + } + CableDyn_GetCoupledLayout(h, NULL, types, n / 3, &err); + CHECK(err == CD_C_OK && types[7] == CD_C_POINT_COUPLED, "a NULL output is skipped"); + CableDyn_GetCoupledLayout(h, ids, types, n / 3 - 1, &err); + CHECK(err == CD_C_BAD_INPUT, "a wrong block count is rejected"); + CableDyn_Close(&h, &err); + return 0; +} + +/* A taut raw-array line: RAW_NODES nodes 2 m apart on the x axis, 1 % pretension, both end + * nodes fixed (the coupled vector: node 1, then node RAW_NODES). */ +static void init_raw_line(void *h, double l0_each, double rho_inf, int *err) +{ + double q0[3 * RAW_NODES] = {0.0}, v0[3 * RAW_NODES] = {0.0}, l0[RAW_ELEM], ea[RAW_ELEM], rho_a[RAW_ELEM]; + int elem_conn[2 * RAW_ELEM]; + const int fixed[6] = {1, 2, 3, 3 * RAW_NODES - 2, 3 * RAW_NODES - 1, 3 * RAW_NODES}; + for (int i = 0; i < RAW_NODES; ++i) q0[3 * i] = 2.0 * i; + for (int e = 0; e < RAW_ELEM; ++e) { + elem_conn[2 * e] = e + 1; + elem_conn[2 * e + 1] = e + 2; + l0[e] = l0_each; + ea[e] = 1.0e6; + rho_a[e] = 10.0; + } + CableDyn_InitLine(h, RAW_NODES, RAW_ELEM, q0, v0, elem_conn, l0, ea, rho_a, fixed, 6, 1, rho_inf, err); +} + +/* CableDyn_InitLines rejected before it reads any array (no line). */ +static void init_no_lines(void *h, int *err) +{ + const int counts[1] = {0}; + CableDyn_InitLines(h, 0, counts, counts, counts, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, 0, 1, 0.8, + err); +} + +static int check_raw_layout(void) +{ + void *h = NULL; + int err = -1, ids[2], types[2], bogus = 0; + const double q0[6] = {0.0, 0.0, 0.0, 10.0, 0.0, 0.0}, v0[6] = {0.0}; + const int elem_conn[2] = {1, 2}, fixed[6] = {1, 2, 3, 4, 5, 6}; + const double l0[1] = {10.0}, ea[1] = {1.0e6}, rho_a[1] = {10.0}; + + CableDyn_Create(&h, &err); + CableDyn_GetCoupledLayout(h, ids, types, 2, &err); + CHECK(err == CD_C_NOT_INITIALIZED, "layout of an uninitialized handle"); + CableDyn_SaveState(h, &err); + CHECK(err == CD_C_NOT_INITIALIZED, "save on an uninitialized handle"); + CableDyn_RestoreState(h, &err); + CHECK(err == CD_C_NOT_INITIALIZED, "restore on an uninitialized handle"); + CableDyn_InitLine(h, 2, 1, q0, v0, elem_conn, l0, ea, rho_a, fixed, 6, 1, 0.8, &err); + CHECK(err == CD_C_OK, "raw line init"); + CableDyn_GetCoupledLayout(h, ids, types, 2, &err); + CHECK(err == CD_C_BAD_INPUT && last_error_has(h, "raw arrays"), "a raw-array handle has no layout"); + CableDyn_GetCoupledLayout((void *)&bogus, ids, types, 2, &err); + CHECK(err == CD_C_BAD_HANDLE, "foreign handle"); + CableDyn_Close(&h, &err); + return 0; +} + +/* The raw line's far end swinging sideways: amplitude amp, sample time t. */ +static void raw_motion(const double *q0, double amp, double t, double *q, double *v, double *a) +{ + const double w = 2.0 * acos(-1.0); + memcpy(q, q0, 6 * sizeof *q); + memset(v, 0, 6 * sizeof *v); + memset(a, 0, 6 * sizeof *a); + q[4] += amp * sin(w * t); + v[4] = amp * w * cos(w * t); + a[4] = -amp * w * w * sin(w * t); +} + +/* Save/restore on a raw-array (InitLine) handle: two trial correctors, restore, steps; bit for + * bit a fresh line taking the same steps. A successful InitLine drops the save. */ +static int check_raw_save_restore(void) +{ + void *h = NULL, *ref = NULL; + double q0[6], q[6], v[6], a[6], f[6], f_ref[6], mq[6], mv[6], ma[6], rq[6], rv[6], ra[6]; + int err = -1, status = 1, n; + const double dt = 1.0e-3; + + CableDyn_Create(&h, &err); + REQUIRE(err == CD_C_OK, "create"); + CableDyn_Create(&ref, &err); + REQUIRE(err == CD_C_OK, "create"); + init_raw_line(h, 1.98, 0.8, &err); + REQUIRE(err == CD_C_OK, "raw line init"); + init_raw_line(ref, 1.98, 0.8, &err); + REQUIRE(err == CD_C_OK, "raw line init"); + n = CableDyn_NCoupledDOF(h, &err); + REQUIRE(err == CD_C_OK && n == 6, "the raw coupled vector is the fixed-DOF list"); + CableDyn_GetCoupledMotion(h, q0, v, a, n, &err); + REQUIRE(err == CD_C_OK, "raw coupled motion"); + CableDyn_SaveState(h, &err); + REQUIRE(err == CD_C_OK, "raw save"); + for (int corrector = 1; corrector <= 2; ++corrector) { + for (int s = 1; s <= 6; ++s) { + raw_motion(q0, 0.1 * corrector, s * dt, q, v, a); + if (step(h, dt, q, v, a, n)) goto done; + } + CableDyn_RestoreState(h, &err); + REQUIRE(err == CD_C_OK, "raw restore"); + } + for (int s = 1; s <= 20; ++s) { + raw_motion(q0, 0.05, s * dt, q, v, a); + if (step(h, dt, q, v, a, n) || step(ref, dt, q, v, a, n)) goto done; + if (loads(h, f, n) || loads(ref, f_ref, n)) goto done; + CableDyn_GetCoupledMotion(h, mq, mv, ma, n, &err); + CableDyn_GetCoupledMotion(ref, rq, rv, ra, n, &err); + REQUIRE(memcmp(f, f_ref, sizeof f) == 0 && memcmp(mq, rq, sizeof mq) == 0 && + memcmp(mv, rv, sizeof mv) == 0 && memcmp(ma, ra, sizeof ma) == 0, + "raw-array route: restore + steps equal the fresh line bit for bit"); + } + REQUIRE(fabs(f[4]) > 1.0e-3, "the swinging end loads the raw line sideways"); + printf("raw-array route: 6 trial steps x 2 correctors, restore, 20 steps: bit-identical to the fresh " + "line\n"); + init_raw_line(h, 1.98, 0.8, &err); + REQUIRE(err == CD_C_OK, "raw line re-initialization"); + CableDyn_RestoreState(h, &err); + REQUIRE(err == CD_C_BAD_INPUT, "a successful InitLine drops the save"); + status = 0; + +done: + CableDyn_Close(&h, &err); + CableDyn_Close(&ref, &err); + return status; +} + +/* The save follows the live model: a failed InitLine/InitLines drops it on a point-route handle + * (whose point model those calls rebuild in place) and keeps it on an aggregate handle, whose + * model stays live; the aggregate then goes on bit for bit from the restored state. */ +static int check_save_after_failed_raw_init(void) +{ + void *h = NULL, *ref = NULL; + double q0[MIX_NDOF], q[MIX_NDOF], v[MIX_NDOF] = {0.0}, a[MIX_NDOF] = {0.0}, f[MIX_NDOF], f_ref[MIX_NDOF]; + int err = -1, status = 1; + + /* point route */ + if (init_deck(&h, g_box)) goto done; + CableDyn_SaveState(h, &err); + REQUIRE(err == CD_C_OK, "point-route save"); + init_raw_line(h, 1.98, 2.0, &err); /* rho_inf out of range */ + REQUIRE(err == CD_C_BAD_INPUT, "a failed InitLine"); + CableDyn_RestoreState(h, &err); + REQUIRE(err == CD_C_BAD_INPUT && last_error_has(h, "no state has been saved"), + "a failed InitLine drops the save of a point-route handle"); + CableDyn_SaveState(h, &err); + REQUIRE(err == CD_C_OK, "point-route save"); + init_no_lines(h, &err); + REQUIRE(err == CD_C_BAD_INPUT, "a failed InitLines"); + CableDyn_RestoreState(h, &err); + REQUIRE(err == CD_C_BAD_INPUT && last_error_has(h, "no state has been saved"), + "a failed InitLines drops the save of a point-route handle"); + CableDyn_Close(&h, &err); + + /* aggregate route */ + if (init_deck(&h, g_mixed) || init_deck(&ref, g_mixed)) goto done; + CableDyn_GetCoupledMotion(h, q0, v, a, MIX_NDOF, &err); + REQUIRE(err == CD_C_OK, "aggregate coupled motion"); + CableDyn_SaveState(h, &err); + REQUIRE(err == CD_C_OK, "aggregate save"); + memcpy(q, q0, sizeof q); + q[0] -= 0.3; + q[3] += 0.3; + if (step(h, MIX_DT, q, v, a, MIX_NDOF)) goto done; + init_raw_line(h, 1.98, 2.0, &err); /* rejected by the argument checks */ + REQUIRE(err == CD_C_BAD_INPUT, "a failed InitLine on the aggregate handle"); + init_raw_line(h, 0.0, 0.8, &err); /* rejected by the line model */ + REQUIRE(err != CD_C_OK, "a failed InitLine (zero length) on the aggregate handle"); + init_no_lines(h, &err); + REQUIRE(err == CD_C_BAD_INPUT, "a failed InitLines on the aggregate handle"); + REQUIRE(CableDyn_IsInitialized(h) && CableDyn_NCoupledDOF(h, &err) == MIX_NDOF, + "the aggregate model stays live"); + CableDyn_RestoreState(h, &err); + REQUIRE(err == CD_C_OK, "a failed InitLine/InitLines keeps the save of an aggregate handle"); + memcpy(q, q0, sizeof q); + q[0] -= 0.05; + if (step(h, MIX_DT, q, v, a, MIX_NDOF) || step(ref, MIX_DT, q, v, a, MIX_NDOF)) goto done; + if (loads(h, f, MIX_NDOF) || loads(ref, f_ref, MIX_NDOF)) goto done; + REQUIRE(memcmp(f, f_ref, sizeof f) == 0, "the restored aggregate steps as the fresh model"); + status = 0; + +done: + CableDyn_Close(&h, &err); + CableDyn_Close(&ref, &err); + return status; +} + +static int check_init_at(void) +{ + void *at = NULL, *full = NULL, *moved = NULL, *plain = NULL; + double q_host[BOX_NHOST], q_full[BOX_NDOF], q[BOX_NDOF], v[BOX_NDOF] = {0.0}, a[BOX_NDOF] = {0.0}; + double f_at[BOX_NDOF], f_full[BOX_NDOF], f_moved[BOX_NDOF], f[BOX_NDOF], f_plain0[BOX_NDOF]; + double drift = 0.0, ring = 0.0, ring_end = 0.0; + int err = -1, n = BOX_NDOF, ids[8], types[8], status = 1; + /* standalone CableDyn with the deck moved to z = -0.077 (MoorDyn: 0.3034, -0.0763, -0.4136) */ + const double f4_ref[3] = {0.3026, -0.0761, -0.4114}; + + box_fairleads(HOST_Z, q_host); + if (init_deck_at(&at, g_box, q_host, BOX_NHOST)) goto done; + n = CableDyn_NCoupledDOF(at, &err); + REQUIRE(err == CD_C_OK && n == BOX_NDOF, "InitDeckAt keeps the route's coupled vector"); + CableDyn_GetCoupledLayout(at, ids, types, 8, &err); + REQUIRE(err == CD_C_OK && ids[7] == 8 && types[7] == CD_C_POINT_COUPLED, "layout after InitDeckAt"); + CableDyn_GetCoupledMotion(at, q, v, a, n, &err); + REQUIRE(err == CD_C_OK, "coupled motion after InitDeckAt"); + for (int p = 0; p < 4; ++p) { + REQUIRE(q[3 * p + 2] == -0.5, "the anchors stay at the deck coordinates"); + REQUIRE(memcmp(&q[12 + 3 * p], &q_host[3 * p], 3 * sizeof(double)) == 0, + "the fairleads start exactly at q0"); + } + for (int i = 0; i < n; ++i) REQUIRE(v[i] == 0.0 && a[i] == 0.0, "the statics start at rest"); + if (loads(at, f_at, n)) goto done; + printf("InitDeckAt z=%.3f: line 4 fairlead load (%.4f, %.4f, %.4f) N\n", HOST_Z, f_at[21], f_at[22], + f_at[23]); + for (int c = 0; c < 3; ++c) + REQUIRE(fabs(f_at[21 + c] - f4_ref[c]) < 1.0e-4, "line 4 fairlead load matches the standalone statics"); + + /* The full-vector form: the Fixed blocks are not read. */ + memcpy(q_full, q, sizeof q_full); + for (int i = 0; i < 12; ++i) q_full[i] = 1.0e3; + if (init_deck_at(&full, g_box, q_full, BOX_NDOF)) goto done; + if (loads(full, f_full, n)) goto done; + REQUIRE(memcmp(f_full, f_at, sizeof f_at) == 0, "full and Coupled-only q0 give the same statics"); + CableDyn_GetCoupledMotion(full, q_full, v, a, n, &err); + REQUIRE(err == CD_C_OK && memcmp(q_full, q, sizeof q) == 0, "the full form ignores the Fixed blocks"); + + /* Bit for bit the statics of the deck moved to the host positions. */ + if (edit_deck(g_box, BOX_MOVED, "-0.062", "-0.077", "Coupled", 4)) goto done; + if (init_deck(&moved, BOX_MOVED)) goto done; + if (loads(moved, f_moved, n)) goto done; + REQUIRE(memcmp(f_moved, f_at, sizeof f_at) == 0, "InitDeckAt equals InitDeck of the moved deck"); + + /* Held at the host positions, the InitDeckAt model stays at equilibrium for 1 s. */ + memset(v, 0, sizeof v); + memset(a, 0, sizeof a); + for (int s = 1; s <= BOX_NSTEP; ++s) { + if (step(at, BOX_DT, q, v, a, n) || loads(at, f, n)) goto done; + for (int i = 12; i < n; ++i) drift = fmax(drift, fabs(f[i] - f_at[i])); + } + printf("InitDeckAt, fairleads held 1 s: max fairlead load change %.3e N\n", drift); + REQUIRE(drift < 1.0e-6, "no start-up transient after InitDeckAt"); + + /* InitDeck at the deck positions, then held at the host positions: the start-up transient. */ + if (init_deck(&plain, g_box)) goto done; + if (loads(plain, f_plain0, n)) goto done; + for (int s = 1; s <= BOX_NSTEP; ++s) { + if (step(plain, BOX_DT, q, v, a, n) || loads(plain, f, n)) goto done; + for (int i = 12; i < n; ++i) { + ring = fmax(ring, fabs(f[i] - f_at[i])); + if (s == BOX_NSTEP) ring_end = fmax(ring_end, fabs(f[i] - f_at[i])); + } + } + printf("InitDeck z=%.3f: line 4 fairlead load (%.4f, %.4f, %.4f) N\n", DECK_Z, f_plain0[21], f_plain0[22], + f_plain0[23]); + printf("InitDeck, then held at z=%.3f for 1 s: max deviation from the equilibrium %.3e N " + "(%.3e N at 1 s)\n", + HOST_Z, ring, ring_end); + REQUIRE(ring > 1.0e4 * drift && ring > 1.0e-2, "the plain start rings"); + + /* Rejections keep the previous model. */ + CableDyn_InitDeckAt(at, g_box, (int)strlen(g_box), q_host, 9, &err); + REQUIRE(err == CD_C_BAD_INPUT && last_error_has(at, "coupled_positions"), "a wrong q0 length is rejected"); + CableDyn_InitDeckAt(at, g_box, (int)strlen(g_box), q_host, 13, &err); + REQUIRE(err == CD_C_BAD_INPUT, "a q0 length that is not a multiple of 3 is rejected"); + CableDyn_InitDeckAt(at, g_box, (int)strlen(g_box), NULL, BOX_NHOST, &err); + REQUIRE(err == CD_C_BAD_INPUT, "a NULL q0 is rejected"); + q_host[5] = NAN; + CableDyn_InitDeckAt(at, g_box, (int)strlen(g_box), q_host, BOX_NHOST, &err); + REQUIRE(err == CD_C_BAD_INPUT, "a non-finite q0 is rejected"); + CableDyn_InitDeckAt(at, g_box, (int)strlen(g_box), NULL, 0, &err); + REQUIRE(err == CD_C_BAD_INPUT, "an empty q0 is rejected for a deck with Coupled points"); + REQUIRE(CableDyn_IsInitialized(at) && CableDyn_NCoupledDOF(at, &err) == BOX_NDOF, + "a rejected InitDeckAt keeps the model"); + status = 0; + +done: + CableDyn_Close(&at, &err); + CableDyn_Close(&full, &err); + CableDyn_Close(&moved, &err); + CableDyn_Close(&plain, &err); + return status; +} + +/* The full-vector form on a deck with a Free point: the Free block is not read, and the Free + * point is solved to its static balance. */ +static int check_free_point_full_form(void) +{ + void *only = NULL, *full = NULL; + const double q_host[3] = {0.5, 0.0, -0.5}; + double q[6], v[6], a[6], q_full[6], f[6], f_full[6]; + int err = -1, ids[2], types[2], status = 1; + + if (init_deck_at(&only, g_free, q_host, 3)) goto done; + REQUIRE(CableDyn_NCoupledDOF(only, &err) == 6, "the Coupled and the Free point have a block each"); + CableDyn_GetCoupledLayout(only, ids, types, 2, &err); + REQUIRE(err == CD_C_OK && ids[0] == 1 && types[0] == CD_C_POINT_COUPLED && ids[1] == 2 && + types[1] == CD_C_POINT_FREE, + "free-point deck layout: the Coupled point, then the Free point"); + CableDyn_GetCoupledMotion(only, q, v, a, 6, &err); + REQUIRE(err == CD_C_OK && memcmp(q, q_host, sizeof q_host) == 0, "the Coupled point starts at q0"); + if (loads(only, f, 6)) goto done; + memcpy(q_full, q, sizeof q); + q_full[3] = q_full[4] = q_full[5] = 1.0e3; + if (init_deck_at(&full, g_free, q_full, 6)) goto done; + if (loads(full, f_full, 6)) goto done; + CableDyn_GetCoupledMotion(full, q_full, v, a, 6, &err); + REQUIRE(err == CD_C_OK && memcmp(q_full, q, sizeof q) == 0 && memcmp(f_full, f, sizeof f) == 0, + "the full form ignores the Free block and equals the Coupled-only form"); + status = 0; + +done: + CableDyn_Close(&only, &err); + CableDyn_Close(&full, &err); + return status; +} + +/* A point shared by an EI=0 and a finite-EI line has two blocks on the aggregate route; q0 must + * give both the same position. The mixed deck is edited so that the cable hangs from the chain + * fairlead 2 (its anchor moved so that the cable keeps its geometry). */ +static int check_shared_point(void) +{ + void *h = NULL; + double q[MIX_NDOF], v[MIX_NDOF], a[MIX_NDOF]; + int err = -1, n, ids[2], types[2], status = 1; + + if (edit_deck(g_mixed, MIXED_SHARED_HALF, "2 4 3", "2 2 3", NULL, 1) || + edit_deck(MIXED_SHARED_HALF, MIXED_SHARED, "3 Fixed 95.0", "3 Fixed 85.0", NULL, 1) || + init_deck(&h, MIXED_SHARED)) + goto done; + n = CableDyn_NCoupledDOF(h, &err); + REQUIRE(err == CD_C_OK && n == MIX_NDOF, "the shared fairlead has a block on each route"); + CableDyn_GetCoupledLayout(h, ids, types, 2, &err); + REQUIRE(err == CD_C_OK && ids[0] == 2 && ids[1] == 2, "both blocks belong to point 2"); + CableDyn_GetCoupledMotion(h, q, v, a, n, &err); + REQUIRE(err == CD_C_OK && memcmp(q, q + 3, 3 * sizeof *q) == 0, "the two blocks start together"); + q[0] -= 0.5; + q[3] -= 0.5; + CableDyn_InitDeckAt(h, MIXED_SHARED, (int)strlen(MIXED_SHARED), q, n, &err); + if (err != CD_C_OK) report(h, "InitDeckAt with one position in both blocks", err); + REQUIRE(err == CD_C_OK, "one position in both blocks of the shared point is accepted"); + q[3] -= 0.5; + CableDyn_InitDeckAt(h, MIXED_SHARED, (int)strlen(MIXED_SHARED), q, n, &err); + REQUIRE(err == CD_C_BAD_INPUT && last_error_has(h, "same position in both"), + "two positions for the shared point are rejected"); + REQUIRE(CableDyn_IsInitialized(h) && CableDyn_NCoupledDOF(h, &err) == MIX_NDOF, + "the rejection keeps the model"); + status = 0; + +done: + CableDyn_Close(&h, &err); + return status; +} + +/* On a deck without Free or Connect points, q0 may not move a line's End A below its Fixed + * End B anchor (the Syrope line runs from the Vessel fairlead 2 to the anchor 1, both at z = 0). */ +static int check_end_a_below_anchor(void) +{ + void *h = NULL; + double q_host[3] = {20.5, 0.0, 0.0}; + int err = -1, status = 1; + + if (init_deck_at(&h, g_syrope, q_host, 3)) goto done; + q_host[2] = -1.0; + CableDyn_InitDeckAt(h, g_syrope, (int)strlen(g_syrope), q_host, 3, &err); + REQUIRE(err == CD_C_BAD_INPUT && last_error_has(h, "coupled_positions displaces a LINE End A"), + "an End A moved below its Fixed anchor is rejected"); + REQUIRE(CableDyn_IsInitialized(h) && CableDyn_NCoupledDOF(h, &err) == 6, "the rejection keeps the model"); + status = 0; + +done: + CableDyn_Close(&h, &err); + return status; +} + +/* A smooth host motion of the Coupled blocks: amplitude amp, sample time t. */ +static void host_motion(const int *types, int nb, const double *q0, double amp, double t, double *q, double *v, + double *a) +{ + const double w = 2.0 * acos(-1.0); + for (int k = 0; k < nb; ++k) { + for (int c = 0; c < 3; ++c) { + q[3 * k + c] = q0[3 * k + c]; + v[3 * k + c] = 0.0; + a[3 * k + c] = 0.0; + } + if (types[k] != CD_C_POINT_COUPLED) continue; + q[3 * k + 0] += amp * sin(w * t); + v[3 * k + 0] = amp * w * cos(w * t); + a[3 * k + 0] = -amp * w * w * sin(w * t); + q[3 * k + 2] += 0.5 * amp * (1.0 - cos(w * t)); + v[3 * k + 2] = 0.5 * amp * w * sin(w * t); + a[3 * k + 2] = 0.5 * amp * w * w * cos(w * t); + } +} + +/* A uniform current at every deck point (the point fluid fields), or still water. */ +static int set_fluid(void *h, double u) +{ + int err = -1, np = CableDyn_NPoints(h, &err); + double *vel = calloc((size_t)(3 * np), sizeof *vel), *acc = calloc((size_t)(3 * np), sizeof *acc); + double *zw = calloc((size_t)np, sizeof *zw); + if (vel != NULL && acc != NULL && zw != NULL) { + for (int p = 0; p < np; ++p) vel[3 * p] = u; + CableDyn_UpdatePointFluidFields(h, vel, acc, zw, np, 1025.0, &err); + } + free(vel); + free(acc); + free(zw); + if (err != CD_C_OK) { + report(h, "UpdatePointFluidFields", err); + return 1; + } + return 0; +} + +/* Save, take n_trial trial steps, restore (n_restore times) and take n_steps steps; the result must + * equal a fresh model taking the same n_steps steps, bit for bit. Between the save and the second + * restore, a failed InitDeck and a failed InitDeckAt must keep the save. With fluid set, the trial + * passes run in a current (CableDyn_UpdatePointFluidFields) the reference model never sees. */ +static int check_save_restore(const char *deck, const double *q_host, int n_host, double dt, double amp, + int n_trial, int n_steps, int fluid, const char *route) +{ + void *h = NULL, *ref = NULL; + double *q0 = NULL, *q = NULL, *v = NULL, *a = NULL, *f = NULL, *f_ref = NULL, *mq = NULL, *mv = NULL; + double *ma = NULL, *rq = NULL, *rv = NULL, *ra = NULL, *xh = NULL, *xr = NULL; + int err = -1, n, *ids = NULL, *types = NULL, status = 1, n_lines; + const char *missing = "capi_host_missing.dat"; + char label[160]; + + if (init_deck_at(&h, deck, q_host, n_host) || init_deck_at(&ref, deck, q_host, n_host)) goto done; + n = CableDyn_NCoupledDOF(h, &err); + n_lines = CableDyn_NLines(h, &err); + q0 = calloc((size_t)n, sizeof *q0); + q = calloc((size_t)n, sizeof *q); + v = calloc((size_t)n, sizeof *v); + a = calloc((size_t)n, sizeof *a); + f = calloc((size_t)n, sizeof *f); + f_ref = calloc((size_t)n, sizeof *f_ref); + mq = calloc((size_t)n, sizeof *mq); + mv = calloc((size_t)n, sizeof *mv); + ma = calloc((size_t)n, sizeof *ma); + rq = calloc((size_t)n, sizeof *rq); + rv = calloc((size_t)n, sizeof *rv); + ra = calloc((size_t)n, sizeof *ra); + ids = calloc((size_t)(n / 3), sizeof *ids); + types = calloc((size_t)(n / 3), sizeof *types); + REQUIRE(q0 && q && v && a && f && f_ref && mq && mv && ma && rq && rv && ra && ids && types, "allocation"); + CableDyn_GetCoupledMotion(h, q0, v, a, n, &err); + CableDyn_GetCoupledLayout(h, ids, types, n / 3, &err); + REQUIRE(err == CD_C_OK, "layout"); + + CableDyn_RestoreState(h, &err); + REQUIRE(err == CD_C_BAD_INPUT, "restore without a save is rejected"); + CableDyn_SaveState(h, &err); + REQUIRE(err == CD_C_OK, "save"); + /* Two outer correctors that take other (larger) trial motions before the final pass. */ + for (int corrector = 0; corrector < 2; ++corrector) { + if (fluid && set_fluid(h, 0.5 * (corrector + 1))) goto done; + for (int s = 1; s <= n_trial; ++s) { + host_motion(types, n / 3, q0, 2.0 * amp * (corrector + 1), s * dt, q, v, a); + if (step(h, dt, q, v, a, n)) goto done; + } + if (corrector == 1) { + /* Failed re-initializations keep the model and its save. */ + CableDyn_InitDeck(h, missing, (int)strlen(missing), &err); + REQUIRE(err != CD_C_OK, "InitDeck of a missing deck fails"); + CableDyn_InitDeckAt(h, deck, (int)strlen(deck), q_host, n_host - 3, &err); + REQUIRE(err == CD_C_BAD_INPUT, "InitDeckAt with a q0 that fits neither form fails"); + } + CableDyn_RestoreState(h, &err); + snprintf(label, sizeof label, "%s: restore (after failed re-initializations on the second)", route); + REQUIRE(err == CD_C_OK, label); + } + for (int s = 1; s <= n_steps; ++s) { + host_motion(types, n / 3, q0, amp, s * dt, q, v, a); + if (step(h, dt, q, v, a, n) || step(ref, dt, q, v, a, n)) goto done; + if (loads(h, f, n) || loads(ref, f_ref, n)) goto done; + CableDyn_GetCoupledMotion(h, mq, mv, ma, n, &err); + CableDyn_GetCoupledMotion(ref, rq, rv, ra, n, &err); + snprintf(label, sizeof label, "%s: restore + step %d equals the fresh model bit for bit", route, s); + REQUIRE(memcmp(f, f_ref, (size_t)n * sizeof *f) == 0, label); + REQUIRE(memcmp(mq, rq, (size_t)n * sizeof *mq) == 0 && memcmp(mv, rv, (size_t)n * sizeof *mv) == 0 && + memcmp(ma, ra, (size_t)n * sizeof *ma) == 0, + label); + } + /* Every line node agrees too. */ + for (int l = 0; l < n_lines; ++l) { + int id = 0, nn = 0, sub = 0; + CableDyn_GetObjectInfo(h, CD_C_OBJ_LINE, l, &id, &nn, &sub, &err); + xh = calloc((size_t)(3 * nn), sizeof *xh); + xr = calloc((size_t)(3 * nn), sizeof *xr); + REQUIRE(xh && xr, "allocation"); + CableDyn_GetLineValues(h, l, CD_C_LINE_POSITION, xh, 3 * nn, &err); + CableDyn_GetLineValues(ref, l, CD_C_LINE_POSITION, xr, 3 * nn, &err); + snprintf(label, sizeof label, "%s: line %d nodes after the restore equal the fresh model", route, id); + REQUIRE(err == CD_C_OK && memcmp(xh, xr, (size_t)(3 * nn) * sizeof *xh) == 0, label); + free(xh); + free(xr); + xh = xr = NULL; + } + printf("%s: %d trial steps x 2 correctors%s, restore, %d steps: bit-identical to the fresh model\n", route, + n_trial, fluid ? " in a current" : "", n_steps); + + /* A successful initialization discards the save. */ + CableDyn_InitDeckAt(h, deck, (int)strlen(deck), q_host, n_host, &err); + REQUIRE(err == CD_C_OK, "re-initialization"); + CableDyn_RestoreState(h, &err); + REQUIRE(err == CD_C_BAD_INPUT, "a re-initialization discards the save"); + status = 0; + +done: + free(q0); + free(q); + free(v); + free(a); + free(f); + free(f_ref); + free(mq); + free(mv); + free(ma); + free(rq); + free(rv); + free(ra); + free(ids); + free(types); + free(xh); + free(xr); + CableDyn_Close(&h, &err); + CableDyn_Close(&ref, &err); + return status; +} + +static int check_aggregate(void) +{ + void *h = NULL, *moved = NULL; + int err = -1, n = MIX_NDOF, ids[2], types[2], status = 1; + double q[MIX_NDOF], v[MIX_NDOF], a[MIX_NDOF], q_host[MIX_NDOF], f[MIX_NDOF], f_moved[MIX_NDOF]; + + if (init_deck(&h, g_mixed)) goto done; + n = CableDyn_NCoupledDOF(h, &err); + REQUIRE(err == CD_C_OK && n == MIX_NDOF, "the aggregate coupled vector holds the two fairleads only"); + CableDyn_GetCoupledLayout(h, ids, types, 2, &err); + REQUIRE(err == CD_C_OK && ids[0] == 2 && ids[1] == 4, "aggregate blocks: the chain, then the cable fairlead"); + REQUIRE(types[0] == CD_C_POINT_COUPLED && types[1] == CD_C_POINT_COUPLED, "aggregate blocks are Coupled"); + CableDyn_GetCoupledMotion(h, q, v, a, n, &err); + REQUIRE(err == CD_C_OK, "aggregate coupled motion"); + + /* InitDeckAt on the aggregate: the fairleads 1 m outward and 0.5 m down. */ + memcpy(q_host, q, sizeof q); + q_host[0] -= 1.0; + q_host[2] -= 0.5; + q_host[3] += 1.0; + q_host[5] -= 0.5; + CableDyn_InitDeckAt(h, g_mixed, (int)strlen(g_mixed), q_host, MIX_NDOF, &err); + if (err != CD_C_OK) report(h, "aggregate InitDeckAt", err); + REQUIRE(err == CD_C_OK, "aggregate InitDeckAt"); + CableDyn_GetCoupledMotion(h, q, v, a, n, &err); + REQUIRE(err == CD_C_OK && memcmp(q, q_host, sizeof q) == 0, "aggregate fairleads start exactly at q0"); + if (loads(h, f, n)) goto done; + printf("aggregate InitDeckAt: fairlead loads (%.1f, %.1f, %.1f) N and (%.1f, %.1f, %.1f) N\n", f[0], f[1], + f[2], f[3], f[4], f[5]); + + /* Bit for bit the statics of the deck with both fairleads moved to q0. */ + REQUIRE(q_host[0] == -6.0 && q_host[2] == -5.5 && q_host[3] == 6.0 && q_host[5] == -5.5, + "the mixed deck fairleads start at (-5, 0, -5) and (5, 0, -5)"); + if (edit_deck(g_mixed, MIXED_HALF, "-5.0 0.0 -5.0", "-6.0 0.0 -5.5", "Coupled", 1) || + edit_deck(MIXED_HALF, MIXED_MOVED, " 5.0 0.0 -5.0", " 6.0 0.0 -5.5", "Coupled", 1) || + init_deck(&moved, MIXED_MOVED) || loads(moved, f_moved, n)) + goto done; + REQUIRE(memcmp(f_moved, f, sizeof f) == 0, "aggregate InitDeckAt equals InitDeck of the moved deck"); + + CableDyn_InitDeckAt(h, g_mixed, (int)strlen(g_mixed), q_host, 3, &err); + REQUIRE(err == CD_C_BAD_INPUT && last_error_has(h, "coupled_positions"), + "a wrong aggregate q0 length is rejected"); + CableDyn_Close(&h, &err); + CableDyn_Close(&moved, &err); + + status = check_save_restore(g_mixed, q_host, MIX_NDOF, MIX_DT, 0.2, 5, 10, 0, "aggregate route"); + +done: + CableDyn_Close(&h, &err); + CableDyn_Close(&moved, &err); + return status; +} + +/* Viscoelastic, Syrope and seabed-friction states, and point fluid fields, through the save. */ +static int check_state_models(void) +{ + /* the viscoelastic catenary's fairlead (deck: 58, 0, -14) and the Syrope fairlead (deck) */ + const double q_visco[3] = {58.5, 0.0, -14.2}, q_syrope[3] = {20.5, 0.0, 0.0}; + const double q_free[3] = {0.5, 0.0, -0.5}; + + /* seabed friction needs a dynamic deck: dtM and TMax come with it */ + if (edit_deck(g_visco, VISCO_FRICTION, "none frictionMu", + "0.02 dtM\n10.0 TMax\n0.5 frictionMu", NULL, 1)) + return 1; + return check_save_restore(VISCO_FRICTION, q_visco, 3, 0.02, 0.2, 4, 10, 0, + "point route, viscoelastic with seabed friction") || + check_save_restore(g_syrope, q_syrope, 3, 0.01, 0.01, 4, 10, 0, "point route, Syrope") || + check_save_restore(g_free, q_free, 3, 0.01, 0.1, 4, 10, 1, "point route, Free point"); +} + +static int run(void) +{ + double q_host[BOX_NHOST]; + box_fairleads(HOST_Z, q_host); + return check_version() || check_point_layout() || check_raw_layout() || check_init_at() || + check_free_point_full_form() || check_shared_point() || check_end_a_below_anchor() || + check_save_restore(g_box, q_host, BOX_NHOST, BOX_DT, 0.005, 7, 20, 0, "point route") || + check_aggregate() || check_raw_save_restore() || check_save_after_failed_raw_init() || + check_state_models(); +} + +int main(int argc, char **argv) +{ + int failed; + + if (argc != 6) { + fputs("usage: test_c_api_host_coupling " + " \n", + stderr); + return 2; + } + g_box = argv[1]; + g_mixed = argv[2]; + g_visco = argv[3]; + g_syrope = argv[4]; + g_free = argv[5]; + remove_written_decks(); + failed = run(); + remove_written_decks(); + if (failed) return 1; + puts("PASS: CableDyn C API host coupling"); + return 0; +} diff --git a/tests/test_c_api_shared.c b/tests/test_c_api_shared.c index 8ea81bef..ecd17d8a 100644 --- a/tests/test_c_api_shared.c +++ b/tests/test_c_api_shared.c @@ -148,7 +148,8 @@ static int check_deck_step(const char *deck) double *xyz = NULL, *seg = NULL, pos[3], force[3], fair = 0.0, ten0 = 0.0; const char *token = "FairTen1"; - CHECK(CableDyn_GetAbiMinor() >= 1 && CABLEDYN_CAPI_ABI_MINOR == 1, "ABI minor level"); + CHECK(CableDyn_GetAbiMinor() >= 1 && CableDyn_GetAbiMinor() == CABLEDYN_CAPI_ABI_MINOR, + "ABI minor level"); nl = CableDyn_NObjects(m, CD_C_OBJ_LINE, &err); CHECK(err == CD_C_OK && nl == CableDyn_NLines(m, &err), "line inventory"); np = CableDyn_NObjects(m, CD_C_OBJ_POINT, &err); diff --git a/tests/test_c_api_stack.c b/tests/test_c_api_stack.c index 65184a16..6c12865d 100644 --- a/tests/test_c_api_stack.c +++ b/tests/test_c_api_stack.c @@ -11,10 +11,14 @@ * MSVC-linked program is 1 MB), so the library must not rely on the stack reserve of * a CableDyn executable. For every deck this program starts one thread whose stack * is KiB and, on that thread, creates a handle, initialises the deck, - * steps it with the coupled points held (coupling step
s), evaluates the coupled - * loads, and closes the handle. A stack overflow ends the process (SIGSEGV on POSIX - * systems, STATUS_STACK_OVERFLOW on Windows), which fails the test. On Windows the - * deepest stack page the thread touched is also reported. + * steps it with the coupled points held (coupling step
s), saves the state, takes + * one more step and restores it (the whole-model copies of CableDyn_SaveState and + * CableDyn_RestoreState), evaluates the coupled loads, initialises the deck again with + * the statics at the coupled positions (CableDyn_InitDeckAt with the full coupled + * vector), evaluates the loads again, and closes the handle. A stack + * overflow ends the process (SIGSEGV on POSIX systems, STATUS_STACK_OVERFLOW on + * Windows), which fails the test. On Windows the deepest stack page the thread touched + * is also reported. */ #include "CableDyn_CAPI.h" @@ -115,6 +119,21 @@ static void run_deck(struct deck_task *t) goto done; } } + CableDyn_SaveState(m, &err); + if (err != CD_C_OK) { + fail(t, m, "state save failed"); + goto done; + } + CableDyn_Step(m, t->dt, q, v, a, ndof, &converged, &stalled, &n_iter, &err); + if (err != CD_C_OK || !converged || stalled) { + fail(t, m, "held-point step after the save did not converge"); + goto done; + } + CableDyn_RestoreState(m, &err); + if (err != CD_C_OK) { + fail(t, m, "state restore failed"); + goto done; + } CableDyn_CalcOutput(m, loads, ndof, &err); if (err != CD_C_OK) { fail(t, m, "output failed"); @@ -126,6 +145,23 @@ static void run_deck(struct deck_task *t) goto done; } } + /* Re-initialise with the statics at the coupled positions (the full-vector q0 form). */ + CableDyn_InitDeckAt(m, t->deck, (int)strlen(t->deck), q, ndof, &err); + if (err != CD_C_OK) { + fail(t, m, "initialisation at the coupled positions failed"); + goto done; + } + CableDyn_CalcOutput(m, loads, ndof, &err); + if (err != CD_C_OK) { + fail(t, m, "output after the initialisation at the coupled positions failed"); + goto done; + } + for (i = 0; i < ndof; ++i) { + if (!isfinite(loads[i])) { + fail(t, NULL, "non-finite coupled load after the initialisation at the coupled positions"); + goto done; + } + } done: free(q); From 4dfbc7ad7e1da8e14208c60085ee1617d8bc1e47 Mon Sep 17 00:00:00 2001 From: Jae Hoon Seo Date: Fri, 16 Oct 2026 20:19:51 +0900 Subject: [PATCH 13/31] perf: faster tension-only line steps; refactor the junction tangent after an unfactored exit (#19) Tension-only (EI = 0) line steps drop work that repeated itself every Newton evaluation, about 10 % of a step: element kernels re-validating section data the line model validates when it is set, repeated scalar checks and message blanking in the Froude-Krylov and added-mass kernels, zero velocity Jacobians added into the band, a consistent-mass band re-assembled although its inputs had not changed, and rescans of a band and factor just checked finite. The kernels take an optional inputs_validated that the line model passes after its own check; public callers keep the full validation and every input error is reported as before. The mass band is reused while its inputs are unchanged, compared exactly, and every other writer clears the reuse. With the release build chain_range_tdp runs 16 % faster, als_volturnus_line_break_time and spar_pinned_rods 13 %, and rod_moored_spar 12 %. With gfortran every output of the 52 example decks is byte-identical; with the release build three output files differ by at most 8.6e-7 of their column maximum. The monolithic body and point coupling back-solved a line step's end tangent with its last factorization, but a fresh tangent evaluation overwrote the band before it was factored while the factored flags stayed set: a step that ended right there (accepted within the near-tolerance allowance, or converged on the fresh tangent) used an unfactored matrix. The flags are now cleared at the evaluation; in a unit test reaching that exit the end tangent was off by 2.3e5 (relative) and now agrees with an ordinary exit to 1.8e-11. No example deck takes this path. Tests: the trusted kernels bit for bit against the validating ones, the reused mass band against a fresh assembly with the expected hits and misses, and the junction tangent after an allowance exit. Signed-off-by: Jae Hoon Seo --- CHANGELOG.md | 22 ++++ src/CableDyn_Damping.f90 | 33 ++++- src/CableDyn_Dynamic.f90 | 120 +++++++++++++++++-- src/CableDyn_Hydro.f90 | 226 +++++++++++++++++++++++++---------- src/CableDyn_Model.f90 | 45 ++++--- src/CableDyn_System.f90 | 4 +- tests/test_cable_dynamic.f90 | 183 ++++++++++++++++++++++++++++ tests/test_damping.f90 | 27 +++++ tests/test_hydro.f90 | 128 ++++++++++++++++++++ 9 files changed, 694 insertions(+), 94 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 0d160eb7..d2006685 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -139,6 +139,17 @@ All notable changes to CableDyn are recorded in this file. The format follows at 0.109 1/m instead of 0.075 1/m, and the anchor tension stays at its static 1.23 kN, where the coarse mesh showed stick-slip peaks up to 4.1 kN. The validation record and the tutorials are updated. +- Faster tension-only (`EI = 0`) line steps. In every Newton evaluation the element kernels of + the line loads (axial damping, Morison drag, Froude-Krylov, buoyancy recovery, added mass) no + longer re-check, element by element, data the line model validates when it is set; the + Froude-Krylov and added-mass kernels check their section data once instead of three times; + the velocity Jacobians of the Froude-Krylov and buoyancy loads, which are zero, are no longer + added into the band; a step reuses the consistent-mass band of the previous one while the + lengths and masses are unchanged; and the Newton solve no longer rescans a matrix already + checked finite. With the release build, `examples/als_volturnus_line_break_time.dat` runs + 13 % faster and `examples/spar_pinned_rods.dat` 13 %. Every input error is reported as + before. With gfortran the results are bit-identical. With the Intel compiler of the release + they can differ in the last printed digit, and by more where a deck amplifies round-off. ### Fixed @@ -258,6 +269,17 @@ All notable changes to CableDyn are recorded in this file. The format follows on the rounded surface. When the anchor walk of a finite-EI line over a non-planar bathymetry reaches a state that is rejected, the failure no longer states that the line is too long for its span to hang as a catenary, which is proven over a planar seabed only. +- Junction end tangent of a tension-only line step that ends right after a fresh tangent + evaluation. In the monolithic body and point coupling, a line step accepted within the + near-tolerance allowance at its Newton iteration limit (or converged on a freshly evaluated + tangent) still marked its last factorization as current, although the new tangent had + overwritten it. The condensed end tangent, and the warm start of a re-solve of the same step, + were then back-solved with the unfactored matrix: in a unit test the end tangent was wrong by + five orders of magnitude, which can slow or misdirect the outer junction iteration. The step + now clears the factorization flags whenever it overwrites the band without factoring it, so + the end query factors the current tangent (one more tangent assembly and factorization for + such a step of a junction solve). The outputs of the example decks and of the other tests + are unchanged. ## [0.1.1] - 2026-10-09 diff --git a/src/CableDyn_Damping.f90 b/src/CableDyn_Damping.f90 index 3f00918d..03e4bdfb 100644 --- a/src/CableDyn_Damping.f90 +++ b/src/CableDyn_Damping.f90 @@ -252,16 +252,27 @@ SUBROUTINE CD_Cable_Axial_Damping_Load(q, v, elem_conn, l0, ba, force, jac_q, ja END DO END SUBROUTINE CD_Cable_Axial_Damping_Load - SUBROUTINE CD_Axial_Damping_Element_Force(qa, qb, va, vb, l0, ba, force, ErrStat, ErrMsg, l0_dot) + SUBROUTINE CD_Axial_Damping_Element_Force(qa, qb, va, vb, l0, ba, force, ErrStat, ErrMsg, l0_dot, & + inputs_validated) !! Two-node axial damping force kernel for model hot paths. + !! `inputs_validated` is an internal hot-path contract (as in CD_Component_Wave_Kinematics), + !! shared with CD_Axial_Damping_Element_Load: a caller that already guarantees a finite + !! state, a finite positive l0 and a finite resolved ba >= 0 skips the per-element input + !! scan. The default remains full validation for public/direct calls. REAL(wp), INTENT(IN) :: qa(3), qb(3), va(3), vb(3), l0, ba REAL(wp), INTENT(OUT) :: force(6) REAL(wp), INTENT(IN), OPTIONAL :: l0_dot !! unstretched-length rate (see the cable-path routines) INTEGER, INTENT(OUT) :: ErrStat CHARACTER(*), INTENT(OUT) :: ErrMsg + LOGICAL, INTENT(IN), OPTIONAL :: inputs_validated REAL(wp) :: chord(3), tang(3), rel(3), length, ldot, td_vec(3) - CALL validate_element_inputs(qa, qb, va, vb, l0, ba, ErrStat, ErrMsg) + IF (trusted(inputs_validated)) THEN + ErrStat = CD_DAMP_OK + ErrMsg = '' + ELSE + CALL validate_element_inputs(qa, qb, va, vb, l0, ba, ErrStat, ErrMsg) + END IF force = CD_ZERO IF (ErrStat /= CD_DAMP_OK) RETURN IF (PRESENT(l0_dot)) THEN @@ -285,18 +296,25 @@ SUBROUTINE CD_Axial_Damping_Element_Force(qa, qb, va, vb, l0, ba, force, ErrStat force(4:6) = -td_vec END SUBROUTINE CD_Axial_Damping_Element_Force - SUBROUTINE CD_Axial_Damping_Element_Load(qa, qb, va, vb, l0, ba, force, jac_q, jac_v, ErrStat, ErrMsg, l0_dot) + SUBROUTINE CD_Axial_Damping_Element_Load(qa, qb, va, vb, l0, ba, force, jac_q, jac_v, ErrStat, ErrMsg, l0_dot, & + inputs_validated) !! Two-node axial damping force and residual-Jacobian kernel. REAL(wp), INTENT(IN) :: qa(3), qb(3), va(3), vb(3), l0, ba REAL(wp), INTENT(OUT) :: force(6), jac_q(6, 6), jac_v(6, 6) REAL(wp), INTENT(IN), OPTIONAL :: l0_dot !! unstretched-length rate: the damped rate is ldot - (length/l0)*l0_dot INTEGER, INTENT(OUT) :: ErrStat CHARACTER(*), INTENT(OUT) :: ErrMsg + LOGICAL, INTENT(IN), OPTIONAL :: inputs_validated !! see CD_Axial_Damping_Element_Force INTEGER :: i REAL(wp) :: chord(3), tang(3), rel(3), length, ldot, k, td_vec(3) REAL(wp) :: eye(3, 3), ktt(3, 3), m1(3, 3), m2(3, 3), dmat(3, 3) - CALL validate_element_inputs(qa, qb, va, vb, l0, ba, ErrStat, ErrMsg) + IF (trusted(inputs_validated)) THEN + ErrStat = CD_DAMP_OK + ErrMsg = '' + ELSE + CALL validate_element_inputs(qa, qb, va, vb, l0, ba, ErrStat, ErrMsg) + END IF force = CD_ZERO jac_q = CD_ZERO jac_v = CD_ZERO @@ -360,6 +378,13 @@ PURE FUNCTION outer(a, b) RESULT(m) END DO END FUNCTION outer + PURE LOGICAL FUNCTION trusted(inputs_validated) RESULT(trust) + !! The value of an optional inputs_validated flag (.FALSE. when absent). + LOGICAL, INTENT(IN), OPTIONAL :: inputs_validated + trust = .FALSE. + IF (PRESENT(inputs_validated)) trust = inputs_validated + END FUNCTION trusted + SUBROUTINE add_block(mat, node_i, node_j, blk) !! Accumulate a 3x3 block into the (node_i, node_j) DOF positions of a global matrix. REAL(wp), INTENT(INOUT) :: mat(:, :) diff --git a/src/CableDyn_Dynamic.f90 b/src/CableDyn_Dynamic.f90 index 90e03ce4..5509fd86 100644 --- a/src/CableDyn_Dynamic.f90 +++ b/src/CableDyn_Dynamic.f90 @@ -145,6 +145,15 @@ MODULE CableDyn_Dynamic REAL(wp), ALLOCATABLE :: nodes_eval(:, :) INTEGER :: topo_n_nodes = 0, bw_kl = 0, bw_ku = 0 LOGICAL :: topo_valid = .FALSE., bw_valid = .FALSE. + ! M_band holds the element consistent mass band assembled for the remembered connectivity + ! and free list (bw_free) from the lengths mb_l0 and masses per length mb_rho; a step whose + ! inputs match reuses it instead of assembling the same band again. Every other writer of + ! M_band clears mb_valid. + LOGICAL :: mb_valid = .FALSE. + REAL(wp), ALLOCATABLE :: mb_l0(:), mb_rho(:) + ! TEST-ONLY diagnostic: the number of steps that reused the remembered mass band (saturating). + ! Only the unit tests read it (to assert that the cache hit); no result depends on it. + INTEGER :: mb_hits = 0 INTEGER :: ad_kl = 0 INTEGER, ALLOCATABLE :: ad_finv(:), ad_ipiv(:), ad_fixed(:) REAL(wp), ALLOCATABLE :: ad_full(:, :), ad_add(:, :), ad_ab(:, :), ad_x(:, :), ad_result(:, :) @@ -164,7 +173,8 @@ MODULE CableDyn_Dynamic LOGICAL :: end_valid = .FALSE. ! the factored effective band in eff_band/ipiv belongs to the current step (a junction solve ! of this step factored it): a warm re-solve of the same step starts with a chord iteration - ! on it instead of assembling and factoring a new tangent + ! on it instead of assembling and factoring a new tangent. Cleared whenever eff_band is + ! overwritten by a tangent that is not factored. LOGICAL :: step_factor = .FALSE. ! force scale of the junction solves (largest element tension of the last one): the ! residual gate of a warm-started junction solve is relative to it, not to its own @@ -311,6 +321,10 @@ SUBROUTINE CD_Clear_GenAlpha_Workspace(work) work%bw_ku = 0 work%topo_valid = .FALSE. work%bw_valid = .FALSE. + work%mb_valid = .FALSE. + work%mb_hits = 0 + IF (ALLOCATED(work%mb_l0)) DEALLOCATE (work%mb_l0) + IF (ALLOCATED(work%mb_rho)) DEALLOCATE (work%mb_rho) IF (ALLOCATED(work%ad_finv)) DEALLOCATE (work%ad_finv) IF (ALLOCATED(work%ad_ipiv)) DEALLOCATE (work%ad_ipiv) IF (ALLOCATED(work%ad_fixed)) DEALLOCATE (work%ad_fixed) @@ -536,6 +550,8 @@ SUBROUTINE CD_Cable_Initial_Acceleration(q, v, elem_conn, l0, ea, rho_a, tension RETURN END IF END IF + ! the band is factored in place below: not the step's reusable mass band + work%mb_valid = .FALSE. IF (use_element_mass_band) THEN CALL assemble_mass_band_free(elem_conn, l0, rho_a, work%dof_marker(1:n_dof), kl, ku, M_band, es, em) ELSE @@ -615,7 +631,7 @@ SUBROUTINE CD_Cable_Gen_Alpha_Step(q, v, a, elem_conn, l0, ea, rho_a, tension_on REAL(wp), POINTER :: a_eval(:), a_alpha(:), q_alpha(:), v_eval(:), v_alpha(:), fint_eval(:) ! q_alpha viewed as (3, n_nodes) nodal coordinates, without a copy REAL(wp), POINTER :: q_alpha_nodes(:, :) - LOGICAL :: topo_ok, bw_hit + LOGICAL :: topo_ok, bw_hit, mb_hit INTEGER :: il, jl REAL(wp), POINTER :: Kt_eval(:, :), tension_eval(:), load_eval(:), jac_q_eval(:, :), jac_v_eval(:, :) REAL(wp), POINTER :: M_eff_eval(:, :), M_add_eval(:, :), dMa_a_dq_eval(:, :) @@ -745,6 +761,7 @@ SUBROUTINE CD_Cable_Gen_Alpha_Step(q, v, a, elem_conn, l0, ea, rho_a, tension_on direct_banded = .NOT. has_load_proc .AND. .NOT. has_added_mass_proc use_element_mass_band = direct_banded .AND. .NOT. PRESENT(structural_mass) CALL validate_topology_once(work, elem_conn, n_dof/3, topo_ok) + bw_hit = .FALSE. IF (direct_banded) THEN bw_hit = topo_ok .AND. work%bw_valid IF (bw_hit) bw_hit = SIZE(work%bw_free) == n_free @@ -753,6 +770,7 @@ SUBROUTINE CD_Cable_Gen_Alpha_Step(q, v, a, elem_conn, l0, ea, rho_a, tension_on kl = work%bw_kl ku = work%bw_ku ELSE + work%mb_valid = .FALSE. CALL CD_Cable_Free_Bandwidth(elem_conn, n_dof/3, free, kl, ku, es, em, topology_validated=topo_ok) IF (es /= 0) THEN CALL fail(ErrStat, ErrMsg, 'bandwidth analysis failed: '//TRIM(em)) @@ -907,9 +925,22 @@ SUBROUTINE CD_Cable_Gen_Alpha_Step(q, v, a, elem_conn, l0, ea, rho_a, tension_on RETURN END IF END IF + es = 0 IF (use_element_mass_band) THEN - CALL assemble_mass_band_free(elem_conn, l0, rho_a, work%dof_marker(1:n_dof), kl, ku, M_band, es, em) + ! The element mass band depends only on the connectivity, the free list, l0 and + ! rho_a: a step with the inputs of the remembered band (bw_hit: same connectivity and + ! free list) reuses it, which is the band the assembly would build again. + mb_hit = .FALSE. + IF (bw_hit) mb_hit = mass_band_matches(work, l0, rho_a) + IF (.NOT. mb_hit) THEN + work%mb_valid = .FALSE. + CALL assemble_mass_band_free(elem_conn, l0, rho_a, work%dof_marker(1:n_dof), kl, ku, M_band, es, em) + IF (es == 0 .AND. work%bw_valid) CALL remember_mass_band(work, l0, rho_a) + ELSE IF (work%mb_hits < HUGE(work%mb_hits)) THEN + work%mb_hits = work%mb_hits + 1 + END IF ELSE + work%mb_valid = .FALSE. CALL pack_dense_free_band(M, free, kl, ku, CD_ONE, M_band, es, em) END IF IF (es /= 0) THEN @@ -955,6 +986,13 @@ SUBROUTINE CD_Cable_Gen_Alpha_Step(q, v, a, elem_conn, l0, ea, rho_a, tension_on IF (tangent_fresh) THEN IF (direct_banded) THEN CALL eval_dynamic(qk, R, es, em, effbandout=eff_band) + ! factored_now and work%step_factor state that eff_band/ipiv hold the LU of the last + ! factorization. eff_band now holds the unfactored tangent at qk, and they are set + ! again only once it is factored below: an exit before that (convergence, or the + ! near-tolerance allowance at the iteration limit) leaves the junction end query and + ! a warm re-solve to factor it instead of back-solving with an unfactored band. + factored_now = .FALSE. + work%step_factor = .FALSE. ELSE CALL eval_dynamic(qk, R, es, em, effout=eff) END IF @@ -1017,7 +1055,10 @@ SUBROUTINE CD_Cable_Gen_Alpha_Step(q, v, a, elem_conn, l0, ea, rho_a, tension_on eff_band_unfactored(il, jl) = eff_band(il, jl) END DO END DO - CALL CD_Factor_Banded(eff_band, kl, ku, ipiv, es, em) + ! eval_dynamic has just checked this band finite when a banded load or added-mass + ! callback contributes to it; the factorization then skips repeating that scan. + CALL CD_Factor_Banded(eff_band, kl, ku, ipiv, es, em, & + matrix_validated=has_load_band_proc .OR. has_added_mass_band_proc) factored_now = es == 0 work%step_factor = factored_now .AND. work%end_request IF (es /= 0) THEN @@ -1031,7 +1072,9 @@ SUBROUTINE CD_Cable_Gen_Alpha_Step(q, v, a, elem_conn, l0, ea, rho_a, tension_on op_norm = MAX(CD_ONE, dense_row_abs_sum_max(eff, free)) END IF IF (direct_banded) THEN - CALL CD_Solve_Factored_Banded(eff_band, kl, ku, ipiv, dq, es, em) + ! A tangent factored in this iteration is the finite LU CD_Factor_Banded returned; a + ! reused one keeps the full check. + CALL CD_Solve_Factored_Banded(eff_band, kl, ku, ipiv, dq, es, em, factor_validated=tangent_fresh) ELSE eff_free = eff(free, free) CALL CD_Solve_Dense_As_Banded(eff_free, dq, es, em) @@ -1758,6 +1801,12 @@ SUBROUTINE ensure_step_workspace(work, n_dof, n_elem, n_free, ldab, need_band, n CALL ensure_real_vector(work%load_eval, n_dof, ErrStat, ErrMsg) IF (ErrStat /= CD_DYN_OK) RETURN IF (need_band) THEN + ! a reallocated mass band no longer holds the remembered one + IF (ALLOCATED(work%M_band)) THEN + IF (SIZE(work%M_band, 1) < ldab .OR. SIZE(work%M_band, 2) < n_free) work%mb_valid = .FALSE. + ELSE + work%mb_valid = .FALSE. + END IF CALL ensure_real_matrix(work%M_band, ldab, n_free, ErrStat, ErrMsg) IF (ErrStat /= CD_DYN_OK) RETURN CALL ensure_real_vector(work%M_add_a_eval, n_dof, ErrStat, ErrMsg) @@ -1863,6 +1912,56 @@ SUBROUTINE remember_bandwidth(work, free, kl, ku, topology_validated) work%bw_valid = .TRUE. END SUBROUTINE remember_bandwidth + LOGICAL FUNCTION mass_band_matches(work, l0, rho_a) RESULT(match) + !! work%M_band holds the element mass band of these l0 and rho_a (for the remembered + !! connectivity and free list). Equality is tested as <= and >= so that a NaN never matches. + TYPE(CD_CableGenAlphaWorkspace), INTENT(IN) :: work + REAL(wp), INTENT(IN) :: l0(:), rho_a(:) + INTEGER :: e + + match = work%mb_valid + IF (match) match = SIZE(work%mb_l0) == SIZE(l0) .AND. SIZE(work%mb_rho) == SIZE(rho_a) + IF (.NOT. match) RETURN + DO e = 1, SIZE(l0) + IF (.NOT. (work%mb_l0(e) <= l0(e) .AND. work%mb_l0(e) >= l0(e))) THEN + match = .FALSE. + RETURN + END IF + END DO + DO e = 1, SIZE(rho_a) + IF (.NOT. (work%mb_rho(e) <= rho_a(e) .AND. work%mb_rho(e) >= rho_a(e))) THEN + match = .FALSE. + RETURN + END IF + END DO + END FUNCTION mass_band_matches + + SUBROUTINE remember_mass_band(work, l0, rho_a) + !! Record the inputs of the element mass band just assembled into work%M_band. + TYPE(CD_CableGenAlphaWorkspace), INTENT(INOUT) :: work + REAL(wp), INTENT(IN) :: l0(:), rho_a(:) + INTEGER :: istat + + work%mb_valid = .FALSE. + IF (ALLOCATED(work%mb_l0)) THEN + IF (SIZE(work%mb_l0) /= SIZE(l0)) DEALLOCATE (work%mb_l0) + END IF + IF (ALLOCATED(work%mb_rho)) THEN + IF (SIZE(work%mb_rho) /= SIZE(rho_a)) DEALLOCATE (work%mb_rho) + END IF + IF (.NOT. ALLOCATED(work%mb_l0)) THEN + ALLOCATE (work%mb_l0(SIZE(l0)), STAT=istat) + IF (istat /= 0) RETURN + END IF + IF (.NOT. ALLOCATED(work%mb_rho)) THEN + ALLOCATE (work%mb_rho(SIZE(rho_a)), STAT=istat) + IF (istat /= 0) RETURN + END IF + work%mb_l0 = l0 + work%mb_rho = rho_a + work%mb_valid = .TRUE. + END SUBROUTINE remember_mass_band + SUBROUTINE partition_free_dofs_workspace(fixed_dofs, n_dof, free, n_free, fixed, marker, ErrStat, ErrMsg) INTEGER, INTENT(IN) :: fixed_dofs(:), n_dof INTEGER, INTENT(INOUT) :: free(:), fixed(:) @@ -1907,14 +2006,15 @@ SUBROUTINE partition_free_dofs_workspace(fixed_dofs, n_dof, free, n_free, fixed, END SUBROUTINE partition_free_dofs_workspace SUBROUTINE ensure_int_vector(x, n, ErrStat, ErrMsg) + !! The ensure_* helpers run for every workspace array on every step: they write ErrMsg only + !! on failure, and their callers (ensure_dof_workspace, ensure_step_workspace) clear it. INTEGER, ALLOCATABLE, INTENT(INOUT) :: x(:) INTEGER, INTENT(IN) :: n INTEGER, INTENT(OUT) :: ErrStat - CHARACTER(*), INTENT(OUT) :: ErrMsg + CHARACTER(*), INTENT(INOUT) :: ErrMsg INTEGER :: istat ErrStat = CD_DYN_OK - ErrMsg = '' IF (n < 0) THEN CALL fail(ErrStat, ErrMsg, 'internal workspace size must be non-negative') RETURN @@ -1931,11 +2031,10 @@ SUBROUTINE ensure_real_vector(x, n, ErrStat, ErrMsg) REAL(wp), ALLOCATABLE, INTENT(INOUT) :: x(:) INTEGER, INTENT(IN) :: n INTEGER, INTENT(OUT) :: ErrStat - CHARACTER(*), INTENT(OUT) :: ErrMsg + CHARACTER(*), INTENT(INOUT) :: ErrMsg INTEGER :: istat ErrStat = CD_DYN_OK - ErrMsg = '' IF (n < 0) THEN CALL fail(ErrStat, ErrMsg, 'internal workspace size must be non-negative') RETURN @@ -1952,11 +2051,10 @@ SUBROUTINE ensure_real_matrix(x, n1, n2, ErrStat, ErrMsg) REAL(wp), ALLOCATABLE, INTENT(INOUT) :: x(:, :) INTEGER, INTENT(IN) :: n1, n2 INTEGER, INTENT(OUT) :: ErrStat - CHARACTER(*), INTENT(OUT) :: ErrMsg + CHARACTER(*), INTENT(INOUT) :: ErrMsg INTEGER :: istat ErrStat = CD_DYN_OK - ErrMsg = '' IF (n1 < 0 .OR. n2 < 0) THEN CALL fail(ErrStat, ErrMsg, 'internal workspace shape must be non-negative') RETURN diff --git a/src/CableDyn_Hydro.f90 b/src/CableDyn_Hydro.f90 index cb8e7b08..2e033c65 100644 --- a/src/CableDyn_Hydro.f90 +++ b/src/CableDyn_Hydro.f90 @@ -267,24 +267,35 @@ SUBROUTINE CD_Cable_Morison_Drag_Force(q, v, elem_conn, l0, fluid_velocity, wate END SUBROUTINE CD_Cable_Morison_Drag_Force SUBROUTINE CD_Morison_Drag_Element_Load(qa, qb, va, vb, l0, fluid_a, fluid_b, wl_a, wl_b, & - rho, diameter, cdn, cdt, force, jac_q, jac_v, ErrStat, ErrMsg) + rho, diameter, cdn, cdt, force, jac_q, jac_v, ErrStat, ErrMsg, & + inputs_validated) !! Two-node Morison drag element kernel for performance-critical model assembly. !! !! This routine is formula-identical to the one-element path of !! CD_Cable_Morison_Drag_Load, but avoids cable-wide shape validation and !! reshape/scatter work inside Newton iterations. + !! `inputs_validated` is an internal hot-path contract (as in CD_Component_Wave_Kinematics), + !! shared by the element kernels below: a caller that already guarantees finite state, + !! fields and waterlines, a positive l0 and valid section scalars skips the per-element + !! input scan. The default remains full validation for public/direct calls. REAL(wp), INTENT(IN) :: qa(3), qb(3), va(3), vb(3), l0, fluid_a(3), fluid_b(3), wl_a, wl_b REAL(wp), INTENT(IN) :: rho, diameter, cdn, cdt REAL(wp), INTENT(OUT) :: force(6), jac_q(6, 6), jac_v(6, 6) INTEGER, INTENT(OUT) :: ErrStat CHARACTER(*), INTENT(OUT) :: ErrMsg + LOGICAL, INTENT(IN), OPTIONAL :: inputs_validated INTEGER :: k REAL(wp) :: za, zb, frac, dfrac_da, dfrac_db, chord(3), length, tangent(3) REAL(wp) :: wa, wb, dwa_da, dwa_db, dwb_da, dwb_db, rel(3), f_per_len(3), Jrel(3, 3) REAL(wp) :: ga(3), gb(3), scale, dscale, drel(3), df(3), proj(3, 3) - CALL validate_drag_element_inputs(qa, qb, va, vb, l0, fluid_a, fluid_b, wl_a, wl_b, & - rho, diameter, cdn, cdt, ErrStat, ErrMsg) + IF (trusted(inputs_validated)) THEN + ErrStat = CD_HYDRO_OK + ErrMsg = '' + ELSE + CALL validate_drag_element_inputs(qa, qb, va, vb, l0, fluid_a, fluid_b, wl_a, wl_b, & + rho, diameter, cdn, cdt, ErrStat, ErrMsg) + END IF force = CD_ZERO jac_q = CD_ZERO jac_v = CD_ZERO @@ -374,18 +385,24 @@ SUBROUTINE CD_Morison_Drag_Element_Load(qa, qb, va, vb, l0, fluid_a, fluid_b, wl END SUBROUTINE CD_Morison_Drag_Element_Load SUBROUTINE CD_Morison_Drag_Element_Force(qa, qb, va, vb, l0, fluid_a, fluid_b, wl_a, wl_b, & - rho, diameter, cdn, cdt, force, ErrStat, ErrMsg) + rho, diameter, cdn, cdt, force, ErrStat, ErrMsg, inputs_validated) !! Two-node Morison drag force kernel for residual-only trial evaluations. REAL(wp), INTENT(IN) :: qa(3), qb(3), va(3), vb(3), l0, fluid_a(3), fluid_b(3), wl_a, wl_b REAL(wp), INTENT(IN) :: rho, diameter, cdn, cdt REAL(wp), INTENT(OUT) :: force(6) INTEGER, INTENT(OUT) :: ErrStat CHARACTER(*), INTENT(OUT) :: ErrMsg + LOGICAL, INTENT(IN), OPTIONAL :: inputs_validated !! see CD_Morison_Drag_Element_Load REAL(wp) :: za, zb, frac, chord(3), length, tangent(3), wa, wb, lower, higher REAL(wp) :: fluid_e(3), rel(3), f_per_len(3) - CALL validate_drag_element_inputs(qa, qb, va, vb, l0, fluid_a, fluid_b, wl_a, wl_b, & - rho, diameter, cdn, cdt, ErrStat, ErrMsg) + IF (trusted(inputs_validated)) THEN + ErrStat = CD_HYDRO_OK + ErrMsg = '' + ELSE + CALL validate_drag_element_inputs(qa, qb, va, vb, l0, fluid_a, fluid_b, wl_a, wl_b, & + rho, diameter, cdn, cdt, ErrStat, ErrMsg) + END IF force = CD_ZERO IF (ErrStat /= CD_HYDRO_OK) RETURN @@ -550,21 +567,29 @@ SUBROUTINE CD_Cable_Froude_Krylov_Force(q, v, elem_conn, l0, fluid_acceleration, END SUBROUTINE CD_Cable_Froude_Krylov_Force SUBROUTINE CD_Froude_Krylov_Element_Load(qa, qb, va, vb, l0, accel_a, accel_b, wl_a, wl_b, & - rho, diameter, can, cat, force, jac_q, jac_v, ErrStat, ErrMsg) + rho, diameter, can, cat, force, jac_q, jac_v, ErrStat, ErrMsg, & + inputs_validated) !! Two-node Froude-Krylov/fluid-inertia load and residual Jacobian. + !! The load is velocity-independent: jac_v is identically zero. REAL(wp), INTENT(IN) :: qa(3), qb(3), va(3), vb(3), l0, accel_a(3), accel_b(3), wl_a, wl_b REAL(wp), INTENT(IN) :: rho, diameter, can, cat REAL(wp), INTENT(OUT) :: force(6), jac_q(6, 6), jac_v(6, 6) INTEGER, INTENT(OUT) :: ErrStat CHARACTER(*), INTENT(OUT) :: ErrMsg + LOGICAL, INTENT(IN), OPTIONAL :: inputs_validated !! see CD_Morison_Drag_Element_Load INTEGER :: k, lo0, hi0, col_a, col_b REAL(wp) :: za, zb, frac, df_da, df_db, chord(3), length, tangent(3), proj(3, 3), dt(3), zero_dt(3) REAL(wp) :: f_lo(3), f_hi(3), df_lo(3), df_hi(3), df_node_lo(3), df_node_hi(3) REAL(wp) :: c_lolo, c_lohi, c_hihi, dc_lolo, dc_lohi, dc_hihi, df_frac, eye(3, 3) REAL(wp) :: acc_lo(3), acc_hi(3) - CALL validate_fk_element_inputs(qa, qb, va, vb, l0, accel_a, accel_b, wl_a, wl_b, & - rho, diameter, can, cat, ErrStat, ErrMsg) + IF (trusted(inputs_validated)) THEN + ErrStat = CD_HYDRO_OK + ErrMsg = '' + ELSE + CALL validate_fk_element_inputs(qa, qb, va, vb, l0, accel_a, accel_b, wl_a, wl_b, & + rho, diameter, can, cat, ErrStat, ErrMsg) + END IF force = CD_ZERO jac_q = CD_ZERO jac_v = CD_ZERO @@ -629,19 +654,28 @@ SUBROUTINE CD_Froude_Krylov_Element_Load(qa, qb, va, vb, l0, accel_a, accel_b, w END SUBROUTINE CD_Froude_Krylov_Element_Load SUBROUTINE CD_Froude_Krylov_Element_Force(qa, qb, va, vb, l0, accel_a, accel_b, wl_a, wl_b, & - rho, diameter, can, cat, force, ErrStat, ErrMsg) - !! Two-node Froude-Krylov/fluid-inertia force. + rho, diameter, can, cat, force, ErrStat, ErrMsg, inputs_validated) + !! Two-node Froude-Krylov/fluid-inertia force. The per-length force is + !! CD_Froude_Krylov_Per_Length evaluated with its shared statements: the section scalars + !! and accelerations are validated once (or by the caller) and only the tangent checks of + !! unit_tangent can still fail, so the unit tangent is formed once for both end nodes. REAL(wp), INTENT(IN) :: qa(3), qb(3), va(3), vb(3), l0, accel_a(3), accel_b(3), wl_a, wl_b REAL(wp), INTENT(IN) :: rho, diameter, can, cat REAL(wp), INTENT(OUT) :: force(6) INTEGER, INTENT(OUT) :: ErrStat CHARACTER(*), INTENT(OUT) :: ErrMsg + LOGICAL, INTENT(IN), OPTIONAL :: inputs_validated !! see CD_Morison_Drag_Element_Load INTEGER :: lo0, hi0 REAL(wp) :: za, zb, frac, chord(3), length, tangent(3), acc_lo(3), acc_hi(3), f_lo(3), f_hi(3) - REAL(wp) :: c_lolo, c_lohi, c_hihi, f + REAL(wp) :: c_lolo, c_lohi, c_hihi, f, unit(3), normal(3), tangential(3) - CALL validate_fk_element_inputs(qa, qb, va, vb, l0, accel_a, accel_b, wl_a, wl_b, & - rho, diameter, can, cat, ErrStat, ErrMsg) + IF (trusted(inputs_validated)) THEN + ErrStat = CD_HYDRO_OK + ErrMsg = '' + ELSE + CALL validate_fk_element_inputs(qa, qb, va, vb, l0, accel_a, accel_b, wl_a, wl_b, & + rho, diameter, can, cat, ErrStat, ErrMsg) + END IF force = CD_ZERO IF (ErrStat /= CD_HYDRO_OK) RETURN za = qa(3) - wl_a @@ -666,10 +700,12 @@ SUBROUTINE CD_Froude_Krylov_Element_Force(qa, qb, va, vb, l0, accel_a, accel_b, acc_lo = accel_b acc_hi = accel_a END IF - CALL CD_Froude_Krylov_Per_Length(acc_lo, tangent, rho, diameter, can, cat, f_lo, ErrStat, ErrMsg) - IF (ErrStat /= CD_HYDRO_OK) RETURN - CALL CD_Froude_Krylov_Per_Length(acc_hi, tangent, rho, diameter, can, cat, f_hi, ErrStat, ErrMsg) + CALL unit_tangent(tangent, unit, ErrStat, ErrMsg) IF (ErrStat /= CD_HYDRO_OK) RETURN + CALL split_about_unit(acc_lo, unit, normal, tangential) + CALL fk_force_from_split(normal, tangential, rho, diameter, can, cat, f_lo) + CALL split_about_unit(acc_hi, unit, normal, tangential) + CALL fk_force_from_split(normal, tangential, rho, diameter, can, cat, f_hi) f = frac c_lolo = l0*(f - f*f + f**3/3.0_wp) c_lohi = l0*(0.5_wp*f*f - f**3/3.0_wp) @@ -757,15 +793,22 @@ SUBROUTINE CD_Cable_Buoyancy_Recovery_Force(q, v, elem_conn, l0, waterline_z, & END SUBROUTINE CD_Cable_Buoyancy_Recovery_Force SUBROUTINE CD_Buoyancy_Recovery_Element_Load(qa, qb, l0, wl_a, wl_b, rho, diameter, gravity, & - force, jac_q, jac_v, ErrStat, ErrMsg) + force, jac_q, jac_v, ErrStat, ErrMsg, inputs_validated) !! Two-node wetting-dependent buoyancy recovery force and residual Jacobian. + !! The load is velocity-independent: jac_v is identically zero. REAL(wp), INTENT(IN) :: qa(3), qb(3), l0, wl_a, wl_b, rho, diameter, gravity REAL(wp), INTENT(OUT) :: force(6), jac_q(6, 6), jac_v(6, 6) INTEGER, INTENT(OUT) :: ErrStat CHARACTER(*), INTENT(OUT) :: ErrMsg + LOGICAL, INTENT(IN), OPTIONAL :: inputs_validated !! see CD_Morison_Drag_Element_Load REAL(wp) :: za, zb, frac, df_da, df_db, half_g, recovery, buoyancy, drec_da, drec_db - CALL validate_buoyancy_element_inputs(qa, qb, l0, wl_a, wl_b, rho, diameter, gravity, ErrStat, ErrMsg) + IF (trusted(inputs_validated)) THEN + ErrStat = CD_HYDRO_OK + ErrMsg = '' + ELSE + CALL validate_buoyancy_element_inputs(qa, qb, l0, wl_a, wl_b, rho, diameter, gravity, ErrStat, ErrMsg) + END IF force = CD_ZERO jac_q = CD_ZERO jac_v = CD_ZERO @@ -787,15 +830,21 @@ SUBROUTINE CD_Buoyancy_Recovery_Element_Load(qa, qb, l0, wl_a, wl_b, rho, diamet END SUBROUTINE CD_Buoyancy_Recovery_Element_Load SUBROUTINE CD_Buoyancy_Recovery_Element_Force(qa, qb, l0, wl_a, wl_b, rho, diameter, gravity, & - force, ErrStat, ErrMsg) + force, ErrStat, ErrMsg, inputs_validated) !! Two-node wetting-dependent buoyancy recovery force. REAL(wp), INTENT(IN) :: qa(3), qb(3), l0, wl_a, wl_b, rho, diameter, gravity REAL(wp), INTENT(OUT) :: force(6) INTEGER, INTENT(OUT) :: ErrStat CHARACTER(*), INTENT(OUT) :: ErrMsg + LOGICAL, INTENT(IN), OPTIONAL :: inputs_validated !! see CD_Morison_Drag_Element_Load REAL(wp) :: za, zb, frac, half_g, recovery, buoyancy - CALL validate_buoyancy_element_inputs(qa, qb, l0, wl_a, wl_b, rho, diameter, gravity, ErrStat, ErrMsg) + IF (trusted(inputs_validated)) THEN + ErrStat = CD_HYDRO_OK + ErrMsg = '' + ELSE + CALL validate_buoyancy_element_inputs(qa, qb, l0, wl_a, wl_b, rho, diameter, gravity, ErrStat, ErrMsg) + END IF force = CD_ZERO IF (ErrStat /= CD_HYDRO_OK) RETURN za = qa(3) - wl_a @@ -1026,20 +1075,26 @@ SUBROUTINE CD_Cable_Added_Mass_Force(q, accel, elem_conn, l0, waterline_z, rho, END SUBROUTINE CD_Cable_Added_Mass_Force SUBROUTINE CD_Added_Mass_Element(qa, qb, accel_a, accel_b, l0, wl_a, wl_b, rho, diameter, can, cat, & - M_add, dMa_a_dq, ErrStat, ErrMsg) + M_add, dMa_a_dq, ErrStat, ErrMsg, inputs_validated) !! Two-node added-mass matrix and directional derivative kernel. REAL(wp), INTENT(IN) :: qa(3), qb(3), accel_a(3), accel_b(3), l0, wl_a, wl_b REAL(wp), INTENT(IN) :: rho, diameter, can, cat REAL(wp), INTENT(OUT) :: M_add(6, 6), dMa_a_dq(6, 6) INTEGER, INTENT(OUT) :: ErrStat CHARACTER(*), INTENT(OUT) :: ErrMsg + LOGICAL, INTENT(IN), OPTIONAL :: inputs_validated !! see CD_Morison_Drag_Element_Load INTEGER :: lo0, hi0 REAL(wp) :: za, zb, frac, df_da, df_db, chord(3), length, tangent(3), proj(3, 3), zero_dt(3) REAL(wp) :: Me(3, 3), dMe(3, 3), acc_lo(3), acc_hi(3) REAL(wp) :: c_lolo, c_lohi, c_hihi, dc_lolo, dc_lohi, dc_hihi, eye(3, 3) - CALL validate_added_mass_element_inputs(qa, qb, accel_a, accel_b, l0, wl_a, wl_b, & - rho, diameter, can, cat, ErrStat, ErrMsg) + IF (trusted(inputs_validated)) THEN + ErrStat = CD_HYDRO_OK + ErrMsg = '' + ELSE + CALL validate_added_mass_element_inputs(qa, qb, accel_a, accel_b, l0, wl_a, wl_b, & + rho, diameter, can, cat, ErrStat, ErrMsg) + END IF M_add = CD_ZERO dMa_a_dq = CD_ZERO IF (ErrStat /= CD_HYDRO_OK) RETURN @@ -1115,34 +1170,40 @@ SUBROUTINE CD_Added_Mass_Element(qa, qb, accel_a, accel_b, l0, wl_a, wl_b, rho, END BLOCK END SUBROUTINE CD_Added_Mass_Element - SUBROUTINE CD_Added_Mass_Element_Matrix(qa, qb, l0, wl_a, wl_b, rho, diameter, can, cat, M_add, ErrStat, ErrMsg) + SUBROUTINE CD_Added_Mass_Element_Matrix(qa, qb, l0, wl_a, wl_b, rho, diameter, can, cat, M_add, ErrStat, ErrMsg, & + inputs_validated) !! Two-node configuration-dependent Morison added-mass matrix without !! d(M*a)/dq work. Used by initial-acceleration solves where the supplied - !! acceleration is exactly zero but the mass matrix is still needed. + !! acceleration is exactly zero but the mass matrix is still needed. The per-length + !! matrix is CD_Morison_Added_Mass_Per_Length evaluated with its shared statements once + !! the section scalars are validated (only the tangent checks of unit_tangent remain). REAL(wp), INTENT(IN) :: qa(3), qb(3), l0, wl_a, wl_b REAL(wp), INTENT(IN) :: rho, diameter, can, cat REAL(wp), INTENT(OUT) :: M_add(6, 6) INTEGER, INTENT(OUT) :: ErrStat CHARACTER(*), INTENT(OUT) :: ErrMsg + LOGICAL, INTENT(IN), OPTIONAL :: inputs_validated !! see CD_Morison_Drag_Element_Load INTEGER :: lo0, hi0 - REAL(wp) :: za, zb, frac, chord(3), length, tangent(3), Me(3, 3) + REAL(wp) :: za, zb, frac, chord(3), length, tangent(3), Me(3, 3), unit(3) REAL(wp) :: c_lolo, c_lohi, c_hihi M_add = CD_ZERO ErrStat = CD_HYDRO_OK ErrMsg = '' - IF (.NOT. (CD_All_Finite(qa) .AND. CD_All_Finite(qb) .AND. & - CD_Is_Finite(l0) .AND. l0 > CD_ZERO .AND. CD_Is_Finite(wl_a) .AND. & - CD_Is_Finite(wl_b))) THEN - CALL fail(ErrStat, ErrMsg, 'added-mass element matrix geometry must be finite') - RETURN - END IF - CALL validate_hydro_scalars(rho, diameter, ErrStat, ErrMsg) - IF (ErrStat /= CD_HYDRO_OK) RETURN - IF (.NOT. (CD_Is_Finite(can) .AND. CD_Is_Finite(cat) .AND. can >= CD_ZERO .AND. cat >= CD_ZERO)) THEN - CALL fail(ErrStat, ErrMsg, 'added-mass coefficients must be finite and non-negative') - RETURN + IF (.NOT. trusted(inputs_validated)) THEN + IF (.NOT. (CD_All_Finite(qa) .AND. CD_All_Finite(qb) .AND. & + CD_Is_Finite(l0) .AND. l0 > CD_ZERO .AND. CD_Is_Finite(wl_a) .AND. & + CD_Is_Finite(wl_b))) THEN + CALL fail(ErrStat, ErrMsg, 'added-mass element matrix geometry must be finite') + RETURN + END IF + CALL validate_hydro_scalars(rho, diameter, ErrStat, ErrMsg) + IF (ErrStat /= CD_HYDRO_OK) RETURN + IF (.NOT. (CD_Is_Finite(can) .AND. CD_Is_Finite(cat) .AND. can >= CD_ZERO .AND. cat >= CD_ZERO)) THEN + CALL fail(ErrStat, ErrMsg, 'added-mass coefficients must be finite and non-negative') + RETURN + END IF END IF za = qa(3) - wl_a @@ -1163,8 +1224,9 @@ SUBROUTINE CD_Added_Mass_Element_Matrix(qa, qb, l0, wl_a, wl_b, rho, diameter, c lo0 = 4 hi0 = 1 END IF - CALL CD_Morison_Added_Mass_Per_Length(tangent, rho, diameter, can, cat, Me, ErrStat, ErrMsg) + CALL unit_tangent(tangent, unit, ErrStat, ErrMsg) IF (ErrStat /= CD_HYDRO_OK) RETURN + CALL added_mass_about_unit(unit, rho, diameter, can, cat, Me) CALL wet_consistent_coefficients(l0, frac, c_lolo, c_lohi, c_hihi) M_add(lo0:lo0 + 2, lo0:lo0 + 2) = M_add(lo0:lo0 + 2, lo0:lo0 + 2) + c_lolo*Me M_add(lo0:lo0 + 2, hi0:hi0 + 2) = M_add(lo0:lo0 + 2, hi0:hi0 + 2) + c_lohi*Me @@ -1173,19 +1235,26 @@ SUBROUTINE CD_Added_Mass_Element_Matrix(qa, qb, l0, wl_a, wl_b, rho, diameter, c END SUBROUTINE CD_Added_Mass_Element_Matrix SUBROUTINE CD_Added_Mass_Element_Force(qa, qb, accel_a, accel_b, l0, wl_a, wl_b, rho, diameter, can, cat, & - force, ErrStat, ErrMsg) - !! Two-node added-mass product M_add(q)*accel for residual-only evaluations. + force, ErrStat, ErrMsg, inputs_validated) + !! Two-node added-mass product M_add(q)*accel for residual-only evaluations. The + !! per-length matrix is formed as in CD_Added_Mass_Element_Matrix. REAL(wp), INTENT(IN) :: qa(3), qb(3), accel_a(3), accel_b(3), l0, wl_a, wl_b REAL(wp), INTENT(IN) :: rho, diameter, can, cat REAL(wp), INTENT(OUT) :: force(6) INTEGER, INTENT(OUT) :: ErrStat CHARACTER(*), INTENT(OUT) :: ErrMsg + LOGICAL, INTENT(IN), OPTIONAL :: inputs_validated !! see CD_Morison_Drag_Element_Load INTEGER :: lo0, hi0 - REAL(wp) :: za, zb, frac, chord(3), length, tangent(3), Me(3, 3) + REAL(wp) :: za, zb, frac, chord(3), length, tangent(3), Me(3, 3), unit(3) REAL(wp) :: c_lolo, c_lohi, c_hihi, acc_lo(3), acc_hi(3) - CALL validate_added_mass_element_inputs(qa, qb, accel_a, accel_b, l0, wl_a, wl_b, & - rho, diameter, can, cat, ErrStat, ErrMsg) + IF (trusted(inputs_validated)) THEN + ErrStat = CD_HYDRO_OK + ErrMsg = '' + ELSE + CALL validate_added_mass_element_inputs(qa, qb, accel_a, accel_b, l0, wl_a, wl_b, & + rho, diameter, can, cat, ErrStat, ErrMsg) + END IF force = CD_ZERO IF (ErrStat /= CD_HYDRO_OK) RETURN @@ -1211,8 +1280,9 @@ SUBROUTINE CD_Added_Mass_Element_Force(qa, qb, accel_a, accel_b, l0, wl_a, wl_b, acc_lo = accel_b acc_hi = accel_a END IF - CALL CD_Morison_Added_Mass_Per_Length(tangent, rho, diameter, can, cat, Me, ErrStat, ErrMsg) + CALL unit_tangent(tangent, unit, ErrStat, ErrMsg) IF (ErrStat /= CD_HYDRO_OK) RETURN + CALL added_mass_about_unit(unit, rho, diameter, can, cat, Me) CALL wet_consistent_coefficients(l0, frac, c_lolo, c_lohi, c_hihi) force(lo0:lo0 + 2) = c_lolo*MATMUL(Me, acc_lo) + c_lohi*MATMUL(Me, acc_hi) force(hi0:hi0 + 2) = c_lohi*MATMUL(Me, acc_lo) + c_hihi*MATMUL(Me, acc_hi) @@ -1225,7 +1295,7 @@ SUBROUTINE CD_Split_Normal_Tangential(vector, tangent, normal, tangential, ErrSt REAL(wp), INTENT(OUT) :: normal(3), tangential(3) INTEGER, INTENT(OUT) :: ErrStat CHARACTER(*), INTENT(OUT) :: ErrMsg - REAL(wp) :: unit(3), dot_vt + REAL(wp) :: unit(3) normal = CD_ZERO tangential = CD_ZERO @@ -1237,9 +1307,7 @@ SUBROUTINE CD_Split_Normal_Tangential(vector, tangent, normal, tangential, ErrSt CALL fail(ErrStat, ErrMsg, 'vector must be finite') RETURN END IF - dot_vt = DOT_PRODUCT(vector, unit) - tangential = dot_vt*unit - normal = vector - tangential + CALL split_about_unit(vector, unit, normal, tangential) END SUBROUTINE CD_Split_Normal_Tangential SUBROUTINE CD_Morison_Drag_Per_Length(rel_velocity, tangent, rho, diameter, cdn, cdt, & @@ -1366,7 +1434,7 @@ SUBROUTINE CD_Morison_Added_Mass_Per_Length(tangent, rho, diameter, can, cat, M_ REAL(wp), INTENT(OUT) :: M_a(3, 3) INTEGER, INTENT(OUT) :: ErrStat CHARACTER(*), INTENT(OUT) :: ErrMsg - REAL(wp) :: unit(3), q_outer(3, 3), eye(3, 3), area + REAL(wp) :: unit(3) M_a = CD_ZERO ErrStat = CD_HYDRO_OK @@ -1379,10 +1447,7 @@ SUBROUTINE CD_Morison_Added_Mass_Per_Length(tangent, rho, diameter, can, cat, M_ END IF CALL unit_tangent(tangent, unit, ErrStat, ErrMsg) IF (ErrStat /= CD_HYDRO_OK) RETURN - eye = identity3() - q_outer = outer3(unit, unit) - area = 0.25_wp*PI*diameter*diameter - M_a = rho*area*(can*(eye - q_outer) + cat*q_outer) + CALL added_mass_about_unit(unit, rho, diameter, can, cat, M_a) END SUBROUTINE CD_Morison_Added_Mass_Per_Length SUBROUTINE CD_Froude_Krylov_Per_Length(fluid_acceleration, tangent, rho, diameter, can, cat, & @@ -1393,7 +1458,7 @@ SUBROUTINE CD_Froude_Krylov_Per_Length(fluid_acceleration, tangent, rho, diamete REAL(wp), INTENT(OUT) :: force(3) INTEGER, INTENT(OUT) :: ErrStat CHARACTER(*), INTENT(OUT) :: ErrMsg - REAL(wp) :: normal(3), tangential(3), area + REAL(wp) :: normal(3), tangential(3) force = CD_ZERO ErrStat = CD_HYDRO_OK @@ -1406,8 +1471,7 @@ SUBROUTINE CD_Froude_Krylov_Per_Length(fluid_acceleration, tangent, rho, diamete END IF CALL CD_Split_Normal_Tangential(fluid_acceleration, tangent, normal, tangential, ErrStat, ErrMsg) IF (ErrStat /= CD_HYDRO_OK) RETURN - area = 0.25_wp*PI*diameter*diameter - force = rho*area*((CD_ONE + can)*normal + (CD_ONE + cat)*tangential) + CALL fk_force_from_split(normal, tangential, rho, diameter, can, cat, force) END SUBROUTINE CD_Froude_Krylov_Per_Length SUBROUTINE CD_Solve_Dispersion_Wavenumber(omega, depth, gravity, k, ErrStat, ErrMsg) @@ -2363,13 +2427,15 @@ END SUBROUTINE validate_waterline_force_shapes SUBROUTINE assemble_added_mass_matrix_only(q, elem_conn, l0, waterline_z, rho, diameter, can, cat, & M_add, ErrStat, ErrMsg) + !! The callers validate the section scalars first, so the per-length matrix is formed with + !! the statements of CD_Morison_Added_Mass_Per_Length after its tangent checks alone. REAL(wp), INTENT(IN) :: q(:), l0(:), waterline_z(:), rho, diameter, can, cat INTEGER, INTENT(IN) :: elem_conn(:, :) REAL(wp), INTENT(OUT) :: M_add(:, :) INTEGER, INTENT(OUT) :: ErrStat CHARACTER(*), INTENT(OUT) :: ErrMsg INTEGER :: e, a, b, lo, hi, n_nodes - REAL(wp) :: frac, za, zb, chord(3), length, tangent(3), Me(3, 3) + REAL(wp) :: frac, za, zb, chord(3), length, tangent(3), Me(3, 3), unit(3) REAL(wp) :: c_lolo, c_lohi, c_hihi, f M_add = CD_ZERO @@ -2402,8 +2468,9 @@ SUBROUTINE assemble_added_mass_matrix_only(q, elem_conn, l0, waterline_z, rho, d lo = b hi = a END IF - CALL CD_Morison_Added_Mass_Per_Length(tangent, rho, diameter, can, cat, Me, ErrStat, ErrMsg) + CALL unit_tangent(tangent, unit, ErrStat, ErrMsg) IF (ErrStat /= CD_HYDRO_OK) RETURN + CALL added_mass_about_unit(unit, rho, diameter, can, cat, Me) f = frac c_lolo = l0(e)*(f - f*f + f**3/3.0_wp) c_lohi = l0(e)*(0.5_wp*f*f - f**3/3.0_wp) @@ -2646,14 +2713,14 @@ SUBROUTINE profile_ratios(k, depth, z_eval, cosh_ratio, sinh_ratio) END SUBROUTINE profile_ratios SUBROUTINE unit_tangent(tangent, unit, ErrStat, ErrMsg) + !! Writes ErrMsg only on failure: every caller has cleared it. REAL(wp), INTENT(IN) :: tangent(3) REAL(wp), INTENT(OUT) :: unit(3) INTEGER, INTENT(OUT) :: ErrStat - CHARACTER(*), INTENT(OUT) :: ErrMsg + CHARACTER(*), INTENT(INOUT) :: ErrMsg REAL(wp) :: norm unit = CD_ZERO ErrStat = CD_HYDRO_OK - ErrMsg = '' IF (.NOT. CD_All_Finite(tangent)) THEN CALL fail(ErrStat, ErrMsg, 'tangent must be finite') RETURN @@ -2666,6 +2733,43 @@ SUBROUTINE unit_tangent(tangent, unit, ErrStat, ErrMsg) unit = tangent/norm END SUBROUTINE unit_tangent + PURE SUBROUTINE split_about_unit(vector, unit, normal, tangential) + !! Normal and tangential parts of vector about a unit tangent from unit_tangent. + REAL(wp), INTENT(IN) :: vector(3), unit(3) + REAL(wp), INTENT(OUT) :: normal(3), tangential(3) + REAL(wp) :: dot_vt + dot_vt = DOT_PRODUCT(vector, unit) + tangential = dot_vt*unit + normal = vector - tangential + END SUBROUTINE split_about_unit + + PURE SUBROUTINE fk_force_from_split(normal, tangential, rho, diameter, can, cat, force) + !! Froude-Krylov plus fluid-inertia force per unit length from the split fluid acceleration. + REAL(wp), INTENT(IN) :: normal(3), tangential(3), rho, diameter, can, cat + REAL(wp), INTENT(OUT) :: force(3) + REAL(wp) :: area + area = 0.25_wp*PI*diameter*diameter + force = rho*area*((CD_ONE + can)*normal + (CD_ONE + cat)*tangential) + END SUBROUTINE fk_force_from_split + + PURE SUBROUTINE added_mass_about_unit(unit, rho, diameter, can, cat, M_a) + !! Morison added-mass matrix per unit length about a unit tangent from unit_tangent. + REAL(wp), INTENT(IN) :: unit(3), rho, diameter, can, cat + REAL(wp), INTENT(OUT) :: M_a(3, 3) + REAL(wp) :: q_outer(3, 3), eye(3, 3), area + eye = identity3() + q_outer = outer3(unit, unit) + area = 0.25_wp*PI*diameter*diameter + M_a = rho*area*(can*(eye - q_outer) + cat*q_outer) + END SUBROUTINE added_mass_about_unit + + PURE LOGICAL FUNCTION trusted(inputs_validated) RESULT(trust) + !! The value of an optional inputs_validated flag (.FALSE. when absent). + LOGICAL, INTENT(IN), OPTIONAL :: inputs_validated + trust = .FALSE. + IF (PRESENT(inputs_validated)) trust = inputs_validated + END FUNCTION trusted + SUBROUTINE validate_hydro_scalars(rho, diameter, ErrStat, ErrMsg) REAL(wp), INTENT(IN) :: rho, diameter INTEGER, INTENT(OUT) :: ErrStat diff --git a/src/CableDyn_Model.f90 b/src/CableDyn_Model.f90 index 7bd66c1f..be545525 100644 --- a/src/CableDyn_Model.f90 +++ b/src/CableDyn_Model.f90 @@ -3467,7 +3467,7 @@ SUBROUTINE CD_Update_Model_SegmentLength(model, elem, l0_new, l0_dot, ErrStat, E END IF END IF ! Commit. The consistent mass follows l0 implicitly (it is applied element by - ! element from the committed lengths, never stored). + ! element from the committed lengths, and the step rebuilds its mass band when they change). l0_entry = model%l0(elem) l0_dot_entry = model%l0_dot(elem) f_ext_entry = model%f_ext @@ -5884,12 +5884,18 @@ SUBROUTINE model_contributor_load_banded(model, q, v, free, kl, ku, force, jac_q END DO END IF + ! q and v are finite (checked above) and every element input the kernels validate -- l0, + ! the damping coefficients, the nodal fluid fields and waterlines, and the section scalars -- + ! is validated wherever the model sets it (CD_Init_Model, CD_Update_Model_Hydro_Fields, + ! CD_Update_Model_SegmentLength): the kernels skip their per-element input scan. Every + ! writer of these fields must validate them (the snapshot restore and the model copies + ! assign only previously validated states). DO e = 1, model%n_elem CALL extract_element_state(model, e, q, v, idx, q2, v2) IF (model%has_damping) THEN CALL CD_Axial_Damping_Element_Load(q2(1:3), q2(4:6), v2(1:3), v2(4:6), model%l0(e), & model%ba_dyn(e), f2, jq2, jv2, ErrStat, ErrMsg, & - l0_dot=model%l0_dot(e)) + l0_dot=model%l0_dot(e), inputs_validated=.TRUE.) IF (ErrStat /= 0) RETURN CALL scatter_element_vector(force, idx, f2) CALL scatter_element_matrix_band(jac_q_band, model%free_map_work, kl, ku, idx, jq2, ErrStat, ErrMsg) @@ -5930,7 +5936,8 @@ SUBROUTINE model_contributor_load_banded(model, q, v, free, kl, ku, force, jac_q CALL CD_Morison_Drag_Element_Load(q2(1:3), q2(4:6), v2(1:3), v2(4:6), model%l0(e), & fluid2(:, 1), fluid2(:, 2), wl2(1), wl2(2), model%drag_rho, & model%drag_diameter_elem(e), model%drag_cdn_elem(e), & - model%drag_cdt_elem(e), f2, jq2, jv2, ErrStat, ErrMsg) + model%drag_cdt_elem(e), f2, jq2, jv2, ErrStat, ErrMsg, & + inputs_validated=.TRUE.) IF (ErrStat /= 0) RETURN CALL scatter_element_vector(force, idx, f2) CALL scatter_element_matrix_band(jac_q_band, model%free_map_work, kl, ku, idx, jq2, ErrStat, ErrMsg) @@ -5944,25 +5951,28 @@ SUBROUTINE model_contributor_load_banded(model, q, v, free, kl, ku, force, jac_q CALL CD_Froude_Krylov_Element_Load(q2(1:3), q2(4:6), v2(1:3), v2(4:6), model%l0(e), & accel2(:, 1), accel2(:, 2), wl2(1), wl2(2), model%fk_rho, & model%fk_diameter_elem(e), model%fk_can_elem(e), & - model%fk_cat_elem(e), f2, jq2, jv2, ErrStat, ErrMsg) + model%fk_cat_elem(e), f2, jq2, jv2, ErrStat, ErrMsg, & + inputs_validated=.TRUE.) IF (ErrStat /= 0) RETURN CALL scatter_element_vector(force, idx, f2) CALL scatter_element_matrix_band(jac_q_band, model%free_map_work, kl, ku, idx, jq2, ErrStat, ErrMsg) IF (ErrStat /= CD_MODEL_OK) RETURN - CALL scatter_element_matrix_band(jac_v_band, model%free_map_work, kl, ku, idx, jv2, ErrStat, ErrMsg) - IF (ErrStat /= CD_MODEL_OK) RETURN + ! jv2 is identically zero (a velocity-independent load), and adding zeros changes no + ! entry of a band that starts at +0 and only accumulates: its scatter is skipped. The + ! index and bandwidth checks of this element ran in the jac_q scatter above (the step + ! passes both bands with the same shape). END IF IF (model%has_buoyancy_recovery) THEN CALL extract_nodal_scalar(model%buoyancy_waterline_z, model, e, wl2) CALL CD_Buoyancy_Recovery_Element_Load(q2(1:3), q2(4:6), model%l0(e), wl2(1), wl2(2), & model%buoyancy_rho, model%buoyancy_diameter_elem(e), & - model%buoyancy_gravity, f2, jq2, jv2, ErrStat, ErrMsg) + model%buoyancy_gravity, f2, jq2, jv2, ErrStat, ErrMsg, & + inputs_validated=.TRUE.) IF (ErrStat /= 0) RETURN CALL scatter_element_vector(force, idx, f2) CALL scatter_element_matrix_band(jac_q_band, model%free_map_work, kl, ku, idx, jq2, ErrStat, ErrMsg) IF (ErrStat /= CD_MODEL_OK) RETURN - CALL scatter_element_matrix_band(jac_v_band, model%free_map_work, kl, ku, idx, jv2, ErrStat, ErrMsg) - IF (ErrStat /= CD_MODEL_OK) RETURN + ! jv2 is identically zero: no scatter (as for Froude-Krylov above) END IF END DO @@ -6083,6 +6093,7 @@ SUBROUTINE model_contributor_force(model, q, v, force, ErrStat, ErrMsg, end_node END DO END IF + ! validated element inputs: see model_contributor_load_banded DO e = 1, model%n_elem IF (ends) THEN IF (ALL(model%elem_conn(:, e) /= 1) .AND. ALL(model%elem_conn(:, e) /= nn)) CYCLE @@ -6092,7 +6103,7 @@ SUBROUTINE model_contributor_force(model, q, v, force, ErrStat, ErrMsg, end_node IF (model%has_damping) THEN CALL CD_Axial_Damping_Element_Force(q2(1:3), q2(4:6), v2(1:3), v2(4:6), model%l0(e), & model%ba_dyn(e), f2, ErrStat, ErrMsg, & - l0_dot=model%l0_dot(e)) + l0_dot=model%l0_dot(e), inputs_validated=.TRUE.) IF (ErrStat /= 0) RETURN CALL scatter_element_vector(force, idx, f2) END IF @@ -6121,7 +6132,7 @@ SUBROUTINE model_contributor_force(model, q, v, force, ErrStat, ErrMsg, end_node CALL CD_Morison_Drag_Element_Force(q2(1:3), q2(4:6), v2(1:3), v2(4:6), model%l0(e), & fluid2(:, 1), fluid2(:, 2), wl2(1), wl2(2), model%drag_rho, & model%drag_diameter_elem(e), model%drag_cdn_elem(e), & - model%drag_cdt_elem(e), f2, ErrStat, ErrMsg) + model%drag_cdt_elem(e), f2, ErrStat, ErrMsg, inputs_validated=.TRUE.) IF (ErrStat /= 0) RETURN CALL scatter_element_vector(force, idx, f2) END IF @@ -6131,7 +6142,7 @@ SUBROUTINE model_contributor_force(model, q, v, force, ErrStat, ErrMsg, end_node CALL CD_Froude_Krylov_Element_Force(q2(1:3), q2(4:6), v2(1:3), v2(4:6), model%l0(e), & accel2(:, 1), accel2(:, 2), wl2(1), wl2(2), model%fk_rho, & model%fk_diameter_elem(e), model%fk_can_elem(e), & - model%fk_cat_elem(e), f2, ErrStat, ErrMsg) + model%fk_cat_elem(e), f2, ErrStat, ErrMsg, inputs_validated=.TRUE.) IF (ErrStat /= 0) RETURN CALL scatter_element_vector(force, idx, f2) END IF @@ -6139,7 +6150,8 @@ SUBROUTINE model_contributor_force(model, q, v, force, ErrStat, ErrMsg, end_node CALL extract_nodal_scalar(model%buoyancy_waterline_z, model, e, wl2) CALL CD_Buoyancy_Recovery_Element_Force(q2(1:3), q2(4:6), model%l0(e), wl2(1), wl2(2), & model%buoyancy_rho, model%buoyancy_diameter_elem(e), & - model%buoyancy_gravity, f2, ErrStat, ErrMsg) + model%buoyancy_gravity, f2, ErrStat, ErrMsg, & + inputs_validated=.TRUE.) IF (ErrStat /= 0) RETURN CALL scatter_element_vector(force, idx, f2) END IF @@ -6756,6 +6768,7 @@ SUBROUTINE model_added_mass_banded(model, q, accel, free, kl, ku, M_add_a, M_add END DO END IF + ! validated element inputs (q and accel checked above): see model_contributor_load_banded DO e = 1, model%n_elem CALL extract_element_state(model, e, q, accel, idx, q2, a2) CALL extract_nodal_scalar(model%added_mass_waterline_z, model, e, wl2) @@ -6764,14 +6777,14 @@ SUBROUTINE model_added_mass_banded(model, q, accel, free, kl, ku, M_add_a, M_add CALL CD_Added_Mass_Element_Matrix(q2(1:3), q2(4:6), model%l0(e), wl2(1), wl2(2), & model%added_mass_rho, model%added_mass_diameter_elem(e), & model%added_mass_can_elem(e), model%added_mass_cat_elem(e), & - m2, ErrStat, ErrMsg) + m2, ErrStat, ErrMsg, inputs_validated=.TRUE.) IF (ErrStat /= 0) RETURN ma2 = CD_ZERO ELSE CALL CD_Added_Mass_Element(q2(1:3), q2(4:6), a2(1:3), a2(4:6), model%l0(e), wl2(1), wl2(2), & model%added_mass_rho, model%added_mass_diameter_elem(e), & model%added_mass_can_elem(e), model%added_mass_cat_elem(e), & - m2, dm2, ErrStat, ErrMsg) + m2, dm2, ErrStat, ErrMsg, inputs_validated=.TRUE.) IF (ErrStat /= 0) RETURN ma2 = MATMUL(m2, a2) END IF @@ -6779,7 +6792,7 @@ SUBROUTINE model_added_mass_banded(model, q, accel, free, kl, ku, M_add_a, M_add CALL CD_Added_Mass_Element_Force(q2(1:3), q2(4:6), a2(1:3), a2(4:6), model%l0(e), wl2(1), wl2(2), & model%added_mass_rho, model%added_mass_diameter_elem(e), & model%added_mass_can_elem(e), model%added_mass_cat_elem(e), & - ma2, ErrStat, ErrMsg) + ma2, ErrStat, ErrMsg, inputs_validated=.TRUE.) IF (ErrStat /= 0) RETURN END IF CALL scatter_element_vector(M_add_a, idx, ma2) diff --git a/src/CableDyn_System.f90 b/src/CableDyn_System.f90 index 65c2c140..aceed8f4 100644 --- a/src/CableDyn_System.f90 +++ b/src/CableDyn_System.f90 @@ -3158,8 +3158,8 @@ SUBROUTINE CD_System_Restore(system, ErrStat, ErrMsg) IF (ALLOCATED(system%lines(i)%f_ext_dist_base)) & system%lines(i)%f_ext_dist_base = system%snap_fbase(lo:hi) IF (MAXVAL(ABS(system%lines(i)%l0 - system%snap_l0(le:he))) > CD_ZERO) THEN - ! The consistent mass follows l0 implicitly (never stored); only the - ! length-dependent seabed coefficients need a rebuild. + ! The consistent mass follows l0 implicitly (the step rebuilds its mass band when the + ! lengths change); only the length-dependent seabed coefficients need a rebuild. system%lines(i)%l0 = system%snap_l0(le:he) IF (system%lines(i)%has_seabed .AND. system%lines(i)%has_seabed_recompute) THEN CALL CD_Nodal_Seabed_Stiffness(system%lines(i)%seabed_kbot, & diff --git a/tests/test_cable_dynamic.f90 b/tests/test_cable_dynamic.f90 index 12478a2c..b38de153 100644 --- a/tests/test_cable_dynamic.f90 +++ b/tests/test_cable_dynamic.f90 @@ -39,6 +39,7 @@ PROGRAM test_cable_dynamic CALL case_dynamic_load_callback_matches_fext() CALL case_banded_load_callback_matches_dense() CALL case_workspace_matches_legacy_step() + CALL case_workspace_mass_band_follows_inputs() CALL case_modified_newton_reuses_tangent() CALL case_line_search_fallback_handles_bad_tangent() CALL case_added_mass_callback_changes_initial_acceleration() @@ -46,6 +47,7 @@ PROGRAM test_cable_dynamic CALL case_preassembled_mass_rejects_offband_entries() CALL case_banded_added_mass_honors_structural_mass() CALL case_banded_dense_callback_mix_rejected() + CALL case_junction_tangent_after_allowance_exit() CALL case_fixed_dofs_held() CALL case_fail_closed() CALL case_failure_returns_input_state() @@ -369,6 +371,87 @@ SUBROUTINE case_workspace_matches_legacy_step() END DO END SUBROUTINE case_workspace_matches_legacy_step + SUBROUTINE case_workspace_mass_band_follows_inputs() + !! A reusable workspace keeps the element mass band of its last step and reuses it while + !! the connectivity, free list, l0 and rho_a are unchanged. A change of any of them, or an + !! initial-acceleration solve (which factors the band in place), rebuilds it: every step + !! equals the same step through a fresh workspace bit for bit. + INTEGER :: conn(2, 2), es + REAL(wp) :: l0(2), ea(2), rho_a(2), q0(9), f_ext(9), q(9), v(9), a(9), l0b(2), rhob(2) + TYPE(CD_CableGenAlphaWorkspace) :: work + CHARACTER(120) :: em + + CALL three_node_chain(conn, l0, ea, rho_a, q0) + f_ext = 0.0_wp + f_ext(6) = -15.0_wp + q = q0 + q(6) = -0.04_wp + v = 0.0_wp + v(6) = -0.05_wp + a = 0.0_wp + a(5) = 0.2_wp + l0b = [0.9_wp, 0.93_wp] + rhob = [5.0_wp, 6.5_wp] + + ! each step states whether it must reuse the remembered band (the workspace's test-only + ! hit counter), so a cache that never hits fails here + CALL mass_band_step_pair(work, q, v, a, conn, l0, ea, rho_a, f_ext, [1, 2, 3, 7, 8, 9], .FALSE., & + 'mass-band:first') + CALL require(work%mb_valid, 'mass-band:remembered') + CALL mass_band_step_pair(work, q, v, a, conn, l0, ea, rho_a, f_ext, [1, 2, 3, 7, 8, 9], .TRUE., & + 'mass-band:reused') + CALL mass_band_step_pair(work, q, v, a, conn, l0b, ea, rho_a, f_ext, [1, 2, 3, 7, 8, 9], .FALSE., & + 'mass-band:new-l0') + CALL mass_band_step_pair(work, q, v, a, conn, l0b, ea, rhob, f_ext, [1, 2, 3, 7, 8, 9], .FALSE., & + 'mass-band:new-rho') + CALL mass_band_step_pair(work, q, v, a, conn, l0b, ea, rhob, f_ext, [1, 2, 3, 7, 8, 9], .TRUE., & + 'mass-band:new-rho-reused') + CALL mass_band_step_pair(work, q, v, a, conn, l0, ea, rho_a, f_ext, [1, 2, 3, 7, 8, 9], .FALSE., & + 'mass-band:back') + CALL mass_band_step_pair(work, q, v, a, conn, l0, ea, rho_a, f_ext, [1, 2, 3], .FALSE., & + 'mass-band:new-free-list') + CALL mass_band_step_pair(work, q, v, a, conn, l0, ea, rho_a, f_ext, [1, 2, 3], .TRUE., & + 'mass-band:new-free-list-reused') + CALL CD_Cable_Initial_Acceleration(q, v, conn, l0, ea, rho_a, .FALSE., f_ext, [1, 2, 3], & + a, es, em, workspace=work) + CALL expect_es(es, CD_DYN_OK, 'mass-band:initial-acceleration') + CALL require(.NOT. work%mb_valid, 'mass-band:initial-acceleration-clears') + CALL mass_band_step_pair(work, q, v, a, conn, l0, ea, rho_a, f_ext, [1, 2, 3], .FALSE., & + 'mass-band:after-initial-acceleration') + CALL mass_band_step_pair(work, q, v, a, conn, l0, ea, rho_a, f_ext, [1, 2, 3], .TRUE., & + 'mass-band:after-initial-acceleration-reused') + END SUBROUTINE case_workspace_mass_band_follows_inputs + + SUBROUTINE mass_band_step_pair(work, q, v, a, conn, l0, ea, rho_a, f_ext, fixed, expect_hit, label) + !! One step through the shared workspace and the same step through a fresh one; the shared + !! step reuses the remembered mass band exactly when expect_hit (test-only counter mb_hits). + TYPE(CD_CableGenAlphaWorkspace), INTENT(INOUT) :: work + REAL(wp), INTENT(IN) :: q(9), v(9), a(9), l0(2), ea(2), rho_a(2), f_ext(9) + INTEGER, INTENT(IN) :: conn(2, 2), fixed(:) + LOGICAL, INTENT(IN) :: expect_hit + CHARACTER(*), INTENT(IN) :: label + INTEGER, PARAMETER :: I8 = SELECTED_INT_KIND(18) + TYPE(GenAlphaConfig) :: cfg + TYPE(CD_CableGenAlphaWorkspace) :: fresh + REAL(wp) :: q_w(9), v_w(9), a_w(9), q_f(9), v_f(9), a_f(9) + INTEGER :: es_w, es_f, it_w, it_f, hits + LOGICAL :: conv_w, conv_f, stall_w, stall_f + CHARACTER(120) :: em_w, em_f + + hits = work%mb_hits + CALL CD_Cable_Gen_Alpha_Step(q, v, a, conn, l0, ea, rho_a, .FALSE., f_ext, fixed, 0.01_wp, cfg, & + q_w, v_w, a_w, conv_w, stall_w, it_w, es_w, em_w, workspace=work) + CALL require(work%mb_hits == hits + MERGE(1, 0, expect_hit), label//':cache-hit') + CALL CD_Cable_Gen_Alpha_Step(q, v, a, conn, l0, ea, rho_a, .FALSE., f_ext, fixed, 0.01_wp, cfg, & + q_f, v_f, a_f, conv_f, stall_f, it_f, es_f, em_f, workspace=fresh) + CALL require(fresh%mb_hits == 0, label//':fresh-no-hit') + CALL expect_es(es_w, CD_DYN_OK, label//':status') + CALL require(conv_w .AND. conv_f .AND. it_w == it_f .AND. es_w == es_f, label//':flags') + CALL require(ALL(TRANSFER(q_w, [0_I8]) == TRANSFER(q_f, [0_I8])) .AND. & + ALL(TRANSFER(v_w, [0_I8]) == TRANSFER(v_f, [0_I8])) .AND. & + ALL(TRANSFER(a_w, [0_I8]) == TRANSFER(a_f, [0_I8])), label//':bitwise') + END SUBROUTINE mass_band_step_pair + SUBROUTINE case_modified_newton_reuses_tangent() !! The EI=0 generalized-alpha config advertises modified Newton. It must reuse !! the tangent within a step without changing the accepted state. @@ -820,6 +903,106 @@ SUBROUTINE case_banded_dense_callback_mix_rejected() CALL expect_es(es, CD_DYN_BADINPUT, 'mix:init-load+amband-rejected') END SUBROUTINE case_banded_dense_callback_mix_rejected + SUBROUTINE case_junction_tangent_after_allowance_exit() + !! A step accepted by the near-tolerance allowance at the iteration limit exits right after + !! a fresh tangent evaluation, which overwrites the factored effective band with the + !! unfactored tangent. The junction end query must not back-solve with it as if it were + !! the last LU factorization: its condensed end tangent and end map must agree with those + !! the same converged iterate gets through an ordinary exit (whose factor is a valid LU). + INTEGER, PARAMETER :: I8 = SELECTED_INT_KIND(18) + INTEGER :: conn(2, 3), n_iter, k + REAL(wp) :: l0(3), ea(3), rho_a(3), f_ext(12), q(12), v(12) + REAL(wp) :: q_b(12), q_r(12), rel_tol, kb(6, 6), kr(6, 6), xb(6, 6), xr(6, 6), err_k, err_x + LOGICAL :: converged, found, valid + + ! two free nodes between held ends, so the effective tangent couples the free nodes + conn = RESHAPE([1, 2, 2, 3, 3, 4], [2, 3]) + l0 = 0.9_wp + ea = 1000.0_wp + rho_a = 5.0_wp + q = [0.0_wp, 0.0_wp, 0.0_wp, 1.0_wp, 0.0_wp, -0.1_wp, 2.0_wp, 0.0_wp, -0.1_wp, 3.0_wp, 0.0_wp, 0.0_wp] + f_ext = 0.0_wp + f_ext(6) = -15.0_wp + v = 0.0_wp + v(6) = -0.005_wp + callback_kq = 20.0_wp + callback_cv = 3.0_wp + ! a tolerance for which the single allowed Newton iteration ends between rel_tol and the + ! allowance 2 rel_tol: the step converges at the limit after a second, fresh tangent + found = .FALSE. + DO k = 0, 40 + rel_tol = 7.0e-9_wp*10.0_wp**(-0.25_wp*REAL(k, wp)) + CALL junction_query_step(conn, l0, ea, rho_a, f_ext, q, v, rel_tol, q_b, converged, n_iter, kb, xb, valid) + IF (converged .AND. n_iter == 1 .AND. callback_tangent_count >= 2) THEN + found = .TRUE. + EXIT + END IF + END DO + CALL require(found, 'allowance-exit:path-taken') + IF (.NOT. found) RETURN + CALL require(valid, 'allowance-exit:end-query-valid') + ! the same iterate through an ordinary exit: the allowance as the tolerance + CALL junction_query_step(conn, l0, ea, rho_a, f_ext, q, v, 2.0_wp*rel_tol, q_r, converged, n_iter, kr, xr, valid) + CALL require(converged .AND. valid .AND. callback_tangent_count == 1, 'allowance-exit:reference-ordinary-exit') + CALL require(ALL(TRANSFER(q_b, [0_I8]) == TRANSFER(q_r, [0_I8])), 'allowance-exit:same-iterate') + err_k = nan_max_abs(kb - kr)/nan_max_abs(kr) + err_x = nan_max_abs(xb - xr)/nan_max_abs(xr) + IF (.NOT. (err_k <= 1.0e-6_wp .AND. err_x <= 1.0e-6_wp)) & + WRITE (*, '(A,ES10.3,A,ES10.3)') 'allowance-exit: relative end-tangent error ', err_k, & + ', end-map error ', err_x + CALL require(err_k <= 1.0e-6_wp, 'allowance-exit:end-tangent-matches-ordinary-exit') + CALL require(err_x <= 1.0e-6_wp, 'allowance-exit:end-map-matches-ordinary-exit') + END SUBROUTINE case_junction_tangent_after_allowance_exit + + SUBROUTINE junction_query_step(conn, l0, ea, rho_a, f_ext, q, v, rel_tol, q_new, converged, n_iter, & + end_k, end_x, valid) + !! One step of the four-node line (ends held) with the junction end query armed, one Newton + !! iteration allowed and a counted banded load, through a fresh workspace. + INTEGER, INTENT(IN) :: conn(2, 3) + REAL(wp), INTENT(IN) :: l0(3), ea(3), rho_a(3), f_ext(12), q(12), v(12), rel_tol + REAL(wp), INTENT(OUT) :: q_new(12), end_k(6, 6), end_x(6, 6) + LOGICAL, INTENT(OUT) :: converged, valid + INTEGER, INTENT(OUT) :: n_iter + TYPE(CD_CableGenAlphaWorkspace) :: work + TYPE(GenAlphaConfig) :: cfg + REAL(wp) :: a(12), v_new(12), a_new(12) + INTEGER :: es + LOGICAL :: stalled + CHARACTER(120) :: em + + ! a consistent start: the predictor is then close to the step solution + CALL CD_Cable_Initial_Acceleration(q, v, conn, l0, ea, rho_a, .FALSE., f_ext, [1, 2, 3, 10, 11, 12], a, es, em, & + load_force_proc=linear_force_only) + CALL expect_es(es, CD_DYN_OK, 'allowance-exit:initial-acceleration') + cfg%rel_tol = rel_tol + cfg%abs_tol = TINY(1.0_wp) + cfg%max_iter = 1 + work%end_request = .TRUE. + callback_tangent_count = 0 + CALL CD_Cable_Gen_Alpha_Step(q, v, a, conn, l0, ea, rho_a, .FALSE., f_ext, [1, 2, 3, 10, 11, 12], 1.0e-3_wp, & + cfg, q_new, v_new, a_new, converged, stalled, n_iter, es, em, & + load_force_proc=linear_force_only, load_band_proc=counting_banded_load, & + workspace=work) + CALL expect_es(es, CD_DYN_OK, 'allowance-exit:step') + end_k = 0.0_wp + end_x = 0.0_wp + valid = work%end_valid + IF (valid) THEN + end_k = work%end_k + end_x = work%end_x + END IF + END SUBROUTINE junction_query_step + + SUBROUTINE counting_banded_load(q_in, v_in, free, kl, ku, force, jac_q_band, jac_v_band, ErrStat, ErrMsg) + !! banded_linear_load, counting the tangent evaluations. + REAL(wp), INTENT(IN) :: q_in(:), v_in(:) + INTEGER, INTENT(IN) :: free(:), kl, ku + REAL(wp), INTENT(OUT) :: force(:), jac_q_band(:, :), jac_v_band(:, :) + INTEGER, INTENT(OUT) :: ErrStat + CHARACTER(*), INTENT(OUT) :: ErrMsg + callback_tangent_count = callback_tangent_count + 1 + CALL banded_linear_load(q_in, v_in, free, kl, ku, force, jac_q_band, jac_v_band, ErrStat, ErrMsg) + END SUBROUTINE counting_banded_load SUBROUTINE case_fixed_dofs_held() !! Fixed DOFs are returned bit-exactly at their q0 value with zero velocity and !! acceleration, even while the free interior node accelerates under gravity. diff --git a/tests/test_damping.f90 b/tests/test_damping.f90 index 3893a850..2de3cb0f 100644 --- a/tests/test_damping.f90 +++ b/tests/test_damping.f90 @@ -101,6 +101,33 @@ SUBROUTINE case_element_kernel_matches_cable_path() force_only, es, em) CALL require(es == CD_DAMP_OK, 'element:force-ok') CALL require(nan_max_abs(force_only - force_ref) < 1.0e-9_wp, 'element:force-only-match') + + ! inputs_validated (the model hot path) skips only the input scan: the outputs, status and + ! message equal the default call's bit for bit, for a regular and a collapsed element + BLOCK + INTEGER, PARAMETER :: I8 = SELECTED_INT_KIND(18) + REAL(wp) :: f2(6), jq2(6, 6), jv2(6, 6) + INTEGER :: es2, icase + CHARACTER(160) :: em2 + DO icase = 1, 2 + IF (icase == 2) q(4:6) = q(1:3) + CALL CD_Axial_Damping_Element_Load(q(1:3), q(4:6), v(1:3), v(4:6), l0(1), ba(1), & + force_elem, jq_elem, jv_elem, es, em, l0_dot=0.3_wp) + CALL CD_Axial_Damping_Element_Load(q(1:3), q(4:6), v(1:3), v(4:6), l0(1), ba(1), & + f2, jq2, jv2, es2, em2, l0_dot=0.3_wp, inputs_validated=.TRUE.) + CALL require(ALL(TRANSFER(force_elem, [0_I8]) == TRANSFER(f2, [0_I8])) .AND. & + ALL(TRANSFER(jq_elem, [0_I8]) == TRANSFER(jq2, [0_I8])) .AND. & + ALL(TRANSFER(jv_elem, [0_I8]) == TRANSFER(jv2, [0_I8])) .AND. & + es == es2 .AND. em == em2, 'element:validated-load-bitwise') + CALL CD_Axial_Damping_Element_Force(q(1:3), q(4:6), v(1:3), v(4:6), l0(1), ba(1), & + force_only, es, em, l0_dot=0.3_wp) + CALL CD_Axial_Damping_Element_Force(q(1:3), q(4:6), v(1:3), v(4:6), l0(1), ba(1), & + f2, es2, em2, l0_dot=0.3_wp, inputs_validated=.TRUE.) + CALL require(ALL(TRANSFER(force_only, [0_I8]) == TRANSFER(f2, [0_I8])) .AND. & + es == es2 .AND. em == em2, 'element:validated-force-bitwise') + END DO + CALL require(es2 == CD_DAMP_BADINPUT, 'element:validated-collapsed-fails') + END BLOCK END SUBROUTINE case_element_kernel_matches_cable_path SUBROUTINE case_signed_tension() diff --git a/tests/test_hydro.f90 b/tests/test_hydro.f90 index 8cb6ad1b..1c5a4fd1 100644 --- a/tests/test_hydro.f90 +++ b/tests/test_hydro.f90 @@ -42,6 +42,7 @@ PROGRAM test_hydro CALL test_added_mass_element_matches_cable_path() CALL test_added_mass_element_matrix_matches_cable_path() CALL test_cable_added_mass_derivative_matches_fd() + CALL test_element_kernels_validated_path() CALL test_added_mass_and_fk() CALL test_current_profile() CALL test_seastate_steady_current() @@ -758,6 +759,133 @@ SUBROUTINE reference_profile_ratios(k, depth, z_eval, cosh_ratio, sinh_ratio) sinh_ratio = (e_kz - e_neg)/denom END SUBROUTINE reference_profile_ratios + SUBROUTINE test_element_kernels_validated_path() + !! inputs_validated (the model hot path) skips only the per-element input scan: on valid + !! inputs every output, status and message of each element kernel is bit-for-bit the + !! default call's, including the failures that remain possible -- a collapsed element and + !! finite end nodes whose chord length overflows (the tangent check of the Froude-Krylov + !! and added-mass per-length forms). + CHARACTER(*), PARAMETER :: NO_DIRECTION = 'CableDyn_Hydro: tangent must be a non-zero direction' + INTEGER :: icase, es1, es2 + REAL(wp) :: q(6), v(6), accel(3, 2), fluid(3, 2), acc6(6), wl(2), l0 + REAL(wp) :: f1(6), f2(6), jq1(6, 6), jq2(6, 6), jv1(6, 6), jv2(6, 6) + CHARACTER(160) :: em1, em2 + CHARACTER(40) :: label + + fluid(:, 1) = [0.8_wp, 0.1_wp, -0.2_wp] + fluid(:, 2) = [0.3_wp, 0.6_wp, 0.1_wp] + accel(:, 1) = [0.5_wp, -0.2_wp, 0.4_wp] + accel(:, 2) = [-0.1_wp, 0.6_wp, 0.2_wp] + acc6 = [0.3_wp, -0.1_wp, 0.2_wp, -0.4_wp, 0.5_wp, -0.2_wp] + v = [0.14_wp, -0.23_wp, 0.04_wp, -0.07_wp, 0.19_wp, -0.11_wp] + wl = [0.05_wp, -0.02_wp] + l0 = 1.7_wp + ! case 4 overflows the chord length on purpose: must not halt a trapping build + CALL IEEE_GET_HALTING_MODE(IEEE_USUAL, fp_halt) + CALL IEEE_SET_HALTING_MODE(IEEE_USUAL, .FALSE.) + DO icase = 1, 4 + SELECT CASE (icase) + CASE (1) ! surface-piercing + q = [-0.2_wp, 0.1_wp, -0.8_wp, 1.4_wp, -0.3_wp, 0.2_wp] + CASE (2) ! fully wet + q = [0.1_wp, -0.2_wp, -2.6_wp, 1.2_wp, 0.4_wp, -1.25_wp] + CASE (3) ! collapsed + q = [0.3_wp, 0.3_wp, -1.0_wp, 0.3_wp, 0.3_wp, -1.0_wp] + CASE DEFAULT ! finite ends, overflowing chord length + q = [-1.0e300_wp, 0.0_wp, -1.0_wp, 1.0e300_wp, 0.0_wp, -1.0_wp] + END SELECT + WRITE (label, '(A,I0,A)') 'validated-path case ', icase, ': ' + + CALL CD_Morison_Drag_Element_Load(q(1:3), q(4:6), v(1:3), v(4:6), l0, fluid(:, 1), fluid(:, 2), & + wl(1), wl(2), 1025.0_wp, 0.24_wp, 1.05_wp, 0.32_wp, f1, jq1, jv1, es1, em1) + CALL CD_Morison_Drag_Element_Load(q(1:3), q(4:6), v(1:3), v(4:6), l0, fluid(:, 1), fluid(:, 2), & + wl(1), wl(2), 1025.0_wp, 0.24_wp, 1.05_wp, 0.32_wp, f2, jq2, jv2, es2, em2, & + inputs_validated=.TRUE.) + CALL require(same_bits(f1, f2) .AND. same_bits(jq1, jq2) .AND. same_bits(jv1, jv2) .AND. & + es1 == es2 .AND. em1 == em2, TRIM(label)//'drag load') + CALL CD_Morison_Drag_Element_Force(q(1:3), q(4:6), v(1:3), v(4:6), l0, fluid(:, 1), fluid(:, 2), & + wl(1), wl(2), 1025.0_wp, 0.24_wp, 1.05_wp, 0.32_wp, f1, es1, em1) + CALL CD_Morison_Drag_Element_Force(q(1:3), q(4:6), v(1:3), v(4:6), l0, fluid(:, 1), fluid(:, 2), & + wl(1), wl(2), 1025.0_wp, 0.24_wp, 1.05_wp, 0.32_wp, f2, es2, em2, & + inputs_validated=.TRUE.) + CALL require(same_bits(f1, f2) .AND. es1 == es2 .AND. em1 == em2, TRIM(label)//'drag force') + + CALL CD_Froude_Krylov_Element_Load(q(1:3), q(4:6), v(1:3), v(4:6), l0, accel(:, 1), accel(:, 2), & + wl(1), wl(2), 1025.0_wp, 0.24_wp, 1.1_wp, 0.2_wp, f1, jq1, jv1, es1, em1) + CALL CD_Froude_Krylov_Element_Load(q(1:3), q(4:6), v(1:3), v(4:6), l0, accel(:, 1), accel(:, 2), & + wl(1), wl(2), 1025.0_wp, 0.24_wp, 1.1_wp, 0.2_wp, f2, jq2, jv2, es2, em2, & + inputs_validated=.TRUE.) + CALL require(same_bits(f1, f2) .AND. same_bits(jq1, jq2) .AND. same_bits(jv1, jv2) .AND. & + es1 == es2 .AND. em1 == em2, TRIM(label)//'FK load') + CALL require(nan_max_abs(jv2) <= CD_ZERO, TRIM(label)//'FK load has no velocity Jacobian') + CALL CD_Froude_Krylov_Element_Force(q(1:3), q(4:6), v(1:3), v(4:6), l0, accel(:, 1), accel(:, 2), & + wl(1), wl(2), 1025.0_wp, 0.24_wp, 1.1_wp, 0.2_wp, f1, es1, em1) + CALL CD_Froude_Krylov_Element_Force(q(1:3), q(4:6), v(1:3), v(4:6), l0, accel(:, 1), accel(:, 2), & + wl(1), wl(2), 1025.0_wp, 0.24_wp, 1.1_wp, 0.2_wp, f2, es2, em2, & + inputs_validated=.TRUE.) + CALL require(same_bits(f1, f2) .AND. es1 == es2 .AND. em1 == em2, TRIM(label)//'FK force') + IF (icase == 4) CALL require(es2 == CD_HYDRO_BADINPUT .AND. em2 == NO_DIRECTION, & + TRIM(label)//'FK force tangent check') + + CALL CD_Buoyancy_Recovery_Element_Load(q(1:3), q(4:6), l0, wl(1), wl(2), 1025.0_wp, 0.24_wp, 9.80665_wp, & + f1, jq1, jv1, es1, em1) + CALL CD_Buoyancy_Recovery_Element_Load(q(1:3), q(4:6), l0, wl(1), wl(2), 1025.0_wp, 0.24_wp, 9.80665_wp, & + f2, jq2, jv2, es2, em2, inputs_validated=.TRUE.) + CALL require(same_bits(f1, f2) .AND. same_bits(jq1, jq2) .AND. same_bits(jv1, jv2) .AND. & + es1 == es2 .AND. em1 == em2, TRIM(label)//'buoyancy load') + CALL require(nan_max_abs(jv2) <= CD_ZERO, TRIM(label)//'buoyancy load has no velocity Jacobian') + CALL CD_Buoyancy_Recovery_Element_Force(q(1:3), q(4:6), l0, wl(1), wl(2), 1025.0_wp, 0.24_wp, 9.80665_wp, & + f1, es1, em1) + CALL CD_Buoyancy_Recovery_Element_Force(q(1:3), q(4:6), l0, wl(1), wl(2), 1025.0_wp, 0.24_wp, 9.80665_wp, & + f2, es2, em2, inputs_validated=.TRUE.) + CALL require(same_bits(f1, f2) .AND. es1 == es2 .AND. em1 == em2, TRIM(label)//'buoyancy force') + + CALL CD_Added_Mass_Element(q(1:3), q(4:6), acc6(1:3), acc6(4:6), l0, wl(1), wl(2), & + 1025.0_wp, 0.24_wp, 1.1_wp, 0.2_wp, jq1, jv1, es1, em1) + CALL CD_Added_Mass_Element(q(1:3), q(4:6), acc6(1:3), acc6(4:6), l0, wl(1), wl(2), & + 1025.0_wp, 0.24_wp, 1.1_wp, 0.2_wp, jq2, jv2, es2, em2, inputs_validated=.TRUE.) + CALL require(same_bits(jq1, jq2) .AND. same_bits(jv1, jv2) .AND. es1 == es2 .AND. em1 == em2, & + TRIM(label)//'added mass') + CALL CD_Added_Mass_Element_Matrix(q(1:3), q(4:6), l0, wl(1), wl(2), 1025.0_wp, 0.24_wp, 1.1_wp, 0.2_wp, & + jq1, es1, em1) + CALL CD_Added_Mass_Element_Matrix(q(1:3), q(4:6), l0, wl(1), wl(2), 1025.0_wp, 0.24_wp, 1.1_wp, 0.2_wp, & + jq2, es2, em2, inputs_validated=.TRUE.) + CALL require(same_bits(jq1, jq2) .AND. es1 == es2 .AND. em1 == em2, TRIM(label)//'added-mass matrix') + IF (icase == 4) CALL require(es2 == CD_HYDRO_BADINPUT .AND. em2 == NO_DIRECTION, & + TRIM(label)//'added-mass matrix tangent check') + CALL CD_Added_Mass_Element_Force(q(1:3), q(4:6), acc6(1:3), acc6(4:6), l0, wl(1), wl(2), & + 1025.0_wp, 0.24_wp, 1.1_wp, 0.2_wp, f1, es1, em1) + CALL CD_Added_Mass_Element_Force(q(1:3), q(4:6), acc6(1:3), acc6(4:6), l0, wl(1), wl(2), & + 1025.0_wp, 0.24_wp, 1.1_wp, 0.2_wp, f2, es2, em2, inputs_validated=.TRUE.) + CALL require(same_bits(f1, f2) .AND. es1 == es2 .AND. em1 == em2, TRIM(label)//'added-mass force') + IF (icase == 4) CALL require(es2 == CD_HYDRO_BADINPUT .AND. em2 == NO_DIRECTION, & + TRIM(label)//'added-mass force tangent check') + END DO + CALL IEEE_SET_FLAG(IEEE_USUAL, .FALSE.) + CALL IEEE_SET_HALTING_MODE(IEEE_USUAL, fp_halt) + END SUBROUTINE test_element_kernels_validated_path + + PURE LOGICAL FUNCTION same_bits(a, b) RESULT(same) + !! a and b hold the same binary64 values bit for bit (signed zeros and NaNs included). + REAL(wp), INTENT(IN) :: a(..), b(..) + INTEGER, PARAMETER :: I8 = SELECTED_INT_KIND(18) + same = .FALSE. + SELECT RANK (a) + RANK (1) + SELECT RANK (b) + RANK (1) + same = SIZE(a) == SIZE(b) + IF (same) same = ALL(TRANSFER(a, [0_I8]) == TRANSFER(b, [0_I8])) + END SELECT + RANK (2) + SELECT RANK (b) + RANK (2) + same = SIZE(a) == SIZE(b) + IF (same) same = ALL(TRANSFER(a, [0_I8]) == TRANSFER(b, [0_I8])) + END SELECT + END SELECT + END FUNCTION same_bits + SUBROUTINE test_fail_closed() REAL(wp) :: force(3), jac_rel(3, 3), jac_tan(3, 3) INTEGER :: es From c66918caa29071124ddf3e25c41e1abc2a166275 Mon Sep 17 00:00:00 2001 From: Jae Hoon Seo Date: Sat, 17 Oct 2026 06:04:39 +0900 Subject: [PATCH 14/31] fix(dynamics): stop EI=0 tension spikes at slack/taut switching (#20) Tension-only (EI = 0) lines produced silent tension spikes of 5x to 360x when parts of a line went slack, at the default rhoInf = 0.4 and every dtM from 0.002 to 0.2 s: a light, axially stiff cable in 3 m heave reported 4.2 MN at the fairlead against about 0.1 MN, the same cable in an Hs 8 m sea 0.41 MN at the anchor against 0.043 MN, and a semi-taut chain-polyester leg 9.5 MN against 4.6 MN. Two mechanisms: the axial force was evaluated at the blended configuration q_alpha, so a segment slack at the start of a step ended it over-stretched; and a segment released from taut to slack within a step returned more work than its strain energy. - The step now blends forces, (1 - af) r(q_{n+1}, v_{n+1}) + af r(q_n, v_n), as the finite-EI path does, for the axial force and every dynamic load (added mass stays at q_alpha). The step-start force is recomputed at the committed state, so no state is added and restarts stay exact. False alpha_force_blend selects the former scheme. - A segment that releases within a step keeps at most the step-start force that its stored energy W_n = T_n e_n / 2 can do over the projected chord shortening l_n - t_n . d_{n+1}, crediting the end share, with a consistent tangent; the bound covers rotating releases, the kept axial-damping share and the viscoelastic and Syrope law tensions (their end tension estimated with the law stiffness). Taut lines that do not turn are never capped. - modified_newton rebuilds the tangent when an iterate reduces the residual by less than a factor four, as the manual states. - The standalone driver audits EI = 0 lines from t = 0: a warning at the first non-physical tension spike of a line, and notes for taut segments turning more than 1 deg per step, for snaps whose axial wave crosses a segment more than once per step, and for rhoInf above 0.95. At the default rhoInf the reproducers now match their fine-step references. Taut lines keep their accuracy: every MoorDyn-C, OrcaFlex, analytic and experimental comparison that runs locally still passes (the snap-load peak at 20 ms improves from 2.76 % to 1.5 %; the Bergdahl record is rerun, RMSE 1.58 N); the OpenFAST and FAST.Farm records using EI = 0 dynamics are unchanged within their recorded figures. Every EI = 0 dynamic output changes; over the shipped examples tension statistics move by at most 0.23 % (mean) and 0.9 % (maximum), except the two line-break decks. Static runs and finite-EI lines are unchanged; EI = 0 dynamic decks cost up to 6 % more time. Signed-off-by: Jae Hoon Seo --- CHANGELOG.md | 69 + CMakeLists.txt | 6 + VALIDATION.md | 28 +- doc/capi.rst | 5 +- doc/driver_format.md | 2 +- doc/options.rst | 31 +- doc/theory.rst | 182 +- doc/troubleshooting.rst | 25 + examples/cabledyn_options_reference.dat | 2 +- src/CableDyn_DeckDriver.f90 | 142 +- src/CableDyn_Dynamic.f90 | 564 ++++++- src/CableDyn_Model.f90 | 387 ++++- tests/test_cable_dynamic.f90 | 56 +- tests/test_core_release_regressions.f90 | 7 +- tests/test_ei0_slack_dynamics.f90 | 1466 +++++++++++++++++ tests/test_validation_records.py | 5 +- validation/experiments/bergdahl/README.md | 11 +- .../bergdahl/aggregate_metrics.json | 18 +- .../bergdahl/comparison_summary.csv | 60 +- .../experiments/bergdahl/provenance.json | 20 +- .../bergdahl/refinement_summary.csv | 4 +- .../bergdahl/refinement_summary.json | 40 +- 22 files changed, 2966 insertions(+), 164 deletions(-) create mode 100644 tests/test_ei0_slack_dynamics.f90 diff --git a/CHANGELOG.md b/CHANGELOG.md index d2006685..d476efcb 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -93,6 +93,19 @@ All notable changes to CableDyn are recorded in this file. The format follows Coupling a host (CFD) solver, that compares the call sequence step by step with MoorDyn's C API: initialisation, vector layout, end-of-step motion, outer correctors, load summation, the fixed step of the aggregate route, and units. +- Run audit of tension-only (`EI = 0`) lines in the standalone driver. On the initial state and + at every output step it tracks the largest turn of a taut segment's chord, the segments that + snap from slack to taut, and non-physical tension spikes: a segment whose tension (the elastic + tension, or that of its viscoelastic or Syrope law) at one step exceeds four times its own one + step before and after, ten times the largest tension anywhere on the line one step before and + after, and the largest tension of the initial state. The first spike of a line is reported as + a warning, once per line, and the run summary counts them. The run ends with a note when a + taut segment turned by more than 1° in one step (the mean and standard deviation of the + tension err by about 1 % and more above it; 1.3 % at 2.9° on a heaving chain), and when + segments snapped taut while the axial wave crosses a segment more than once per step, so the + snap peaks are not resolved in time. The standalone driver also prints a note for a dynamic + deck with `rhoInf` above 0.95, on the missing numerical dissipation. See the manual's + troubleshooting page. ### Changed @@ -153,6 +166,62 @@ All notable changes to CableDyn are recorded in this file. The format follows ### Fixed +- Tension spikes of tension-only (`EI = 0`) lines that go slack. The generalised-α step evaluated + the axial force and the dynamic loads at the blended configuration + `q_α = (1 − α_f) q_{n+1} + α_f q_n`. A segment that was slack at the start of a step and + carries tension at `q_α` then ends the step stretched beyond it, + `q_{n+1} = (q_α − α_f q_n)/(1 − α_f)`, and a segment going slack within a step returned more + work to the motion than its strain energy. Both happened silently at the default + `rhoInf = 0.4`, at every `dtM` from 0.002 to 0.2 s, on realistic input: a light, axially stiff + cable (80 kg/m, EA 8e8 N) under 3 m heave reported 4.2 MN at the fairlead and 3.4 MN at the + anchor (`dtM` 0.0025 s) and 20 MN at the anchor (`dtM` 0.1 s), against 0.1 to 0.18 MN at + `rhoInf = 0`, at `dtM` down to 0.25 ms and with a finite-EI model; the same cable in an `Hs` + 8 m JONSWAP sea 0.41 MN at the anchor against 0.043 MN; the shipped viscoelastic polyester in + 15 m surge 2.69 MN against 1.80 MN; a semi-taut chain–polyester leg 9.5 MN at the anchor + against 4.6 MN; and a line on a stiff seabed failed the plausibility guard. The step now blends + forces, `(1 − α_f) r(q_{n+1}, v_{n+1}) + α_f r(q_n, v_n)`, as the finite-EI path does, for the + axial force and every dynamic load (damping, viscoelastic and Syrope laws, seabed, drag, + Froude–Krylov, buoyancy; added mass stays at `q_α`). The step-start force is evaluated afresh + at the committed state, so no state is added and restarts stay exact. An element that + releases within a step returns at most its strain energy over the step, so a release can no + longer create energy. Its step-start force acts along its step-start chord for the whole step, + so the cap takes the shortening projected on that chord, which a segment that turns as it goes + slack exceeds by far (a nearly unstretched segment turning by 90° would otherwise return + hundreds of times its strain energy), and it fades out continuously as the end state crosses + the rest length. The viscoelastic and Syrope segments are capped the same way with the tension + of their law, their end tension estimated with a secant stiffness bounded by the law's axial + stiffness, so that damping carried at a vanishing stretch does not make the cap switch + abruptly (the same cable made lightly damped viscoelastic peaks at 0.085 MN at the anchor at + `dtM` 0.1 s, a snap that step does not resolve, against 0.145 MN without the cap on its + segments and 0.082 to 0.095 MN at 0.5 to 2.5 ms). An elastic segment with axial damping + keeps the step-start dashpot force along its old chord too; where its end state is slack, or + taut by less than `α_f/(1 − α_f)` of its stretch, the cap covers that force as well, crediting + the dashpot's end share, so that the whole blend of a segment ending slack returns at most its + strain energy unless that end share alone returns more (in the test chain it returned up to + 2750 times that with only the elastic share capped); a damped segment that ends taut beyond + that band keeps the plain force blend. The seabed contact of + a node that lifts off within a step is not capped (see the manual's theory page). At the + default `rhoInf` the reproducers now give 0.10 / 0.09 MN, 0.092 / 0.106 MN, 0.075 / 0.043 MN + and 1.80 MN, as their references, and the stiff-seabed line runs to completion; the + chain–polyester anchor snap peaks at 5.7 MN at `dtM` 0.05 s, a single-step peak (4.6 MN at + 0.0025 s) that the new snap note reports. On a linear element the scheme is unchanged, so taut + lines keep their accuracy: every MoorDyn-C, OrcaFlex, analytic and experimental comparison that + runs locally still passes, and its reported error moves by at most 0.35 percentage points (the + minimum fairlead tension of the one-hour VolturnUS-S record, 0.15 % to 0.50 %; the snap-load + peak at 20 ms improves from 2.76 %, published as 2.7 %, to 1.5 %; see VALIDATION.md). Every + `EI = 0` dynamic output changes. Over the shipped examples the statistics of the tensions + change by at most 0.23 % (mean) and 0.9 % (maximum), except the two `als_volturnus` decks, + whose pre-failure anchor snap at 250 s is resolved by one or two samples and peaks 10 % lower. + Static runs and finite-EI lines are unchanged. The step costs up to 6 % more wall time on + `EI = 0` dynamic decks (one more force evaluation per step and about 4 % more Newton + iterations). `False alpha_force_blend`, which until now applied to finite-EI lines only, + selects the former scheme for `EI = 0` lines as well. Lines that the C API builds without a + deck (`CableDyn_InitLine`, `CableDyn_InitLines`) always take the force blend. +- `modified_newton` on `EI = 0` lines (with or without the force blend, so also under + `False alpha_force_blend`) rebuilds the tangent when an iterate reduces the residual by less + than a factor four, as the manual states; it had kept the first tangent for the whole step, + which a slow linear contraction could exhaust (30 iterations at the start of the 5 m heave + cells of the L2-2 parity test with the force blend). - The development environment (`environment.yml`) excludes OpenBLAS 0.3.34, which caused the access violation in the modal analysis tests listed under Known issues for 0.1.1. On AMD Zen 4 and Zen 5 CPUs that expose AVX-512, OpenBLAS 0.3.34 enlarges the GEMM blocking, diff --git a/CMakeLists.txt b/CMakeLists.txt index e0006d2e..a6dbf325 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -1781,6 +1781,12 @@ add_executable(test_dynamics_regressions tests/test_dynamics_regressions.f90) target_link_libraries(test_dynamics_regressions PRIVATE cabledyn_core) add_test(NAME dynamics_regressions COMMAND test_dynamics_regressions) set_tests_properties(dynamics_regressions PROPERTIES LABELS "fortran;driver;integration;dynamic") +# Tension-only lines going slack and snapping taut at the default rhoInf: force blend, release +# cap and the driver's run audit (the driver executable is passed for its stdout). +add_executable(test_ei0_slack_dynamics tests/test_ei0_slack_dynamics.f90) +target_link_libraries(test_ei0_slack_dynamics PRIVATE cabledyn_core) +add_test(NAME ei0_slack_dynamics COMMAND test_ei0_slack_dynamics $) +set_tests_properties(ei0_slack_dynamics PROPERTIES LABELS "fortran;driver;integration;dynamic") add_executable(test_deck_reader_io tests/test_deck_reader_io.f90) target_link_libraries(test_deck_reader_io PRIVATE cabledyn_core) diff --git a/VALIDATION.md b/VALIDATION.md index 6349554c..cd0fe35a 100644 --- a/VALIDATION.md +++ b/VALIDATION.md @@ -74,15 +74,15 @@ article's methods, are compared in | **L3-6c** | Irregular-sea (JONSWAP) dynamic lazy-wave | OrcaFlex 11.6d (same 80-component sea) | curv 0.21%; tension 0.20/0.19/0.23%; wave-driven curv rise 1.0%, tension range 2.1% | curv <2%, tension <1%; rise <15%, range <10% | Pass | | **L3-6d** | Moving-touchdown dynamic contact | OrcaFlex 11.6d installed | curv 0.48/0.58%, tension 0.74/0.90/0.80%, TDP 0.08 m, migration 2–3 m/cycle | curv <3–5%, tension <2–3%, TDP excursion bounds <1.5 m | Pass | | **L3-6e** | Out-of-plane / 3D whirl response | OrcaFlex 11.6d | 3D curv 0.52%, interior Y env ≤1.0 mm, sag ≤22 mm, tension 0.14/0.17/0.12% | curv <3%, env <5 cm, tension <2–3% | Pass | -| **L3-7** | 1-hour VolturnUS-S mooring dynamic | OrcaFlex 11.6d | `FairTen` mean 0.28%, std 0.25%, min/max 0.15/0.43%, Fourier 0.27/1.13% | ≤5% | Pass | +| **L3-7** | 1-hour VolturnUS-S mooring dynamic | OrcaFlex 11.6d | `FairTen` mean 0.27%, std 0.26%, min/max 0.50/0.43%, Fourier 0.27/1.14% | ≤5% | Pass | | **L3-H** | Holcombe static lazy-wave experiment | measured marker geometry | position RMSE 1.07–1.89% of suspended length; peak marker-curvature error 0.34–5.54% | end-restraint bracket | Pass | -| **L3-B** | Bergdahl chain experiment, 30 orbit conditions | measured upper-end force | RMSE 1.58 N; MAPE 3.11%; Pearson 0.993; Lin concordance 0.989 | full published matrix | Pass | +| **L3-B** | Bergdahl chain experiment, 30 orbit conditions | measured upper-end force | RMSE 1.58 N; MAPE 3.13%; Pearson 0.993; Lin concordance 0.989 | full published matrix | Pass | | **L-fig** | Along-arc curvature overlay (CableDyn / OrcaFlex / MoorDyn-F ±4×) | 3-code committed record | CableDyn peak 0.11% from OrcaFlex | <0.5% | Pass | | **L4-1** | Coupled platform + mooring | synthetic reference | bit-for-bit | — | Pass | | **L4-1b** | VolturnUS-S coupled platform + power cable | OpenFAST v5.0.0 (CompMooring 5 vs 3) | platform DOFs <0.6% (3-seed DLC-1.1); fairlead and anchor <0.001% static | <3% platform | Pass | | **L4-1c** | Lozon lazy-wave cable under coupled FOWT motion, 3 depths | OrcaFlex 11.6d | curv amplification 0.05/0.09/0.01%; dyn curv 0.24/0.35/1.01%; tension <0.7% | ampl <2%, curv <2–3%, tension <1.5–2% | Pass | | **L4-rot** | Coupled mooring rotational stiffness | held 1° pitch geometry | upwind −16.0 kN, downwind +7.8 kN each; first-order restoring moment | signs + first-order | Pass | -| **L5-stab** | Snap-load Δt-stability | sub-CFL fine-dt (0.5 ms) self-ref | peak 2.7% at dt = 20 ms (explicit limit 3.2 ms) | — | Pass | +| **L5-stab** | Snap-load Δt-stability | sub-CFL fine-dt (0.5 ms) self-ref | peak 1.5% at dt = 20 ms (explicit limit 3.2 ms) | — | Pass | | **L5-stab** | Snap-load Δt-stability, implicit and explicit steps | MoorDyn-C explicit step limit | 20 ms implicit; ~1 ms explicit | — | Pass | | **L5-V** | VolturnUS-S 1-hr mooring wall-clock | measured, matched protocol | CableDyn 18.1–32 s across repeated runs (full Newton) vs OrcaFlex 14.5 s; heave-only config 10.3 s | — | Pass (response at L3-7) | | **L5-wc** | Wall-clock vs explicit C solver | external-C RK2 (WD chain) | L2 0.967 s vs external-C 0.541 s; traces validated | matched comparison reported | Pass measured | @@ -178,7 +178,7 @@ initialisation. - **L3-1 WD0050 static** (`l3_orcaflex_static`): fairlead/anchor **0.154% / 0.848%**. The OrcaFlex reference is within 0.657/0.731% of MoorDyn-C. - **L3-2 regular-wave dynamic** (`l3_orcaflex_wave_dynamic`): mean fairlead - tension **0.298%** (2% acceptance), swing **8.405%** (15% acceptance) against an + tension **0.298%** (2% acceptance), swing **8.411%** (15% acceptance) against an OrcaFlex reference with implicit dt 0.005 s. Wave stretching changes the OrcaFlex swing by only 0.18%, and the unpinned OrcaFlex dt=0.1 s is not converged (refinement moves it toward CableDyn). The residual comes from surface-piercing @@ -255,10 +255,11 @@ initialisation. **0.14 / 0.17 / 0.12%**. - **L3-7 1-hour mooring dynamic** (`l3_longduration_mooring`): VolturnUS-S all-chain line driven for one hour by 5 m/90 s surge + 2 m/12 s heave. Over the - steady 3400 s window the `FairTen` channel differs from OrcaFlex by **0.28% in - mean, 0.25% in std, 0.15 / 0.43% in minimum / maximum, and 0.27% (90 s) / 1.13% + steady 3400 s window the `FairTen` channel differs from OrcaFlex by **0.27% in + mean, 0.26% in std, 0.50 / 0.43% in minimum / maximum, and 0.27% (90 s) / 1.14% (12 s) in Fourier amplitude**. The end-element tension carries the 1.28% static - offset of L2-V in its mean and extremes. + offset of L2-V in its mean and extremes. The force-blended `EI = 0` step moved the + minimum by +7 kN (0.15% before) and the other statistics by at most 0.01%. - **L-fig curvature overlay**: `l3_lazywave_dynamic` writes each site's along-arc curvature profile. [`validation/scripts/curvature_profile_overlay.py`](https://github.com/SMI-Lab-Inha/CableDyn/blob/main/validation/scripts/curvature_profile_overlay.py) @@ -287,10 +288,13 @@ scripts, results, and source provenance are in - **L3-B Bergdahl dynamic chain test** ([Bergdahl et al., 2016](https://cabledyn.readthedocs.io/en/latest/references.html#ref-bergdahl2016)): over the full 30-condition period-radius matrix, cycle-maximum upper-end force - has RMSE 1.58 N, mean absolute percentage error 3.11%, Pearson correlation + has RMSE 1.58 N, mean absolute percentage error 3.13%, Pearson correlation 0.993, and Lin concordance 0.989. Two phase-averaged measured histories have - waveform RMSEs of 5.95% and 2.54% of their force ranges. Halving the mesh length - and the time step changes the mean cycle maximum by at most 0.49% and 0.28%. The + waveform RMSEs of 5.95% and 2.54% of their force ranges; these two were computed with the + executable of the 2026-10-09 record (the configuration-blended `EI = 0` step), because the + article supplement's `expData.dat` they need was not available for the rerun (see the + experiment's README and `provenance.json`). Halving the mesh length + and the time step changes the mean cycle maximum by at most 0.52% and 0.19%. The 0.3125 ms step resolves the segment axial modes that the snap loads excite; at 1.25 ms the maxima are 2–15% higher and vary from cycle to cycle. @@ -373,7 +377,9 @@ scripts, results, and source provenance are in - **Snap load** (`snap_load`): a grounded tension-only line goes slack, then snaps to ~10 MN. Implicit generalised-α integrates it at **dt = 20 ms, above the explicit CFL limit of about 3.2 ms**, with every step converged (stable up to about - 30 ms in a sweep); the peak is within **2.7%** of the 0.5 ms sub-CFL reference. + 30 ms in a sweep); the peak is within **1.5%** of the 0.5 ms sub-CFL reference + (1.1% at 10 ms, 0.05% at 5 ms). Before the force-blended `EI = 0` step these were + 2.76 / 0.62 / 0.16%; the 2.76% at 20 ms is the value published as 2.7% (truncated). - **Implicit and explicit steps**: on the matched near-taut snap, MoorDyn-C's explicit RK2 needs `dtM ≲ 1 ms`, as expected of an explicit scheme at this line stiffness; CableDyn's implicit step remains stable at **20 ms**. diff --git a/doc/capi.rst b/doc/capi.rst index 3bdcab8d..aad269a4 100644 --- a/doc/capi.rst +++ b/doc/capi.rst @@ -1044,7 +1044,10 @@ solve returns ``CD_C_SOLVE_FAIL``. The Newton settings are fixed at their defaults: relative residual tolerance :math:`10^{-8}`, at most 30 iterations per step, and at -most 12 line-search backtracks. +most 12 line-search backtracks. So is the generalised-α scheme: these lines always take the +force-blended step (``alpha_force_blend`` ``True``, with the release cap on a tension-only line, +:doc:`theory`). They cannot select the configuration blend of 0.1.1 and earlier +(``False alpha_force_blend``), which only a deck sets, through ``CableDyn_InitDeck``. ``CableDyn_InitLines`` ~~~~~~~~~~~~~~~~~~~~~~ diff --git a/doc/driver_format.md b/doc/driver_format.md index 5b39e369..944eb78f 100644 --- a/doc/driver_format.md +++ b/doc/driver_format.md @@ -1006,7 +1006,7 @@ syntax form. The most frequently edited keywords are: | `cable_load_feedback` | coupled finite-EI cable reaction switch. `True` returns cable force and moment to the host. `False` marches the cable with the same moving boundary and host fluid field and keeps its output channels, but returns zero force and moment; use it for a one-way comparison, not as a physical model | `True` | | `adaptive_mesh` | `True`/`False`; allow finite-EI mesh refinement when the static resolution check is fragile | `False` | | `cable_statics` | `continuation` or `sequenced`: which finite-EI static route runs first (the other is its fallback); both results are audited | `continuation` | -| `alpha_force_blend` | `True`/`False`; generalised-α blend of the finite-EI dynamics: forces (`True`) or the configuration `q_αf` (`False`), which biases the mean tension of a rotating line at large `dtM` | `True` | +| `alpha_force_blend` | `True`/`False`; generalised-α blend of the finite-EI and `EI = 0` dynamics: forces (`True`) or the configuration `q_αf` (`False`), which biases the mean tension of a rotating finite-EI line at large `dtM` and lets `EI = 0` segments that go slack report spurious tension spikes | `True` | | `tensile_safety` | `False`, `warn`, or `True`; audits the element-mean axial force (three-point Gauss mean of the signed axial resultant, averaged over an element and its two neighbours). `True` rejects. `warn` commits the state, counts accepted-step events, and reports the worst force, threshold, element and time (the printed `xi` is always 0.5, the element centre) | `False` | | `tensile_strain_tolerance` | non-negative strain band for the dynamic tensile audit | `2e-6` | | `recovery_max_substeps` | integer from 4 to 65536; maximum step subdivision for dynamic-step recovery on tension-only and bending lines. Internal prescribed states lie on one C2 quintic trajectory and land on the nominal coupling endpoint. The standalone summary reports recovered intervals and the largest subdivision used | `1024` | diff --git a/doc/options.rst b/doc/options.rst index ac834613..6129c06d 100644 --- a/doc/options.rst +++ b/doc/options.rst @@ -294,7 +294,17 @@ rejected as unknown. The dynamic Newton controls are set with ``dynamic_solver`` * - ``rhoInf`` / ``rho_inf`` - real, – - ``0.4`` - - finite, in ``[0, 1]``; generalised-alpha high-frequency spectral radius + - finite, in ``[0, 1]``; generalised-alpha high-frequency spectral radius. Smaller values + damp the modes ``dtM`` does not resolve (axial waves, slack-taut transitions) faster; + ``0`` annihilates them in one step. Above ``0.95`` the march has almost no numerical + dissipation: those modes then keep the residual each Newton step leaves and the energy + of under-resolved snaps, and the standalone driver prints a note. In an irregular sea a + finite-EI lazy wave at ``1 rhoInf`` with a ``1e-4`` relative Newton tolerance peaked at + 2.0e5 N against 1.02e4 N (3.1e4 N at ``0.99``) and was exact with ``1e-6``; ``EI = 0`` + lines at ``1`` and + ``1e-4`` failed the ``maxStrain`` guard, and at the default tolerance their peaks rose + 2 to 5 times at ``0.95`` to ``1``. Keep ``rhoInf`` at or below ``0.95``, or tighten the + ``dynamic_solver`` relative tolerance to ``1e-6`` and resolve the snaps with ``dtM`` - both - ``0.4 rhoInf`` * - ``maxStrain`` / ``max_strain`` @@ -371,16 +381,23 @@ Finite-EI cable controls * - ``alpha_force_blend`` / ``alphaforceblend`` - logical - ``True`` - - Generalised-α blend of the finite-EI dynamics. ``True`` blends the forces of the - two step ends; ``False`` evaluates the forces at the blended configuration - :math:`q_{\alpha_f}` (Chung and Hulbert), whose blended tangent vectors are shortened - while the line rotates and raise the mean tension at large ``dtM``: on the Lozon Gulf of + - Generalised-α blend of the dynamics of finite-EI and ``EI = 0`` lines. ``True`` blends + the forces of the two step ends; ``False`` evaluates the forces at the blended + configuration :math:`q_{\alpha_f}` (Chung and Hulbert), the ``EI = 0`` scheme of 0.1.1 and + earlier. On ``EI = 0`` lines ``False`` lets a segment that turns taut within a step carry + the stretch extrapolated past the blended state, and lets a release create energy: on a + light, axially stiff cable (80 kg/m, EA 8e8 N) under 3 m heave the fairlead peaks at + 4.2 MN against 0.10 MN with ``True`` (see :doc:`theory`). On finite-EI lines the blended + tangent vectors are shortened while the line rotates and raise the mean tension at large + ``dtM``: on the Lozon Gulf of Mexico 80 m cable in 3 m surge the mean hang-off tension is 12511 / 10097 / 9507 / 9360 N at ``dtM`` 0.1 / 0.05 / 0.025 / 0.0125 s with ``False`` and 9424 / 9322 / 9314 / 9311 N with ``True``. A run prints a note when a nodal tangent turns by more than 0.25 deg (``True``) or 0.1 deg (``False``) in one step. A dynamic run with a torsional line - (``END CONNECTIONS`` ``TorsStiffness`` at both ends) needs ``True`` - - standalone and coupled (finite-EI lines) + (``END CONNECTIONS`` ``TorsStiffness`` at both ends) needs ``True``. The lines the raw C + API builds without a deck (``CableDyn_InitLine``, ``CableDyn_InitLines``) always use + ``True``: their only integrator setting is ``rho_inf`` (:doc:`capi`) + - standalone and coupled (finite-EI and ``EI = 0`` lines) - ``False alpha_force_blend`` * - ``cable_statics`` / ``cablestatics`` - mode diff --git a/doc/theory.rst b/doc/theory.rst index 46fbf879..c71717d6 100644 --- a/doc/theory.rst +++ b/doc/theory.rst @@ -1280,7 +1280,8 @@ and the residual is evaluated at the intermediate states - \mathbf{f}_\text{ext}(\mathbf{q}_\alpha, \mathbf{v}_\alpha, t_\alpha), \qquad (\cdot)_\alpha = (1 - \alpha_f)(\cdot)_{n+1} + \alpha_f(\cdot)_n . -Time-dependent loads (waves) are evaluated at :math:`t_\alpha`. The Hermite path blends the +On the finite-EI path time-dependent loads (waves) are then evaluated at :math:`t_\alpha`; the +``EI = 0`` path holds the fluid fields over the step (below). By default both paths blend the *forces* instead (``alpha_force_blend``, default ``True``; ``False`` selects the form above), .. math:: @@ -1290,15 +1291,145 @@ Time-dependent loads (waves) are evaluated at :math:`t_\alpha`. The Hermite path + \alpha_f\,\mathbf{r}(\mathbf{q}_n, \mathbf{v}_n, t_n), \qquad \mathbf{r} = \mathbf{f}_\text{int} - \mathbf{f}_\text{ext}, -with the same accuracy and tangent. Its position and tangent-vector DOFs rotate with the line, -and a blended configuration :math:`\mathbf{q}_\alpha` would shorten the tangents of a rotating -element, a spurious stretch of order :math:`\alpha_f(1 - \alpha_f)(\omega\Delta t)^2 EA` that -raises the mean tension at large time steps. :math:`\mathbf{r}_n` is the previous step's -converged force, reused unless the state or the load configuration changed in between. Since it -enters every later step, the accepted state is taken one Newton correction beyond the tolerance -(the last factorisation reused), so a loose Newton tolerance does not bias the response. Both -forms converge to the same response; the force blend removes the rotation-driven bias (see -``alpha_force_blend`` in :doc:`options`). The effective tangent is +with the same accuracy and tangent. On the Hermite path the position and tangent-vector DOFs +rotate with the line, and a blended configuration :math:`\mathbf{q}_\alpha` would shorten the +tangents of a rotating element, a spurious stretch of order +:math:`\alpha_f(1 - \alpha_f)(\omega\Delta t)^2 EA` that raises the mean tension at large time +steps. There :math:`\mathbf{r}_n` is the previous step's converged force, reused unless the state +or the load configuration changed in between. Since it enters every later step, the accepted +state is taken one Newton correction beyond the tolerance (the last factorisation reused), so a +loose Newton tolerance does not bias the response. Both forms converge to the same response; the +force blend removes the rotation-driven bias (see ``alpha_force_blend`` in :doc:`options`). + +On the ``EI = 0`` path the force blend covers the axial force of the elements and every +dynamic load: axial damping, the viscoelastic and Syrope laws, seabed contact, damping and +friction, Morison drag, Froude–Krylov and buoyancy loads. Added mass stays at +:math:`(\mathbf{q}_\alpha, \mathbf{a}_{\alpha_m})`. :math:`\mathbf{r}_n` is evaluated afresh at +the committed state of every step, with the viscoelastic and Syrope elements at their committed +internal state, so the scheme carries no extra state and a restart is exact; a re-solve of the +same step from the same state (the junction coupling) reuses it. The fluid fields of an +``EI = 0`` line (current, wave velocity and acceleration, and the waterline) are held over the +step: before the step the host (the standalone driver, or the coupling host) samples them for +the end of the step, :math:`t_{n+1}`, at the committed node positions, and every load +evaluation of the step uses them. Both shares of the force blend therefore see the fields of +:math:`t_{n+1}`, so :math:`\mathbf{r}_n` is :math:`\mathbf{r}(\mathbf{q}_n, \mathbf{v}_n)` with +those fields rather than with the fields of :math:`t_n`, and the configuration blend evaluates +the loads with them at :math:`(\mathbf{q}_\alpha, \mathbf{v}_\alpha)` rather than at +:math:`t_\alpha`, as it did before the force blend. The finite-EI path instead evaluates its +wave loads at :math:`t_{n+1}` for the end share and reuses its :math:`\mathbf{r}_n`, evaluated at +its own :math:`t_n` in the previous step. The configuration blend fails at slack–taut +transitions. A tension-only element is a +one-sided spring, and the residual sets its force at :math:`\mathbf{q}_\alpha`; the end state +:math:`\mathbf{q}_{n+1} = (\mathbf{q}_\alpha - \alpha_f\mathbf{q}_n)/(1 - \alpha_f)` extrapolates +past it. A segment slack at :math:`t_n` that carries a tension at :math:`t_\alpha` thus ends the +step stretched by :math:`\alpha_f/(1 - \alpha_f)` of its former slack on top: with +:math:`\rho_\infty = 0.4` a 2 m segment of a light, axially stiff cable (80 kg/m, EA 8e8 N) that +was 0.2 m slack reports about 30 MN. A mass dropped 1 m onto a tension-only spring +(:math:`\omega = 1000` rad/s) peaks at 6.9 MN at :math:`\Delta t` = 0.1 s with the configuration +blend, against the resolved 0.35 MN; the force blend gives 5.7 kN, the under-resolved impact +dissipated as at :math:`\rho_\infty = 0`. + +**Release cap.** The force blend alone still creates energy when a taut element releases +within one step. An element with tension :math:`T_n`, stretch :math:`e_n = l_n - l_0 > 0` and +chord :math:`\mathbf{d}_n = l_n \mathbf{t}_n` at :math:`t_n` keeps :math:`\alpha_f T_n` along +:math:`\mathbf{t}_n` for the whole step, a constant force. Over the relative displacement +:math:`\mathbf{d}_{n+1} - \mathbf{d}_n` of its ends it returns the work :math:`\alpha_f T_n p` to +the motion, with the projected shortening :math:`p = l_n - \mathbf{t}_n \cdot \mathbf{d}_{n+1}`. +This is not the shortening :math:`e_n - e_{n+1}` of the element: since +:math:`p = (e_n - e_{n+1}) + l_{n+1}(1 - \mathbf{t}_n \cdot \mathbf{t}_{n+1})`, a segment that +turns as it releases moves much further against that force than it shortens. The end share +:math:`(1 - \alpha_f) T_{n+1} \mathbf{t}_{n+1}` returns :math:`-(1 - \alpha_f) T_{n+1} p_{n+1}`, +with :math:`p_{n+1} = l_{n+1} - \mathbf{t}_{n+1} \cdot \mathbf{d}_n`. The element released only +its strain energy :math:`W_n = \tfrac{1}{2} T_n e_n`. An element that ends slack +(:math:`T_{n+1} = 0`) therefore creates energy once :math:`p > e_n/(2\alpha_f)`: along a fixed +chord, a release deeper than :math:`e_n (1/(2\alpha_f) - 1)` (0.75 :math:`e_n` at +:math:`\rho_\infty = 0.4`); a nearly unstretched segment that turns by 90° returns about +:math:`\alpha_f T_n l_n`, hundreds of times :math:`W_n`. On a slack light cable this feeds a +sustained rattle of single-step tension spikes. The cap bounds the work of the element's blended +force by :math:`W_n`: along :math:`\mathbf{t}_n` the element carries the smaller of +:math:`\alpha_f T_n` and :math:`(W_n + (1 - \alpha_f) T_{n+1} p_{n+1})/p`, which is the discrete +energy gradient :math:`W_n/p` when it ends slack, and the residual and the tangent take the +difference (:math:`\partial p/\partial \mathbf{d}_{n+1} = -\mathbf{t}_n`). With +:math:`T_{n+1} = T_n e_{n+1}/e_n`, the tension of a linear element, the cap fades out as the end +state crosses the rest length, so the residual stays continuous in :math:`\mathbf{q}_{n+1}`. A +cap on the slack end states alone would jump there, by up to :math:`\alpha_f T_n` for a turned +element. The cap does not act on an element that ends above :math:`\alpha_f/(1 - \alpha_f)\,T_n` +(0.4 :math:`T_n`), nor on one that keeps its direction and ends taut, nor on one slack at +:math:`t_n`: those elements, every element going taut (where the force blend dissipates), and +every line that allows compression keep the force blend. In the slack-cable case above the +internal forces created 2.7e8 J over 20 s with the configuration blend, 6.7e7 J with the force +blend alone, 0.19 J with a cap on :math:`e_n - e_{n+1}` (the turn of the releasing segments) and +4e-4 J (round-off) with the projected cap. The fairlead peak is 0.10 MN. The snap is not +resolved in time: with the cap the peak ranges from 0.10 to 0.18 MN over :math:`\Delta t` from +2.5 to 0.25 ms, against 0.13 to 0.19 MN at :math:`\rho_\infty = 0`. For a linear element the +force blend and the cap reduce to the configuration blend, so the linear spectral properties and +the second-order accuracy are unchanged. + +The segments whose tension comes from a constitutive law, the viscoelastic and Syrope segments +(whose law enters the step as a dynamic load), are capped in the same way: :math:`T_n` is the +law's tension at the committed state, the force :math:`\mathbf{r}_n` carries, with the same +:math:`e_n` and :math:`W_n = \tfrac{1}{2} T_n e_n`. For the viscoelastic law at rest :math:`W_n` +is the energy of its two springs, which both carry :math:`T_n` and whose stretches add up to +:math:`e_n`; for the Syrope law, whose loading curve stiffens, it bounds the energy below the +curve from above. A law's tension is not proportional to the stretch: damping or the lagged +internal state can carry :math:`T_n` at a vanishing :math:`e_n`, where the secant +:math:`T_n/e_n` is unbounded and the cap would switch off within a band of width about +:math:`e_n`, nearly a jump for the Newton iteration. The cap therefore estimates the end +tension as :math:`\hat T_{n+1} = k\,e_{n+1}` with :math:`k = \min(T_n/e_n, k_n)`, :math:`k_n` +the law's axial stiffness at the committed state (:math:`EA_D/l_0` for the viscoelastic law, +:math:`K_1/l_0 = (\alpha + \beta T_\text{mean})/l_0` for Syrope). In general the blend of an +element returns at most :math:`W_n + (1 - \alpha_f)(\hat T_{n+1} - T_{n+1})\,p_{n+1}` over the +step, :math:`T_{n+1}` its actual end tension, and never more than without the cap. For an +elastic segment the two tensions coincide and the bound is :math:`W_n`. A law segment that ends +below :math:`l_0` with no law tension returns at most :math:`W_n` as well; one that ends above +:math:`l_0` with less law tension than the estimate (zero once the slow branch has taken up the +stretch, or below Syrope's minimum strain) can return up to +:math:`(1 - \alpha_f)\,k\,e_{n+1} p_{n+1}` more. With the light cable above made lightly damped +viscoelastic (EA 8e8 | 1.6e9 N, BA 1e8 | 1e6 N s) the anchor peaks at 0.085 MN at +:math:`\Delta t` = 0.1 s with the cap on its +segments (the snap is not resolved at that step, so the peak depends on round-off: other +compilers and platforms give other values) and at 0.145 MN without it, against 0.082 to +0.095 MN at :math:`\Delta t` from 0.5 to 2.5 ms. A taut Syrope line in 4 m +surge that goes slack peaks at 1.64 MN at 0.1 s, against 1.78 MN at 1 and 2.5 ms, with or +without the cap. + +An elastic segment with axial damping (``BA``) also keeps :math:`\alpha_f T_{d,n}` along +:math:`\mathbf{t}_n`, :math:`T_{d,n}` the tension of its dashpot at :math:`t_n`. A segment that +extends at :math:`t_n` and releases within the step carries that force against the shortening +as well: in the test chain (dashpot tension 1.6 to 62 times the elastic one) the blend of a +segment that turns and releases returned up to 2750 :math:`W_n` with only its elastic share +capped. +The dashpot pushes as well as pulls, so its end share +:math:`(1 - \alpha_f) T_{d,n+1}\mathbf{t}_{n+1}` acts at a slack end state too, and it stores no +energy, so the budget stays :math:`W_n`. The cap covers the dashpot with a weight :math:`\phi` +that is 1 while the end state is at or below :math:`l_0` and falls linearly to 0 at +:math:`l_0 + c\,e_n`, :math:`c = \alpha_f/(1 - \alpha_f)` (the end stretch below which the cap +can act on an elastic segment): the kept force :math:`\alpha_f (T_n + \phi T_{d,n})` is replaced +by :math:`N/p` when that is smaller, with +:math:`N = \max(W_n + (1 - \alpha_f)(\hat T_{n+1} + \phi T_{d,n+1})\,p_{n+1}, 0)` and +:math:`T_{d,n+1}` the dashpot tension the residual carries at +:math:`(\mathbf{q}_{n+1}, \mathbf{v}_{n+1})`; the tangent carries its dependence on +:math:`\mathbf{q}_{n+1}` through :math:`\mathbf{v}_{n+1}` (the factor +:math:`\gamma/(\beta\Delta t)`). Over a step in which it shortens along :math:`\mathbf{t}_n` +(:math:`p > 0`; the cap leaves the other steps alone) the blend of such a segment then returns +at most :math:`W_n + (1 - \phi) D`, :math:`D = \alpha_f T_{d,n} p - (1 - \alpha_f) +T_{d,n+1} p_{n+1}` the work of its uncapped blended dashpot, except when the end share alone +returns more than :math:`W_n` (:math:`N` would be negative; the capped kept force is then +zero). At +and below :math:`l_0` that is :math:`W_n`. Above :math:`l_0 + c\,e_n` the cap is the elastic one, +so the force-blended dashpot of a taut segment keeps the standard generalised-α treatment, under +which a linear dashpot is dissipative; :math:`\phi` is continuous, and so is the capped force. +The viscoelastic law keeps its total tension, dashpots included, as :math:`T_n` (above). + +The one-sided seabed contact is not capped. A node that leaves the floor within a step keeps +:math:`\alpha_f` of its step-start contact force :math:`N_n` for the whole step: over a lift-off +distance :math:`d` it returns at most :math:`\alpha_f N_n d` to the motion, against the energy +:math:`\tfrac{1}{2} N_n g_n` of the penalty spring at the penetration :math:`g_n` (millimetres). +The excess is the step-start support acting for :math:`\alpha_f` of a step longer than it should, +an impulse of at most :math:`\alpha_f N_n \Delta t` per lift-off that vanishes with +:math:`\Delta t`; the contact law's sloped-floor normal and the friction anchors, which the step +does not see, leave no energy bound as simple as the segments'. Seabed damping and friction are +dissipative and keep the plain force blend as well. The effective tangent is .. math:: @@ -1393,9 +1524,34 @@ partly subdivided state is ever committed. **Step size.** Being implicit, the scheme is not bound by the explicit axial-wave limit. In the snap-load verification a slack line snapping to about 10 MN integrates stably at :math:`\Delta t = 20\,\mathrm{ms}`, well above the explicit limit of 3.2 ms, with the peak -within 2.7% of a 2 ms reference (:doc:`validation`). The time step must still resolve the +within 1.5% of a 0.5 ms reference (:doc:`validation`). The time step must still resolve the response of interest and, for explicitly integrated points and bodies (below), their own -stability limit. +stability limit. The standalone driver audits every ``EI = 0`` line on the initial state and at +each output step, and reports at the end of the run: + +- the largest turn of the chord of a taut segment in one step. Above 1 deg it prints a note: + against a 3.125 ms reference on chain catenaries under 5 m heave, 10 m surge and 15 m sway + and on a light laid cable under 10 m sway, the mean and standard deviation of the fairlead + tension err by 0.9 % at 1.2 deg per step (sway, standard deviation), and by 0.6 % at + 1.4 deg and 1.3 % at 2.9 deg (heave, mean), in proportion with the turn; +- segments that go from slack to taut above the initial tension in one step while the axial + wave crosses a segment more than once per step (:math:`\Delta t\,c/l_0 > 1`, + :math:`c = \sqrt{EA/m}` with the dynamic stiffness of the segment, :math:`EA_D` of a viscoelastic + segment and :math:`\alpha + \beta T` of a Syrope one): the snap peaks are then not resolved in + time, and the note asks for a confirmation at a smaller ``dtM``; +- non-physical tension spikes. The tension of a segment at one step (its elastic tension, or the + tension of its viscoelastic or Syrope law at the committed state) is a spike when it exceeds + four times its own tension one step before and one step after, ten times the largest + tension anywhere on the line one step before and one step after, and the largest tension of + the initial state. A physical snap or tension wave persists over the axial transit time and is + shared by the neighbouring segments, so no line carries such an isolated single-step peak. + The first spike of a line is reported as a warning with its segment, tension and time, at most + once per line, and the run summary gives the count. Over the 746 decks of a dynamics + robustness campaign it warns in none of the 704 runs that complete. Applied to the same + decks' configuration-blend results it flags 37 of the 49 runs whose segment tensions were 3 + to 370 times those of the force blend, and 1 of the 158 runs within 25 % of them. Spikes + that persist over several steps (a rattle at :math:`\rho_\infty` near 1) are left to the + ``maxStrain`` guard and the ``rhoInf`` note. Attached objects and line ends ------------------------------ @@ -1566,7 +1722,7 @@ added mass, gyroscopic terms, hydrostatics, drag and seabed contact, and the lin The iteration is a multilevel Newton. For a trial :math:`\mathbf{x}` every attached line is stepped from its committed state with the resulting end motion prescribed, and returns its reaction at the alpha level, :math:`\mathbf{f}_e = -\mathbf{R}_E` (the end rows of its own -residual :math:`\mathbf{M}\mathbf{a}_{\alpha_m} + \mathbf{f}_\text{int}(\mathbf{q}_{\alpha_f}) - \mathbf{f}_\text{ext}`), +residual :math:`\mathbf{M}\mathbf{a}_{\alpha_m} + (1 - \alpha_f)\,\mathbf{r}_{n+1} + \alpha_f\,\mathbf{r}_n`), so the end-node inertia, drag and added mass enter exactly, and its condensed dynamic end stiffness :math:`\mathbf{K}_e = \mathbf{S}_{EE} - \mathbf{S}_{EF}\mathbf{S}_{FF}^{-1}\mathbf{S}_{FE}` of the step's effective tangent :math:`\mathbf{S}`, the exact implicit-function derivative of diff --git a/doc/troubleshooting.rst b/doc/troubleshooting.rst index c2f34a07..2ef21c85 100644 --- a/doc/troubleshooting.rst +++ b/doc/troubleshooting.rst @@ -561,6 +561,31 @@ Warnings and notes that do not stop a run * - ``Note: line ...: a nodal tangent turned up to ... deg in one step`` - the time-step audit of a finite-EI line: above 0.25° per step (0.1° with ``False alpha_force_blend``) the mean tension can err by about 1 %. Reduce ``dtM``. + * - ``Note: line ...: a taut segment turned up to ... deg in one step`` + - the time-step audit of an ``EI = 0`` line: above 1° per step the mean and standard + deviation of the tension can err by about 1 % (1.3 % at 2.9° on a heaving chain). Reduce + ``dtM`` if that matters for the result. + * - ``Note: line ...: ... segment step(s) went from slack to taut above the initial tension`` + - snap loads on an ``EI = 0`` line at a ``dtM`` that does not resolve the axial wave over a + segment: the peak is set by a single step (a 15 m surge of a semi-taut chain–polyester + line peaks at 5.7 MN at ``dtM`` 0.05 s against 4.6 MN at 0.0025 s). The run is valid; + confirm design peaks with a smaller ``dtM``. + * - ``Warning: line ...: segment ... carried ... N at t = ... s for a single step, ... times + the largest tension on the line one step before and after`` + - a non-physical tension spike: the tension of one segment (elastic, viscoelastic or + Syrope) rose and fell within one step to ten times anything the line carried one step + before and after, which no physical + snap or tension wave does. It is the signature of an under-resolved slack–taut + transition integrated without energy control, for example with + ``False alpha_force_blend`` (the ``EI = 0`` scheme of 0.1.1 and earlier) or with + ``rhoInf`` near 1. Remove ``False alpha_force_blend``, keep ``rhoInf`` at or below + 0.95, or reduce ``dtM``; the run summary counts the spikes of the line. + * - ``Note: rhoInf = ... leaves almost no numerical dissipation`` + - printed by the standalone driver for a dynamic deck with ``rhoInf`` above 0.95: the modes ``dtM`` does not resolve keep the residual of each + Newton step and the energy of under-resolved snaps. In an irregular sea this can raise the + tensions several times (a lazy wave at ``1 rhoInf`` with a ``1e-4`` Newton tolerance + peaked at twenty times the converged value). Use ``rhoInf`` ≤ 0.95 (default 0.4), or a + ``dynamic_solver`` relative tolerance of ``1e-6`` or tighter and a smaller ``dtM``. * - ``Note: line ...: elements as short as ... are below sqrt(EI/EA)`` - the finite-EI deck mesh is finer than the axial-bending length :math:`\sqrt{EI/EA}`: the axial stiffness of each element swamps its bending stiffness and the static diff --git a/examples/cabledyn_options_reference.dat b/examples/cabledyn_options_reference.dat index a4223f66..79ae9cbf 100644 --- a/examples/cabledyn_options_reference.dat +++ b/examples/cabledyn_options_reference.dat @@ -40,7 +40,7 @@ False modified_newton - Tangent-reuse mode {False=full Newton; True=guarded True cable_load_feedback - Return finite-EI cable reactions to OpenFAST {False; True} [default: True] False adaptive_mesh - Automatic finite-EI refinement {False; True} [default: False] continuation cable_statics - Finite-EI static route order {continuation; sequenced} [default: continuation] -True alpha_force_blend - Finite-EI generalised-alpha force blend {True; False=configuration blend} [default: True] +True alpha_force_blend - Generalised-alpha force blend, finite-EI and EI=0 lines {True; False=configuration blend} [default: True] False tensile_safety - Element-mean axial-force audit {False; warn; True=reject} [default: False] 2.0e-6 tensile_strain_tolerance - Dynamic audit strain band [default: 2.0e-6] 1024 recovery_max_substeps - Internal dynamic-step recovery ceiling {4..65536} [default: 1024] diff --git a/src/CableDyn_DeckDriver.f90 b/src/CableDyn_DeckDriver.f90 index ce5edfed..a4d79fbe 100644 --- a/src/CableDyn_DeckDriver.f90 +++ b/src/CableDyn_DeckDriver.f90 @@ -55,7 +55,8 @@ MODULE CableDyn_DeckDriver CD_Get_Model_CoupledDofs, CD_Get_Model_State, CD_Get_Model_Tension, & CD_Get_Model_EndForces, & CD_Update_Model_CoupledMotion, CD_Update_Model_Hydro_Fields, & - CD_Recompute_Model_Acceleration, CD_Step_Model, CD_Step_Model_Recovering, CD_MODEL_OK + CD_Recompute_Model_Acceleration, CD_Step_Model, CD_Step_Model_Recovering, CD_MODEL_OK, & + CD_Audit_Model_Step USE CableDyn_System, ONLY: CD_SystemType, CD_SystemPointType, CD_LineEndpointBinding, & CD_Init_System_From_Points, CD_End_System, CD_System_Line_NDOF, & CD_System_Line_NElem, CD_Get_System_Point_State, CD_Get_System_Line_State, & @@ -242,6 +243,8 @@ MODULE CableDyn_DeckDriver CHARACTER(*), PARAMETER :: TORSION_NEEDS_FORCE_BLEND = 'torsion in a dynamic run needs the force-blended '// & 'generalised-alpha (OPTION alpha_force_blend True)' REAL(wp), PARAMETER :: QUARTER_PI = 0.785398163397448309616_wp ! pi/4 (displaced-area factor) + ! rhoInf above which a dynamic run notes the missing numerical dissipation (run_deck_driver) + REAL(wp), PARAMETER :: RHO_INF_NOTE = 0.95_wp REAL(wp), PARAMETER :: CD_RAD2DEG = 57.29577951308232087680_wp ! 180/pi (declination/azimuth output) INTEGER, PARAMETER :: WAVE_NONE = 0, WAVE_AIRY = 1, WAVE_JONSWAP = 2, WAVE_COMPONENTS = 3 ! WAVE_SEA: spectral/multi-train/spread seas of CableDyn_WaveSpectra @@ -7089,6 +7092,18 @@ SUBROUTINE run_deck_driver(deck_path, out_root, converged, ErrStat, ErrMsg) TRIM(int_to_str(lines(li)%id))//' is torsionally restrained at one end only; with the other end free '// & 'to twist it carries no torque, so no torsion is solved.' END DO + ! rhoInf near 1 leaves the march without numerical dissipation of the modes dtM does not + ! resolve (axial waves, slack-taut transitions). In an irregular sea a finite-EI lazy wave + ! at rhoInf = 1 with a 1e-4 Newton tolerance peaked at 2e5 N against 1.02e4 N (3e4 N at + ! 0.99), and was exact at 1e-6; EI=0 lines at rhoInf = 1 and 1e-4 failed the plausibility + ! guard, and at the default tolerance their peaks rose by factors of 2 to 5 at rhoInf >= 0.95. + IF (opts%has_dtm .AND. opts%has_tmax .AND. opts%tmax > CD_ZERO .AND. opts%rho_inf > RHO_INF_NOTE) THEN + WRITE (output_unit, '(A,F5.3,A)') ' Note: rhoInf = ', opts%rho_inf, ' leaves almost no numerical '// & + 'dissipation: modes dtM does not resolve (axial waves, slack-taut transitions) keep the residual a '// & + 'Newton step leaves and the energy of under-resolved snaps, which can raise tensions several times. '// & + 'Use rhoInf <= 0.95 (default 0.4), or a relative dynamic_solver tolerance of 1e-6 or tighter and a '// & + 'dtM that resolves the snaps.' + END IF IF (ANY([(line_torsion_active(lines(li)), li=1, SIZE(lines))])) THEN IF (opts%has_tmax .AND. opts%tmax > CD_ZERO .AND. .NOT. opts%alpha_force_blend) THEN CALL fail(ErrStat, ErrMsg, TORSION_NEEDS_FORCE_BLEND); RETURN @@ -7581,6 +7596,7 @@ SUBROUTINE init_one_model(ln, sections, types, points, opts, model, ErrStat, Err dynamic_cfg%max_iter = opts%dynamic_max_iter dynamic_cfg%armijo_max_backtracks = opts%dynamic_backtracks dynamic_cfg%modified_newton = opts%dynamic_modified_newton + dynamic_cfg%force_blend = opts%alpha_force_blend CALL CD_Build_Line_Mesh(secs, lts, .TRUE., conn, l0, ea, mpl, diam, es, em) IF (es /= CD_LINE_OK) THEN CALL fail(ErrStat, ErrMsg, 'line mesh for model init: '//TRIM(em)); RETURN @@ -15471,6 +15487,8 @@ SUBROUTINE write_dynamic_out(out_root, channels, lines, points, opts, models, co CALL close_dynamic_line_outputs(pos_units, ten_units) RETURN END IF + ! the run audit starts from the initial state (its tension scale is that of t = 0) + CALL audit_line_models(models, lines, CD_ZERO, opts%dtM) CALL start_driver_progress(progress, nstep, opts%dtM) DO step = 1, nstep t = REAL(step, wp)*opts%dtM @@ -15523,6 +15541,7 @@ SUBROUTINE write_dynamic_out(out_root, channels, lines, points, opts, models, co ErrMsg = TRIM(ErrMsg)//INSPECTION_NOTE RETURN END IF + CALL audit_line_models(models, lines, t, opts%dtM) CALL CD_Profile_Step() CALL CD_Profile_Enter(CD_PROF_OUTPUT) IF (opts%has_motion_file) THEN @@ -15552,6 +15571,7 @@ SUBROUTINE write_dynamic_out(out_root, channels, lines, points, opts, models, co WRITE (output_unit, '(A,I0,A,I0,A)') ' Recovery audit: dynamic run subdivided ', & recovery_event_count, ' nominal interval(s); maximum substeps used=', recovery_max_substeps_used, '.' END IF + IF (ErrStat == CD_DECKDRV_OK) CALL report_line_model_audits(models, lines, opts%dtM) IF (ErrStat == CD_DECKDRV_OK .AND. converged) CALL range_write(output_work%rset, out_root, ErrStat, ErrMsg) END SUBROUTINE write_dynamic_out @@ -15632,6 +15652,8 @@ SUBROUTINE write_system_dynamic_out(out_root, channels, lines, points, opts, sys CALL close_dynamic_line_outputs(pos_units, ten_units) RETURN END IF + ! the run audit starts from the initial state (its tension scale is that of t = 0) + CALL audit_system_lines(system, lines, CD_ZERO, opts%dtM) CALL start_driver_progress(progress, nstep, opts%dtM) DO step = 1, nstep t = REAL(step, wp)*opts%dtM @@ -15679,6 +15701,7 @@ SUBROUTINE write_system_dynamic_out(out_root, channels, lines, points, opts, sys converged = .FALSE. RETURN END IF + CALL audit_system_lines(system, lines, t, opts%dtM) IF (PRESENT(failures)) THEN CALL check_and_fire_failures(system, lines, points, failures, t, es, em) IF (es /= CD_DECKDRV_OK) THEN @@ -15710,6 +15733,7 @@ SUBROUTINE write_system_dynamic_out(out_root, channels, lines, points, opts, sys CALL close_dynamic_line_outputs(pos_units, ten_units) CALL CD_Classify_Dynamic_Completion('dynamic point-system run', nstep, miss_count, max_consecutive_miss, & first_miss_time, last_miss_time, converged, ErrStat, ErrMsg) + IF (ErrStat == CD_DECKDRV_OK) CALL report_system_line_audits(system, lines, opts%dtM) IF (ErrStat == CD_DECKDRV_OK .AND. converged) CALL range_write(output_work%rset, out_root, ErrStat, ErrMsg) END SUBROUTINE write_system_dynamic_out @@ -16012,6 +16036,8 @@ SUBROUTINE write_rigid6_dynamic_out(out_root, channels, bodies, lines, points, o CALL close_dynamic_line_outputs(pos_units, ten_units) RETURN END IF + ! the run audit starts from the initial state (its tension scale is that of t = 0) + CALL audit_system_lines(system, lines, CD_ZERO, opts%dtM) CALL start_driver_progress(progress, nstep, opts%dtM) DO step = 1, nstep t = REAL(step, wp)*opts%dtM @@ -16057,6 +16083,7 @@ SUBROUTINE write_rigid6_dynamic_out(out_root, channels, bodies, lines, points, o converged = .FALSE. RETURN END IF + CALL audit_system_lines(system, lines, t, opts%dtM) IF (PRESENT(failures)) THEN CALL check_and_fire_failures(system, lines, points, failures, t, es, em) IF (es /= CD_DECKDRV_OK) THEN @@ -16089,6 +16116,7 @@ SUBROUTINE write_rigid6_dynamic_out(out_root, channels, bodies, lines, points, o CALL close_dynamic_line_outputs(pos_units, ten_units) CALL CD_Classify_Dynamic_Completion('Rigid6 dynamic run', nstep, miss_count, max_consecutive_miss, & first_miss_time, last_miss_time, converged, ErrStat, ErrMsg) + IF (ErrStat == CD_DECKDRV_OK) CALL report_system_line_audits(system, lines, opts%dtM) IF (ErrStat == CD_DECKDRV_OK .AND. converged) CALL range_write(output_work%rset, out_root, ErrStat, ErrMsg) END SUBROUTINE write_rigid6_dynamic_out @@ -16198,6 +16226,8 @@ SUBROUTINE write_rod_dynamic_out(out_root, channels, rod_types, rods, lines, poi CALL close_dynamic_rod_outputs(rod_pos_units) RETURN END IF + ! the run audit starts from the initial state (its tension scale is that of t = 0) + CALL audit_system_lines(system, lines, CD_ZERO, opts%dtM) CALL start_driver_progress(progress, nstep, opts%dtM) DO step = 1, nstep t = REAL(step, wp)*opts%dtM @@ -16247,6 +16277,7 @@ SUBROUTINE write_rod_dynamic_out(out_root, channels, rod_types, rods, lines, poi converged = .FALSE. RETURN END IF + CALL audit_system_lines(system, lines, t, opts%dtM) CALL CD_Profile_Step() CALL CD_Profile_Enter(CD_PROF_OUTPUT) CALL write_system_model_row(unit, t, channels, lines, points, system, output_work, ErrStat, ErrMsg, & @@ -16279,6 +16310,7 @@ SUBROUTINE write_rod_dynamic_out(out_root, channels, rod_types, rods, lines, poi CALL close_dynamic_rod_outputs(rod_pos_units) CALL CD_Classify_Dynamic_Completion('rod dynamic run', nstep, miss_count, max_consecutive_miss, & first_miss_time, last_miss_time, converged, ErrStat, ErrMsg) + IF (ErrStat == CD_DECKDRV_OK) CALL report_system_line_audits(system, lines, opts%dtM) IF (ErrStat == CD_DECKDRV_OK .AND. converged) CALL range_write(output_work%rset, out_root, ErrStat, ErrMsg) END SUBROUTINE write_rod_dynamic_out @@ -17727,6 +17759,8 @@ SUBROUTINE write_multibody_dynamic_out(deck_path, out_root, channels, types, bod IF (ErrStat /= CD_DECKDRV_OK) GOTO 800 CALL mb_outputs(CD_ZERO) IF (ErrStat /= CD_DECKDRV_OK) GOTO 800 + ! the run audit starts from the initial state (its tension scale is that of t = 0) + IF (mb%has_sys) CALL audit_system_lines(mb%system, sys_lines, CD_ZERO, opts%dtM) CALL start_driver_progress(progress, nstep, opts%dtM) DO step = 1, nstep t = REAL(step, wp)*opts%dtM @@ -17753,6 +17787,7 @@ SUBROUTINE write_multibody_dynamic_out(deck_path, out_root, channels, types, bod ErrMsg = TRIM(ErrMsg)//INSPECTION_NOTE GOTO 800 END IF + CALL audit_system_lines(mb%system, sys_lines, t, opts%dtM) END IF CALL CD_Profile_Step() CALL CD_Profile_Enter(CD_PROF_OUTPUT) @@ -17768,6 +17803,7 @@ SUBROUTINE write_multibody_dynamic_out(deck_path, out_root, channels, types, bod END IF CALL CD_Classify_Dynamic_Completion('multibody dynamic run', nstep, miss_count, max_consecutive_miss, & first_miss_time, last_miss_time, converged, ErrStat, ErrMsg) + IF (ErrStat == CD_DECKDRV_OK .AND. mb%has_sys) CALL report_system_line_audits(mb%system, sys_lines, opts%dtM) IF (ErrStat == CD_DECKDRV_OK .AND. converged) CALL range_write(mb_ranges, out_root, ErrStat, ErrMsg) 800 CONTINUE CLOSE (unit) @@ -26394,6 +26430,110 @@ SUBROUTINE update_wave_models(models, opts, time, work, ErrStat, ErrMsg, initial END DO END SUBROUTINE update_wave_models + SUBROUTINE audit_line_models(models, lines, time, dt) + !! Run audit of one committed host step over the standalone EI=0 line models (models(i) + !! is deck line i): see CD_Audit_Model_Step. Every route that audits calls it once on the + !! initial state (time 0) before its march. Warns once per line, at the line's first + !! implausible tension spike. + TYPE(CD_ModelType), INTENT(INOUT) :: models(:) + TYPE(DeckLine), INTENT(IN) :: lines(:) + REAL(wp), INTENT(IN) :: time, dt + INTEGER :: i + LOGICAL :: spike + DO i = 1, SIZE(models) + CALL CD_Audit_Model_Step(models(i), time, dt, spike) + IF (spike) CALL warn_line_spike(models(i), audited_line_id(lines, i)) + END DO + END SUBROUTINE audit_line_models + + SUBROUTINE audit_system_lines(system, lines, time, dt) + !! audit_line_models over the EI=0 lines of a point-connected system. + TYPE(CD_SystemType), INTENT(INOUT) :: system + TYPE(DeckLine), INTENT(IN) :: lines(:) + REAL(wp), INTENT(IN) :: time, dt + INTEGER :: i + LOGICAL :: spike + IF (.NOT. ALLOCATED(system%lines)) RETURN + DO i = 1, SIZE(system%lines) + CALL CD_Audit_Model_Step(system%lines(i), time, dt, spike) + IF (spike) CALL warn_line_spike(system%lines(i), audited_line_id(lines, i)) + END DO + END SUBROUTINE audit_system_lines + + INTEGER FUNCTION audited_line_id(lines, i) RESULT(id) + !! Deck id of line i (i itself past the deck lines). + TYPE(DeckLine), INTENT(IN) :: lines(:) + INTEGER, INTENT(IN) :: i + id = i + IF (i <= SIZE(lines)) id = lines(i)%id + END FUNCTION audited_line_id + + SUBROUTINE warn_line_spike(model, line_id) + !! The once-per-line warning of the run audit's first implausible tension spike. + TYPE(CD_ModelType), INTENT(IN) :: model + INTEGER, INTENT(IN) :: line_id + INTEGER :: ios + WRITE (output_unit, '(A,I0,A,I0,A,ES10.3,A,F10.3,A,F0.1,A)', IOSTAT=ios) ' Warning: line ', line_id, & + ': segment ', model%audit_spike_elem, ' carried ', model%audit_spike_tension, ' N at t =', & + model%audit_spike_time, ' s for a single step, ', model%audit_spike_ratio, & + ' times the largest tension on the line one step before and after: a non-physical tension spike '// & + '(an under-resolved slack-taut transition). Check the result with a smaller dtM (doc: troubleshooting).' + END SUBROUTINE warn_line_spike + + SUBROUTINE report_model_audit(model, line_id, dt) + !! End-of-run notes of the run audit of one EI=0 line: the time-step advisory (largest + !! chord turn of a taut segment in one step; calibrated against dtM 3.125 ms on chain + !! catenaries under 5 m heave, 10 m surge and 15 m sway and on a light laid cable under + !! 10 m sway: the mean and standard deviation of the fairlead tension err by 0.9 % at + !! 1.2 deg per step (sway, standard deviation), 0.6 % at 1.4 deg and 1.3 % at 2.9 deg + !! (heave, mean), in proportion with the turn), the unresolved slack-to-taut snaps, and + !! the number of implausible tension spikes after the warned first one. + TYPE(CD_ModelType), INTENT(IN) :: model + INTEGER, INTENT(IN) :: line_id + REAL(wp), INTENT(IN) :: dt + REAL(wp), PARAMETER :: EI0_TURN_NOTE = 1.0_wp + INTEGER :: ios + IF (model%audit_max_turn > EI0_TURN_NOTE) THEN + WRITE (output_unit, '(A,I0,A,F7.3,A)', IOSTAT=ios) ' Note: line ', line_id, ': a taut segment turned up to ', & + model%audit_max_turn, ' deg in one step; a smaller dtM would resolve the line''s rotation (tension '// & + 'mean and standard-deviation errors of about 1 % and more above 1 deg per step).' + END IF + IF (model%audit_snaps > 0 .AND. model%audit_snap_courant > CD_ONE) THEN + WRITE (output_unit, '(A,I0,A,I0,A,ES9.2,A,F0.1,A)', IOSTAT=ios) ' Note: line ', line_id, ': ', & + model%audit_snaps, ' segment step(s) went from slack to taut above the initial tension; at dtM =', & + dt, ' s the axial wave crosses a segment up to ', model%audit_snap_courant, & + ' times per step, so the snap-load peaks are not resolved in time: confirm peak tensions with a '// & + 'smaller dtM.' + END IF + IF (model%audit_spikes > 1) THEN + WRITE (output_unit, '(A,I0,A,I0,A)', IOSTAT=ios) ' Warning: line ', line_id, ': ', model%audit_spikes, & + ' non-physical single-step tension spikes in all (the first is reported above).' + END IF + END SUBROUTINE report_model_audit + + SUBROUTINE report_line_model_audits(models, lines, dt) + !! report_model_audit over the standalone EI=0 line models. + TYPE(CD_ModelType), INTENT(IN) :: models(:) + TYPE(DeckLine), INTENT(IN) :: lines(:) + REAL(wp), INTENT(IN) :: dt + INTEGER :: i + DO i = 1, SIZE(models) + CALL report_model_audit(models(i), audited_line_id(lines, i), dt) + END DO + END SUBROUTINE report_line_model_audits + + SUBROUTINE report_system_line_audits(system, lines, dt) + !! report_model_audit over the EI=0 lines of a point-connected system. + TYPE(CD_SystemType), INTENT(IN) :: system + TYPE(DeckLine), INTENT(IN) :: lines(:) + REAL(wp), INTENT(IN) :: dt + INTEGER :: i + IF (.NOT. ALLOCATED(system%lines)) RETURN + DO i = 1, SIZE(system%lines) + CALL report_model_audit(system%lines(i), audited_line_id(lines, i), dt) + END DO + END SUBROUTINE report_system_line_audits + SUBROUTINE check_model_plausibility(model, max_strain, line_id, time, ErrStat, ErrMsg) !! Per-step plausibility guard on one committed EI=0 line state. A generalized-alpha !! step can converge on a numerically unstable (exploding) trajectory; its residual diff --git a/src/CableDyn_Dynamic.f90 b/src/CableDyn_Dynamic.f90 index 5509fd86..e7646397 100644 --- a/src/CableDyn_Dynamic.f90 +++ b/src/CableDyn_Dynamic.f90 @@ -10,12 +10,16 @@ MODULE CableDyn_Dynamic !! and C-facing lifecycle layers. !! !! One consistent-mass step advances (q_n, v_n, a_n) -> (q_{n+1}, v_{n+1}, a_{n+1}) - !! over dt by solving, at the alpha-blended configuration q_alpha, - !! R(q) = M a_alpha + f_int(q_alpha) - f_ext = 0 + !! over dt by solving the force-blended residual (GenAlphaConfig%force_blend, default) + !! R(q) = M a_alpha + (1 - alpha_f) r(q_{n+1}, v_{n+1}) + alpha_f r(q_n, v_n) = 0, + !! r = f_int - f_ext - f_load, + !! with a release cap on tension-only elements that release within the step (see + !! apply_release_cap), or the configuration-blended R(q) = M a_alpha + f_int(q_alpha) - ..., !! for the Newton variable q = q_{n+1} with a Newton + Armijo line search on the !! 1/2||R||^2 merit. Optional callbacks add dynamic loads, force-only residual - !! evaluations, added mass, and prescribed support motion. The effective tangent is - !! (1 - alpha_m)/(beta dt^2) M + (1 - alpha_f) K_t(q_alpha), + !! evaluations, added mass (at q_alpha either way), and prescribed support motion. The + !! effective tangent is + !! (1 - alpha_m)/(beta dt^2) M + (1 - alpha_f) K_t(q_{n+1} or q_alpha), !! and the free-DOF block is assembled and solved directly in banded DGBSV !! storage when no arbitrary dense callback Jacobian is active. !! @@ -73,6 +77,11 @@ MODULE CableDyn_Dynamic !! (CD_Cosserat_Gen_Alpha_Step) reads it; the EI=0 cable !! path has no rotation DOFs. With .TRUE. the step fails !! closed on moving supports and dynamic load callbacks. + LOGICAL :: force_blend = .TRUE. !! EI=0 cable step only: .TRUE. blends the internal force + !! and the dynamic loads, (1 - alpha_f) r(q_{n+1}, v_{n+1}) + !! + alpha_f r(q_n, v_n); .FALSE. evaluates them at the + !! blended configuration (q_alpha, v_alpha). The finite-EI + !! paths have their own setting. END TYPE GenAlphaConfig TYPE :: CD_CableGenAlphaWorkspace @@ -114,6 +123,22 @@ MODULE CableDyn_Dynamic REAL(wp), ALLOCATABLE :: fint_eval(:) REAL(wp), ALLOCATABLE :: tension_eval(:) REAL(wp), ALLOCATABLE :: load_eval(:) + ! force blend (GenAlphaConfig%force_blend): the configuration the internal force and the + ! dynamic loads are evaluated at (q_{n+1}), and the step-start internal force and dynamic + ! load (at q_n, v_n) that enter the blend with weight alpha_f + REAL(wp), ALLOCATABLE :: q_force(:) + REAL(wp), ALLOCATABLE :: fint_n(:) + REAL(wp), ALLOCATABLE :: load_n(:) + ! release cap of the force blend (tension-only elements): the step-start tension, stretch + ! l - l0 and unit chord of every element, and the bound of its secant stiffness + ! (start_stiffness of a law element, HUGE otherwise) + REAL(wp), ALLOCATABLE :: tension_n(:), stretch_n(:), chord_n(:, :), stiff_n(:) + ! the axial dashpot of an elastic element (axial_damping): BA/l0, the payout rate l0_dot/l0 + ! and the dashpot tension at the step start, zero without one + REAL(wp), ALLOCATABLE :: dcoef_n(:), rl0dot_n(:), damp_n(:) + ! fint_n, load_n and the release-cap data hold the step-start values of the last call: a + ! warm re-solve of the same step (guess_armed, from the same committed state) reuses them + LOGICAL :: start_valid = .FALSE. REAL(wp), ALLOCATABLE :: eff(:, :) REAL(wp), ALLOCATABLE :: eff_free(:, :) REAL(wp), ALLOCATABLE :: Kt_eval(:, :) @@ -294,6 +319,17 @@ SUBROUTINE CD_Clear_GenAlpha_Workspace(work) IF (ALLOCATED(work%fint_eval)) DEALLOCATE (work%fint_eval) IF (ALLOCATED(work%tension_eval)) DEALLOCATE (work%tension_eval) IF (ALLOCATED(work%load_eval)) DEALLOCATE (work%load_eval) + IF (ALLOCATED(work%q_force)) DEALLOCATE (work%q_force) + IF (ALLOCATED(work%fint_n)) DEALLOCATE (work%fint_n) + IF (ALLOCATED(work%load_n)) DEALLOCATE (work%load_n) + IF (ALLOCATED(work%tension_n)) DEALLOCATE (work%tension_n) + IF (ALLOCATED(work%stretch_n)) DEALLOCATE (work%stretch_n) + IF (ALLOCATED(work%chord_n)) DEALLOCATE (work%chord_n) + IF (ALLOCATED(work%stiff_n)) DEALLOCATE (work%stiff_n) + IF (ALLOCATED(work%dcoef_n)) DEALLOCATE (work%dcoef_n) + IF (ALLOCATED(work%rl0dot_n)) DEALLOCATE (work%rl0dot_n) + IF (ALLOCATED(work%damp_n)) DEALLOCATE (work%damp_n) + work%start_valid = .FALSE. IF (ALLOCATED(work%eff)) DEALLOCATE (work%eff) IF (ALLOCATED(work%eff_free)) DEALLOCATE (work%eff_free) IF (ALLOCATED(work%Kt_eval)) DEALLOCATE (work%Kt_eval) @@ -577,7 +613,9 @@ SUBROUTINE CD_Cable_Gen_Alpha_Step(q, v, a, elem_conn, l0, ea, rho_a, tension_on converged, stalled, n_iter, ErrStat, ErrMsg, & load_proc, added_mass_proc, load_force_proc, & load_band_proc, prescribed_q, prescribed_v, prescribed_a, structural_mass, & - workspace, added_mass_band_proc) + workspace, added_mass_band_proc, start_load, start_tension, & + probe_q, probe_R, probe_K, start_stiffness, axial_damping, & + axial_l0_rate) !! One generalized-alpha step: the constant load f_ext plus the optional load, !! banded-load, force-only and added-mass callbacks (hydrodynamics, damping, contact). !! On a singular effective tangent returns CD_DYN_SINGULAR; on a line-search @@ -622,6 +660,42 @@ SUBROUTINE CD_Cable_Gen_Alpha_Step(q, v, a, elem_conn, l0, ea, rho_a, tension_on REAL(wp), INTENT(IN), OPTIONAL :: prescribed_q(:), prescribed_v(:), prescribed_a(:) REAL(wp), INTENT(IN), OPTIONAL :: structural_mass(:, :) TYPE(CD_CableGenAlphaWorkspace), INTENT(INOUT), TARGET, OPTIONAL :: workspace + !! Force blend (cfg%force_blend) with a load callback: the dynamic load at the step-start + !! state (q, v) as the callbacks return it for the committed state (a constitutive law + !! with internal state, such as the viscoelastic and Syrope contributors, gives its + !! committed force there, not one advanced over the step). Absent: the step evaluates the + !! force-only callback (or load_proc) at (q, v). Full (3 n_nodes) array. + REAL(wp), INTENT(IN), OPTIONAL :: start_load(:) + !! Force blend on a tension-only line whose load callbacks carry the axial law of some + !! elements (ea = 0 there; the viscoelastic and Syrope elements of a line model): the + !! step-start tension of each element (n_elem), the along-chord force of that law in + !! start_load (or in the step-start load the step evaluates). The release cap then bounds + !! the force blend of those elements as it bounds that of the elastic ones; entries of + !! elements with ea > 0 are ignored. Absent: the cap covers the elastic elements only. + REAL(wp), INTENT(IN), OPTIONAL :: start_tension(:) + !! With start_tension: the axial stiffness of each law element at the step-start state + !! (n_elem, N per metre of elongation, >= 0; the viscoelastic EA_D/l0 and the Syrope + !! K1/l0 = (alpha + beta T_mean)/l0 of a line model). It bounds the secant stiffness + !! T_n/e_n with which the release cap estimates the end tension of a law element that ends + !! taut (see apply_release_cap). Entries of elements with ea > 0 are ignored. Absent: the + !! secant is not bounded. + REAL(wp), INTENT(IN), OPTIONAL :: start_stiffness(:) + !! Force blend on a tension-only line whose load callbacks carry a linear axial dashpot on + !! elements with ea > 0 (the axial damping of a line model): its coefficient BA per element + !! (n_elem, N s, >= 0), the dashpot force on node a being (BA/l0) (t . (v_b - v_a) + !! - (l/l0) l0_dot) t, with axial_l0_rate the unstretched-length rate l0_dot (n_elem; absent: + !! zero). The release cap then covers the dashpot's step-start share too (see + !! apply_release_cap). Entries of elements with ea = 0 are ignored. Absent: the cap covers + !! the elastic force only. + REAL(wp), INTENT(IN), OPTIONAL :: axial_damping(:), axial_l0_rate(:) + !! TEST HOOK (unit tests of the tangent; production callers omit it). With probe_q (full + !! 3 n_nodes array, the fixed DOFs at their t_{n+1} values) present, the step returns after + !! its setup without iterating: probe_R is the residual (3 n_nodes) and probe_K the free-free + !! effective tangent (n_free x n_free, free DOFs in ascending order) of the Newton iteration + !! at probe_q, exactly as the iteration assembles them (banded or dense path). All three + !! are passed together; the state outputs are the t_n state, converged = .FALSE. + REAL(wp), INTENT(IN), OPTIONAL :: probe_q(:) + REAL(wp), INTENT(OUT), OPTIONAL :: probe_R(:), probe_K(:, :) INTEGER :: n_dof, n_elem, n_free, bt, kl, ku, ldab INTEGER, POINTER :: free(:), fixed(:), ipiv(:) @@ -631,6 +705,15 @@ SUBROUTINE CD_Cable_Gen_Alpha_Step(q, v, a, elem_conn, l0, ea, rho_a, tension_on REAL(wp), POINTER :: a_eval(:), a_alpha(:), q_alpha(:), v_eval(:), v_alpha(:), fint_eval(:) ! q_alpha viewed as (3, n_nodes) nodal coordinates, without a copy REAL(wp), POINTER :: q_alpha_nodes(:, :) + ! force blend: q_force holds q_{n+1} for the force evaluation, fint_n and load_n the + ! step-start internal force and dynamic load; qf, vf (qf_nodes) are the state the internal + ! force and the dynamic loads are evaluated at (q_{n+1}, v_{n+1} with the force blend, + ! q_alpha, v_alpha without) + REAL(wp), POINTER :: q_force(:), q_n_nodes(:, :), fint_n(:), load_n(:) + REAL(wp), POINTER :: qf(:), vf(:), qf_nodes(:, :) + REAL(wp), POINTER :: tension_n(:), stretch_n(:), chord_n(:, :), stiff_n(:) + REAL(wp), POINTER :: dcoef_n(:), rl0dot_n(:), damp_n(:) + LOGICAL :: force_blend, release_cap LOGICAL :: topo_ok, bw_hit, mb_hit INTEGER :: il, jl REAL(wp), POINTER :: Kt_eval(:, :), tension_eval(:), load_eval(:), jac_q_eval(:, :), jac_v_eval(:, :) @@ -661,6 +744,10 @@ SUBROUTINE CD_Cable_Gen_Alpha_Step(q, v, a, elem_conn, l0, ea, rho_a, tension_on n_iter = 0 ErrStat = CD_DYN_OK ErrMsg = '' + ! Only a warm re-solve of the step whose step-start data the workspace holds may reuse + ! them (start_valid): any other call drops them before its first return, so an unarmed + ! call that fails early cannot leave an older step's data to a later armed re-solve. + IF (PRESENT(workspace)) workspace%start_valid = workspace%start_valid .AND. workspace%guess_armed n_dof = SIZE(q) has_load_proc = PRESENT(load_proc) has_load_band_proc = PRESENT(load_band_proc) @@ -865,6 +952,28 @@ SUBROUTINE CD_Cable_Gen_Alpha_Step(q, v, a, elem_conn, l0, ea, rho_a, tension_on END DO END IF + ! --- force blend: the step-start internal force and dynamic load, the alpha_f share of + ! the blended residual (1 - alpha_f) r(q_{n+1}, v_{n+1}) + alpha_f r(q_n, v_n) --- + ! A warm re-solve of the same step (the junction coupling re-steps the line from the + ! same committed state with moved ends) reuses those of the previous call. + force_blend = cfg%force_blend + release_cap = .FALSE. + IF (force_blend) THEN + IF (work%guess_armed .AND. work%start_valid) THEN + release_cap = tension_only .AND. alpha_f > CD_ZERO + ELSE + work%start_valid = .FALSE. + CALL start_forces(es, em) + IF (es /= 0) THEN + CALL fail_callback(ErrStat, ErrMsg, em, es) + RETURN + END IF + work%start_valid = .TRUE. + END IF + ELSE + work%start_valid = .FALSE. + END IF + DO il = 1, n_dof qk(il) = q_pred(il) END DO @@ -949,6 +1058,11 @@ SUBROUTINE CD_Cable_Gen_Alpha_Step(q, v, a, elem_conn, l0, ea, rho_a, tension_on END IF END IF + IF (PRESENT(probe_q)) THEN + CALL probe_tangent() + RETURN + END IF + r0 = CD_ZERO scale = CD_ONE tension_scale = CD_ZERO @@ -1199,7 +1313,10 @@ SUBROUTINE CD_Cable_Gen_Alpha_Step(q, v, a, elem_conn, l0, ea, rho_a, tension_on EXIT END IF END IF - IF (.NOT. cfg%modified_newton) have_eff = .FALSE. + ! modified Newton keeps the factorised tangent only while each iterate reduces the + ! residual to at most a quarter of the previous one (a frozen tangent converges + ! linearly, and a slow contraction would spend the iteration budget) + IF (.NOT. cfg%modified_newton .OR. norm > 0.25_wp*norm_before) have_eff = .FALSE. END DO work%resid_first = converged .AND. n_iter == 0 .AND. .NOT. guess_used @@ -1377,6 +1494,141 @@ SUBROUTINE end_junction_data() work%end_valid = CD_All_Finite(work%end_k) .AND. CD_All_Finite(work%end_r) END SUBROUTINE end_junction_data + SUBROUTINE start_forces(es_s, em_s) + !! fint_n = f_int(q_n) and load_n = the dynamic load at (q_n, v_n): start_load when the + !! caller supplies it, else the force-only callback (or load_proc) evaluated there. + INTEGER, INTENT(OUT) :: es_s + CHARACTER(*), INTENT(OUT) :: em_s + INTEGER :: i + es_s = 0 + em_s = '' + CALL CD_Assemble_Cable_Internal_Force(q_n_nodes, elem_conn, l0, ea, tension_only, fint_n, es_s, em_s, & + topology_validated=topo_ok) + IF (es_s /= 0) THEN + es_s = CD_DYN_BADINPUT + em_s = 'step-start internal-force assembly failed: '//TRIM(em_s) + RETURN + END IF + ! release cap: the step-start tension, stretch and chord of every stretched element (the + ! assembly above has validated the connectivity and the element lengths). An element + ! with ea = 0 takes the tension of the law its load callback carries (start_tension) and + ! the bound of its secant stiffness (start_stiffness). + release_cap = tension_only .AND. alpha_f > CD_ZERO + IF (release_cap .AND. PRESENT(start_tension)) THEN + IF (SIZE(start_tension) /= n_elem) THEN + es_s = CD_DYN_BADINPUT + em_s = 'start_tension must have shape (n_elem)' + RETURN + END IF + IF (.NOT. CD_All_Finite(start_tension)) THEN + es_s = CD_DYN_BADINPUT + em_s = 'start_tension must be finite' + RETURN + END IF + IF (PRESENT(start_stiffness)) THEN + IF (SIZE(start_stiffness) /= n_elem) THEN + es_s = CD_DYN_BADINPUT + em_s = 'start_stiffness must have shape (n_elem)' + RETURN + END IF + IF (.NOT. CD_All_Finite(start_stiffness) .OR. ANY(start_stiffness < CD_ZERO)) THEN + es_s = CD_DYN_BADINPUT + em_s = 'start_stiffness must be finite and non-negative' + RETURN + END IF + END IF + END IF + IF (release_cap .AND. PRESENT(axial_damping)) THEN + IF (SIZE(axial_damping) /= n_elem) THEN + es_s = CD_DYN_BADINPUT + em_s = 'axial_damping must have shape (n_elem)' + RETURN + END IF + IF (.NOT. CD_All_Finite(axial_damping) .OR. ANY(axial_damping < CD_ZERO)) THEN + es_s = CD_DYN_BADINPUT + em_s = 'axial_damping must be finite and non-negative' + RETURN + END IF + IF (PRESENT(axial_l0_rate)) THEN + IF (SIZE(axial_l0_rate) /= n_elem) THEN + es_s = CD_DYN_BADINPUT + em_s = 'axial_l0_rate must have shape (n_elem)' + RETURN + END IF + IF (.NOT. CD_All_Finite(axial_l0_rate)) THEN + es_s = CD_DYN_BADINPUT + em_s = 'axial_l0_rate must be finite' + RETURN + END IF + END IF + END IF + IF (release_cap) THEN + DO i = 1, n_elem + BLOCK + REAL(wp) :: d(3), ell + d = q_n_nodes(:, elem_conn(2, i)) - q_n_nodes(:, elem_conn(1, i)) + ell = NORM2(d) + chord_n(:, i) = d/ell + stretch_n(i) = ell - l0(i) + tension_n(i) = CD_ZERO + stiff_n(i) = HUGE(CD_ONE) + dcoef_n(i) = CD_ZERO + rl0dot_n(i) = CD_ZERO + damp_n(i) = CD_ZERO + IF (ea(i) > CD_ZERO .AND. PRESENT(axial_damping)) THEN + IF (axial_damping(i) > CD_ZERO) THEN + ! the dashpot tension the start load carries, as the callback evaluates it + dcoef_n(i) = axial_damping(i)/l0(i) + IF (PRESENT(axial_l0_rate)) rl0dot_n(i) = axial_l0_rate(i)/l0(i) + damp_n(i) = dcoef_n(i)*(DOT_PRODUCT(chord_n(:, i), v_n(3*elem_conn(2, i) - 2:3*elem_conn(2, i)) - & + v_n(3*elem_conn(1, i) - 2:3*elem_conn(1, i))) - ell*rl0dot_n(i)) + END IF + END IF + IF (stretch_n(i) > CD_ZERO) THEN + IF (ea(i) > CD_ZERO) THEN + tension_n(i) = ea(i)*(ell/l0(i) - CD_ONE) + ELSE IF (PRESENT(start_tension)) THEN + tension_n(i) = MAX(start_tension(i), CD_ZERO) + IF (PRESENT(start_stiffness)) stiff_n(i) = start_stiffness(i) + END IF + END IF + END BLOCK + END DO + END IF + DO i = 1, n_dof + load_n(i) = CD_ZERO + END DO + IF (.NOT. (has_load_proc .OR. has_load_band_proc)) RETURN + IF (PRESENT(start_load)) THEN + IF (SIZE(start_load) /= n_dof) THEN + es_s = CD_DYN_BADINPUT + em_s = 'start_load must have shape (3 n_nodes)' + RETURN + END IF + DO i = 1, n_dof + load_n(i) = start_load(i) + END DO + ELSE IF (has_load_force_proc) THEN + CALL load_force_proc_cb(q_n, v_n, load_n, es_s, em_s) + IF (es_s /= 0) THEN + em_s = 'step-start dynamic force load failed: '//TRIM(em_s) + RETURN + END IF + ELSE + jac_q_eval = CD_ZERO + jac_v_eval = CD_ZERO + CALL load_proc_cb(q_n, v_n, load_n, jac_q_eval, jac_v_eval, es_s, em_s) + IF (es_s /= 0) THEN + em_s = 'step-start dynamic load failed: '//TRIM(em_s) + RETURN + END IF + END IF + IF (.NOT. CD_All_Finite(load_n)) THEN + es_s = CD_DYN_BADINPUT + em_s = 'step-start dynamic load is non-finite' + END IF + END SUBROUTINE start_forces + SUBROUTINE refresh_band_scales() !! Diagonal scale and max absolute row sum of the current (unfactored) effective band. IF (.NOT. scales_stale) RETURN @@ -1428,8 +1680,28 @@ SUBROUTINE bind_step_workspace(workspace_ref) a_alpha => workspace_ref%a_alpha(1:n_dof) q_alpha => workspace_ref%q_alpha(1:n_dof) q_alpha_nodes(1:3, 1:n_dof/3) => workspace_ref%q_alpha(1:n_dof) + q_force => workspace_ref%q_force(1:n_dof) + q_n_nodes(1:3, 1:n_dof/3) => workspace_ref%q_n(1:n_dof) + fint_n => workspace_ref%fint_n(1:n_dof) + load_n => workspace_ref%load_n(1:n_dof) + tension_n => workspace_ref%tension_n(1:n_elem) + stretch_n => workspace_ref%stretch_n(1:n_elem) + chord_n => workspace_ref%chord_n(1:3, 1:n_elem) + stiff_n => workspace_ref%stiff_n(1:n_elem) + dcoef_n => workspace_ref%dcoef_n(1:n_elem) + rl0dot_n => workspace_ref%rl0dot_n(1:n_elem) + damp_n => workspace_ref%damp_n(1:n_elem) v_eval => workspace_ref%v_eval(1:n_dof) v_alpha => workspace_ref%v_alpha(1:n_dof) + IF (cfg%force_blend) THEN + qf => workspace_ref%q_force(1:n_dof) + qf_nodes(1:3, 1:n_dof/3) => workspace_ref%q_force(1:n_dof) + vf => workspace_ref%v_eval(1:n_dof) + ELSE + qf => workspace_ref%q_alpha(1:n_dof) + qf_nodes(1:3, 1:n_dof/3) => workspace_ref%q_alpha(1:n_dof) + vf => workspace_ref%v_alpha(1:n_dof) + END IF fint_eval => workspace_ref%fint_eval(1:n_dof) tension_eval => workspace_ref%tension_eval(1:n_elem) load_eval => workspace_ref%load_eval(1:n_dof) @@ -1493,6 +1765,44 @@ REAL(wp) FUNCTION free_dot(x) RESULT(r) END DO END FUNCTION free_dot + SUBROUTINE probe_tangent() + !! The residual and free-free effective tangent at probe_q (see probe_q). + INTEGER :: i, j + IF (.NOT. (PRESENT(probe_R) .AND. PRESENT(probe_K))) THEN + CALL fail(ErrStat, ErrMsg, 'probe_q needs probe_R and probe_K') + RETURN + END IF + IF (SIZE(probe_q) /= n_dof .OR. SIZE(probe_R) /= n_dof .OR. SIZE(probe_K, 1) /= n_free .OR. & + SIZE(probe_K, 2) /= n_free) THEN + CALL fail(ErrStat, ErrMsg, 'probe_q, probe_R must have shape (3 n_nodes), probe_K (n_free, n_free)') + RETURN + END IF + IF (direct_banded) THEN + CALL eval_dynamic(probe_q, R, es, em, effbandout=eff_band) + ELSE + CALL eval_dynamic(probe_q, R, es, em, effout=eff) + END IF + IF (es /= 0) THEN + CALL fail_callback(ErrStat, ErrMsg, em, es) + RETURN + END IF + DO i = 1, n_dof + probe_R(i) = R(i) + END DO + probe_K = CD_ZERO + DO j = 1, n_free + IF (direct_banded) THEN + DO i = MAX(1, j - ku), MIN(n_free, j + kl) + probe_K(i, j) = eff_band(kl + ku + 1 + i - j, j) + END DO + ELSE + DO i = 1, n_free + probe_K(i, j) = eff(free(i), free(j)) + END DO + END IF + END DO + END SUBROUTINE probe_tangent + SUBROUTINE form_trial(stp) !! q_trial = qk, then q_trial(free) += stp*dq. REAL(wp), INTENT(IN) :: stp @@ -1506,9 +1816,10 @@ SUBROUTINE form_trial(stp) END SUBROUTINE form_trial SUBROUTINE eval_dynamic(q_eval, Rout, es_e, em_e, effout, effbandout) - !! R = M a_alpha + f_int(q_alpha) - f_ext (f_ext_alpha = f_ext, constant). When + !! R = M a_alpha + (1-af) r(q_eval, v_eval) + af r(q_n, v_n) with the force blend, else + !! M a_alpha + f_int(q_alpha) - f_ext - load(q_alpha, v_alpha) (f_ext constant). When !! the OPTIONAL effout is present it also returns the effective tangent - !! (1-am)/(beta dt^2) M + (1-af) K_t(q_alpha); when absent only the internal + !! (1-am)/(beta dt^2) M + (1-af) K_t(q_eval or q_alpha); when absent only the internal !! force is assembled (the residual-only path the line search uses). Host- !! associates M, q_pred, q_n, a_n, f_ext, the Chung-Hulbert params, and the mesh. REAL(wp), INTENT(IN) :: q_eval(:) @@ -1531,6 +1842,11 @@ SUBROUTINE eval_dynamic(q_eval, Rout, es_e, em_e, effout, effbandout) q_alpha(iv) = (CD_ONE - alpha_f)*q_eval(iv) + alpha_f*q_n(iv) v_alpha(iv) = (CD_ONE - alpha_f)*v_eval(iv) + alpha_f*v_n(iv) END DO + IF (force_blend) THEN + DO iv = 1, n_dof + q_force(iv) = q_eval(iv) + END DO + END IF IF (obj_levels) THEN DO il2 = 1, SIZE(fixed) IF (.NOT. object_level(il2)) CYCLE @@ -1543,7 +1859,7 @@ SUBROUTINE eval_dynamic(q_eval, Rout, es_e, em_e, effout, effbandout) END IF load_eval = CD_ZERO IF (PRESENT(effbandout)) THEN - CALL CD_Assemble_Cable_Tangent_Force_Banded_Free(q_alpha_nodes, elem_conn, l0, ea, & + CALL CD_Assemble_Cable_Tangent_Force_Banded_Free(qf_nodes, elem_conn, l0, ea, & tension_only, free, kl, ku, Kt_band, fint_eval, & tension_eval, es_e, em_e, topology_validated=topo_ok, & free_map=work%dof_marker(1:n_dof)) @@ -1555,7 +1871,7 @@ SUBROUTINE eval_dynamic(q_eval, Rout, es_e, em_e, effout, effbandout) END IF IF (has_load_band_proc) THEN ! the callback defines every INTENT(OUT) band entry itself - CALL load_band_proc_cb(q_alpha, v_alpha, free, kl, ku, load_eval, jq_band, jv_band, es_e, em_e) + CALL load_band_proc_cb(qf, vf, free, kl, ku, load_eval, jq_band, jv_band, es_e, em_e) IF (es_e /= 0) THEN em_e = 'dynamic banded load failed: '//TRIM(em_e) Rout = CD_ZERO @@ -1572,7 +1888,7 @@ SUBROUTINE eval_dynamic(q_eval, Rout, es_e, em_e, effout, effbandout) END IF END IF ELSE IF (PRESENT(effout)) THEN - CALL CD_Assemble_Cable_Tangent_Force(q_alpha_nodes, elem_conn, l0, ea, & + CALL CD_Assemble_Cable_Tangent_Force(qf_nodes, elem_conn, l0, ea, & tension_only, Kt_eval, fint_eval, tension_eval, es_e, em_e, & topology_validated=topo_ok) IF (es_e /= 0) THEN @@ -1582,7 +1898,7 @@ SUBROUTINE eval_dynamic(q_eval, Rout, es_e, em_e, effout, effbandout) RETURN END IF ELSE - CALL CD_Assemble_Cable_Internal_Force(q_alpha_nodes, elem_conn, l0, ea, & + CALL CD_Assemble_Cable_Internal_Force(qf_nodes, elem_conn, l0, ea, & tension_only, fint_eval, es_e, em_e, topology_validated=topo_ok) IF (es_e /= 0) THEN em_e = 'internal-force assembly failed: '//TRIM(em_e) @@ -1594,7 +1910,7 @@ SUBROUTINE eval_dynamic(q_eval, Rout, es_e, em_e, effout, effbandout) IF (tangent_requested .AND. has_load_proc) THEN jac_q_eval = CD_ZERO jac_v_eval = CD_ZERO - CALL load_proc_cb(q_alpha, v_alpha, load_eval, jac_q_eval, jac_v_eval, es_e, em_e) + CALL load_proc_cb(qf, vf, load_eval, jac_q_eval, jac_v_eval, es_e, em_e) IF (es_e /= 0) THEN em_e = 'dynamic load failed: '//TRIM(em_e) Rout = CD_ZERO @@ -1612,7 +1928,7 @@ SUBROUTINE eval_dynamic(q_eval, Rout, es_e, em_e, effout, effbandout) RETURN END IF ELSE IF (has_load_force_proc .AND. .NOT. tangent_requested) THEN - CALL load_force_proc_cb(q_alpha, v_alpha, load_eval, es_e, em_e) + CALL load_force_proc_cb(qf, vf, load_eval, es_e, em_e) IF (es_e /= 0) THEN em_e = 'dynamic force load failed: '//TRIM(em_e) Rout = CD_ZERO @@ -1629,7 +1945,7 @@ SUBROUTINE eval_dynamic(q_eval, Rout, es_e, em_e, effout, effbandout) ELSE IF (has_load_proc) THEN jac_q_eval = CD_ZERO jac_v_eval = CD_ZERO - CALL load_proc_cb(q_alpha, v_alpha, load_eval, jac_q_eval, jac_v_eval, es_e, em_e) + CALL load_proc_cb(qf, vf, load_eval, jac_q_eval, jac_v_eval, es_e, em_e) IF (es_e /= 0) THEN em_e = 'dynamic load failed: '//TRIM(em_e) Rout = CD_ZERO @@ -1678,6 +1994,18 @@ SUBROUTINE eval_dynamic(q_eval, Rout, es_e, em_e, effout, effbandout) RETURN END IF END IF + IF (force_blend) THEN + ! (1 - alpha_f) r(q_{n+1}, v_{n+1}) + alpha_f r(q_n, v_n); the tangent below takes the + ! (1 - alpha_f) share of the derivatives at q_{n+1} + DO iv = 1, n_dof + fint_eval(iv) = (CD_ONE - alpha_f)*fint_eval(iv) + alpha_f*fint_n(iv) + END DO + IF (has_load_proc .OR. has_load_band_proc) THEN + DO iv = 1, n_dof + load_eval(iv) = (CD_ONE - alpha_f)*load_eval(iv) + alpha_f*load_n(iv) + END DO + END IF + END IF IF (has_added_mass_proc) THEN Rout = MATMUL(M_eff_eval, a_alpha) + fint_eval - f_ext - load_eval ELSE IF (has_added_mass_band_proc) THEN @@ -1717,8 +2045,194 @@ SUBROUTINE eval_dynamic(q_eval, Rout, es_e, em_e, effout, effbandout) RETURN END IF END IF + IF (force_blend .AND. release_cap) THEN + IF (PRESENT(effbandout)) THEN + CALL apply_release_cap(q_eval, Rout, effbandout=effbandout) + ELSE IF (PRESENT(effout)) THEN + CALL apply_release_cap(q_eval, Rout, effout=effout) + ELSE + CALL apply_release_cap(q_eval, Rout) + END IF + END IF END SUBROUTINE eval_dynamic + SUBROUTINE apply_release_cap(q_eval, Rout, effout, effbandout) + !! Release cap of the force blend. A tension-only element taut at t_n (tension T_0, + !! stretch e_0 = l_n - l0 > 0, chord d_0 = l_n t_0) carries alpha_f T_0 along its + !! step-start chord t_0 in the blended residual, a constant force over the step. Over the + !! relative displacement d_1 - d_0 of its ends it returns the work alpha_f T_0 p to the + !! motion, with the projected shortening p = l_n - t_0 . d_1, not the shortening + !! e_0 - e_1 = l_n - |d_1|: a segment that turns as it releases has p well above e_0 - e_1 + !! (up to l_n + |d_1| for a reversed chord). The end share (1 - alpha_f) T_1 t_1, T_1 the + !! tension at t_{n+1}, returns -(1 - alpha_f) T_1 p_1 with p_1 = |d_1| - t_1 . d_0. The + !! element itself only released its strain energy W_0 = T_0 e_0/2, so the blend of an + !! element that releases (deeply, or turning) within one step can create energy. The cap + !! uses an estimate T^_1 of T_1: T^_1 = k e_1 for e_1 > 0 and 0 otherwise, with the secant + !! k = T_0/e_0. When alpha_f T_0 p exceeds N = W_0 + (1 - alpha_f) T^_1 p_1 the element + !! carries N/p instead of alpha_f T_0 along t_0 (the smaller of the two is kept, so the + !! blend is continuous in d_1), so its blend returns at most + !! W_0 + (1 - alpha_f)(T^_1 - T_1) p_1 over the step, and never more than without the cap. + !! T^_1 vanishes as the end state crosses the rest length, so the cap fades out + !! continuously there (a cap on slack end states alone would jump by up to alpha_f T_0). + !! For an elastic element T^_1 = T_1: its blend returns at most W_0 over every step (an + !! element that ends slack carries the discrete energy gradient W_0/p and returns exactly + !! W_0), and the cap acts on a taut end state only when the element turned and + !! T_1 < alpha_f/(1 - alpha_f) T_0. An element slack at t_n keeps the force blend. + !! N >= W_0/2 always (k e_0 <= T_0), so 4 alpha_f p <= e_0 is a sufficient test of an + !! inactive cap. The residual and the tangent are corrected by the difference. + !! An element whose axial law a load callback carries (ea = 0, T_0 from start_tension) is + !! capped the same way with the same W_0 = T_0 e_0/2 (the energy of the viscoelastic + !! springs at rest, an upper bound of the energy below a stiffening loading curve such as + !! Syrope's) and k = min(T_0/e_0, k_n), k_n its step-start axial stiffness + !! (start_stiffness), which bounds the secant where T_0 is mostly damping or lagged state + !! at a small e_0. Its law tension T_1 is not that of a linear spring, so its blend + !! returns at most W_0 when (T^_1 - T_1) p_1 <= 0: always when it ends below l0 with no + !! law tension, and otherwise not guaranteed, e.g. when it ends above l0 with less law + !! tension than T^_1 (zero once the slow branch has taken up the stretch, or below + !! Syrope's minimum strain), by up to (1 - alpha_f) k e_1 p_1. + !! An elastic element with a linear axial dashpot (axial_damping) also keeps alpha_f T_d,0 + !! along t_0, T_d,0 the dashpot tension at t_n, and its end share carries + !! (1 - alpha_f) T_d,1 t_1 (the dashpot pushes and pulls; it is not tension-only). The + !! dashpot stores no energy, so the budget stays W_0. Where the end state lies below the + !! band edge l0 + c e_0, c = alpha_f/(1 - alpha_f), the cap covers the dashpot with the + !! weight phi = 1 at and below l0, falling linearly to 0 at the band edge: it replaces the + !! kept force alpha_f (T_0 + phi T_d,0) by N/p when that is smaller, with + !! N = max(W_0 + (1 - alpha_f)(T^_1 + phi T_d,1) p_1, 0), T_d,1 the dashpot tension the + !! residual carries at (q_{n+1}, v_{n+1}). Over a step with p > 0 (the cap leaves an + !! element that does not shorten along t_0) the blend of such an element then returns at + !! most W_0 + (1 - phi) D, D the work of its uncapped blended dashpot + !! alpha_f T_d,0 p - (1 - alpha_f) T_d,1 p_1, unless N would be negative (its end share + !! alone returns more than W_0; the capped kept force is then zero). At and below l0 + !! (phi = 1) that is W_0. Above the band edge (phi = 0), and on every element without a + !! dashpot, the cap is the one above, so the force-blended dashpot of a taut line keeps the + !! standard generalised-alpha treatment. The weight is continuous, so is the capped force; + !! the tangent carries dT_d,1/dq_{n+1} through v_{n+1} (gamma/(beta dt)). + REAL(wp), INTENT(IN) :: q_eval(:) + REAL(wp), INTENT(INOUT) :: Rout(:) + REAL(wp), INTENT(INOUT), OPTIONAL :: effout(:, :), effbandout(:, :) + INTEGER :: e, na, nb, i, j, gi(6), fi, fj + REAL(wp) :: d1(3), l1, e1, e0, t0, p, p1, num, ln, k0, ten1, cosang, dg, delta, t1(3), g(3), blk(3, 3), sgn + REAL(wp) :: band, phi, dphi, td1, dv(3), dp1(3), dtd1(3), kc + LOGICAL :: taut_end, damped + band = alpha_f/(CD_ONE - alpha_f) + DO e = 1, n_elem + t0 = tension_n(e) + IF (.NOT. t0 > CD_ZERO) CYCLE + na = elem_conn(1, e) + nb = elem_conn(2, e) + d1 = q_eval(3*nb - 2:3*nb) - q_eval(3*na - 2:3*na) + e0 = stretch_n(e) + ! projected shortening p = l_n - t_0 . d_1 (l_n = l0 + e_0); the common case, an element + ! that does not release, is decided here without a root + p = e0 + (l0(e) - (chord_n(1, e)*d1(1) + chord_n(2, e)*d1(2) + chord_n(3, e)*d1(3))) + ! a damped element whose end state lies below the band edge l0 + band e_0 + damped = dcoef_n(e) > CD_ZERO + IF (damped) damped = d1(1)*d1(1) + d1(2)*d1(2) + d1(3)*d1(3) < (l0(e) + band*e0)**2 + IF (damped) THEN + IF (.NOT. p > CD_ZERO) CYCLE + l1 = NORM2(d1) + IF (.NOT. l1 > CD_ZERO) CYCLE + e1 = l1 - l0(e) + ln = l0(e) + e0 + t1 = d1/l1 + cosang = t1(1)*chord_n(1, e) + t1(2)*chord_n(2, e) + t1(3)*chord_n(3, e) + p1 = (e1 - e0) + 0.5_wp*ln*((t1(1) - chord_n(1, e))**2 + (t1(2) - chord_n(2, e))**2 + & + (t1(3) - chord_n(3, e))**2) + k0 = MIN(t0/e0, stiff_n(e)) + ten1 = k0*MAX(e1, CD_ZERO) + ! the dashpot weight and its slope along t_1 (zero at and below l0) + phi = CD_ONE + dphi = CD_ZERO + IF (e1 > CD_ZERO) THEN + phi = MAX(CD_ONE - e1/(band*e0), CD_ZERO) + IF (phi > CD_ZERO) dphi = -CD_ONE/(band*e0) + END IF + ! the end share's dashpot tension, as the residual evaluates it at (q_eval, v_eval) + dv = v_eval(3*nb - 2:3*nb) - v_eval(3*na - 2:3*na) + td1 = dcoef_n(e)*(DOT_PRODUCT(t1, dv) - l1*rl0dot_n(e)) + num = 0.5_wp*t0*e0 + (CD_ONE - alpha_f)*(ten1 + phi*td1)*p1 + kc = t0 + phi*damp_n(e) + dg = MAX(num, CD_ZERO)/p + IF (dg >= alpha_f*kc) CYCLE + delta = dg - alpha_f*kc + Rout(3*na - 2:3*na) = Rout(3*na - 2:3*na) - delta*chord_n(:, e) + Rout(3*nb - 2:3*nb) = Rout(3*nb - 2:3*nb) + delta*chord_n(:, e) + IF (.NOT. (PRESENT(effout) .OR. PRESENT(effbandout))) CYCLE + ! d(delta)/d(x_b) = g, d(delta)/d(x_a) = -g: dp/dd_1 = -t_0, dp_1/dd_1 as above, + ! d(phi)/dd_1 = dphi t_1, and dT_d,1/dx_b = (BA/l0)((dv - (t_1 . dv) t_1)/l_1 + ! + (gamma/(beta dt) - l0_dot/l0) t_1), v_b moving with gamma/(beta dt) x_b + g = -alpha_f*damp_n(e)*dphi*t1 + IF (num > CD_ZERO) THEN + dp1 = t1 - (ln/l1)*(chord_n(:, e) - cosang*t1) + dtd1 = dcoef_n(e)*((dv - DOT_PRODUCT(t1, dv)*t1)/l1 + (gamma/(beta*dt) - rl0dot_n(e))*t1) + g = g + (num/(p*p))*chord_n(:, e) + ((CD_ONE - alpha_f)/p)*((ten1 + phi*td1)*dp1 + phi*p1*dtd1 + & + dphi*td1*p1*t1) + IF (e1 > CD_ZERO) g = g + ((CD_ONE - alpha_f)/p)*k0*p1*t1 + END IF + ELSE + IF (.NOT. 4.0_wp*alpha_f*p > e0) CYCLE + num = 0.5_wp*t0*e0 + taut_end = d1(1)*d1(1) + d1(2)*d1(2) + d1(3)*d1(3) > l0(e)*l0(e) + l1 = CD_ZERO + e1 = CD_ZERO + ten1 = CD_ZERO + IF (taut_end) THEN + ! the end share's work: p_1 = |d_1| - t_1 . d_0 = (e_1 - e_0) + l_n (1 - t_1 . t_0), + ! with 1 - t_1 . t_0 = |t_1 - t_0|^2/2 (no cancellation at small turns) + l1 = NORM2(d1) + e1 = l1 - l0(e) + taut_end = e1 > CD_ZERO + END IF + IF (taut_end) THEN + ln = l0(e) + e0 + ! the secant stiffness, bounded for a law element by its step-start axial stiffness + k0 = MIN(t0/e0, stiff_n(e)) + ten1 = k0*e1 + t1 = d1/l1 + cosang = t1(1)*chord_n(1, e) + t1(2)*chord_n(2, e) + t1(3)*chord_n(3, e) + p1 = (e1 - e0) + 0.5_wp*ln*((t1(1) - chord_n(1, e))**2 + (t1(2) - chord_n(2, e))**2 + & + (t1(3) - chord_n(3, e))**2) + num = num + (CD_ONE - alpha_f)*ten1*p1 + END IF + dg = num/p + IF (dg >= alpha_f*t0) CYCLE + delta = dg - alpha_f*t0 + Rout(3*na - 2:3*na) = Rout(3*na - 2:3*na) - delta*chord_n(:, e) + Rout(3*nb - 2:3*nb) = Rout(3*nb - 2:3*nb) + delta*chord_n(:, e) + IF (.NOT. (PRESENT(effout) .OR. PRESENT(effbandout))) CYCLE + ! d(delta)/d(x_b) = g, d(delta)/d(x_a) = -g, with dp/dd_1 = -t_0, + ! dT_1/dd_1 = k0 t_1 and dp_1/dd_1 = t_1 - (l_n/|d_1|)(t_0 - (t_1 . t_0) t_1) + g = (num/(p*p))*chord_n(:, e) + IF (taut_end) g = g + ((CD_ONE - alpha_f)/p)*((k0*p1 + ten1)*t1 - & + ten1*(ln/l1)*(chord_n(:, e) - cosang*t1)) + END IF + DO j = 1, 3 + DO i = 1, 3 + blk(i, j) = chord_n(i, e)*g(j) + END DO + END DO + DO i = 1, 3 + gi(i) = 3*na - 3 + i + gi(3 + i) = 3*nb - 3 + i + END DO + DO j = 1, 6 + DO i = 1, 6 + ! rows of node a carry -delta t_0, columns of node a d(delta)/d(x_a) = -g + sgn = MERGE(-CD_ONE, CD_ONE, i <= 3)*MERGE(-CD_ONE, CD_ONE, j <= 3) + IF (PRESENT(effout)) THEN + effout(gi(i), gi(j)) = effout(gi(i), gi(j)) + sgn*blk(MOD(i - 1, 3) + 1, MOD(j - 1, 3) + 1) + ELSE + fi = work%dof_marker(gi(i)) + fj = work%dof_marker(gi(j)) + IF (fi <= 0 .OR. fj <= 0) CYCLE + effbandout(kl + ku + 1 + fi - fj, fj) = effbandout(kl + ku + 1 + fi - fj, fj) + & + sgn*blk(MOD(i - 1, 3) + 1, MOD(j - 1, 3) + 1) + END IF + END DO + END DO + END DO + END SUBROUTINE apply_release_cap + END SUBROUTINE CD_Cable_Gen_Alpha_Step ! --------------------------------------------------------------------------- ! @@ -1800,6 +2314,26 @@ SUBROUTINE ensure_step_workspace(work, n_dof, n_elem, n_free, ldab, need_band, n IF (ErrStat /= CD_DYN_OK) RETURN CALL ensure_real_vector(work%load_eval, n_dof, ErrStat, ErrMsg) IF (ErrStat /= CD_DYN_OK) RETURN + CALL ensure_real_vector(work%q_force, n_dof, ErrStat, ErrMsg) + IF (ErrStat /= CD_DYN_OK) RETURN + CALL ensure_real_vector(work%fint_n, n_dof, ErrStat, ErrMsg) + IF (ErrStat /= CD_DYN_OK) RETURN + CALL ensure_real_vector(work%load_n, n_dof, ErrStat, ErrMsg) + IF (ErrStat /= CD_DYN_OK) RETURN + CALL ensure_real_vector(work%tension_n, n_elem, ErrStat, ErrMsg) + IF (ErrStat /= CD_DYN_OK) RETURN + CALL ensure_real_vector(work%stretch_n, n_elem, ErrStat, ErrMsg) + IF (ErrStat /= CD_DYN_OK) RETURN + CALL ensure_real_matrix(work%chord_n, 3, n_elem, ErrStat, ErrMsg) + IF (ErrStat /= CD_DYN_OK) RETURN + CALL ensure_real_vector(work%stiff_n, n_elem, ErrStat, ErrMsg) + IF (ErrStat /= CD_DYN_OK) RETURN + CALL ensure_real_vector(work%dcoef_n, n_elem, ErrStat, ErrMsg) + IF (ErrStat /= CD_DYN_OK) RETURN + CALL ensure_real_vector(work%rl0dot_n, n_elem, ErrStat, ErrMsg) + IF (ErrStat /= CD_DYN_OK) RETURN + CALL ensure_real_vector(work%damp_n, n_elem, ErrStat, ErrMsg) + IF (ErrStat /= CD_DYN_OK) RETURN IF (need_band) THEN ! a reallocated mass band no longer holds the remembered one IF (ALLOCATED(work%M_band)) THEN diff --git a/src/CableDyn_Model.f90 b/src/CableDyn_Model.f90 index be545525..ffa0736a 100644 --- a/src/CableDyn_Model.f90 +++ b/src/CableDyn_Model.f90 @@ -103,6 +103,7 @@ MODULE CableDyn_Model PUBLIC :: CD_Recompute_Model_Acceleration PUBLIC :: CD_Model_Is_Initialized PUBLIC :: CD_Copy_Model + PUBLIC :: CD_Audit_Model_Step INTEGER, PARAMETER, PUBLIC :: CD_MODEL_OK = 0 INTEGER, PARAMETER, PUBLIC :: CD_MODEL_BADINPUT = 1 @@ -168,6 +169,19 @@ MODULE CableDyn_Model INTEGER, ALLOCATABLE :: free_map_work(:) TYPE(CD_CableGenAlphaWorkspace) :: dynamic_workspace REAL(wp), ALLOCATABLE :: load_force_work(:) + ! the load contributors at the committed state, the step-start share of the force-blended + ! generalised-alpha residual (scratch, rebuilt every step) + REAL(wp), ALLOCATABLE :: load_start_work(:) + ! the tension of the viscoelastic and Syrope elements in load_start_work (n_elem, zero for + ! the other elements; allocated only on a model with either law): the release cap of the + ! force blend bounds their alpha_f share as it bounds that of the elastic elements + REAL(wp), ALLOCATABLE :: tension_start_work(:) + ! their axial stiffness at the committed state (EA_D/l0, Syrope K1/l0; n_elem, allocated + ! with tension_start_work), which bounds the secant end tension of the release cap + REAL(wp), ALLOCATABLE :: stiffness_start_work(:) + ! load_start_work holds the committed-state load of the last step: a warm re-solve of the + ! same step (the junction coupling, dynamic_workspace%guess_armed) reuses it + LOGICAL :: load_start_valid = .FALSE. REAL(wp), ALLOCATABLE :: load_jq_work(:, :) REAL(wp), ALLOCATABLE :: load_jv_work(:, :) LOGICAL :: has_seabed = .FALSE. @@ -277,6 +291,23 @@ MODULE CableDyn_Model REAL(wp), ALLOCATABLE :: added_mass_can_elem(:) REAL(wp), ALLOCATABLE :: added_mass_cat_elem(:) TYPE(GenAlphaConfig) :: cfg + ! Run audit of the committed host steps (CD_Audit_Model_Step), diagnostics only: never part + ! of the state, of a copy, or of a result. audit_t holds the segment tensions of the last two + ! audited states (column 1 the latest; the elastic tension, or that of the viscoelastic or + ! Syrope law; -1 marks a segment whose law could not be evaluated), audit_u the unit chords + ! of the latest one, audit_n how many states are held (0 to 2). audit_floor is the largest + ! tension of the first audited state (the initial state: the driver audits it before its + ! march). audit_max_turn is the largest turn of a taut segment's chord in one step (deg), + ! audit_snaps the segments that went from slack to taut above audit_floor in one step and + ! audit_snap_courant the largest dt*c/l0 (c the axial wave speed) among them. audit_spikes + ! counts the implausible tension spikes, the first one recorded with its time, segment, + ! tension and ratio to the largest tension of the line one step before and after. + INTEGER :: audit_n = 0 + REAL(wp), ALLOCATABLE :: audit_t(:, :), audit_u(:, :), audit_now(:) + REAL(wp) :: audit_time = CD_ZERO, audit_floor = CD_ZERO, audit_max_turn = CD_ZERO + REAL(wp) :: audit_snap_courant = CD_ZERO + INTEGER :: audit_snaps = 0, audit_spikes = 0, audit_spike_elem = 0 + REAL(wp) :: audit_spike_time = CD_ZERO, audit_spike_tension = CD_ZERO, audit_spike_ratio = CD_ZERO END TYPE CD_ModelType CONTAINS @@ -373,6 +404,7 @@ SUBROUTINE CD_Init_Model(model, q0, v0, elem_conn, l0, ea, rho_a, tension_only, ! under memory pressure before any checked allocation runs). CALL clear_model_load_contributor_workspace(model) CALL CD_Clear_GenAlpha_Workspace(model%dynamic_workspace) + CALL clear_model_audit(model) old_model = model n_dof = SIZE(q0) @@ -1832,6 +1864,10 @@ SUBROUTINE CD_Step_Model(model, dt, converged, stalled, n_iter, ErrStat, ErrMsg, n_iter = 0 ErrStat = CD_MODEL_OK ErrMsg = '' + ! Only a warm re-solve of the step whose committed-state load load_start_work holds may + ! reuse it: any other call drops it before its first return (see the step workspace's + ! start_valid), so an unarmed call that fails early leaves no older step's load behind. + IF (.NOT. model%dynamic_workspace%guess_armed) model%load_start_valid = .FALSE. IF (.NOT. model%initialized) THEN ErrStat = CD_MODEL_NOT_INITIALIZED ErrMsg = 'CableDyn_Model: model is not initialized' @@ -1852,6 +1888,71 @@ SUBROUTINE CD_Step_Model(model, dt, converged, stalled, n_iter, ErrStat, ErrMsg, has_load = model%has_seabed .OR. model%has_seabed_damping .OR. model%has_seabed_friction .OR. & model%has_damping .OR. model%has_viscoelastic .OR. model%has_syrope .OR. model%has_morison_drag .OR. & model%has_froude_krylov .OR. model%has_buoyancy_recovery + ! Force-blended generalised alpha: the load contributors at the committed state (q_n, v_n) + ! carry the alpha_f share of the residual. They are evaluated here, in the instantaneous + ! limit (ve_dt = 0), so the viscoelastic and Syrope elements give their committed force, + ! whose tension (tension_start_work) the release cap of the step bounds like the elastic + ! tension. A warm re-solve of the same step (the junction coupling re-steps the line from + ! the same committed state with moved ends) reuses the load of the previous call. + IF (.NOT. (has_load .AND. model%cfg%force_blend)) THEN + model%load_start_valid = .FALSE. + ELSE IF (.NOT. (model%dynamic_workspace%guess_armed .AND. model%load_start_valid)) THEN + model%load_start_valid = .FALSE. + IF (ALLOCATED(model%load_start_work)) THEN + IF (SIZE(model%load_start_work) /= model%n_dof) DEALLOCATE (model%load_start_work) + END IF + IF (.NOT. ALLOCATED(model%load_start_work)) THEN + ALLOCATE (model%load_start_work(model%n_dof), STAT=es) + IF (es /= 0) THEN + ErrStat = CD_MODEL_ALLOCFAIL + ErrMsg = 'CableDyn_Model: step-start load workspace allocation failed' + RETURN + END IF + END IF + ! tension_start_work stays unallocated without a viscoelastic or Syrope element, and the + ! step then sees start_tension absent + IF (ALLOCATED(model%tension_start_work)) THEN + IF (SIZE(model%tension_start_work) /= model%n_elem .OR. & + .NOT. (model%has_viscoelastic .OR. model%has_syrope)) DEALLOCATE (model%tension_start_work) + END IF + IF ((model%has_viscoelastic .OR. model%has_syrope) .AND. .NOT. ALLOCATED(model%tension_start_work)) THEN + ALLOCATE (model%tension_start_work(model%n_elem), STAT=es) + IF (es /= 0) THEN + ErrStat = CD_MODEL_ALLOCFAIL + ErrMsg = 'CableDyn_Model: step-start tension workspace allocation failed' + RETURN + END IF + END IF + IF (ALLOCATED(model%stiffness_start_work)) THEN + IF (.NOT. ALLOCATED(model%tension_start_work)) THEN + DEALLOCATE (model%stiffness_start_work) + ELSE IF (SIZE(model%stiffness_start_work) /= model%n_elem) THEN + DEALLOCATE (model%stiffness_start_work) + END IF + END IF + IF (ALLOCATED(model%tension_start_work) .AND. .NOT. ALLOCATED(model%stiffness_start_work)) THEN + ALLOCATE (model%stiffness_start_work(model%n_elem), STAT=es) + IF (es /= 0) THEN + ErrStat = CD_MODEL_ALLOCFAIL + ErrMsg = 'CableDyn_Model: step-start stiffness workspace allocation failed' + RETURN + END IF + END IF + model%ve_dt = CD_ZERO + IF (ALLOCATED(model%tension_start_work)) THEN + CALL model_contributor_force(model, model%q, model%v, model%load_start_work, es, em, & + law_tension=model%tension_start_work, & + law_stiffness=model%stiffness_start_work) + ELSE + CALL model_contributor_force(model, model%q, model%v, model%load_start_work, es, em) + END IF + IF (es /= CD_MODEL_OK) THEN + ErrStat = es + ErrMsg = 'CableDyn_Model: step-start load failed: '//TRIM(em) + RETURN + END IF + model%load_start_valid = .TRUE. + END IF ! arm the viscoelastic contributors with the step size: in-step load ! evaluations use the backward-Euler-eliminated dl_1(q, v); it is reset to ! the instantaneous limit (0) on EVERY exit below so committed-state queries @@ -1865,7 +1966,10 @@ SUBROUTINE CD_Step_Model(model, dt, converged, stalled, n_iter, ErrStat, ErrMsg, es, em, load_force_proc=model_force, load_band_proc=model_load_band, & added_mass_band_proc=model_added_mass_band, prescribed_q=prescribed_q, & prescribed_v=prescribed_v, prescribed_a=prescribed_a, & - workspace=model%dynamic_workspace) + workspace=model%dynamic_workspace, start_load=model%load_start_work, & + start_tension=model%tension_start_work, & + start_stiffness=model%stiffness_start_work, & + axial_damping=model%ba_dyn, axial_l0_rate=model%l0_dot) ELSE IF (PRESENT(prescribed_q) .AND. has_load) THEN CALL CD_Cable_Gen_Alpha_Step(model%q, model%v, model%a, model%elem_conn, model%l0, model%ea_dyn, & model%rho_a, model%tension_only, model%f_ext, model%fixed_dofs, & @@ -1873,7 +1977,10 @@ SUBROUTINE CD_Step_Model(model, dt, converged, stalled, n_iter, ErrStat, ErrMsg, n_iter, & es, em, load_force_proc=model_force, load_band_proc=model_load_band, & prescribed_q=prescribed_q, prescribed_v=prescribed_v, & - prescribed_a=prescribed_a, workspace=model%dynamic_workspace) + prescribed_a=prescribed_a, workspace=model%dynamic_workspace, & + start_load=model%load_start_work, start_tension=model%tension_start_work, & + start_stiffness=model%stiffness_start_work, & + axial_damping=model%ba_dyn, axial_l0_rate=model%l0_dot) ELSE IF (PRESENT(prescribed_q) .AND. model%has_added_mass) THEN CALL CD_Cable_Gen_Alpha_Step(model%q, model%v, model%a, model%elem_conn, model%l0, model%ea_dyn, & model%rho_a, model%tension_only, model%f_ext, model%fixed_dofs, & @@ -1895,14 +2002,20 @@ SUBROUTINE CD_Step_Model(model, dt, converged, stalled, n_iter, ErrStat, ErrMsg, dt, model%cfg, model%q_step, model%v_step, model%a_step, converged, stalled, & n_iter, es, em, & load_force_proc=model_force, load_band_proc=model_load_band, & - added_mass_band_proc=model_added_mass_band, workspace=model%dynamic_workspace) + added_mass_band_proc=model_added_mass_band, workspace=model%dynamic_workspace, & + start_load=model%load_start_work, start_tension=model%tension_start_work, & + start_stiffness=model%stiffness_start_work, & + axial_damping=model%ba_dyn, axial_l0_rate=model%l0_dot) ELSE IF (has_load) THEN CALL CD_Cable_Gen_Alpha_Step(model%q, model%v, model%a, model%elem_conn, model%l0, model%ea_dyn, & model%rho_a, model%tension_only, model%f_ext, model%fixed_dofs, & dt, model%cfg, model%q_step, model%v_step, model%a_step, converged, stalled, & n_iter, es, em, & load_force_proc=model_force, load_band_proc=model_load_band, & - workspace=model%dynamic_workspace) + workspace=model%dynamic_workspace, start_load=model%load_start_work, & + start_tension=model%tension_start_work, & + start_stiffness=model%stiffness_start_work, & + axial_damping=model%ba_dyn, axial_l0_rate=model%l0_dot) ELSE IF (model%has_added_mass) THEN CALL CD_Cable_Gen_Alpha_Step(model%q, model%v, model%a, model%elem_conn, model%l0, model%ea_dyn, & model%rho_a, model%tension_only, model%f_ext, model%fixed_dofs, & @@ -3625,7 +3738,10 @@ SUBROUTINE CD_Set_Model_EndQuery(model, request, active, arm_guess, refresh, lev !! converged step then leaves the alpha-level reaction rows of its fixed DOFs and the !! condensed dynamic end tangent (CD_Get_Model_EndQuery). active (one flag per fixed DOF, !! in model%fixed_dofs order) limits the tangent columns to the junction DOFs; arm_guess - !! warm-starts the step from the previous converged solve of the same step. + !! warm-starts the step from the previous converged solve of the same step. arm_guess + !! must be set only for a re-solve of that step from the same committed state (the + !! line rolled back to it): the warm re-solve also reuses the step-start force and load + !! of the force blend computed by the previous call. TYPE(CD_ModelType), INTENT(INOUT) :: model LOGICAL, INTENT(IN) :: request LOGICAL, INTENT(IN), OPTIONAL :: active(:) @@ -3972,10 +4088,27 @@ SUBROUTINE CD_Get_Model_Tension(model, tension, ErrStat, ErrMsg) END DO END BLOCK END IF + ! the viscoelastic and Syrope elements report their own law's tension + CALL model_law_tensions(model, tension, ErrStat, ErrMsg) + END SUBROUTINE CD_Get_Model_Tension + + SUBROUTINE model_law_tensions(model, tension, ErrStat, ErrMsg) + !! Overwrite the entries of the viscoelastic and Syrope elements of tension (n_elem) with + !! their law's tension at the committed state (CD_Get_Model_Tension); the other entries + !! are left as they are. + TYPE(CD_ModelType), INTENT(IN) :: model + REAL(wp), INTENT(INOUT) :: tension(:) + INTEGER, INTENT(OUT) :: ErrStat + CHARACTER(*), INTENT(OUT) :: ErrMsg + INTEGER :: es + CHARACTER(160) :: em + + ErrStat = CD_MODEL_OK + ErrMsg = '' IF (model%has_viscoelastic) THEN ! viscoelastic elements report the series-Kelvin tension MagT + MagTd at the - ! COMMITTED state and dl_1 (the elastic EA recovery above does not apply - ! to them -- their dynamic elastic stiffness lives in the state) + ! COMMITTED state and dl_1 (the elastic EA recovery of CD_Get_Model_Tension does not + ! apply to them -- their dynamic elastic stiffness lives in the state) BLOCK INTEGER :: e, na, nb REAL(wp) :: ea_d_eff, ea_1_eff @@ -4004,8 +4137,8 @@ SUBROUTINE CD_Get_Model_Tension(model, tension, ErrStat, ErrMsg) END IF IF (model%has_syrope) THEN ! Syrope elements report the working-curve tension at the COMMITTED state - ! (the along-tangent component of the element force; the elastic EA - ! recovery above does not apply -- their stiffness lives in the states) + ! (the along-tangent component of the element force; the elastic EA recovery of + ! CD_Get_Model_Tension does not apply -- their stiffness lives in the states) BLOCK INTEGER :: e, idx_scr(6) REAL(wp) :: q2b(6), v2b(6), f6(6), j6(6, 6), jv6(6, 6), tmean, dslow, chord(3) @@ -4023,7 +4156,7 @@ SUBROUTINE CD_Get_Model_Tension(model, tension, ErrStat, ErrMsg) END DO END BLOCK END IF - END SUBROUTINE CD_Get_Model_Tension + END SUBROUTINE model_law_tensions SUBROUTINE CD_Update_Model_Hydro_Fields(model, ErrStat, ErrMsg, fluid_velocity, drag_waterline_z, & fluid_acceleration, fk_waterline_z, added_mass_waterline_z, & @@ -4601,6 +4734,196 @@ SUBROUTINE model_added_mass_band(q, accel, free, kl, ku, M_add_a, M_add_band, dM END SUBROUTINE model_added_mass_band END SUBROUTINE CD_Recompute_Model_Acceleration + SUBROUTINE CD_Audit_Model_Step(model, time, dt, new_spike) + !! Audit one committed host step of an EI=0 line (called by the standalone driver on the + !! initial state and once per output step, after the step's plausibility guard). Cheap, + !! O(n_elem) (and one evaluation of the viscoelastic and Syrope laws), and + !! diagnostic only. It tracks + !! + !! * the largest turn of a taut segment's chord over one step, the measure of how well + !! dtM resolves the rotation of the line (time-step advisory); + !! * slack-to-taut snaps above the initial tension scale, with the largest dt*c/l0 among + !! them (c = sqrt(EA/m) the axial wave speed; EA the dynamic stiffness: EA_D of a + !! viscoelastic segment, alpha + beta*T of a Syrope one): dt*c/l0 > 1 leaves the snap + !! peak unresolved in time; + !! * implausible tension spikes. A segment's tension T_n at the previous audited + !! step is a spike when it exceeds four times its own tension one step before and one + !! step after, ten times the largest tension anywhere on the line one step before and + !! one step after, and the largest tension of the initial state. A physical snap or + !! tension wave persists over the axial transit time and is shared by the neighbouring + !! segments, so no line, resolved or not, carries such an isolated single-step peak; an + !! integrator artefact (an under-resolved slack-taut transition) does. + !! + !! new_spike reports the line's first spike (so the caller warns once per line). The + !! tension is EA*max(strain, 0) of the elastic elements (EA*strain on a line that allows + !! compression) and the tension of their own law at the committed state for the + !! viscoelastic and Syrope elements (CD_Get_Model_Tension); the driver calls the audit + !! once on the initial state, so the "initial tension" is that of t = 0. + TYPE(CD_ModelType), INTENT(INOUT) :: model + REAL(wp), INTENT(IN) :: time, dt + LOGICAL, INTENT(OUT) :: new_spike + REAL(wp), PARAMETER :: SPIKE_ISOLATION = 4.0_wp, SPIKE_LINE_FACTOR = 10.0_wp + ! A segment counts as taut for the turn advisory above this fraction of the initial + ! line tension (a nearly slack segment turns freely, its tension error is irrelevant); + ! the spike test needs this many segments (the neighbours share the axial wave). + REAL(wp), PARAMETER :: TURN_TAUT_FRACTION = 1.0e-3_wp + INTEGER, PARAMETER :: SPIKE_MIN_ELEMS = 3 + INTEGER :: e, na, nb, istat, es + REAL(wp) :: d(3), ell, strain, u(3), c, line_max, tn + REAL(wp), ALLOCATABLE :: law(:) + LOGICAL :: fresh, laws + CHARACTER(160) :: em + + new_spike = .FALSE. + IF (.NOT. model%initialized .OR. model%n_elem < 1) RETURN + fresh = .NOT. (ALLOCATED(model%audit_t) .AND. ALLOCATED(model%audit_u) .AND. ALLOCATED(model%audit_now)) + IF (.NOT. fresh) fresh = SIZE(model%audit_t, 1) /= model%n_elem + IF (fresh) THEN + IF (ALLOCATED(model%audit_t)) DEALLOCATE (model%audit_t) + IF (ALLOCATED(model%audit_u)) DEALLOCATE (model%audit_u) + IF (ALLOCATED(model%audit_now)) DEALLOCATE (model%audit_now) + ALLOCATE (model%audit_t(model%n_elem, 2), model%audit_u(3, model%n_elem), model%audit_now(model%n_elem), & + STAT=istat) + IF (istat /= 0) RETURN + model%audit_n = 0 + END IF + ! the law tensions of the viscoelastic and Syrope segments at the committed state (a + ! segment whose law cannot be evaluated is left out, -1, as is every segment without a + ! tension when the evaluation fails) + laws = model%has_viscoelastic .OR. model%has_syrope + IF (laws) THEN + ! a local array, not model%audit_now itself (the law evaluation reads the model) + ALLOCATE (law(model%n_elem), STAT=istat) + laws = istat == 0 + END IF + IF (laws) THEN + law = -CD_ONE + CALL model_law_tensions(model, law, es, em) + laws = es == CD_MODEL_OK + IF (laws) model%audit_now = law + END IF + ! current tensions, chords and the chord turn against the previous audited state + DO e = 1, model%n_elem + na = model%elem_conn(1, e) + nb = model%elem_conn(2, e) + d = model%q(3*nb - 2:3*nb) - model%q(3*na - 2:3*na) + ell = NORM2(d) + IF (.NOT. ell > CD_ZERO) THEN + u = CD_ZERO + ELSE + u = d/ell + END IF + IF (model%ea_dyn(e) > CD_ZERO) THEN + strain = ell/model%l0(e) - CD_ONE + IF (model%tension_only .AND. strain < CD_ZERO) strain = CD_ZERO + model%audit_now(e) = model%ea_dyn(e)*strain + ELSE IF (laws .AND. law_element(e)) THEN + ! a tension-only law reports no compression; keep a finite value only + IF (.NOT. CD_Is_Finite(model%audit_now(e))) THEN + model%audit_now(e) = -CD_ONE + ELSE IF (model%tension_only) THEN + model%audit_now(e) = MAX(model%audit_now(e), CD_ZERO) + END IF + ELSE + model%audit_now(e) = -CD_ONE + END IF + IF (model%audit_n >= 1) THEN + ! the turn of a segment taut at both states (a slack segment turns freely and carries + ! no tension whose accuracy the turn would measure) + IF (model%audit_now(e) > TURN_TAUT_FRACTION*model%audit_floor .AND. & + model%audit_now(e) > CD_ZERO .AND. & + model%audit_t(e, 1) > TURN_TAUT_FRACTION*model%audit_floor .AND. model%audit_t(e, 1) > CD_ZERO) & + model%audit_max_turn = MAX(model%audit_max_turn, & + ACOS(MAX(-CD_ONE, MIN(CD_ONE, DOT_PRODUCT(u, model%audit_u(:, e)))))* & + (180.0_wp/ACOS(-CD_ONE))) + ! slack at the previous state, taut above the initial tension scale now + IF (model%audit_t(e, 1) >= CD_ZERO .AND. .NOT. model%audit_t(e, 1) > CD_ZERO .AND. & + model%audit_now(e) > model%audit_floor) THEN + model%audit_snaps = model%audit_snaps + 1 + c = SQRT(wave_stiffness(e)/model%rho_a(e)) + model%audit_snap_courant = MAX(model%audit_snap_courant, dt*c/model%l0(e)) + END IF + END IF + model%audit_u(:, e) = u + END DO + IF (model%audit_n == 0) model%audit_floor = MAX(CD_ZERO, MAXVAL(model%audit_now)) + ! spike test on the previous state, between its two neighbours + IF (model%audit_n >= 2 .AND. model%n_elem >= SPIKE_MIN_ELEMS) THEN + line_max = MAX(MAXVAL(model%audit_t(:, 2)), MAXVAL(model%audit_now)) + DO e = 1, model%n_elem + tn = model%audit_t(e, 1) + IF (.NOT. (tn > model%audit_floor)) CYCLE + IF (tn <= SPIKE_ISOLATION*MAX(model%audit_t(e, 2), model%audit_now(e))) CYCLE + IF (tn <= SPIKE_LINE_FACTOR*line_max) CYCLE + model%audit_spikes = model%audit_spikes + 1 + IF (model%audit_spikes == 1) THEN + model%audit_spike_time = model%audit_time + model%audit_spike_elem = e + model%audit_spike_tension = tn + model%audit_spike_ratio = tn/MAX(line_max, TINY(CD_ONE)) + new_spike = .TRUE. + END IF + END DO + END IF + model%audit_t(:, 2) = model%audit_t(:, 1) + model%audit_t(:, 1) = model%audit_now + model%audit_time = time + model%audit_n = MIN(model%audit_n + 1, 2) + + CONTAINS + + LOGICAL FUNCTION law_element(k) RESULT(is_law) + !! Segment k carries the viscoelastic or the Syrope law. + INTEGER, INTENT(IN) :: k + is_law = .FALSE. + IF (model%has_viscoelastic) is_law = model%ve_mode(k) /= 0 + IF (model%has_syrope .AND. .NOT. is_law) is_law = model%syrope_is(k) + END FUNCTION law_element + + REAL(wp) FUNCTION wave_stiffness(k) RESULT(stiff) + !! The axial stiffness of segment k that sets its wave speed: EA of an elastic segment, + !! the fast spring of a law (EA_D of the viscoelastic law, alpha + beta*T of the Syrope + !! law at the segment tension T); the static EA if the law's value is unavailable. + INTEGER, INTENT(IN) :: k + REAL(wp) :: ea_d_eff, ea_1_eff + INTEGER :: es_k + CHARACTER(200) :: em_k + stiff = model%ea_dyn(k) + IF (stiff > CD_ZERO) RETURN + stiff = model%ea(k) + IF (model%has_viscoelastic) THEN + IF (model%ve_mode(k) /= 0) THEN + CALL model_viscoelastic_coeffs(model, k, ea_d_eff, ea_1_eff, es_k, em_k) + IF (es_k == CD_MODEL_OK .AND. ea_d_eff > CD_ZERO) stiff = ea_d_eff + RETURN + END IF + END IF + IF (model%has_syrope) THEN + IF (model%syrope_is(k)) stiff = model%syrope_type(k)%alpha + & + model%syrope_type(k)%beta*MAX(model%audit_now(k), CD_ZERO) + END IF + END FUNCTION wave_stiffness + END SUBROUTINE CD_Audit_Model_Step + + SUBROUTINE clear_model_audit(model) + !! Reset the run audit (CD_Audit_Model_Step). + TYPE(CD_ModelType), INTENT(INOUT) :: model + IF (ALLOCATED(model%audit_t)) DEALLOCATE (model%audit_t) + IF (ALLOCATED(model%audit_u)) DEALLOCATE (model%audit_u) + IF (ALLOCATED(model%audit_now)) DEALLOCATE (model%audit_now) + model%audit_n = 0 + model%audit_time = CD_ZERO + model%audit_floor = CD_ZERO + model%audit_max_turn = CD_ZERO + model%audit_snap_courant = CD_ZERO + model%audit_snaps = 0 + model%audit_spikes = 0 + model%audit_spike_elem = 0 + model%audit_spike_time = CD_ZERO + model%audit_spike_tension = CD_ZERO + model%audit_spike_ratio = CD_ZERO + END SUBROUTINE clear_model_audit + SUBROUTINE CD_End_Model(model, ErrStat, ErrMsg) !! Release all allocatable model storage. Safe to call on an uninitialised model. TYPE(CD_ModelType), INTENT(INOUT) :: model @@ -4642,6 +4965,7 @@ SUBROUTINE CD_End_Model(model, ErrStat, ErrMsg) IF (ALLOCATED(model%free_map_work)) DEALLOCATE (model%free_map_work) CALL CD_Clear_GenAlpha_Workspace(model%dynamic_workspace) CALL clear_model_load_contributor_workspace(model) + CALL clear_model_audit(model) IF (ALLOCATED(model%seabed_kn)) DEALLOCATE (model%seabed_kn) IF (ALLOCATED(model%seabed_cn)) DEALLOCATE (model%seabed_cn) CALL CD_End_Bathymetry(model%bathymetry) @@ -5397,6 +5721,10 @@ SUBROUTINE clear_model_load_contributor_workspace(model) IF (ALLOCATED(model%load_force_work)) DEALLOCATE (model%load_force_work) IF (ALLOCATED(model%load_jq_work)) DEALLOCATE (model%load_jq_work) IF (ALLOCATED(model%load_jv_work)) DEALLOCATE (model%load_jv_work) + IF (ALLOCATED(model%load_start_work)) DEALLOCATE (model%load_start_work) + IF (ALLOCATED(model%tension_start_work)) DEALLOCATE (model%tension_start_work) + IF (ALLOCATED(model%stiffness_start_work)) DEALLOCATE (model%stiffness_start_work) + model%load_start_valid = .FALSE. END SUBROUTINE clear_model_load_contributor_workspace PURE LOGICAL FUNCTION mode3_marked(alpha_mbl, e) RESULT(marked) @@ -5982,7 +6310,8 @@ SUBROUTINE model_contributor_load_banded(model, q, v, free, kl, ku, force, jac_q END IF END SUBROUTINE model_contributor_load_banded - SUBROUTINE model_contributor_force(model, q, v, force, ErrStat, ErrMsg, end_nodes_only) + SUBROUTINE model_contributor_force(model, q, v, force, ErrStat, ErrMsg, end_nodes_only, law_tension, & + law_stiffness) !! Assemble all configured non-structural model load contributors without tangents. !! end_nodes_only: only the first and last node's entries are needed (end-force recovery); !! the other nodes and the elements not touching an end are skipped, and the two end entries @@ -5990,12 +6319,19 @@ SUBROUTINE model_contributor_force(model, q, v, force, ErrStat, ErrMsg, end_node !! compact 9-vector [first node (3), last node (3), sum over the other nodes the end !! elements reach (3)], so the recovery needs no n_dof-long scratch; the third block only !! carries the finiteness check of the full assembly. + !! law_tension (n_elem; with a full assembly): the along-chord tension of the element force + !! of the viscoelastic and Syrope laws in `force`, zero for every other element. + !! law_stiffness (n_elem; with law_tension): the axial stiffness of those laws at (q, v), in + !! N per metre of elongation: EA_D/l0 (the dynamic branch, at the committed state of a + !! load-dependent EA_D) and Syrope's K1/l0 = (alpha + beta T_mean)/l0; zero elsewhere. TYPE(CD_ModelType), INTENT(IN) :: model REAL(wp), INTENT(IN) :: q(:), v(:) REAL(wp), INTENT(OUT) :: force(:) INTEGER, INTENT(OUT) :: ErrStat CHARACTER(*), INTENT(OUT) :: ErrMsg LOGICAL, INTENT(IN), OPTIONAL :: end_nodes_only + REAL(wp), INTENT(OUT), OPTIONAL :: law_tension(:) + REAL(wp), INTENT(OUT), OPTIONAL :: law_stiffness(:) INTEGER :: n, e, i, ix, iy, iz, idx(6), nn LOGICAL :: ends @@ -6013,6 +6349,22 @@ SUBROUTINE model_contributor_force(model, q, v, force, ErrStat, ErrMsg, end_node ErrMsg = 'CableDyn_Model: model force received inconsistent q/v/force shapes' RETURN END IF + IF (PRESENT(law_tension)) THEN + IF (ends .OR. SIZE(law_tension) /= model%n_elem) THEN + ErrStat = CD_MODEL_BADINPUT + ErrMsg = 'CableDyn_Model: model force law tensions need a full assembly and shape (n_elem)' + RETURN + END IF + law_tension = CD_ZERO + END IF + IF (PRESENT(law_stiffness)) THEN + IF (.NOT. PRESENT(law_tension) .OR. SIZE(law_stiffness) /= model%n_elem) THEN + ErrStat = CD_MODEL_BADINPUT + ErrMsg = 'CableDyn_Model: model force law stiffnesses need the law tensions and shape (n_elem)' + RETURN + END IF + law_stiffness = CD_ZERO + END IF ErrStat = CD_MODEL_OK ErrMsg = '' nn = n/3 @@ -6117,6 +6469,8 @@ SUBROUTINE model_contributor_force(model, q, v, force, ErrStat, ErrMsg, end_node f2, ErrStat, ErrMsg) IF (ErrStat /= 0) RETURN CALL scatter_element_vector(force, idx, f2) + IF (PRESENT(law_tension)) law_tension(e) = element_law_tension() + IF (PRESENT(law_stiffness)) law_stiffness(e) = ea_d_eff/model%l0(e) END IF END IF IF (model%has_syrope) THEN @@ -6124,6 +6478,9 @@ SUBROUTINE model_contributor_force(model, q, v, force, ErrStat, ErrMsg, end_node CALL model_syrope_element(model, e, q2, v2, f2, syr_jac, syr_jac_v, syr_tm, syr_ds, ErrStat, ErrMsg) IF (ErrStat /= CD_MODEL_OK) RETURN CALL scatter_element_vector(force, idx, f2) + IF (PRESENT(law_tension)) law_tension(e) = element_law_tension() + IF (PRESENT(law_stiffness)) law_stiffness(e) = (model%syrope_type(e)%alpha + & + model%syrope_type(e)%beta*syr_tm)/model%l0(e) END IF END IF IF (model%has_morison_drag) THEN @@ -6175,6 +6532,14 @@ PURE INTEGER FUNCTION slot(k) RESULT(j) j = j + 6 END IF END FUNCTION slot + + REAL(wp) FUNCTION element_law_tension() RESULT(t) + !! Along-chord tension of the element force f2 on node a (the laws keep the element + !! longer than their collapse length, so the chord is nonzero). + REAL(wp) :: chord(3) + chord = q2(4:6) - q2(1:3) + t = DOT_PRODUCT(f2(1:3), chord/NORM2(chord)) + END FUNCTION element_law_tension END SUBROUTINE model_contributor_force SUBROUTINE seabed_normal_damping_load(q, v, z_floor, c_n, force, jac_q, jac_v, ErrStat, ErrMsg) diff --git a/tests/test_cable_dynamic.f90 b/tests/test_cable_dynamic.f90 index b38de153..28f3f2ed 100644 --- a/tests/test_cable_dynamic.f90 +++ b/tests/test_cable_dynamic.f90 @@ -184,39 +184,46 @@ END SUBROUTINE case_axial_period SUBROUTINE case_reference_one_step() !! One generalized-alpha step of a taut 3-node chain under gravity (node 2 free, - !! ends fixed) reproduces the reference q/v/a to the float64 floor. - INTEGER :: conn(2, 2), fixed(6), es, n_iter, i + !! ends fixed) reproduces the reference q/v/a to the float64 floor, for the force blend + !! (the default) and the configuration blend. The references solve the same step for + !! the middle node's z in 40-digit decimal arithmetic: G(z) = M a_alpha + f(z) - F with + !! f the force blend (1 - af) f_z(q_{n+1}) + af f_z(q_n) or the configuration blend + !! f_z((1 - af) q_{n+1} + af q_n), rho_inf = 0.8, dt = 0.01, from rest with a0 = -15. + !! The tight tolerance keeps the Newton error below the reference precision. + INTEGER :: conn(2, 2), fixed(6), es, n_iter, i, k REAL(wp) :: l0(2), ea(2), rho_a(2), q0(9), f_ext(9), load(3, 2) REAL(wp) :: q(9), v(9), a(9), q_new(9), v_new(9), a_new(9) LOGICAL :: converged, stalled TYPE(GenAlphaConfig) :: cfg CHARACTER(120) :: em - REAL(wp), PARAMETER :: want_q(9) = [0.0_wp, 0.0_wp, 0.0_wp, & - 1.0_wp, 0.0_wp, -7.485738187584846e-4_wp, & - 2.0_wp, 0.0_wp, 0.0_wp] - REAL(wp), PARAMETER :: want_v(9) = [0.0_wp, 0.0_wp, 0.0_wp, & - 0.0_wp, 0.0_wp, -0.14971761611417994_wp, & - 0.0_wp, 0.0_wp, 0.0_wp] - REAL(wp), PARAMETER :: want_a(9) = [0.0_wp, 0.0_wp, 0.0_wp, & - 0.0_wp, 0.0_wp, -14.9537917277749_wp, & - 0.0_wp, 0.0_wp, 0.0_wp] + REAL(wp), PARAMETER :: want_z(2) = [-7.4857381553276945e-4_wp, -7.4857381801437368e-4_wp] + REAL(wp), PARAMETER :: want_vz(2) = [-0.149717615475488341_wp, -0.149717615966845990_wp] + REAL(wp), PARAMETER :: want_az(2) = [-14.95379162326173_wp, -14.95379170366571_wp] CALL three_node_chain(conn, l0, ea, rho_a, q0) load = SPREAD([0.0_wp, 0.0_wp, -50.0_wp], 2, 2) CALL CD_Assemble_Distributed_Load(conn, l0, load, f_ext, es, em) CALL expect_es(es, 0, 'reference:fext-ErrStat') - q = q0; v = 0.0_wp fixed = [1, 2, 3, 7, 8, 9] - CALL CD_Cable_Initial_Acceleration(q, v, conn, l0, ea, rho_a, .FALSE., f_ext, fixed, a, es, em) - CALL expect_es(es, CD_DYN_OK, 'reference:a0-ErrStat') - CALL expect(a(6), -15.0_wp, 'reference:a0-z') - CALL CD_Cable_Gen_Alpha_Step(q, v, a, conn, l0, ea, rho_a, .FALSE., f_ext, fixed, & - 0.01_wp, cfg, q_new, v_new, a_new, converged, stalled, n_iter, es, em) - CALL expect_es(es, CD_DYN_OK, 'reference:step-ErrStat') - CALL require(converged, 'reference:converged') - DO i = 1, 9 - CALL expect(q_new(i), want_q(i), 'reference:q') - CALL expect(v_new(i), want_v(i), 'reference:v') - CALL expect(a_new(i), want_a(i), 'reference:a') + cfg%rel_tol = 1.0e-14_wp + DO k = 1, 2 + cfg%force_blend = k == 1 + q = q0; v = 0.0_wp + CALL CD_Cable_Initial_Acceleration(q, v, conn, l0, ea, rho_a, .FALSE., f_ext, fixed, a, es, em) + CALL expect_es(es, CD_DYN_OK, 'reference:a0-ErrStat') + CALL expect(a(6), -15.0_wp, 'reference:a0-z') + CALL CD_Cable_Gen_Alpha_Step(q, v, a, conn, l0, ea, rho_a, .FALSE., f_ext, fixed, & + 0.01_wp, cfg, q_new, v_new, a_new, converged, stalled, n_iter, es, em) + CALL expect_es(es, CD_DYN_OK, 'reference:step-ErrStat') + CALL require(converged, 'reference:converged') + DO i = 1, 9 + IF (i == 6) CYCLE + CALL expect(q_new(i), q0(i), 'reference:q-held') + CALL expect(v_new(i), 0.0_wp, 'reference:v-held') + CALL expect(a_new(i), 0.0_wp, 'reference:a-held') + END DO + CALL expect(q_new(6), want_z(k), 'reference:q') + CALL expect(v_new(6), want_vz(k), 'reference:v') + CALL expect(a_new(6), want_az(k), 'reference:a') END DO END SUBROUTINE case_reference_one_step @@ -549,6 +556,9 @@ SUBROUTINE case_line_search_fallback_handles_bad_tangent() a_bad = a_ref cfg%max_iter = 80 cfg%armijo_max_backtracks = 14 + ! both steps converged far below the comparison tolerance (a = (q - q_pred)/(beta dt^2) + ! magnifies the Newton error in q by 4e4 at this step) + cfg%rel_tol = 1.0e-12_wp CALL CD_Cable_Gen_Alpha_Step(q_ref, v_ref, a_ref, conn, l0, ea, rho_a, .FALSE., f_ext, fixed, & 0.01_wp, cfg, q_clean_out, v_clean_out, a_clean_out, & diff --git a/tests/test_core_release_regressions.f90 b/tests/test_core_release_regressions.f90 index 0a569e38..a692c8f1 100644 --- a/tests/test_core_release_regressions.f90 +++ b/tests/test_core_release_regressions.f90 @@ -159,12 +159,13 @@ SUBROUTINE case_fallback_restores_constitutive_state() ALLOCATE (qc(nc), vc(nc), ac(nc)) CALL CD_Get_System_CoupledMotion(system, qc, vc, ac, es, em) CALL require(es == CD_SYSTEM_OK, 'fallback:coupled-motion') - ! pull both ends of both lines outward + ! pull both ends of both lines outward, unevenly so the free middle node must move (a + ! symmetric pull leaves it balanced at its predictor up to round-off) DO i = 0, 1 qc(6*i + 1) = qc(6*i + 1) - 0.004_wp vc(6*i + 1) = -0.2_wp - qc(6*i + 4) = qc(6*i + 4) + 0.004_wp - vc(6*i + 4) = 0.2_wp + qc(6*i + 4) = qc(6*i + 4) + 0.010_wp + vc(6*i + 4) = 0.5_wp END DO ac = 0.0_wp diff --git a/tests/test_ei0_slack_dynamics.f90 b/tests/test_ei0_slack_dynamics.f90 new file mode 100644 index 00000000..167883b1 --- /dev/null +++ b/tests/test_ei0_slack_dynamics.f90 @@ -0,0 +1,1466 @@ +! File: tests/test_ei0_slack_dynamics.f90 +! SPDX-License-Identifier: Apache-2.0 +! Copyright (c) 2026 Jae Hoon Seo, SMI Lab, Inha University +PROGRAM test_ei0_slack_dynamics + !! Tension-only (EI = 0) lines that go slack and snap taut, at the default rhoInf = 0.4: + !! 1. A light, axially stiff cable (80 kg/m, EA 8e8 N, 115 x 2 m segments) under 3 m / 10 s + !! heave at dtM 0.1 s. The configuration-blended step reported 0.61 MN at the fairlead and + !! 20 MN at the anchor against about 0.1 MN (rhoInf 0 and small-step references); the + !! force blend stays below 0.2 MN. + !! 2. The same cable at dtM 0.01 s, where the force blend alone still fed a rattle of + !! single-step segment spikes (2.3 MN by 24 s) through the energy a release creates; + !! with the release cap every segment stays below 0.2 MN. + !! 3. The shipped viscoelastic polyester (Es|Ed, Bs|Bd) under 15 m surge at dtM 0.1 s: + !! 1.80 MN at the fairlead (2.69 MN configuration-blended), as at dtM 0.0025 s. + !! 4. The run audit of the driver (stdout of the executable given as the first argument): + !! the configuration blend (False alpha_force_blend) of case 1 warns of a non-physical + !! tension spike, the force blend does not; rhoInf above 0.95 prints its note; a 10 m + !! sway at dtM 0.2 s prints the segment-turn advisory; the unresolved slack-to-taut + !! snaps of case 1 print the snap note. + !! 5. The Newton tangent of the force-blended step against a central finite difference of its + !! residual (the step's probe_q hook), on a three-segment tension-only chain with one fixed + !! node: all segments taut at t_n and at the trial state (release cap inactive), a segment + !! taut at t_n and deeply slack at the trial state (cap active, its energy-gradient force + !! W_n/p on the projected shortening p and tangent), a segment slack at both states, and a + !! segment that turns by 45 degrees and ends slack (capped), taut at a tenth of its + !! tension (capped with the work of the end share) or taut at 3/4 of it (not capped); + !! each on the banded and the dense path. The residual is also checked against the closed + !! form. The blend of a segment that turns by 0 to 180 degrees within the step and ends + !! slack or taut returns at most its step-start strain energy W_n (up to 1100 W_n before + !! the cap took the projected shortening), one that keeps its direction and ends taut keeps + !! the plain force blend, and the force is continuous across the rest length. + !! 6. The same chain with a segment whose tension-only law a load callback carries (ea = 0, + !! as the viscoelastic and Syrope segments of a line model): with its step-start tension + !! (start_tension) its release, deep or turning, is capped like an elastic one, closed + !! form and finite difference tangent; without it the segment keeps the plain force blend. + !! A damped law segment whose step-start tension is almost all damping at a vanishing + !! stretch: with its axial stiffness (start_stiffness) bounding the secant end tension, + !! the cap force varies with the end stretch at a slope of order that stiffness (a jump + !! with the unbounded secant), the blend keeps the stated energy bound, and the tangent + !! matches the finite difference. An elastic segment with a two-sided axial dashpot + !! (axial_damping) that extends at t_n and turns and releases within the step: the blend, + !! dashpot included, keeps the stated bound (W_n when it ends slack), a segment that keeps + !! its direction and ends taut keeps the plain force blend, the force is continuous at the + !! rest length and the band edge, and the tangent matches the finite difference. + !! 7. The finite-difference tangent of the step with nonzero dynamic loads (a quadratic drag + !! and a cubic position load, plus a position-dependent added mass on the dense path), and + !! the closed form of the blended load (1 - alpha_f) f(q_{n+1}, v_{n+1}) + alpha_f f(q_n, v_n). + !! 8. A warm re-solve of the same step (guess_armed, the junction coupling) reuses the + !! step-start force, load and release-cap data of the previous call: its solution equals a + !! cold solve bit for bit while the start data it is given are wrong (so they are not + !! read); after an unarmed call that fails before computing them, an armed call recomputes + !! them instead of reusing those of an older state. + !! 9. A lightly damped viscoelastic version of the light cable at dtM 0.1 s (the cap on its + !! law segments) and a long taut Syrope line in 4 m surge that goes slack: no spike + !! warning, and peaks within the band of small-step references. + USE CableDyn_Precision, ONLY: wp + USE CableDyn_DeckDriver, ONLY: CD_Run_Deck_Driver, CD_DECKDRV_OK + USE CableDyn_Dynamic, ONLY: GenAlphaConfig, CD_CableGenAlphaWorkspace, CD_Cable_Gen_Alpha_Step, CD_DYN_OK + IMPLICIT NONE + + REAL(wp), PARAMETER :: PI = 3.141592653589793238462643383279502884197_wp + CHARACTER(*), PARAMETER :: CABLE = 'cable 0.2 80.0 8.0e8 0.0 0.0 1.2 0.1 1.0 0.0' + CHARACTER(*), PARAMETER :: POLY_VE = 'poly_ve 0.1438 22.42 1.424e8|2.50e8 4.0e9|1.1e7 0.0 1.2 0.2 1.0 0.0' + ! the light cable as a lightly damped viscoelastic line (Es|Ed, Bs|Bd) + CHARACTER(*), PARAMETER :: CABLE_VE = 'cable 0.2 80.0 8.0e8|1.6e9 1.0e8|1.0e6 0.0 1.2 0.1 1.0 0.0' + INTEGER :: nfail + CHARACTER(1024) :: driver + ! dynamic load of the chain cases 6 to 8 (host-associated by the load callbacks): nodal + ! quadratic drag -cb_drag |v| v, nodal cubic load -cb_spring |q - cb_q0|^2 (q - cb_q0), the + ! tension-only law (EA cb_ea_law, length cb_l0_law) of segment cb_law_elem (0: none), and the + ! added mass cb_madd (1 + 0.3 z^2) per DOF of the dense path + REAL(wp) :: cb_drag = 0.0_wp, cb_spring = 0.0_wp, cb_ea_law = 0.0_wp, cb_l0_law = 1.0_wp, cb_madd = 0.0_wp + ! axial damping of the segment law, tension cb_ea_law (l/l0 - 1) + cb_ba_law (dl/dt)/l0 + REAL(wp) :: cb_ba_law = 0.0_wp + ! a two-sided axial dashpot (BA cb_ba_dash, force cb_ba_dash (dl/dt)/l0 along the chord, as the + ! line model's axial damping) on segment cb_dash_elem (0: none) of rest length cb_l0_dash + REAL(wp) :: cb_ba_dash = 0.0_wp, cb_l0_dash = 1.0_wp + INTEGER :: cb_dash_elem = 0 + REAL(wp) :: cb_q0(12) = 0.0_wp + INTEGER :: cb_law_elem = 0 + + nfail = 0 + driver = '' + IF (COMMAND_ARGUMENT_COUNT() >= 1) CALL GET_COMMAND_ARGUMENT(1, driver) + CALL case_tangent_consistency() + CALL case_release_energy() + CALL case_law_release_cap() + CALL case_law_damped_release() + CALL case_damped_elastic_release() + CALL case_load_share_tangent() + CALL case_warm_resolve_reuse() + CALL case_light_cable_coarse_step() + CALL case_light_cable_release_cap() + CALL case_viscoelastic_surge() + IF (LEN_TRIM(driver) > 0) THEN + CALL case_run_audit() + CALL case_law_slack_runs() + ELSE + WRITE (*, '(A)') 'MISMATCH [audit: the driver executable is the first argument]' + nfail = nfail + 1 + END IF + + IF (nfail > 0) THEN + WRITE (*, '(A,I0,A)') 'FAIL: ', nfail, ' assertion(s) failed' + ERROR STOP 1 + END IF + WRITE (*, '(A)') 'PASS: EI = 0 slack-taut dynamics (force blend, release cap, run audit)' + +CONTAINS + + SUBROUTINE require(cond, label) + LOGICAL, INTENT(IN) :: cond + CHARACTER(*), INTENT(IN) :: label + IF (.NOT. cond) THEN + WRITE (*, '(A)') 'MISMATCH ['//label//']' + nfail = nfail + 1 + END IF + END SUBROUTINE require + + SUBROUTINE write_motion(path, pid, x0, axis, amp, period, ramp, dt, tmax) + !! Harmonic translation of one point, amp*r(t)*sin(w t), with the C2 quintic start-up + !! ramp r over `ramp` seconds and its exact velocity and acceleration. + CHARACTER(*), INTENT(IN) :: path + INTEGER, INTENT(IN) :: pid, axis + REAL(wp), INTENT(IN) :: x0(3), amp, period, ramp, dt, tmax + INTEGER :: u, i, n + REAL(wp) :: t, s, r, rd, rdd, w, p(3), v(3), a(3) + OPEN (NEWUNIT=u, FILE=path, STATUS='REPLACE', ACTION='WRITE') + WRITE (u, '(A)') '# time id x y z vx vy vz ax ay az' + n = NINT(tmax/dt) + w = 2.0_wp*PI/period + DO i = 0, n + t = REAL(i, wp)*dt + s = MIN(t/ramp, 1.0_wp) + r = 10.0_wp*s**3 - 15.0_wp*s**4 + 6.0_wp*s**5 + rd = 0.0_wp + rdd = 0.0_wp + IF (t < ramp) THEN + rd = (30.0_wp*s**2 - 60.0_wp*s**3 + 30.0_wp*s**4)/ramp + rdd = (60.0_wp*s - 180.0_wp*s**2 + 120.0_wp*s**3)/ramp**2 + END IF + p = x0 + v = 0.0_wp + a = 0.0_wp + p(axis) = p(axis) + amp*r*SIN(w*t) + v(axis) = amp*(rd*SIN(w*t) + r*w*COS(w*t)) + a(axis) = amp*(rdd*SIN(w*t) + 2.0_wp*rd*w*COS(w*t) - r*w*w*SIN(w*t)) + WRITE (u, '(ES17.10,1X,I0,9(1X,ES17.10))') t, pid, p, v, a + END DO + CLOSE (u) + END SUBROUTINE write_motion + + SUBROUTINE write_deck(path, linetype, anchor, fairlead, length, nseg, depth, outputs, options) + !! One line from a Coupled fairlead (point 1, End A) to a Fixed anchor (point 2). + CHARACTER(*), INTENT(IN) :: path, linetype, outputs, options(:) + REAL(wp), INTENT(IN) :: anchor(3), fairlead(3), length, depth + INTEGER, INTENT(IN) :: nseg + INTEGER :: u, i + CHARACTER(32) :: name + OPEN (NEWUNIT=u, FILE=path, STATUS='REPLACE', ACTION='WRITE') + WRITE (u, '(A)') 'EI = 0 slack-taut dynamics regression deck' + WRITE (u, '(A)') '--- LINE TYPES ---' + WRITE (u, '(A)') 'Name Diam Mass EA BA EI Cdn Cdt Can Cat' + WRITE (u, '(A)') '(-) (m) (kg/m) (N) (-) (Nm2) (-) (-) (-) (-)' + WRITE (u, '(A)') TRIM(linetype) + READ (linetype, *) name + 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,3(1X,ES16.9),A)') '1 Coupled', fairlead, ' 0 0 0 0' + WRITE (u, '(A,3(1X,ES16.9),A)') '2 Fixed', anchor, ' 0 0 0 0' + WRITE (u, '(A)') '--- LINES ---' + WRITE (u, '(A)') 'ID NodeA NodeB Outputs' + WRITE (u, '(A)') '(-) (-) (-) (-)' + WRITE (u, '(A,A)') '1 1 2 ', outputs + WRITE (u, '(A)') '--- SECTIONS ---' + WRITE (u, '(A)') 'LineID LineType Length NumSegs' + WRITE (u, '(A)') '(-) (-) (m) (-)' + WRITE (u, '(A,A,1X,ES16.9,1X,I0)') '1 ', TRIM(name), length, nseg + WRITE (u, '(A)') '--- OPTIONS ---' + WRITE (u, '(ES16.9,A)') depth, ' WtrDpth' + DO i = 1, SIZE(options) + IF (LEN_TRIM(options(i)) > 0) WRITE (u, '(A)') TRIM(options(i)) + END DO + WRITE (u, '(A)') '--- OUTPUTS ---' + WRITE (u, '(A)') 'FairTen1 AnchTen1' + WRITE (u, '(A)') '--- end ---' + CLOSE (u) + END SUBROUTINE write_deck + + SUBROUTINE light_cable_deck(path, dt, tmax, extra, outputs) + !! The light, axially stiff cable from the fairlead (5, 0, -14) to the anchor (205, 0, -80), + !! 230 m in 115 segments, heaving 3 m at 10 s after a 10 s ramp. + CHARACTER(*), INTENT(IN) :: path, extra, outputs + REAL(wp), INTENT(IN) :: dt, tmax + CHARACTER(64) :: opts(4) + CALL write_motion('ei0slack_heave.txt', 1, [5.0_wp, 0.0_wp, -14.0_wp], 3, 3.0_wp, 10.0_wp, 10.0_wp, dt, tmax) + WRITE (opts(1), '(ES14.7,A)') dt, ' dtM' + WRITE (opts(2), '(ES14.7,A)') tmax, ' TMax' + opts(3) = 'ei0slack_heave.txt motionFile' + opts(4) = extra + CALL write_deck(path, CABLE, [205.0_wp, 0.0_wp, -80.0_wp], [5.0_wp, 0.0_wp, -14.0_wp], 230.0_wp, 115, 80.0_wp, & + outputs, opts) + END SUBROUTINE light_cable_deck + + SUBROUTINE read_out(path, data, nrow) + !! Numeric rows of a driver output file (comment and header lines skipped). + CHARACTER(*), INTENT(IN) :: path + REAL(wp), ALLOCATABLE, INTENT(OUT) :: data(:, :) + INTEGER, INTENT(OUT) :: nrow + INTEGER :: u, ios, ncol, k + CHARACTER(8192) :: line + LOGICAL :: header_seen + REAL(wp), ALLOCATABLE :: grow(:, :) + nrow = 0 + ncol = 0 + header_seen = .FALSE. + ALLOCATE (data(0, 0)) + OPEN (NEWUNIT=u, FILE=path, STATUS='OLD', ACTION='READ', IOSTAT=ios) + IF (ios /= 0) RETURN + DO + READ (u, '(A)', IOSTAT=ios) line + IF (ios /= 0) EXIT + IF (line(1:1) == '#' .OR. LEN_TRIM(line) == 0) CYCLE + IF (.NOT. header_seen) THEN + header_seen = .TRUE. + ncol = count_tokens(line) + DEALLOCATE (data) + ALLOCATE (data(ncol, 64)) + CYCLE + END IF + IF (nrow == SIZE(data, 2)) THEN + ALLOCATE (grow(ncol, 2*SIZE(data, 2))) + grow(:, 1:nrow) = data(:, 1:nrow) + CALL MOVE_ALLOC(grow, data) + END IF + nrow = nrow + 1 + READ (line, *) (data(k, nrow), k=1, ncol) + END DO + CLOSE (u) + END SUBROUTINE read_out + + INTEGER FUNCTION count_tokens(line) RESULT(n) + CHARACTER(*), INTENT(IN) :: line + INTEGER :: i + LOGICAL :: inside + n = 0 + inside = .FALSE. + DO i = 1, LEN_TRIM(line) + IF (line(i:i) == ' ' .OR. line(i:i) == CHAR(9)) THEN + inside = .FALSE. + ELSE IF (.NOT. inside) THEN + inside = .TRUE. + n = n + 1 + END IF + END DO + END FUNCTION count_tokens + + REAL(wp) FUNCTION column_max(path, first_col, last_col) RESULT(mx) + !! Largest value of the columns first_col..last_col (last_col 0: through the last column). + CHARACTER(*), INTENT(IN) :: path + INTEGER, INTENT(IN) :: first_col, last_col + REAL(wp), ALLOCATABLE :: d(:, :) + INTEGER :: nrow, lc + mx = -HUGE(1.0_wp) + CALL read_out(path, d, nrow) + IF (nrow < 1) RETURN + lc = last_col + IF (lc == 0) lc = SIZE(d, 1) + mx = MAXVAL(d(first_col:lc, 1:nrow)) + END FUNCTION column_max + + LOGICAL FUNCTION file_contains(path, needle) RESULT(found) + CHARACTER(*), INTENT(IN) :: path, needle + INTEGER :: u, ios + CHARACTER(4096) :: line + found = .FALSE. + OPEN (NEWUNIT=u, FILE=path, STATUS='OLD', ACTION='READ', IOSTAT=ios) + IF (ios /= 0) RETURN + DO + READ (u, '(A)', IOSTAT=ios) line + IF (ios /= 0) EXIT + IF (INDEX(line, needle) > 0) THEN + found = .TRUE. + EXIT + END IF + END DO + CLOSE (u) + END FUNCTION file_contains + + SUBROUTINE echo_tail(path, n) + !! Print the last n lines of a log (the reason a driver run stopped). + CHARACTER(*), INTENT(IN) :: path + INTEGER, INTENT(IN) :: n + CHARACTER(4096) :: ring(16), line + INTEGER :: u, ios, k, m, i + m = MIN(MAX(n, 1), SIZE(ring)) + k = 0 + OPEN (NEWUNIT=u, FILE=path, STATUS='OLD', ACTION='READ', IOSTAT=ios) + IF (ios /= 0) RETURN + DO + READ (u, '(A)', IOSTAT=ios) line + IF (ios /= 0) EXIT + k = k + 1 + ring(MOD(k - 1, m) + 1) = line + END DO + CLOSE (u) + WRITE (*, '(A)') ' --- end of '//path//':' + DO i = MAX(1, k - m + 1), k + WRITE (*, '(A)') ' '//TRIM(ring(MOD(i - 1, m) + 1)) + END DO + END SUBROUTINE echo_tail + + SUBROUTINE run_driver_logged(deck, root, log, ok) + !! Run the driver executable on a deck, its stdout and stderr to log. + CHARACTER(*), INTENT(IN) :: deck, root, log + LOGICAL, INTENT(OUT) :: ok + INTEGER :: ex, cs + CALL EXECUTE_COMMAND_LINE('"'//TRIM(driver)//'" '//deck//' '//root//' > '//log//' 2>&1', & + WAIT=.TRUE., EXITSTAT=ex, CMDSTAT=cs) + ok = cs == 0 .AND. ex == 0 + END SUBROUTINE run_driver_logged + + SUBROUTINE zero_load(q, v, force, jac_q, jac_v, ErrStat, ErrMsg) + !! No dynamic load; selects the dense (load_proc) path of the step. + REAL(wp), INTENT(IN) :: q(:), v(:) + REAL(wp), INTENT(OUT) :: force(:), jac_q(:, :), jac_v(:, :) + INTEGER, INTENT(OUT) :: ErrStat + CHARACTER(*), INTENT(OUT) :: ErrMsg + force = 0.0_wp + jac_q = 0.0_wp + jac_v = 0.0_wp + ErrStat = 0 + ErrMsg = '' + END SUBROUTINE zero_load + + SUBROUTINE chain_nodes(dirs, strain, l0, q) + !! Nodes of the chain from the fixed node at the origin: segment e runs along dirs(:, e) + !! with the length l0(e)*(1 + strain(e)). + REAL(wp), INTENT(IN) :: dirs(3, 3), strain(3), l0(3) + REAL(wp), INTENT(OUT) :: q(12) + INTEGER :: e + q(1:3) = 0.0_wp + DO e = 1, 3 + q(3*e + 1:3*e + 3) = q(3*e - 2:3*e) + dirs(:, e)/NORM2(dirs(:, e))*l0(e)*(1.0_wp + strain(e)) + END DO + END SUBROUTINE chain_nodes + + SUBROUTINE blended_force(qn, q1, l0, ea, alpha_f, capped, f) + !! Closed form of the blended internal force (1 - alpha_f) f(q1) + alpha_f f(qn) of the + !! tension-only chain, with the release cap (capped) or without it: the retained share + !! alpha_f T_n along the step-start chord t_n is at most + !! (W_n + (1 - alpha_f) T_1 p_1)/p, W_n = T_n e_n/2, with the projected shortening + !! p = |d_n| - t_n . d_1 and p_1 = |d_1| - t_1 . d_n, so that the blend returns at most W_n. + REAL(wp), INTENT(IN) :: qn(12), q1(12), l0(3), ea(3), alpha_f + LOGICAL, INTENT(IN) :: capped + REAL(wp), INTENT(OUT) :: f(12) + INTEGER :: e + REAL(wp) :: dn(3), d1(3), ln, l1, t0, t1, e0, dg, p, p1, share(3) + f = 0.0_wp + DO e = 1, 3 + dn = qn(3*e + 1:3*e + 3) - qn(3*e - 2:3*e) + d1 = q1(3*e + 1:3*e + 3) - q1(3*e - 2:3*e) + ln = NORM2(dn) + l1 = NORM2(d1) + t0 = MAX(0.0_wp, ea(e)*(ln/l0(e) - 1.0_wp)) + t1 = MAX(0.0_wp, ea(e)*(l1/l0(e) - 1.0_wp)) + e0 = ln - l0(e) + dg = alpha_f*t0 + p = ln - DOT_PRODUCT(dn/ln, d1) + p1 = l1 - DOT_PRODUCT(d1/l1, dn) + IF (capped .AND. t0 > 0.0_wp .AND. p > 0.0_wp) dg = MIN(dg, (0.5_wp*t0*e0 + (1.0_wp - alpha_f)*t1*p1)/p) + share = (1.0_wp - alpha_f)*t1*d1/l1 + dg*dn/ln + f(3*e - 2:3*e) = f(3*e - 2:3*e) - share + f(3*e + 1:3*e + 3) = f(3*e + 1:3*e + 3) + share + END DO + END SUBROUTINE blended_force + + SUBROUTINE probe_step(qn, vn, an, q1, l0, ea, rho_a, dense, R, K) + !! Residual and effective tangent of the force-blended step at q1 (the probe_q hook). + REAL(wp), INTENT(IN) :: qn(12), vn(12), an(12), q1(12), l0(3), ea(3), rho_a(3) + LOGICAL, INTENT(IN) :: dense + REAL(wp), INTENT(OUT) :: R(12), K(9, 9) + INTEGER :: conn(2, 3), n_iter, es + REAL(wp) :: qo(12), vo(12), ao(12) + LOGICAL :: converged, stalled + TYPE(GenAlphaConfig) :: cfg + TYPE(CD_CableGenAlphaWorkspace) :: work + CHARACTER(120) :: em + conn = RESHAPE([1, 2, 2, 3, 3, 4], [2, 3]) + cfg%rho_inf = 0.4_wp + IF (dense) THEN + CALL CD_Cable_Gen_Alpha_Step(qn, vn, an, conn, l0, ea, rho_a, .TRUE., 0.0_wp*qn, [1, 2, 3], 0.05_wp, cfg, & + qo, vo, ao, converged, stalled, n_iter, es, em, load_proc=zero_load, & + workspace=work, probe_q=q1, probe_R=R, probe_K=K) + ELSE + CALL CD_Cable_Gen_Alpha_Step(qn, vn, an, conn, l0, ea, rho_a, .TRUE., 0.0_wp*qn, [1, 2, 3], 0.05_wp, cfg, & + qo, vo, ao, converged, stalled, n_iter, es, em, & + workspace=work, probe_q=q1, probe_R=R, probe_K=K) + END IF + IF (es /= CD_DYN_OK) THEN + WRITE (*, '(A)') 'MISMATCH [tangent:probe '//TRIM(em)//']' + nfail = nfail + 1 + R = 0.0_wp + K = 0.0_wp + END IF + END SUBROUTINE probe_step + + SUBROUTINE tangent_config(label, strain_n, strain_1, expect_cap, dirs_trial) + !! One configuration of the three-segment chain (node 1 fixed): segment strains at t_n and + !! at the trial state of the step, t_n at rest but for a small velocity and acceleration. + !! dirs_trial: the segment directions at the trial state (default: turned a few degrees). + CHARACTER(*), INTENT(IN) :: label + REAL(wp), INTENT(IN) :: strain_n(3), strain_1(3) + LOGICAL, INTENT(IN) :: expect_cap + REAL(wp), INTENT(IN), OPTIONAL :: dirs_trial(3, 3) + REAL(wp), PARAMETER :: L0(3) = [1.0_wp, 1.2_wp, 0.8_wp], EA(3) = [1.0e6_wp, 1.5e6_wp, 0.8e6_wp] + REAL(wp), PARAMETER :: DIRS_N(3, 3) = RESHAPE([1.0_wp, 0.2_wp, 0.1_wp, 0.3_wp, 1.0_wp, -0.2_wp, & + -0.2_wp, 0.4_wp, 1.0_wp], [3, 3]) + REAL(wp), PARAMETER :: DIRS_1(3, 3) = RESHAPE([1.0_wp, 0.27_wp, 0.04_wp, 0.36_wp, 1.0_wp, -0.12_wp, & + -0.12_wp, 0.46_wp, 1.0_wp], [3, 3]) + REAL(wp), PARAMETER :: H = 1.0e-6_wp, ALPHA_F = 0.4_wp/1.4_wp + INTEGER :: p, j, free(9), i + REAL(wp) :: qn(12), vn(12), an(12), q1(12), qp(12), rho_a(3), R(12), Rp(12), Rm(12), K(9, 9), Kfd(9, 9) + REAL(wp) :: Kdump(9, 9), f_cap(12), f_raw(12), scale, err + LOGICAL :: dense + free = [(i + 3, i=1, 9)] + CALL chain_nodes(DIRS_N, strain_n, L0, qn) + IF (PRESENT(dirs_trial)) THEN + CALL chain_nodes(dirs_trial, strain_1, L0, q1) + ELSE + CALL chain_nodes(DIRS_1, strain_1, L0, q1) + END IF + vn = 0.0_wp + an = 0.0_wp + DO i = 4, 12 + vn(i) = 0.01_wp*SIN(1.7_wp*REAL(i, wp)) + an(i) = 0.02_wp*COS(2.3_wp*REAL(i, wp)) + END DO + ! the closed-form blended force: the residual of a nearly massless chain is the force + rho_a = 1.0e-9_wp + CALL probe_step(qn, 0.0_wp*vn, 0.0_wp*an, q1, L0, EA, rho_a, .FALSE., R, Kdump) + CALL blended_force(qn, q1, L0, EA, ALPHA_F, .TRUE., f_cap) + CALL blended_force(qn, q1, L0, EA, ALPHA_F, .FALSE., f_raw) + scale = MAXVAL(ABS(f_raw)) + CALL require(MAXVAL(ABS(R(4:12) - f_cap(4:12))) < 1.0e-6_wp*scale, 'tangent:'//label//':residual-closed-form') + IF (expect_cap) THEN + CALL require(MAXVAL(ABS(f_cap - f_raw)) > 1.0e-2_wp*scale, 'tangent:'//label//':cap-active') + ELSE + CALL require(MAXVAL(ABS(f_cap - f_raw)) < 1.0e-12_wp*scale, 'tangent:'//label//':cap-inactive') + END IF + ! the tangent against the central difference of the residual, with inertia + rho_a = [2.0_wp, 3.0_wp, 1.5_wp] + DO p = 1, 2 + dense = p == 2 + CALL probe_step(qn, vn, an, q1, L0, EA, rho_a, dense, R, K) + DO j = 1, 9 + qp = q1 + qp(free(j)) = q1(free(j)) + H + CALL probe_step(qn, vn, an, qp, L0, EA, rho_a, dense, Rp, Kdump) + qp(free(j)) = q1(free(j)) - H + CALL probe_step(qn, vn, an, qp, L0, EA, rho_a, dense, Rm, Kdump) + Kfd(:, j) = (Rp(4:12) - Rm(4:12))/(2.0_wp*H) + END DO + scale = MAXVAL(ABS(K)) + err = MAXVAL(ABS(K - Kfd))/scale + WRITE (*, '(A,A,A,L1,A,ES9.2)') ' tangent ', label, ' dense=', dense, ': max |K - K_fd|/max|K| = ', err + CALL require(err < 1.0e-8_wp, 'tangent:'//label//TRIM(MERGE(':dense ', ':banded', dense))//':fd-tangent') + END DO + END SUBROUTINE tangent_config + + SUBROUTINE case_tangent_consistency() + ! segment 1 turned by 45 degrees from (1, 0.2, 0.1), the others as in DIRS_1 + REAL(wp), PARAMETER :: DIRS_TURN(3, 3) = RESHAPE([0.6_wp, 0.9_wp, 0.1_wp, 0.36_wp, 1.0_wp, -0.12_wp, & + -0.12_wp, 0.46_wp, 1.0_wp], [3, 3]) + ! (a) all segments taut at t_n and at the trial state: the cap is inactive + CALL tangent_config('taut-taut', [0.010_wp, 0.020_wp, 0.010_wp], [0.020_wp, 0.015_wp, 0.020_wp], .FALSE.) + ! (b) segment 1 taut at t_n and deeply slack at the trial state (release deeper than + ! 0.75 e_n, turned a few degrees): it carries the energy gradient W_n/p on its projected + ! shortening p instead of alpha_f T_n + CALL tangent_config('release-cap', [0.010_wp, 0.020_wp, 0.010_wp], [-0.050_wp, 0.015_wp, 0.020_wp], .TRUE.) + ! (c) segment 2 slack at both states + CALL tangent_config('slack-slack', [0.010_wp, -0.020_wp, 0.010_wp], [0.020_wp, -0.030_wp, 0.015_wp], .FALSE.) + ! (d) segment 1 turns by 45 degrees and ends 0.05 % slack, a quarter of its stretch e_n + ! below the rest length (the former cap on e_n - e_{n+1} left it uncapped), but shortens + ! by about 150 e_n along its step-start chord: capped at W_n/p + CALL tangent_config('turning-release', [0.002_wp, 0.020_wp, 0.010_wp], [-0.0005_wp, 0.015_wp, 0.020_wp], & + .TRUE., DIRS_TURN) + ! (e) the same turn ending taut at a tenth of its step-start tension: capped with the work + ! of the end share, (W_n + (1 - alpha_f) T_1 p_1)/p + CALL tangent_config('turning-taut-release', [0.002_wp, 0.020_wp, 0.010_wp], [0.0002_wp, 0.015_wp, 0.020_wp], & + .TRUE., DIRS_TURN) + ! (f) the same turn ending at 3/4 of its step-start tension: the force blend is kept + CALL tangent_config('turning-taut', [0.002_wp, 0.020_wp, 0.010_wp], [0.0015_wp, 0.015_wp, 0.020_wp], & + .FALSE., DIRS_TURN) + END SUBROUTINE case_tangent_consistency + + SUBROUTINE case_release_energy() + !! Energy of the force blend over one step of a segment that turns while it releases: the + !! end segment of the chain (l0 0.8 m, EA 0.8e6 N, stretch e_n = 0.8 mm, W_n = 0.32 J) turns + !! by theta about an axis normal to its chord and ends at the strain s1, slack or taut, the + !! rest of the chain held. The blended force on its free node returns the work + !! W = -f . (x_{n+1} - x_n) to the motion; the retained share alone (slack end) or with the + !! end share (taut end) must return at most W_n. Before the projected cap the 90 degree turn + !! of a segment that ends 0.1 % slack returned 160 J. + REAL(wp), PARAMETER :: L0(3) = [1.0_wp, 1.2_wp, 0.8_wp], EA(3) = [1.0e6_wp, 1.5e6_wp, 0.8e6_wp] + REAL(wp), PARAMETER :: DIRS(3, 3) = RESHAPE([1.0_wp, 0.2_wp, 0.1_wp, 0.3_wp, 1.0_wp, -0.2_wp, & + -0.2_wp, 0.4_wp, 1.0_wp], [3, 3]) + REAL(wp), PARAMETER :: THETA(8) = [0.0_wp, 2.0_wp, 5.0_wp, 20.0_wp, 45.0_wp, 90.0_wp, 135.0_wp, 180.0_wp] + REAL(wp), PARAMETER :: S1(11) = [-0.5_wp, -0.01_wp, -1.0e-3_wp, -1.0e-4_wp, -1.0e-12_wp, 1.0e-12_wp, & + 1.0e-4_wp, 2.0e-4_wp, 5.0e-4_wp, 1.0e-3_wp, 2.0e-3_wp] + REAL(wp) :: qn(12), q1(12), z(12), R(12), Rm(12), K(9, 9), tn(3), u(3), dir(3), w0, wk, wmax, ratio, jump + REAL(wp) :: f_raw(12), dev + INTEGER :: i, j + CALL chain_nodes(DIRS, [0.010_wp, 0.020_wp, 0.001_wp], L0, qn) + z = 0.0_wp + tn = (qn(10:12) - qn(7:9))/NORM2(qn(10:12) - qn(7:9)) + u = [tn(2), -tn(1), 0.0_wp] + u = u/NORM2(u) + w0 = 0.5_wp*(EA(3)*0.001_wp)*(L0(3)*0.001_wp) + wmax = -HUGE(1.0_wp) + DO i = 1, SIZE(THETA) + DO j = 1, SIZE(S1) + dir = COS(THETA(i)*PI/180.0_wp)*tn + SIN(THETA(i)*PI/180.0_wp)*u + q1 = qn + q1(10:12) = qn(7:9) + L0(3)*(1.0_wp + S1(j))*dir + ! a nearly massless chain at rest at t_n: the residual is the blended force + CALL probe_step(qn, z, z, q1, L0, EA, [1.0e-12_wp, 1.0e-12_wp, 1.0e-12_wp], .FALSE., R, K) + wk = -DOT_PRODUCT(R(10:12), q1(10:12) - qn(10:12)) + wmax = MAX(wmax, wk/w0) + IF (THETA(i) == 0.0_wp .AND. S1(j) > 0.0_wp) THEN + ! a segment that keeps its direction and ends taut keeps the plain force blend + CALL blended_force(qn, q1, L0, EA, 0.4_wp/1.4_wp, .FALSE., f_raw) + dev = MAXVAL(ABS(R(10:12) - f_raw(10:12))) + CALL require(dev < 1.0e-9_wp*EA(3)*0.001_wp, 'release-energy:taut-end-uncapped') + END IF + IF (.NOT. wk <= w0*(1.0_wp + 1.0e-9_wp)) THEN + WRITE (*, '(A,F6.1,A,ES10.2,A,ES10.3,A,ES10.3,A)') ' release energy: theta ', THETA(i), ' s1 ', S1(j), & + ': returned ', wk, ' J, W_n ', w0, ' J' + CALL require(.FALSE., 'release-energy:bounded') + END IF + END DO + END DO + WRITE (*, '(A,ES10.3)') ' release energy: largest returned work / W_n over the turns = ', wmax + ! the retained force is continuous where the end state crosses the rest length (turned 45 deg) + dir = COS(PI/4.0_wp)*tn + SIN(PI/4.0_wp)*u + q1 = qn + q1(10:12) = qn(7:9) + L0(3)*(1.0_wp + 1.0e-12_wp)*dir + CALL probe_step(qn, z, z, q1, L0, EA, [1.0e-12_wp, 1.0e-12_wp, 1.0e-12_wp], .FALSE., R, K) + q1(10:12) = qn(7:9) + L0(3)*(1.0_wp - 1.0e-12_wp)*dir + CALL probe_step(qn, z, z, q1, L0, EA, [1.0e-12_wp, 1.0e-12_wp, 1.0e-12_wp], .FALSE., Rm, K) + jump = MAXVAL(ABS(R(10:12) - Rm(10:12))) + ratio = jump/(EA(3)*0.001_wp) + WRITE (*, '(A,ES10.3)') ' release energy: force jump across the rest length / T_n = ', ratio + CALL require(ratio < 1.0e-6_wp, 'release-energy:continuous-at-rest-length') + END SUBROUTINE case_release_energy + + SUBROUTINE case_light_cable_coarse_step() + LOGICAL :: conv + INTEGER :: es + CHARACTER(512) :: em + REAL(wp) :: fair, anch + CALL light_cable_deck('ei0slack_coarse.dat', 0.1_wp, 40.0_wp, '', '-') + CALL CD_Run_Deck_Driver('ei0slack_coarse.dat', 'ei0slack_coarse', conv, es, em) + CALL require(es == CD_DECKDRV_OK .AND. conv, 'coarse:run '//TRIM(em)) + fair = column_max('ei0slack_coarse.out', 2, 2) + anch = column_max('ei0slack_coarse.out', 3, 3) + WRITE (*, '(A,ES10.3,A,ES10.3,A)') ' light cable, dtM 0.1 s: FairTen1 max ', fair, ' N, AnchTen1 max ', anch, ' N' + CALL require(fair > 5.0e4_wp .AND. fair < 2.0e5_wp, 'coarse:fairlead-peak') + CALL require(anch > 2.0e4_wp .AND. anch < 2.0e5_wp, 'coarse:anchor-peak') + END SUBROUTINE case_light_cable_coarse_step + + SUBROUTINE case_light_cable_release_cap() + LOGICAL :: conv + INTEGER :: es + CHARACTER(512) :: em + REAL(wp) :: seg + CALL light_cable_deck('ei0slack_release.dat', 0.01_wp, 24.0_wp, '', 't') + CALL CD_Run_Deck_Driver('ei0slack_release.dat', 'ei0slack_release', conv, es, em) + CALL require(es == CD_DECKDRV_OK .AND. conv, 'release:run '//TRIM(em)) + seg = column_max('ei0slack_release.Line1.t.out', 2, 0) + WRITE (*, '(A,ES10.3,A)') ' light cable, dtM 0.01 s: largest segment tension ', seg, ' N' + CALL require(seg > 5.0e4_wp .AND. seg < 2.0e5_wp, 'release:segment-peak') + END SUBROUTINE case_light_cable_release_cap + + SUBROUTINE case_viscoelastic_surge() + LOGICAL :: conv + INTEGER :: es + CHARACTER(512) :: em + CHARACTER(64) :: opts(4) + REAL(wp) :: fair + CALL write_motion('ei0slack_surge.txt', 1, [58.0_wp, 0.0_wp, -14.0_wp], 1, 15.0_wp, 12.0_wp, 12.0_wp, & + 0.1_wp, 48.0_wp) + opts(1) = '0.1 dtM' + opts(2) = '48.0 TMax' + opts(3) = 'ei0slack_surge.txt motionFile' + opts(4) = '3.0e6 kBot' + CALL write_deck('ei0slack_ve.dat', POLY_VE, [700.0_wp, 0.0_wp, -200.0_wp], [58.0_wp, 0.0_wp, -14.0_wp], & + 690.0_wp, 50, 200.0_wp, '-', opts) + CALL CD_Run_Deck_Driver('ei0slack_ve.dat', 'ei0slack_ve', conv, es, em) + CALL require(es == CD_DECKDRV_OK .AND. conv, 've:run '//TRIM(em)) + fair = column_max('ei0slack_ve.out', 2, 2) + WRITE (*, '(A,ES10.3,A)') ' viscoelastic polyester, 15 m surge, dtM 0.1 s: FairTen1 max ', fair, ' N' + CALL require(fair > 1.6e6_wp .AND. fair < 1.9e6_wp, 've:fairlead-peak') + END SUBROUTINE case_viscoelastic_surge + + SUBROUTINE case_run_audit() + LOGICAL :: ok + CHARACTER(64) :: opts(4) + ! the configuration blend of case 1: its spikes are reported once, as a warning. Its + ! non-physical spikes make the run chaotic: whether it completes or a later spike stops it + ! fail-closed depends on round-off (it did both on Linux CI runners of the same commit), so + ! only the warning, written at the first spike, is required of it + CALL light_cable_deck('ei0slack_audit_cfg.dat', 0.1_wp, 40.0_wp, 'False alpha_force_blend', '-') + CALL run_driver_logged('ei0slack_audit_cfg.dat', 'ei0slack_audit_cfg', 'ei0slack_audit_cfg.log', ok) + IF (.NOT. ok) CALL echo_tail('ei0slack_audit_cfg.log', 6) + CALL require(file_contains('ei0slack_audit_cfg.log', 'Warning: line 1: segment '), & + 'audit:configuration-blend-spike-warned') + CALL require(file_contains('ei0slack_audit_cfg.log', 'for a single step'), 'audit:spike-message') + ! the default force blend: no spike warning + CALL light_cable_deck('ei0slack_audit_fb.dat', 0.1_wp, 40.0_wp, '', '-') + CALL run_driver_logged('ei0slack_audit_fb.dat', 'ei0slack_audit_fb', 'ei0slack_audit_fb.log', ok) + IF (.NOT. ok) CALL echo_tail('ei0slack_audit_fb.log', 6) + CALL require(ok, 'audit:force-blend-run') + CALL require(.NOT. file_contains('ei0slack_audit_fb.log', 'Warning: line'), 'audit:force-blend-no-warning') + ! snaps of the light cable (axial wave crossing a segment ~160 times per step) are noted. The + ! 3 m heave above snaps only just past the initial tension, so whether a coarse step counts a + ! snap there depends on round-off; a 6 m heave at 8 s snaps the line well past it + CALL write_motion('ei0slack_snap.txt', 1, [5.0_wp, 0.0_wp, -14.0_wp], 3, 6.0_wp, 8.0_wp, 8.0_wp, & + 0.1_wp, 40.0_wp) + opts(1) = '0.1 dtM' + opts(2) = '40.0 TMax' + opts(3) = 'ei0slack_snap.txt motionFile' + opts(4) = '' + CALL write_deck('ei0slack_audit_snap.dat', CABLE, [205.0_wp, 0.0_wp, -80.0_wp], [5.0_wp, 0.0_wp, -14.0_wp], & + 230.0_wp, 115, 80.0_wp, '-', opts) + CALL run_driver_logged('ei0slack_audit_snap.dat', 'ei0slack_audit_snap', 'ei0slack_audit_snap.log', ok) + IF (.NOT. ok) CALL echo_tail('ei0slack_audit_snap.log', 6) + CALL require(ok, 'audit:snap-run') + CALL require(file_contains('ei0slack_audit_snap.log', 'went from slack to taut above the initial tension'), & + 'audit:snap-note') + CALL require(file_contains('ei0slack_audit_snap.log', 'snap-load peaks are not resolved in time'), & + 'audit:snap-note-text') + CALL require(.NOT. file_contains('ei0slack_audit_fb.log', 'Note: rhoInf'), 'audit:default-rhoinf-no-note') + ! rhoInf above 0.95 + CALL light_cable_deck('ei0slack_audit_rho.dat', 0.1_wp, 12.0_wp, '0.99 rhoInf', '-') + CALL run_driver_logged('ei0slack_audit_rho.dat', 'ei0slack_audit_rho', 'ei0slack_audit_rho.log', ok) + CALL require(ok, 'audit:rhoinf-run') + CALL require(file_contains('ei0slack_audit_rho.log', 'Note: rhoInf = 0.990 leaves almost no numerical'), & + 'audit:rhoinf-note') + ! a 10 m sway at dtM 0.2 s turns the segments by several degrees per step + CALL write_motion('ei0slack_sway.txt', 1, [5.0_wp, 0.0_wp, -14.0_wp], 2, 10.0_wp, 10.0_wp, 10.0_wp, & + 0.2_wp, 20.0_wp) + opts(1) = '0.2 dtM' + opts(2) = '20.0 TMax' + opts(3) = 'ei0slack_sway.txt motionFile' + opts(4) = '' + CALL write_deck('ei0slack_audit_sway.dat', CABLE, [205.0_wp, 0.0_wp, -80.0_wp], [5.0_wp, 0.0_wp, -14.0_wp], & + 230.0_wp, 115, 80.0_wp, '-', opts) + CALL run_driver_logged('ei0slack_audit_sway.dat', 'ei0slack_audit_sway', 'ei0slack_audit_sway.log', ok) + CALL require(ok, 'audit:sway-run') + CALL require(file_contains('ei0slack_audit_sway.log', 'Note: line 1: a taut segment turned up to'), & + 'audit:segment-turn-note') + CALL require(.NOT. file_contains('ei0slack_audit_sway.log', 'Warning: line'), 'audit:sway-no-warning') + END SUBROUTINE case_run_audit + + ! ------------------------------------------------------------------------------------------ + ! Chain cases 6 to 8: a load callback with drag, a position load and a segment law + ! ------------------------------------------------------------------------------------------ + + FUNCTION outer3(x, y) RESULT(m) + REAL(wp), INTENT(IN) :: x(3), y(3) + REAL(wp) :: m(3, 3) + INTEGER :: i + DO i = 1, 3 + m(:, i) = x*y(i) + END DO + END FUNCTION outer3 + + SUBROUTINE chain_load(q, v, force, jac_q, jac_v) + !! The chain load (see cb_drag) and its residual Jacobians -d(force)/dq, -d(force)/dv. + REAL(wp), INTENT(IN) :: q(:), v(:) + REAL(wp), INTENT(OUT) :: force(:), jac_q(:, :), jac_v(:, :) + INTEGER :: n, i, a, b + REAL(wp) :: d(3), w(3), dd, sp, c(3), ell, t(3), ten, kb(3, 3), eye(3, 3), kv(3, 3) + force = 0.0_wp + jac_q = 0.0_wp + jac_v = 0.0_wp + eye = 0.0_wp + DO i = 1, 3 + eye(i, i) = 1.0_wp + END DO + DO n = 1, SIZE(q)/3 + d = q(3*n - 2:3*n) - cb_q0(3*n - 2:3*n) + w = v(3*n - 2:3*n) + dd = DOT_PRODUCT(d, d) + sp = NORM2(w) + force(3*n - 2:3*n) = -cb_drag*sp*w - cb_spring*dd*d + jac_q(3*n - 2:3*n, 3*n - 2:3*n) = cb_spring*(dd*eye + 2.0_wp*outer3(d, d)) + IF (sp > 0.0_wp) jac_v(3*n - 2:3*n, 3*n - 2:3*n) = cb_drag*(sp*eye + outer3(w, w)/sp) + END DO + IF (cb_law_elem > 0) THEN + ! the tension-only segment law: force T t on node a, -T t on node b + a = cb_law_elem + b = a + 1 + c = q(3*b - 2:3*b) - q(3*a - 2:3*a) + ell = NORM2(c) + t = c/ell + w = v(3*b - 2:3*b) - v(3*a - 2:3*a) + ten = cb_ea_law*(ell/cb_l0_law - 1.0_wp) + cb_ba_law*DOT_PRODUCT(t, w)/cb_l0_law + IF (ten > 0.0_wp) THEN + force(3*a - 2:3*a) = force(3*a - 2:3*a) + ten*t + force(3*b - 2:3*b) = force(3*b - 2:3*b) - ten*t + ! kb = d(force_a)/d(q_b), kv = d(force_a)/d(v_b) + kb = (cb_ea_law/cb_l0_law)*outer3(t, t) + ten*(eye - outer3(t, t))/ell + & + (cb_ba_law/cb_l0_law)*outer3(t, MATMUL(eye - outer3(t, t), w)/ell) + kv = (cb_ba_law/cb_l0_law)*outer3(t, t) + jac_q(3*a - 2:3*a, 3*a - 2:3*a) = jac_q(3*a - 2:3*a, 3*a - 2:3*a) + kb + jac_q(3*a - 2:3*a, 3*b - 2:3*b) = jac_q(3*a - 2:3*a, 3*b - 2:3*b) - kb + jac_q(3*b - 2:3*b, 3*a - 2:3*a) = jac_q(3*b - 2:3*b, 3*a - 2:3*a) - kb + jac_q(3*b - 2:3*b, 3*b - 2:3*b) = jac_q(3*b - 2:3*b, 3*b - 2:3*b) + kb + jac_v(3*a - 2:3*a, 3*a - 2:3*a) = jac_v(3*a - 2:3*a, 3*a - 2:3*a) + kv + jac_v(3*a - 2:3*a, 3*b - 2:3*b) = jac_v(3*a - 2:3*a, 3*b - 2:3*b) - kv + jac_v(3*b - 2:3*b, 3*a - 2:3*a) = jac_v(3*b - 2:3*b, 3*a - 2:3*a) - kv + jac_v(3*b - 2:3*b, 3*b - 2:3*b) = jac_v(3*b - 2:3*b, 3*b - 2:3*b) + kv + END IF + END IF + IF (cb_dash_elem > 0) THEN + ! the dashpot: force (BA/l0) (t . w) t on node a, the opposite on node b, in both senses + a = cb_dash_elem + b = a + 1 + c = q(3*b - 2:3*b) - q(3*a - 2:3*a) + ell = NORM2(c) + t = c/ell + w = v(3*b - 2:3*b) - v(3*a - 2:3*a) + ten = cb_ba_dash*DOT_PRODUCT(t, w)/cb_l0_dash + force(3*a - 2:3*a) = force(3*a - 2:3*a) + ten*t + force(3*b - 2:3*b) = force(3*b - 2:3*b) - ten*t + kb = ten*(eye - outer3(t, t))/ell + (cb_ba_dash/cb_l0_dash)*outer3(t, MATMUL(eye - outer3(t, t), w)/ell) + kv = (cb_ba_dash/cb_l0_dash)*outer3(t, t) + jac_q(3*a - 2:3*a, 3*a - 2:3*a) = jac_q(3*a - 2:3*a, 3*a - 2:3*a) + kb + jac_q(3*a - 2:3*a, 3*b - 2:3*b) = jac_q(3*a - 2:3*a, 3*b - 2:3*b) - kb + jac_q(3*b - 2:3*b, 3*a - 2:3*a) = jac_q(3*b - 2:3*b, 3*a - 2:3*a) - kb + jac_q(3*b - 2:3*b, 3*b - 2:3*b) = jac_q(3*b - 2:3*b, 3*b - 2:3*b) + kb + jac_v(3*a - 2:3*a, 3*a - 2:3*a) = jac_v(3*a - 2:3*a, 3*a - 2:3*a) + kv + jac_v(3*a - 2:3*a, 3*b - 2:3*b) = jac_v(3*a - 2:3*a, 3*b - 2:3*b) - kv + jac_v(3*b - 2:3*b, 3*a - 2:3*a) = jac_v(3*b - 2:3*b, 3*a - 2:3*a) - kv + jac_v(3*b - 2:3*b, 3*b - 2:3*b) = jac_v(3*b - 2:3*b, 3*b - 2:3*b) + kv + END IF + END SUBROUTINE chain_load + + SUBROUTINE cb_load(q, v, force, jac_q, jac_v, ErrStat, ErrMsg) + REAL(wp), INTENT(IN) :: q(:), v(:) + REAL(wp), INTENT(OUT) :: force(:), jac_q(:, :), jac_v(:, :) + INTEGER, INTENT(OUT) :: ErrStat + CHARACTER(*), INTENT(OUT) :: ErrMsg + CALL chain_load(q, v, force, jac_q, jac_v) + ErrStat = 0 + ErrMsg = '' + END SUBROUTINE cb_load + + SUBROUTINE cb_force(q, v, force, ErrStat, ErrMsg) + REAL(wp), INTENT(IN) :: q(:), v(:) + REAL(wp), INTENT(OUT) :: force(:) + INTEGER, INTENT(OUT) :: ErrStat + CHARACTER(*), INTENT(OUT) :: ErrMsg + REAL(wp) :: jq(SIZE(q), SIZE(q)), jv(SIZE(q), SIZE(q)) + CALL chain_load(q, v, force, jq, jv) + ErrStat = 0 + ErrMsg = '' + END SUBROUTINE cb_force + + SUBROUTINE cb_load_band(q, v, free, kl, ku, force, jac_q_band, jac_v_band, ErrStat, ErrMsg) + !! The chain load with its Jacobians in the reduced free/free band storage of the step. + REAL(wp), INTENT(IN) :: q(:), v(:) + INTEGER, INTENT(IN) :: free(:), kl, ku + REAL(wp), INTENT(OUT) :: force(:), jac_q_band(:, :), jac_v_band(:, :) + INTEGER, INTENT(OUT) :: ErrStat + CHARACTER(*), INTENT(OUT) :: ErrMsg + REAL(wp) :: jq(SIZE(q), SIZE(q)), jv(SIZE(q), SIZE(q)) + INTEGER :: i, j + CALL chain_load(q, v, force, jq, jv) + jac_q_band = 0.0_wp + jac_v_band = 0.0_wp + DO j = 1, SIZE(free) + DO i = 1, SIZE(free) + IF (i - j > kl .OR. j - i > ku) CYCLE + jac_q_band(kl + ku + 1 + i - j, j) = jq(free(i), free(j)) + jac_v_band(kl + ku + 1 + i - j, j) = jv(free(i), free(j)) + END DO + END DO + ErrStat = 0 + ErrMsg = '' + END SUBROUTINE cb_load_band + + SUBROUTINE cb_added_mass(q, accel, M_add, dMa_a_dq, ErrStat, ErrMsg) + !! Position-dependent nodal added mass cb_madd (1 + 0.3 z^2) and d(M_add a)/dq. + REAL(wp), INTENT(IN) :: q(:), accel(:) + REAL(wp), INTENT(OUT) :: M_add(:, :), dMa_a_dq(:, :) + INTEGER, INTENT(OUT) :: ErrStat + CHARACTER(*), INTENT(OUT) :: ErrMsg + INTEGER :: n, i + M_add = 0.0_wp + dMa_a_dq = 0.0_wp + DO n = 1, SIZE(q)/3 + DO i = 3*n - 2, 3*n + M_add(i, i) = cb_madd*(1.0_wp + 0.3_wp*q(3*n)**2) + dMa_a_dq(i, 3*n) = cb_madd*0.6_wp*q(3*n)*accel(i) + END DO + END DO + ErrStat = 0 + ErrMsg = '' + END SUBROUTINE cb_added_mass + + SUBROUTINE probe_chain(qn, vn, an, q1, l0, ea, rho_a, banded, R, K, start_tension, start_stiffness, & + axial_damping) + !! Residual and effective tangent at q1 of the force-blended step of the chain with the + !! callback load: banded (load_band_proc + load_force_proc) or dense (load_proc, with the + !! added mass when cb_madd > 0). + REAL(wp), INTENT(IN) :: qn(12), vn(12), an(12), q1(12), l0(3), ea(3), rho_a(3) + LOGICAL, INTENT(IN) :: banded + REAL(wp), INTENT(OUT) :: R(12), K(9, 9) + REAL(wp), INTENT(IN), OPTIONAL :: start_tension(:), start_stiffness(:), axial_damping(:) + INTEGER :: conn(2, 3), n_iter, es + REAL(wp) :: qo(12), vo(12), ao(12) + LOGICAL :: converged, stalled + TYPE(GenAlphaConfig) :: cfg + TYPE(CD_CableGenAlphaWorkspace) :: work + CHARACTER(120) :: em + conn = RESHAPE([1, 2, 2, 3, 3, 4], [2, 3]) + cfg%rho_inf = 0.4_wp + IF (banded) THEN + CALL CD_Cable_Gen_Alpha_Step(qn, vn, an, conn, l0, ea, rho_a, .TRUE., 0.0_wp*qn, [1, 2, 3], 0.05_wp, cfg, & + qo, vo, ao, converged, stalled, n_iter, es, em, load_band_proc=cb_load_band, & + load_force_proc=cb_force, workspace=work, start_tension=start_tension, & + start_stiffness=start_stiffness, axial_damping=axial_damping, & + probe_q=q1, probe_R=R, probe_K=K) + ELSE IF (cb_madd > 0.0_wp) THEN + CALL CD_Cable_Gen_Alpha_Step(qn, vn, an, conn, l0, ea, rho_a, .TRUE., 0.0_wp*qn, [1, 2, 3], 0.05_wp, cfg, & + qo, vo, ao, converged, stalled, n_iter, es, em, load_proc=cb_load, & + added_mass_proc=cb_added_mass, workspace=work, start_tension=start_tension, & + start_stiffness=start_stiffness, axial_damping=axial_damping, & + probe_q=q1, probe_R=R, probe_K=K) + ELSE + CALL CD_Cable_Gen_Alpha_Step(qn, vn, an, conn, l0, ea, rho_a, .TRUE., 0.0_wp*qn, [1, 2, 3], 0.05_wp, cfg, & + qo, vo, ao, converged, stalled, n_iter, es, em, load_proc=cb_load, & + workspace=work, start_tension=start_tension, & + start_stiffness=start_stiffness, axial_damping=axial_damping, & + probe_q=q1, probe_R=R, probe_K=K) + END IF + IF (es /= CD_DYN_OK) THEN + WRITE (*, '(A)') 'MISMATCH [chain:probe '//TRIM(em)//']' + nfail = nfail + 1 + R = 0.0_wp + K = 0.0_wp + END IF + END SUBROUTINE probe_chain + + SUBROUTINE fd_tangent_check(label, qn, vn, an, q1, l0, ea, rho_a, banded, start_tension, start_stiffness, & + axial_damping) + !! The step's tangent against the central difference of its residual. + CHARACTER(*), INTENT(IN) :: label + REAL(wp), INTENT(IN) :: qn(12), vn(12), an(12), q1(12), l0(3), ea(3), rho_a(3) + LOGICAL, INTENT(IN) :: banded + REAL(wp), INTENT(IN), OPTIONAL :: start_tension(:), start_stiffness(:), axial_damping(:) + REAL(wp), PARAMETER :: H = 1.0e-6_wp + INTEGER :: j + REAL(wp) :: qp(12), R(12), Rp(12), Rm(12), K(9, 9), Kfd(9, 9), Kdump(9, 9), err + CALL probe_chain(qn, vn, an, q1, l0, ea, rho_a, banded, R, K, start_tension, start_stiffness, axial_damping) + DO j = 1, 9 + qp = q1 + qp(3 + j) = q1(3 + j) + H + CALL probe_chain(qn, vn, an, qp, l0, ea, rho_a, banded, Rp, Kdump, start_tension, start_stiffness, & + axial_damping) + qp(3 + j) = q1(3 + j) - H + CALL probe_chain(qn, vn, an, qp, l0, ea, rho_a, banded, Rm, Kdump, start_tension, start_stiffness, & + axial_damping) + Kfd(:, j) = (Rp(4:12) - Rm(4:12))/(2.0_wp*H) + END DO + err = MAXVAL(ABS(K - Kfd))/MAXVAL(ABS(K)) + WRITE (*, '(A,A,A,L1,A,ES9.2)') ' tangent ', label, ' banded=', banded, ': max |K - K_fd|/max|K| = ', err + CALL require(err < 1.0e-8_wp, label//TRIM(MERGE(':banded', ':dense ', banded))//':fd-tangent') + END SUBROUTINE fd_tangent_check + + SUBROUTINE chain_states(strain_n, strain_1, l0, qn, vn, an, q1, dirs_trial) + !! The chain of case 5 at t_n and at the trial state, with a small velocity and + !! acceleration at t_n (dirs_trial: the segment directions at the trial state). + REAL(wp), INTENT(IN) :: strain_n(3), strain_1(3), l0(3) + REAL(wp), INTENT(OUT) :: qn(12), vn(12), an(12), q1(12) + REAL(wp), INTENT(IN), OPTIONAL :: dirs_trial(3, 3) + REAL(wp), PARAMETER :: DIRS_N(3, 3) = RESHAPE([1.0_wp, 0.2_wp, 0.1_wp, 0.3_wp, 1.0_wp, -0.2_wp, & + -0.2_wp, 0.4_wp, 1.0_wp], [3, 3]) + REAL(wp), PARAMETER :: DIRS_1(3, 3) = RESHAPE([1.0_wp, 0.27_wp, 0.04_wp, 0.36_wp, 1.0_wp, -0.12_wp, & + -0.12_wp, 0.46_wp, 1.0_wp], [3, 3]) + INTEGER :: i + CALL chain_nodes(DIRS_N, strain_n, l0, qn) + IF (PRESENT(dirs_trial)) THEN + CALL chain_nodes(dirs_trial, strain_1, l0, q1) + ELSE + CALL chain_nodes(DIRS_1, strain_1, l0, q1) + END IF + vn = 0.0_wp + an = 0.0_wp + DO i = 4, 12 + vn(i) = 0.01_wp*SIN(1.7_wp*REAL(i, wp)) + an(i) = 0.02_wp*COS(2.3_wp*REAL(i, wp)) + END DO + END SUBROUTINE chain_states + + SUBROUTINE reset_chain_load() + cb_drag = 0.0_wp + cb_spring = 0.0_wp + cb_ea_law = 0.0_wp + cb_l0_law = 1.0_wp + cb_madd = 0.0_wp + cb_q0 = 0.0_wp + cb_law_elem = 0 + cb_ba_law = 0.0_wp + cb_ba_dash = 0.0_wp + cb_l0_dash = 1.0_wp + cb_dash_elem = 0 + END SUBROUTINE reset_chain_load + + SUBROUTINE case_law_release_cap() + !! Segment 3 carries a tension-only law through the load callback (ea(3) = 0) and + !! releases within the step: deeply, turning by about 50 degrees as it goes slack, and + !! turning as it ends taut at a tenth of its step-start tension. + REAL(wp), PARAMETER :: DIRS_TURN(3, 3) = RESHAPE([1.0_wp, 0.27_wp, 0.04_wp, 0.36_wp, 1.0_wp, -0.12_wp, & + 0.6_wp, 0.4_wp, 0.6_wp], [3, 3]) + CALL law_cap_config('law-cap', [0.010_wp, 0.020_wp, 0.010_wp], [0.020_wp, 0.015_wp, -0.050_wp]) + CALL law_cap_config('law-cap-turning', [0.010_wp, 0.020_wp, 0.002_wp], [0.020_wp, 0.015_wp, -0.0005_wp], & + DIRS_TURN) + CALL law_cap_config('law-cap-turning-taut', [0.010_wp, 0.020_wp, 0.002_wp], [0.020_wp, 0.015_wp, 0.0002_wp], & + DIRS_TURN) + END SUBROUTINE case_law_release_cap + + SUBROUTINE case_law_damped_release() + !! A law segment whose step-start tension is almost all damping: segment 3 (law EA 0.8e6 N, + !! BA 2e5 N s) stretched by e_n = 0.8 um and lengthening at 0.05 m/s carries T_n = 1.25e4 N, + !! a secant T_n/e_n = 1.6e10 N/m against its axial stiffness k_n = EA/l0 = 1e6 N/m. It turns + !! by 45 degrees and ends at a stretch e_{n+1} from -0.1 to 1.9 mm. With start_stiffness the + !! cap's force varies with e_{n+1} at a slope of order k_n; with the unbounded secant it + !! switches over a band of width ~e_n, a jump at this resolution. The blend returns at most + !! W_n + (1 - alpha_f)(T^_{n+1} - T_{n+1}) p_{n+1} (T^ the estimate k e_{n+1}, T_{n+1} the + !! law's end tension), and the tangent matches the finite difference where the cap acts. + REAL(wp), PARAMETER :: L0(3) = [1.0_wp, 1.2_wp, 0.8_wp], EA(3) = [1.0e6_wp, 1.5e6_wp, 0.0_wp] + REAL(wp), PARAMETER :: DIRS(3, 3) = RESHAPE([1.0_wp, 0.2_wp, 0.1_wp, 0.3_wp, 1.0_wp, -0.2_wp, & + -0.2_wp, 0.4_wp, 1.0_wp], [3, 3]) + REAL(wp), PARAMETER :: EA_LAW = 0.8e6_wp, BA_LAW = 2.0e5_wp, ALPHA_F = 0.4_wp/1.4_wp + REAL(wp), PARAMETER :: RHO_TINY(3) = [1.0e-12_wp, 1.0e-12_wp, 1.0e-12_wp] + INTEGER, PARAMETER :: NG = 201 + REAL(wp) :: qn(12), vn(12), an(12), q1(12), sl(12), jq(12, 12), jv(12, 12), tn(3), u(3), dir(3) + REAL(wp) :: Rk(12), Ru(12), Rp(12), K(9, 9), ck(3, NG), cu(3, NG), e1(NG), t0, e0, w0, kn, kc, de + REAL(wp) :: d0(3), d1(3), l1, t1(3), p1, ten1, that, wk, bound, slope_k, slope_u, worst + INTEGER :: i, nact + CALL reset_chain_load() + cb_law_elem = 3 + cb_ea_law = EA_LAW + cb_l0_law = L0(3) + cb_ba_law = BA_LAW + CALL chain_nodes(DIRS, [0.010_wp, 0.020_wp, 1.0e-6_wp], L0, qn) + d0 = qn(10:12) - qn(7:9) + tn = d0/NORM2(d0) + u = [tn(2), -tn(1), 0.0_wp] + u = u/NORM2(u) + vn = 0.0_wp + vn(10:12) = 0.05_wp*tn + an = 0.0_wp + CALL chain_load(qn, vn, sl, jq, jv) + t0 = DOT_PRODUCT(sl(7:9), tn) + e0 = NORM2(d0) - L0(3) + w0 = 0.5_wp*t0*e0 + kn = EA_LAW/L0(3) + kc = MIN(t0/e0, kn) + CALL require(t0 > 1.2e4_wp .AND. t0/e0 > 1.0e4_wp*kn, 'law-damped:damping-dominated-start') + dir = COS(PI/4.0_wp)*tn + SIN(PI/4.0_wp)*u + de = 2.0e-3_wp/REAL(NG - 1, wp) + nact = 0 + worst = -HUGE(1.0_wp) + DO i = 1, NG + e1(i) = -1.0e-4_wp + REAL(i - 1, wp)*de + q1 = qn + q1(10:12) = qn(7:9) + (L0(3) + e1(i))*dir + CALL probe_chain(qn, vn, an, q1, L0, EA, RHO_TINY, .TRUE., Rk, K, start_tension=[0.0_wp, 0.0_wp, t0], & + start_stiffness=[0.0_wp, 0.0_wp, kn]) + CALL probe_chain(qn, vn, an, q1, L0, EA, RHO_TINY, .TRUE., Ru, K, start_tension=[0.0_wp, 0.0_wp, t0]) + CALL probe_chain(qn, vn, an, q1, L0, EA, RHO_TINY, .TRUE., Rp, K) + ck(:, i) = Rk(10:12) - Rp(10:12) + cu(:, i) = Ru(10:12) - Rp(10:12) + IF (NORM2(ck(:, i)) > 1.0e-6_wp*t0) nact = nact + 1 + ! the law's end tension from the plain blend at the free node: (1 - alpha_f) T_1 t_1 + + ! alpha_f T_n t_n (the step-start law force), inertia negligible + d1 = q1(10:12) - q1(7:9) + l1 = NORM2(d1) + t1 = d1/l1 + ten1 = (DOT_PRODUCT(Rp(10:12), t1) - ALPHA_F*t0*DOT_PRODUCT(tn, t1))/(1.0_wp - ALPHA_F) + p1 = l1 - DOT_PRODUCT(t1, d0) + that = kc*MAX(e1(i), 0.0_wp) + wk = -DOT_PRODUCT(Rk(10:12), q1(10:12) - qn(10:12)) + bound = w0 + (1.0_wp - ALPHA_F)*(that - ten1)*p1 + worst = MAX(worst, wk - bound) + END DO + slope_k = 0.0_wp + slope_u = 0.0_wp + DO i = 1, NG - 1 + slope_k = MAX(slope_k, NORM2(ck(:, i + 1) - ck(:, i))/de) + slope_u = MAX(slope_u, NORM2(cu(:, i + 1) - cu(:, i))/de) + END DO + WRITE (*, '(A,I0,A,ES10.3,A,ES10.3,A,ES10.3,A)') ' law damped release: cap active at ', nact, & + ' stretches; largest slope of the cap force ', slope_k/kn, ' k_n (unbounded secant ', slope_u/kn, & + ' k_n); work above the bound ', worst, ' J' + CALL require(nact > NG/2, 'law-damped:cap-active') + CALL require(slope_k < 3.0_wp*kn, 'law-damped:bounded-slope') + CALL require(slope_u > 100.0_wp*kn, 'law-damped:unbounded-secant-jumps') + CALL require(worst <= 1.0e-6_wp, 'law-damped:energy-bound') + ! the tangent where the cap acts on a taut end state with the bounded secant (e_{n+1} = 0.8 mm) + q1 = qn + q1(10:12) = qn(7:9) + (L0(3) + 8.0e-4_wp)*dir + CALL fd_tangent_check('law-damped', qn, vn, an, q1, L0, EA, [2.0_wp, 3.0_wp, 1.5_wp], .TRUE., & + start_tension=[0.0_wp, 0.0_wp, t0], start_stiffness=[0.0_wp, 0.0_wp, kn]) + CALL fd_tangent_check('law-damped', qn, vn, an, q1, L0, EA, [2.0_wp, 3.0_wp, 1.5_wp], .FALSE., & + start_tension=[0.0_wp, 0.0_wp, t0], start_stiffness=[0.0_wp, 0.0_wp, kn]) + CALL reset_chain_load() + END SUBROUTINE case_law_damped_release + + SUBROUTINE case_damped_elastic_release() + !! An elastic segment with a two-sided axial dashpot (BA 2e4 N s on the end segment, l0 0.8 m, + !! EA 0.8e6 N, e_n = 0.8 mm, W_n = 0.32 J) that extends at t_n at 0.05, 0.5 or 2 m/s + !! (dashpot tension 1.6 to 62 times the elastic one) and turns by 0 to 180 degrees within + !! the step, ending slack or taut. Its kept dashpot share alone returned up to 7e4 W_n and + !! the whole blend up to 2.8e3 W_n before the cap covered it. With axial_damping the blend + !! returns at most W_n + (1 - phi) D (D the uncapped blended dashpot's work, phi the dashpot + !! weight: 1 at and below l0, 0 above l0 + c e_n), more only by the end share's own excess + !! when N < 0; at and below l0 that is W_n. A segment that keeps its direction and ends taut + !! keeps the plain force blend, and the tangent matches the finite difference. + REAL(wp), PARAMETER :: L0(3) = [1.0_wp, 1.2_wp, 0.8_wp], EA(3) = [1.0e6_wp, 1.5e6_wp, 0.8e6_wp] + REAL(wp), PARAMETER :: DIRS(3, 3) = RESHAPE([1.0_wp, 0.2_wp, 0.1_wp, 0.3_wp, 1.0_wp, -0.2_wp, & + -0.2_wp, 0.4_wp, 1.0_wp], [3, 3]) + REAL(wp), PARAMETER :: THETA(8) = [0.0_wp, 2.0_wp, 5.0_wp, 20.0_wp, 45.0_wp, 90.0_wp, 135.0_wp, 180.0_wp] + REAL(wp), PARAMETER :: S1(11) = [-0.5_wp, -0.01_wp, -1.0e-3_wp, -1.0e-4_wp, -1.0e-12_wp, 1.0e-12_wp, & + 1.0e-4_wp, 2.0e-4_wp, 5.0e-4_wp, 1.0e-3_wp, 2.0e-3_wp] + REAL(wp), PARAMETER :: RATE(3) = [0.05_wp, 0.5_wp, 2.0_wp], DT = 0.05_wp, RHO = 0.4_wp, BA = 2.0e4_wp + REAL(wp), PARAMETER :: RHO_TINY(3) = [1.0e-12_wp, 1.0e-12_wp, 1.0e-12_wp], AD(3) = [0.0_wp, 0.0_wp, BA] + REAL(wp) :: qn(12), q1(12), vn(12), z(12), v1(12), R(12), Rp(12), K(9, 9), tn(3), u(3), dir(3) + REAL(wp) :: d0(3), d1(3), t1(3), w0, t0, e0, wt, l1, e1, tel1, td0, td1, p, p1, am, af, beta, gamma, band + REAL(wp) :: phi, dash, nn, excess, worst, slack_worst, unc_max, dev, uncapped + INTEGER :: i, j, ir, nact, nneg + CALL reset_chain_load() + cb_dash_elem = 3 + cb_ba_dash = BA + cb_l0_dash = L0(3) + am = (2.0_wp*RHO - 1.0_wp)/(RHO + 1.0_wp) + af = RHO/(RHO + 1.0_wp) + beta = 0.25_wp*(1.0_wp - am + af)**2 + gamma = 0.5_wp - am + af + band = af/(1.0_wp - af) + CALL chain_nodes(DIRS, [0.010_wp, 0.020_wp, 0.001_wp], L0, qn) + z = 0.0_wp + d0 = qn(10:12) - qn(7:9) + tn = d0/NORM2(d0) + u = [tn(2), -tn(1), 0.0_wp] + u = u/NORM2(u) + e0 = NORM2(d0) - L0(3) + t0 = EA(3)*e0/L0(3) + w0 = 0.5_wp*t0*e0 + worst = -HUGE(1.0_wp) + slack_worst = -HUGE(1.0_wp) + unc_max = -HUGE(1.0_wp) + nact = 0 + nneg = 0 + DO ir = 1, SIZE(RATE) + vn = 0.0_wp + vn(10:12) = RATE(ir)*tn + td0 = BA*RATE(ir)/L0(3) + DO i = 1, SIZE(THETA) + DO j = 1, SIZE(S1) + dir = COS(THETA(i)*PI/180.0_wp)*tn + SIN(THETA(i)*PI/180.0_wp)*u + q1 = qn + q1(10:12) = qn(7:9) + L0(3)*(1.0_wp + S1(j))*dir + CALL probe_chain(qn, vn, z, q1, L0, EA, RHO_TINY, .TRUE., R, K, axial_damping=AD) + CALL probe_chain(qn, vn, z, q1, L0, EA, RHO_TINY, .TRUE., Rp, K) + ! the closed-form kinematics and forces of the end segment at the trial state + v1 = gamma/(beta*DT)*(q1 - qn) + (1.0_wp - gamma/beta)*vn + v1(1:3) = 0.0_wp + d1 = q1(10:12) - q1(7:9) + l1 = NORM2(d1) + t1 = d1/l1 + e1 = l1 - L0(3) + p = NORM2(d0) - DOT_PRODUCT(tn, d1) + p1 = l1 - DOT_PRODUCT(t1, d0) + tel1 = MAX(0.0_wp, EA(3)*e1/L0(3)) + td1 = BA*DOT_PRODUCT(t1, v1(10:12) - v1(7:9))/L0(3) + phi = MIN(1.0_wp, MAX(0.0_wp, 1.0_wp - e1/(band*e0))) + dash = af*td0*p - (1.0_wp - af)*td1*p1 + nn = w0 + (1.0_wp - af)*(tel1 + phi*td1)*p1 + wt = -DOT_PRODUCT(R(10:12), q1(10:12) - qn(10:12)) + uncapped = af*(t0 + td0)*p - (1.0_wp - af)*(tel1 + td1)*p1 + IF (MAXVAL(ABS(R(10:12) - Rp(10:12))) > 1.0e-9_wp*t0) nact = nact + 1 + IF (nn < 0.0_wp) nneg = nneg + 1 + excess = wt - (w0 + (1.0_wp - phi)*dash + MAX(-nn, 0.0_wp)) + worst = MAX(worst, excess/w0) + IF (e1 <= 0.0_wp .AND. nn >= 0.0_wp) slack_worst = MAX(slack_worst, wt/w0) + IF (e1 <= 0.0_wp) unc_max = MAX(unc_max, uncapped/w0) + IF (THETA(i) == 0.0_wp .AND. S1(j) > 0.0_wp) THEN + ! a segment that keeps its direction and ends taut: the cap stays inactive + dev = MAXVAL(ABS(R(10:12) - Rp(10:12))) + CALL require(dev < 1.0e-9_wp*t0, 'damped-release:taut-end-uncapped') + END IF + END DO + END DO + END DO + WRITE (*, '(A,I0,A,I0,A,ES10.3,A,ES10.3,A,ES10.3)') ' damped release: cap active at ', nact, & + ' rows (N < 0 at ', nneg, '); slack-end blend work / W_n ', slack_worst, & + ' (uncapped ', unc_max, '); largest excess over the bound / W_n ', worst + CALL require(unc_max > 10.0_wp, 'damped-release:uncapped-creates-energy') + CALL require(slack_worst <= 1.0_wp + 1.0e-9_wp, 'damped-release:slack-end-bounded') + CALL require(worst <= 1.0e-9_wp, 'damped-release:bound') + ! the capped force is continuous where the end state crosses the rest length and the band + ! edge l0 + c e_n (turning 5 degrees, extending at 0.5 m/s at t_n) + vn = 0.0_wp + vn(10:12) = 0.5_wp*tn + dir = COS(5.0_wp*PI/180.0_wp)*tn + SIN(5.0_wp*PI/180.0_wp)*u + DO i = 1, 2 + e1 = MERGE(0.0_wp, band*e0, i == 1) + q1 = qn + q1(10:12) = qn(7:9) + (L0(3) + e1 + 1.0e-12_wp)*dir + CALL probe_chain(qn, vn, z, q1, L0, EA, RHO_TINY, .TRUE., R, K, axial_damping=AD) + q1(10:12) = qn(7:9) + (L0(3) + e1 - 1.0e-12_wp)*dir + CALL probe_chain(qn, vn, z, q1, L0, EA, RHO_TINY, .TRUE., Rp, K, axial_damping=AD) + dev = MAXVAL(ABS(R(10:12) - Rp(10:12)))/(BA*0.5_wp/L0(3)) + WRITE (*, '(A,A,A,ES10.3)') ' damped release: force jump across the ', & + TRIM(MERGE('rest length', 'band edge ', i == 1)), ' / T_d,n = ', dev + CALL require(dev < 1.0e-6_wp, 'damped-release:continuous') + END DO + ! the tangent where the cap acts: a slack end and a taut end in the band, turning 5 degrees + q1 = qn + q1(10:12) = qn(7:9) + L0(3)*(1.0_wp - 1.0e-4_wp)*dir + CALL damped_tangent_case('damped-release-slack', qn, vn, q1, L0, EA, AD, t0) + q1(10:12) = qn(7:9) + L0(3)*(1.0_wp + 1.0e-4_wp)*dir + CALL damped_tangent_case('damped-release-band', qn, vn, q1, L0, EA, AD, t0) + CALL reset_chain_load() + END SUBROUTINE case_damped_elastic_release + + SUBROUTINE damped_tangent_case(label, qn, vn, q1, l0, ea, ad, t0) + !! The damped chain of case_damped_elastic_release at one trial state where the cap acts: + !! the cap is active, and the tangent matches the finite difference on both paths. + CHARACTER(*), INTENT(IN) :: label + REAL(wp), INTENT(IN) :: qn(12), vn(12), q1(12), l0(3), ea(3), ad(3), t0 + REAL(wp) :: Ra(12), Rb(12), Kd(9, 9), z(12) + z = 0.0_wp + CALL probe_chain(qn, vn, z, q1, l0, ea, [1.0e-12_wp, 1.0e-12_wp, 1.0e-12_wp], .TRUE., Ra, Kd, axial_damping=ad) + CALL probe_chain(qn, vn, z, q1, l0, ea, [1.0e-12_wp, 1.0e-12_wp, 1.0e-12_wp], .TRUE., Rb, Kd) + CALL require(MAXVAL(ABS(Ra(10:12) - Rb(10:12))) > 1.0e-2_wp*t0, label//':cap-active') + CALL fd_tangent_check(label, qn, vn, z, q1, l0, ea, [2.0_wp, 3.0_wp, 1.5_wp], .TRUE., axial_damping=ad) + CALL fd_tangent_check(label, qn, vn, z, q1, l0, ea, [2.0_wp, 3.0_wp, 1.5_wp], .FALSE., axial_damping=ad) + END SUBROUTINE damped_tangent_case + + SUBROUTINE law_cap_config(label, strain_n, strain_1, dirs_trial) + CHARACTER(*), INTENT(IN) :: label + REAL(wp), INTENT(IN) :: strain_n(3), strain_1(3) + REAL(wp), INTENT(IN), OPTIONAL :: dirs_trial(3, 3) + REAL(wp), PARAMETER :: L0(3) = [1.0_wp, 1.2_wp, 0.8_wp], EA(3) = [1.0e6_wp, 1.5e6_wp, 0.0_wp] + REAL(wp), PARAMETER :: EA_LAW = 0.8e6_wp, ALPHA_F = 0.4_wp/1.4_wp + REAL(wp) :: qn(12), vn(12), an(12), q1(12), R(12), Rnone(12), Rel(12), K(9, 9), f_cap(12), f_raw(12) + REAL(wp) :: t0, scale + INTEGER, PARAMETER :: I8 = SELECTED_INT_KIND(18) + CALL reset_chain_load() + cb_law_elem = 3 + cb_ea_law = EA_LAW + cb_l0_law = L0(3) + CALL chain_states(strain_n, strain_1, L0, qn, vn, an, q1, dirs_trial) + t0 = EA_LAW*(NORM2(qn(10:12) - qn(7:9))/L0(3) - 1.0_wp) + ! nearly massless chain at rest at t_n: the residual is the blended force + CALL probe_chain(qn, 0.0_wp*vn, 0.0_wp*an, q1, L0, EA, [1.0e-9_wp, 1.0e-9_wp, 1.0e-9_wp], .TRUE., R, K, & + start_tension=[0.0_wp, 0.0_wp, t0]) + CALL probe_chain(qn, 0.0_wp*vn, 0.0_wp*an, q1, L0, EA, [1.0e-9_wp, 1.0e-9_wp, 1.0e-9_wp], .TRUE., Rnone, K) + ! the entries of the elastic segments are ignored + CALL probe_chain(qn, 0.0_wp*vn, 0.0_wp*an, q1, L0, EA, [1.0e-9_wp, 1.0e-9_wp, 1.0e-9_wp], .TRUE., Rel, K, & + start_tension=[99.0_wp, -5.0_wp, t0]) + CALL blended_force(qn, q1, L0, [EA(1), EA(2), EA_LAW], ALPHA_F, .TRUE., f_cap) + CALL blended_force(qn, q1, L0, [EA(1), EA(2), EA_LAW], ALPHA_F, .FALSE., f_raw) + scale = MAXVAL(ABS(f_raw)) + CALL require(MAXVAL(ABS(f_cap - f_raw)) > 1.0e-2_wp*scale, label//':cap-active') + CALL require(MAXVAL(ABS(R(4:12) - f_cap(4:12))) < 1.0e-6_wp*scale, label//':residual-closed-form') + CALL require(MAXVAL(ABS(Rnone(4:12) - f_raw(4:12))) < 1.0e-6_wp*scale, label//':no-start-tension-uncapped') + CALL require(ALL(TRANSFER(Rel, [0_I8]) == TRANSFER(R, [0_I8])), label//':elastic-entries-ignored') + ! the tangent with inertia, on both paths + CALL fd_tangent_check(label, qn, vn, an, q1, L0, EA, [2.0_wp, 3.0_wp, 1.5_wp], .TRUE., & + start_tension=[0.0_wp, 0.0_wp, t0]) + CALL fd_tangent_check(label, qn, vn, an, q1, L0, EA, [2.0_wp, 3.0_wp, 1.5_wp], .FALSE., & + start_tension=[0.0_wp, 0.0_wp, t0]) + CALL reset_chain_load() + END SUBROUTINE law_cap_config + + SUBROUTINE case_load_share_tangent() + !! All segments elastic and taut; the callback load carries a quadratic drag and a cubic + !! position load (and an added mass on the dense path). + REAL(wp), PARAMETER :: L0(3) = [1.0_wp, 1.2_wp, 0.8_wp], EA(3) = [1.0e6_wp, 1.5e6_wp, 0.8e6_wp] + REAL(wp), PARAMETER :: RHO = 0.4_wp, DT = 0.05_wp + REAL(wp) :: qn(12), vn(12), an(12), q1(12), v1(12), R(12), K(9, 9), f_int(12), f1(12), fn0(12) + REAL(wp) :: jq(12, 12), jv(12, 12), alpha_m, alpha_f, beta, gamma, scale, load_scale + INTEGER :: i + CALL reset_chain_load() + CALL chain_states([0.010_wp, 0.020_wp, 0.010_wp], [0.020_wp, 0.015_wp, 0.020_wp], L0, qn, vn, an, q1) + cb_drag = 2.0e4_wp + cb_spring = 1.0e8_wp + DO i = 1, 12 + cb_q0(i) = qn(i) + 0.05_wp*SIN(0.9_wp*REAL(i, wp)) + END DO + alpha_m = (2.0_wp*RHO - 1.0_wp)/(RHO + 1.0_wp) + alpha_f = RHO/(RHO + 1.0_wp) + beta = 0.25_wp*(1.0_wp - alpha_m + alpha_f)**2 + gamma = 0.5_wp - alpha_m + alpha_f + ! closed form, nearly massless chain at rest at t_n: v_{n+1} = gamma/(beta dt) (q1 - qn) at + ! the free nodes, the fixed node held + v1 = gamma/(beta*DT)*(q1 - qn) + v1(1:3) = 0.0_wp + CALL probe_chain(qn, 0.0_wp*vn, 0.0_wp*an, q1, L0, EA, [1.0e-9_wp, 1.0e-9_wp, 1.0e-9_wp], .TRUE., R, K) + CALL blended_force(qn, q1, L0, EA, alpha_f, .TRUE., f_int) + CALL chain_load(q1, v1, f1, jq, jv) + CALL chain_load(qn, 0.0_wp*vn, fn0, jq, jv) + scale = MAXVAL(ABS(f_int)) + load_scale = MAXVAL(ABS(f1(4:12))) + CALL require(load_scale > 0.1_wp*scale, 'load-share:load-significant') + CALL require(MAXVAL(ABS(R(4:12) - (f_int(4:12) - (1.0_wp - alpha_f)*f1(4:12) - alpha_f*fn0(4:12)))) < & + 1.0e-6_wp*scale, 'load-share:residual-closed-form') + ! the tangent with inertia: banded, and dense with the added mass + CALL fd_tangent_check('load-share', qn, vn, an, q1, L0, EA, [2.0_wp, 3.0_wp, 1.5_wp], .TRUE.) + cb_madd = 50.0_wp + CALL fd_tangent_check('load-share+added-mass', qn, vn, an, q1, L0, EA, [2.0_wp, 3.0_wp, 1.5_wp], .FALSE.) + CALL reset_chain_load() + END SUBROUTINE case_load_share_tangent + + SUBROUTINE solve_chain(work, qn, vn, an, ends, dt, start_load, start_tension, q_out, v_out, a_out, n_iter, es) + !! One banded step of the chain with node 1 prescribed at ends (at rest). + TYPE(CD_CableGenAlphaWorkspace), INTENT(INOUT) :: work + REAL(wp), INTENT(IN) :: qn(12), vn(12), an(12), ends(3), dt, start_load(12), start_tension(3) + REAL(wp), INTENT(OUT) :: q_out(12), v_out(12), a_out(12) + INTEGER, INTENT(OUT) :: n_iter, es + REAL(wp), PARAMETER :: L0(3) = [1.0_wp, 1.2_wp, 0.8_wp], EA(3) = [1.0e6_wp, 1.5e6_wp, 0.0_wp] + INTEGER :: conn(2, 3) + REAL(wp) :: pq(12) + LOGICAL :: converged, stalled + TYPE(GenAlphaConfig) :: cfg + CHARACTER(120) :: em + conn = RESHAPE([1, 2, 2, 3, 3, 4], [2, 3]) + cfg%rho_inf = 0.4_wp + pq = qn + pq(1:3) = ends + CALL CD_Cable_Gen_Alpha_Step(qn, vn, an, conn, L0, EA, [2.0_wp, 3.0_wp, 1.5_wp], .TRUE., 0.0_wp*qn, [1, 2, 3], & + dt, cfg, q_out, v_out, a_out, converged, stalled, n_iter, es, em, & + load_band_proc=cb_load_band, load_force_proc=cb_force, prescribed_q=pq, & + prescribed_v=0.0_wp*qn, prescribed_a=0.0_wp*qn, workspace=work, & + start_load=start_load, start_tension=start_tension) + IF (es == CD_DYN_OK .AND. .NOT. converged) es = -1 + END SUBROUTINE solve_chain + + LOGICAL FUNCTION same_bits(x, y) RESULT(same) + REAL(wp), INTENT(IN) :: x(:), y(:) + INTEGER, PARAMETER :: I8 = SELECTED_INT_KIND(18) + same = ALL(TRANSFER(x, [0_I8]) == TRANSFER(y, [0_I8])) + END FUNCTION same_bits + + SUBROUTINE case_warm_resolve_reuse() + !! A junction-style re-solve of the same step (guess_armed) from the same committed state + !! with moved ends: the step-start data of the first call are reused. + REAL(wp), PARAMETER :: L0(3) = [1.0_wp, 1.2_wp, 0.8_wp], EA_LAW = 0.8e6_wp, ALPHA_F = 0.4_wp/1.4_wp + REAL(wp), PARAMETER :: DIRS(3, 3) = RESHAPE([1.0_wp, 0.2_wp, 0.1_wp, 0.3_wp, 1.0_wp, -0.2_wp, & + -0.2_wp, 0.4_wp, 1.0_wp], [3, 3]) + TYPE(CD_CableGenAlphaWorkspace) :: warm, cold, wrong, cold2 + REAL(wp) :: qn(12), vn(12), an(12), qn2(12), sl(12), sl2(12), ends_a(3), ends_b(3), u3(3) + REAL(wp) :: qw(12), vw(12), aw(12), qc(12), vc(12), ac(12), qx(12), vx(12), ax(12), t0, t02, e0, e1 + REAL(wp) :: jq(12, 12), jv(12, 12) + INTEGER :: itw, itc, itx, es + CALL reset_chain_load() + cb_law_elem = 3 + cb_ea_law = EA_LAW + cb_l0_law = L0(3) + cb_drag = 500.0_wp + cb_spring = 1.0e6_wp + CALL chain_nodes(DIRS, [0.010_wp, 0.020_wp, 0.010_wp], L0, qn) + cb_q0 = qn + ! node 4 runs toward node 3, so segment 3 (the law) releases deeply within the step + u3 = (qn(10:12) - qn(7:9))/NORM2(qn(10:12) - qn(7:9)) + vn = 0.0_wp + vn(10:12) = -1.5_wp*u3 + vn(4:6) = [0.05_wp, -0.02_wp, 0.01_wp] + an = 0.0_wp + ends_a = qn(1:3) + [0.01_wp, 0.0_wp, 0.0_wp] + ends_b = qn(1:3) + [0.0_wp, 0.012_wp, -0.004_wp] + CALL chain_load(qn, vn, sl, jq, jv) + t0 = EA_LAW*0.010_wp + ! first call (cold), then the armed re-solve given wrong start data, against a cold solve + CALL solve_chain(warm, qn, vn, an, ends_a, 0.05_wp, sl, [0.0_wp, 0.0_wp, t0], qw, vw, aw, itw, es) + CALL require(es == CD_DYN_OK, 'reuse:first-call') + warm%guess_armed = .TRUE. + CALL solve_chain(warm, qn, vn, an, ends_b, 0.05_wp, sl + 1.0e3_wp, [0.0_wp, 0.0_wp, 5.0_wp*t0], qw, vw, aw, & + itw, es) + CALL require(es == CD_DYN_OK, 'reuse:warm-call') + CALL solve_chain(cold, qn, vn, an, ends_b, 0.05_wp, sl, [0.0_wp, 0.0_wp, t0], qc, vc, ac, itc, es) + CALL require(es == CD_DYN_OK, 'reuse:cold-call') + CALL require(itw == itc .AND. same_bits(qw, qc) .AND. same_bits(vw, vc) .AND. same_bits(aw, ac), & + 'reuse:warm-equals-cold-bitwise') + ! the cap is active at the solution, and the wrong start data would change it + e0 = NORM2(qn(10:12) - qn(7:9)) - L0(3) + e1 = NORM2(qc(10:12) - qc(7:9)) - L0(3) + CALL require(e0 - e1 > e0/(2.0_wp*ALPHA_F), 'reuse:cap-active') + CALL solve_chain(wrong, qn, vn, an, ends_b, 0.05_wp, sl + 1.0e3_wp, [0.0_wp, 0.0_wp, 5.0_wp*t0], qx, vx, ax, & + itx, es) + CALL require(es == CD_DYN_OK .AND. .NOT. same_bits(qx, qc), 'reuse:start-data-matter') + ! an unarmed call that fails before computing its start data (dt < 0), then an armed call + ! from another state: it must not reuse the start data of the first state + qn2 = qn + qn2(7:9) = qn2(7:9) + [0.003_wp, -0.002_wp, 0.001_wp] + CALL chain_load(qn2, vn, sl2, jq, jv) + t02 = EA_LAW*(NORM2(qn2(10:12) - qn2(7:9))/L0(3) - 1.0_wp) + CALL solve_chain(warm, qn2, vn, an, ends_b, -1.0_wp, sl2, [0.0_wp, 0.0_wp, t02], qx, vx, ax, itx, es) + CALL require(es /= CD_DYN_OK, 'reuse:early-failure') + warm%guess_armed = .TRUE. + CALL solve_chain(warm, qn2, vn, an, ends_b, 0.05_wp, sl2, [0.0_wp, 0.0_wp, t02], qw, vw, aw, itw, es) + CALL require(es == CD_DYN_OK, 'reuse:armed-after-failure') + CALL solve_chain(cold2, qn2, vn, an, ends_b, 0.05_wp, sl2, [0.0_wp, 0.0_wp, t02], qc, vc, ac, itc, es) + CALL require(es == CD_DYN_OK .AND. itw == itc .AND. same_bits(qw, qc) .AND. same_bits(vw, vc) .AND. & + same_bits(aw, ac), 'reuse:no-stale-start-data') + CALL reset_chain_load() + END SUBROUTINE case_warm_resolve_reuse + + ! ------------------------------------------------------------------------------------------ + ! Case 9: viscoelastic and Syrope lines that go slack (driver runs) + ! ------------------------------------------------------------------------------------------ + + SUBROUTINE write_syrope_files() + !! The settings and OWC table of the shipped Syrope example (examples/data/syrope). + REAL(wp), PARAMETER :: OWC(2, 30) = RESHAPE([ & + 0.00000e+00_wp, 0.00000e+00_wp, 2.06897e-03_wp, 1.71768e+05_wp, & + 4.13793e-03_wp, 3.30952e+05_wp, 6.20690e-03_wp, 4.78788e+05_wp, & + 8.27586e-03_wp, 6.16510e+05_wp, 1.03448e-02_wp, 7.45355e+05_wp, & + 1.24138e-02_wp, 8.66556e+05_wp, 1.44828e-02_wp, 9.81351e+05_wp, & + 1.65517e-02_wp, 1.09097e+06_wp, 1.86207e-02_wp, 1.19666e+06_wp, & + 2.06897e-02_wp, 1.29964e+06_wp, 2.27586e-02_wp, 1.40116e+06_wp, & + 2.48276e-02_wp, 1.50245e+06_wp, 2.68966e-02_wp, 1.60474e+06_wp, & + 2.89655e-02_wp, 1.70927e+06_wp, 3.10345e-02_wp, 1.81728e+06_wp, & + 3.31034e-02_wp, 1.93000e+06_wp, 3.51724e-02_wp, 2.04866e+06_wp, & + 3.72414e-02_wp, 2.17450e+06_wp, 3.93103e-02_wp, 2.30876e+06_wp, & + 4.13793e-02_wp, 2.45267e+06_wp, 4.34483e-02_wp, 2.60747e+06_wp, & + 4.55172e-02_wp, 2.77439e+06_wp, 4.75862e-02_wp, 2.95467e+06_wp, & + 4.96552e-02_wp, 3.14954e+06_wp, 5.17241e-02_wp, 3.36024e+06_wp, & + 5.37931e-02_wp, 3.58800e+06_wp, 5.58621e-02_wp, 3.83406e+06_wp, & + 5.79310e-02_wp, 4.09965e+06_wp, 6.00000e-02_wp, 4.38601e+06_wp], [2, 30]) + INTEGER :: u, i + OPEN (NEWUNIT=u, FILE='ei0slack_syrope_settings.dat', STATUS='REPLACE', ACTION='WRITE') + WRITE (u, '(A)') 'ei0slack_syrope_owc.dat OWC - Original working-curve table file' + WRITE (u, '(A)') 'EXP WCType - Working-curve formulation' + WRITE (u, '(A)') '0.20 k1 - First working-curve shape parameter' + WRITE (u, '(A)') '1.50 k2 - Second working-curve shape parameter' + CLOSE (u) + OPEN (NEWUNIT=u, FILE='ei0slack_syrope_owc.dat', STATUS='REPLACE', ACTION='WRITE') + WRITE (u, '(A)') 'Strain Tension' + WRITE (u, '(A)') '(-) (N)' + DO i = 1, 30 + WRITE (u, '(ES13.5,1X,ES13.5)') OWC(1, i), OWC(2, i) + END DO + CLOSE (u) + END SUBROUTINE write_syrope_files + + SUBROUTINE write_syrope_deck(path, dt, tmax) + !! A 230 m Syrope polyester line (115 segments, 80 kg/m) taut from the fairlead + !! (5, 0, -14) to the anchor (227, 0, -80), working curve of a 1 MN running maximum. + CHARACTER(*), INTENT(IN) :: path + REAL(wp), INTENT(IN) :: dt, tmax + INTEGER :: u + OPEN (NEWUNIT=u, FILE=path, STATUS='REPLACE', ACTION='WRITE') + WRITE (u, '(A)') 'EI = 0 slack-taut dynamics regression deck (Syrope)' + WRITE (u, '(A)') '--- LINE TYPES ---' + WRITE (u, '(A)') 'Name Diam Mass EA BA EI Cdn Cdt Can Cat' + WRITE (u, '(A)') '(-) (m) (kg/m) (N) (-) (Nm2) (-) (-) (-) (-)' + WRITE (u, '(A)') 'rope 0.2 80.0 "SYROPE:ei0slack_syrope_settings.dat|1.53e8|23.12" 1.0e8|1.0e5 0.0 1.2 0.1 1.0 0.0' + WRITE (u, '(A)') '--- POINTS ---' + WRITE (u, '(A)') 'ID Type X Y Z Mass Vol CdA Ca' + WRITE (u, '(A)') '(-) (-) (m) (m) (m) (kg) (m^3) (m^2) (-)' + WRITE (u, '(A)') '1 Coupled 5.0 0.0 -14.0 0 0 0 0' + WRITE (u, '(A)') '2 Fixed 227.0 0.0 -80.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 t' + WRITE (u, '(A)') '--- SYROPE IC ---' + WRITE (u, '(A)') 'Line(s) Tmax0 Tmean0' + WRITE (u, '(A)') '(-) (N) (N)' + WRITE (u, '(A)') '1 1.0e6 5.0e5' + WRITE (u, '(A)') '--- SECTIONS ---' + WRITE (u, '(A)') 'LineID LineType Length NumSegs' + WRITE (u, '(A)') '(-) (-) (m) (-)' + WRITE (u, '(A)') '1 rope 230.0 115' + WRITE (u, '(A)') '--- OPTIONS ---' + WRITE (u, '(A)') '80.0 WtrDpth' + WRITE (u, '(ES14.7,A)') dt, ' dtM' + WRITE (u, '(ES14.7,A)') tmax, ' TMax' + WRITE (u, '(A)') 'ei0slack_surge_syr.txt motionFile' + WRITE (u, '(A)') '--- OUTPUTS ---' + WRITE (u, '(A)') 'FairTen1 AnchTen1' + WRITE (u, '(A)') '--- end ---' + CLOSE (u) + END SUBROUTINE write_syrope_deck + + REAL(wp) FUNCTION column_min(path, first_col, last_col) RESULT(mn) + !! Smallest value of the columns first_col..last_col (last_col 0: through the last column). + CHARACTER(*), INTENT(IN) :: path + INTEGER, INTENT(IN) :: first_col, last_col + REAL(wp), ALLOCATABLE :: d(:, :) + INTEGER :: nrow, lc + mn = HUGE(1.0_wp) + CALL read_out(path, d, nrow) + IF (nrow < 1) RETURN + lc = last_col + IF (lc == 0) lc = SIZE(d, 1) + mn = MINVAL(d(first_col:lc, 1:nrow)) + END FUNCTION column_min + + SUBROUTINE case_law_slack_runs() + LOGICAL :: ok + CHARACTER(64) :: opts(4) + REAL(wp) :: fair, anch, seg_min + ! the light cable as a lightly damped viscoelastic line, 3 m heave at dtM 0.1 s: anchor + ! 8.2e4 to 9.5e4 N and fairlead 0.97e5 to 1.02e5 N at dtM 0.5 to 2.5 ms; without the cap + ! on its law segments 1.45e5 N at the anchor. At 0.1 s the anchor snap is not resolved in + ! time (the run notes it), so its peak depends on round-off: 8.5e4 N with gfortran on + ! Windows, other values on other platforms. The upper bound is the check of the cap; the + ! lower bound only asks that the snap reaches the anchor. + CALL write_motion('ei0slack_heave_ve.txt', 1, [5.0_wp, 0.0_wp, -14.0_wp], 3, 3.0_wp, 10.0_wp, 10.0_wp, & + 0.1_wp, 40.0_wp) + opts(1) = '0.1 dtM' + opts(2) = '40.0 TMax' + opts(3) = 'ei0slack_heave_ve.txt motionFile' + opts(4) = '' + CALL write_deck('ei0slack_ve_light.dat', CABLE_VE, [205.0_wp, 0.0_wp, -80.0_wp], [5.0_wp, 0.0_wp, -14.0_wp], & + 230.0_wp, 115, 80.0_wp, 't', opts) + CALL run_driver_logged('ei0slack_ve_light.dat', 'ei0slack_ve_light', 'ei0slack_ve_light.log', ok) + CALL require(ok, 've-slack:run') + fair = column_max('ei0slack_ve_light.out', 2, 2) + anch = column_max('ei0slack_ve_light.out', 3, 3) + seg_min = column_min('ei0slack_ve_light.Line1.t.out', 2, 0) + WRITE (*, '(A,ES10.3,A,ES10.3,A,ES10.3,A)') ' viscoelastic light cable, dtM 0.1 s: FairTen1 max ', fair, & + ' N, AnchTen1 max ', anch, ' N, smallest segment tension ', seg_min, ' N' + CALL require(seg_min <= 0.0_wp, 've-slack:goes-slack') + CALL require(anch > 4.0e4_wp .AND. anch < 1.0e5_wp, 've-slack:anchor-peak') + CALL require(fair > 8.0e4_wp .AND. fair < 1.2e5_wp, 've-slack:fairlead-peak') + CALL require(.NOT. file_contains('ei0slack_ve_light.log', 'Warning: line'), 've-slack:no-spike-warning') + ! a taut Syrope line in 4 m surge that goes slack, dtM 0.1 s: fairlead 1.78 MN at dtM 1 and + ! 2.5 ms + CALL write_syrope_files() + CALL write_motion('ei0slack_surge_syr.txt', 1, [5.0_wp, 0.0_wp, -14.0_wp], 1, 4.0_wp, 10.0_wp, 10.0_wp, & + 0.1_wp, 40.0_wp) + CALL write_syrope_deck('ei0slack_syrope.dat', 0.1_wp, 40.0_wp) + CALL run_driver_logged('ei0slack_syrope.dat', 'ei0slack_syrope', 'ei0slack_syrope.log', ok) + CALL require(ok, 'syrope-slack:run') + fair = column_max('ei0slack_syrope.out', 2, 2) + seg_min = column_min('ei0slack_syrope.Line1.t.out', 2, 0) + WRITE (*, '(A,ES10.3,A,ES10.3,A)') ' Syrope line, 4 m surge, dtM 0.1 s: FairTen1 max ', fair, & + ' N, smallest segment tension ', seg_min, ' N' + CALL require(seg_min <= 0.0_wp, 'syrope-slack:goes-slack') + CALL require(fair > 1.5e6_wp .AND. fair < 1.95e6_wp, 'syrope-slack:fairlead-peak') + CALL require(.NOT. file_contains('ei0slack_syrope.log', 'Warning: line'), 'syrope-slack:no-spike-warning') + END SUBROUTINE case_law_slack_runs + +END PROGRAM test_ei0_slack_dynamics diff --git a/tests/test_validation_records.py b/tests/test_validation_records.py index 0bac61da..b4085527 100644 --- a/tests/test_validation_records.py +++ b/tests/test_validation_records.py @@ -42,11 +42,14 @@ def test_provenance_uses_the_release_version(self) -> None: match = re.search(r"project\(CableDynCore VERSION (\d+\.\d+\.\d+)", cmake) self.assertIsNotNone(match) expected = f"v{match.group(1)}" + # A record rerun on an unreleased development build after that release says so; the + # version bump of the next release makes it fail here until the record is rerun. + development = f"{expected}+dev (unreleased)" for relative in ( "experiments/holcombe/provenance.json", "experiments/bergdahl/provenance.json", ): - self.assertEqual(load_json(VALIDATION / relative)["CableDyn_release"], expected) + self.assertIn(load_json(VALIDATION / relative)["CableDyn_release"], (expected, development)) def test_holcombe_marker_curvature_summary(self) -> None: directory = VALIDATION / "experiments" / "holcombe" diff --git a/validation/experiments/bergdahl/README.md b/validation/experiments/bergdahl/README.md index 0354bdf4..1d7a615b 100644 --- a/validation/experiments/bergdahl/README.md +++ b/validation/experiments/bergdahl/README.md @@ -71,11 +71,12 @@ committed summary file (`sha256sum`, or `Get-FileHash` in PowerShell). `comparison_summary.csv`, `aggregate_metrics.json` and `provenance.json` hold the compact results and the checksum of the executable used. The calculated force is `FairTen1`, the force at the upper line end. Across the 30 conditions, the cycle maxima have an RMSE of 1.58 N, a -mean absolute percentage error of 3.11%, a mean bias of +0.46 N, a Pearson correlation of 0.993 +mean absolute percentage error of 3.13%, a mean bias of +0.46 N, a Pearson correlation of 0.993 and a Lin concordance coefficient of 0.989. For the two waveform conditions, halving the nominal -element length and the time step changes the mean cycle maximum by no more than 0.49% and -0.28%, respectively, and the phase-averaged force histories have RMSEs of 5.95% and 2.54% of -the measured force range. The waveform CSVs carry the measured phase averages computed from the +element length and the time step changes the mean cycle maximum by no more than 0.52% and +0.19%, respectively, and the phase-averaged force histories have RMSEs of 5.95% and 2.54% of +the measured force range (computed with the executable of the 2026-10-09 record; see +`provenance.json`). The waveform CSVs carry the measured phase averages computed from the supplement's `expData.dat`. ## Time step @@ -85,7 +86,7 @@ modes up to about 2c/l ≈ 3500 rad/s. The force maxima are snap loads, which co step only once the step resolves these modes, roughly dtM ≲ l/(2c) ≈ 0.29 ms (see "Snap loads on slack lines" in the [modelling guide](https://cabledyn.readthedocs.io/en/latest/modeling.html)). At a coarser step the maxima do not settle: at the T = 1.25 s, 0.20 m condition they are -72.5 N at 0.625 ms, against 68.0 N at 0.3125 ms and 67.8 N at 0.15625 ms. Coarse steps also +72.2 N at 0.625 ms, against 68.0 N at 0.3125 ms and 67.8 N at 0.15625 ms. Coarse steps also leave the maxima sensitive to the Newton tolerance and to small changes in the solver's iteration path. With a 1.25 ms step and a relative tolerance of 1e-5, the five cycle maxima of a condition have standard deviations of up to 1.6 N, their means are 2–15% above the converged diff --git a/validation/experiments/bergdahl/aggregate_metrics.json b/validation/experiments/bergdahl/aggregate_metrics.json index 56f98784..7e090b78 100644 --- a/validation/experiments/bergdahl/aggregate_metrics.json +++ b/validation/experiments/bergdahl/aggregate_metrics.json @@ -1,12 +1,12 @@ { "completed_cases": 30, - "mean_bias_N": 0.4581405133333342, - "mean_bias_percent_of_measured": 1.5799650380013595, - "mae_N": 1.3216888866666683, - "mape_percent": 3.114363588294243, - "rmse_N": 1.5803063158422797, - "maximum_absolute_error_percent": 7.720632768361595, - "pearson_correlation": 0.993312061701205, - "correlation_r_squared": 0.9866688519210985, - "lin_concordance_correlation": 0.9891670912995935 + "mean_bias_N": 0.4616683466666679, + "mean_bias_percent_of_measured": 1.5855886766627234, + "mae_N": 1.327560893333332, + "mape_percent": 3.1267980284256174, + "rmse_N": 1.5827470765235303, + "maximum_absolute_error_percent": 7.717337853107351, + "pearson_correlation": 0.9932561631491675, + "correlation_r_squared": 0.9865578056338057, + "lin_concordance_correlation": 0.9891388894227845 } diff --git a/validation/experiments/bergdahl/comparison_summary.csv b/validation/experiments/bergdahl/comparison_summary.csv index 2aa54285..cb97a7df 100644 --- a/validation/experiments/bergdahl/comparison_summary.csv +++ b/validation/experiments/bergdahl/comparison_summary.csv @@ -1,31 +1,31 @@ case,period_s,radius_m,measured_maximum_N,dt_s,number_of_elements,element_length_m,total_cycles,ramp_cycles,rho_inf,published_ground_modulus_Pa_per_m,published_ground_damping_ratio,published_contact_diameter_m,equivalent_volume_diameter_m,kbot_Pa_per_m,cbot_Pa_s_per_m,contact_coefficients_overridden,ba_N_s,friction_mu,solver_relative_tolerance,analysis_start_s,deck_sha256,motion_sha256,samples_analysed,predicted_mean_N,predicted_minimum_N,predicted_absolute_maximum_N,predicted_mean_cycle_maximum_N,predicted_cycle_maximum_std_N,predicted_range_N,maximum_error_N,maximum_error_percent -bergdahl_T1p25_R0p075_h0p200_dt0p0003,1.25,0.075,42.5,0.0003125,165,0.2,12,3,0.4,3000000000.0,1.0,0.0022,0.003654133499998645,1806173748.168327,402155.67857087706,False,0.0,0.3,1e-08,8.75,9a15c83cd584db2d41b7425c2464d45b951e064312e22d2bd5f2bdc5d62c78be,200c532b956836233ff1706360190a636fa05d658c6e4dc8b0eeda6ac38665d7,20001,22.757913497956103,0.91928107,41.741344,41.5666928,0.15081908732385152,40.82206293,-0.9333072000000016,-2.1960169411764743 -bergdahl_T1p25_R0p100_h0p200_dt0p0003,1.25,0.1,46.8,0.0003125,165,0.2,12,3,0.4,3000000000.0,1.0,0.0022,0.003654133499998645,1806173748.168327,402155.67857087706,False,0.0,0.3,1e-08,8.75,35f623bef1aa930eca217ccf056b72d26a2a3003af68a8efbce83fadb8921146,deb435829efdb15fd5c8f0b8db9dd0c83cfa10aab269a24dcd1fae02d0156547,20001,23.42198186325699,0.080218397,47.574447,47.3751466,0.13386717413279436,47.494228602999996,0.5751466000000036,1.2289457264957342 -bergdahl_T1p25_R0p125_h0p200_dt0p0003,1.25,0.125,54.1,0.0003125,165,0.2,12,3,0.4,3000000000.0,1.0,0.0022,0.003654133499998645,1806173748.168327,402155.67857087706,False,0.0,0.3,1e-08,8.75,3db8b8c41f6fd9b122135c92bb6311db9c79ed022cea0e9341c82e382ea2d8c4,350bd646ce87b6afcfec808548ada2624a25186efabbcd00dc72864f1b20fbf0,20001,24.47982608920114,0.080218397,53.386241,53.1851858,0.12232783660598176,53.306022602999995,-0.9148142000000021,-1.6909689463955677 -bergdahl_T1p25_R0p150_h0p200_dt0p0003,1.25,0.15,60.4,0.0003125,165,0.2,12,3,0.4,3000000000.0,1.0,0.0022,0.003654133499998645,1806173748.168327,402155.67857087706,False,0.0,0.3,1e-08,8.75,6db3b6e1e3a34c320567820a2b227905aea57c8940efdebb14afb0b1a4bb6b8b,a8a5c083de018445740094b398496386e405db1c896d75c8e01c6acd0c985d3c,20001,25.727289597256586,0.080218397,58.143098,58.109511600000005,0.03453248117787073,58.062879603,-2.290488399999994,-3.7921993377483343 -bergdahl_T1p25_R0p200_h0p200_dt0p0003,1.25,0.2,70.3,0.0003125,165,0.2,12,3,0.4,3000000000.0,1.0,0.0022,0.003654133499998645,1806173748.168327,402155.67857087706,False,0.0,0.3,1e-08,8.75,79b6ad075892ffbad6f63343cb55454aa2380387002b23c95dd63ec99ad89757,a3f02e630a2f80e08b9367d4362b4bb09c37f3fb5935ecdc3f548d38fb0f22da,20001,28.52542219594885,0.042117789,68.112197,67.993336,0.09316263462086093,68.07007921099999,-2.306663999999998,-3.281172119487906 -bergdahl_T1p50_R0p075_h0p200_dt0p0003,1.5,0.075,41.0,0.0003125,165,0.2,12,3,0.4,3000000000.0,1.0,0.0022,0.003654133499998645,1806173748.168327,402155.67857087706,False,0.0,0.3,1e-08,10.5,c84e640a68f2f9a806a08b3afb2b220a49025cf6cf3f75a4439df1e5007eb536,c93b19181604134c73d29a1e343dadd769c4cf5510d2214a929e96ad98bab6d7,24001,22.593075607858005,2.2231129,39.931283,39.884565599999995,0.03634136753480782,37.708170100000004,-1.1154344000000052,-2.720571707317086 -bergdahl_T1p50_R0p100_h0p200_dt0p0003,1.5,0.1,45.3,0.0003125,165,0.2,12,3,0.4,3000000000.0,1.0,0.0022,0.003654133499998645,1806173748.168327,402155.67857087706,False,0.0,0.3,1e-08,10.5,89df9b353f05c33ad5b47160fb17b0ef2fb9aaaddc5f9c1bb6faa1aa651345b0,08aff391d95ba06a6e36de8101f986e34725034f826dcb56c079f6de0e8c63db,24001,23.09723013602354,0.080218397,46.281435,46.079744999999996,0.18946747132291658,46.201216603,0.7797449999999984,1.7212913907284733 -bergdahl_T1p50_R0p125_h0p200_dt0p0003,1.5,0.125,51.5,0.0003125,165,0.2,12,3,0.4,3000000000.0,1.0,0.0022,0.003654133499998645,1806173748.168327,402155.67857087706,False,0.0,0.3,1e-08,10.5,b08f6f7411a4c6bf6c51479886cdd5e5ec05048995f7df56b314f38602a6ac68,8da6cf5077f315d1445f9fa86597eb0c45f4a47ea564b2a14f53dbfcb12d70c0,24001,24.025272591529433,0.080218397,51.735435,51.464737400000004,0.1866767005582109,51.655216603,-0.035262599999995814,-0.06847106796115691 -bergdahl_T1p50_R0p150_h0p200_dt0p0003,1.5,0.15,59.0,0.0003125,165,0.2,12,3,0.4,3000000000.0,1.0,0.0022,0.003654133499998645,1806173748.168327,402155.67857087706,False,0.0,0.3,1e-08,10.5,4adab994765aca18aa52757ef82e30d15cd9ad09a908cf44bae00cd890218bcb,d399fa50a0dcd35fa3a55d5e8cfddae96652df14bc08b3707dae3766fb725531,24001,25.22633455551252,0.080218397,56.478759,56.4289086,0.059061602122699515,56.398540602999994,-2.5710914000000002,-4.357782033898306 -bergdahl_T1p50_R0p200_h0p200_dt0p0003,1.5,0.2,68.0,0.0003125,165,0.2,12,3,0.4,3000000000.0,1.0,0.0022,0.003654133499998645,1806173748.168327,402155.67857087706,False,0.0,0.3,1e-08,10.5,4087f2ecb4c0dc5d8d29440397162646e11ea24585c1bff5229079b1c9e4bda0,80096d02b10970eabc9320273215f978a016c2ea4add6012ca7ecd21c68c2851,24001,27.948856067797383,0.049679647,67.019091,66.9282054,0.06287931010515363,66.969411353,-1.071794600000004,-1.5761685294117707 -bergdahl_T2p00_R0p075_h0p200_dt0p0003,2.0,0.075,36.0,0.0003125,165,0.2,12,3,0.4,3000000000.0,1.0,0.0022,0.003654133499998645,1806173748.168327,402155.67857087706,False,0.0,0.3,1e-08,14.0,788d6c963eaccba31443ed29b33d8dd37dcde8e5945ac02f4c63728f4bcede11,06b2ee6b12d716e9c4757c91d6e330d7985b118f411d8673f0e3be1317cd10b7,32001,22.50804684523296,7.0649794,36.03519,36.0282418,0.006254782426273169,28.9702106,0.028241800000003536,0.07844944444445427 -bergdahl_T2p00_R0p100_h0p200_dt0p0003,2.0,0.1,39.5,0.0003125,165,0.2,12,3,0.4,3000000000.0,1.0,0.0022,0.003654133499998645,1806173748.168327,402155.67857087706,False,0.0,0.3,1e-08,14.0,66b4e4070897810cc0c2db78a9da33350dbf480ff297311b5ade518c36518e72,7cfeecfbc7673140d72af2c7a475ead3ce77736e54552c663e5df1b72cf6afdd,32001,22.72296470571639,0.17566248,41.917193,41.8896122,0.020646613613374106,41.74153052,2.389612200000002,6.0496511392405115 -bergdahl_T2p00_R0p125_h0p200_dt0p0003,2.0,0.125,47.5,0.0003125,165,0.2,12,3,0.4,3000000000.0,1.0,0.0022,0.003654133499998645,1806173748.168327,402155.67857087706,False,0.0,0.3,1e-08,14.0,11d53518b7f6d58facee9b5d62e582bbdc94a289098bbf6d3ac61defaf82c7e8,b2a8c64acddab4c852169269cca4e60bb258479eda2a6495d094c99f39cf76d3,32001,23.436324952588418,0.080218397,47.558421,47.498478,0.04779005098867373,47.478202603,-0.0015220000000013556,-0.0032042105263186435 -bergdahl_T2p00_R0p150_h0p200_dt0p0003,2.0,0.15,54.1,0.0003125,165,0.2,12,3,0.4,3000000000.0,1.0,0.0022,0.003654133499998645,1806173748.168327,402155.67857087706,False,0.0,0.3,1e-08,14.0,d423c8a5aeb69a63655c03060d6f2b45742420795e5d8004b716da8908cd126d,71ae7988f4e286c2a5c4f8b21cbdf9cf0c5138bb68f74c9e2e7083d2bd8a9c39,32001,24.446300337184304,0.080218397,52.9366,52.902586799999995,0.04157151256208951,52.856381602999996,-1.1974132000000068,-2.213333086876168 -bergdahl_T2p00_R0p200_h0p200_dt0p0003,2.0,0.2,62.3,0.0003125,165,0.2,12,3,0.4,3000000000.0,1.0,0.0022,0.003654133499998645,1806173748.168327,402155.67857087706,False,0.0,0.3,1e-08,14.0,a640e7f76fa6bb1ae074d28e43f3958084d3e75bf7d9d368fd414b9849f14e25,5211abe84187c30899ee1759f47f60ddd307427b5aaa577a132c9269b8d0b0f1,32001,26.993355555060432,0.068192523,63.169503,63.11926520000001,0.045996168396943246,63.101310477,0.8192652000000109,1.315032423756037 -bergdahl_T2p50_R0p075_h0p200_dt0p0003,2.5,0.075,31.1,0.0003125,165,0.2,12,3,0.4,3000000000.0,1.0,0.0022,0.003654133499998645,1806173748.168327,402155.67857087706,False,0.0,0.3,1e-08,17.5,87645fbd5487107bb7b4710a95d6eebc3da8d0309ba5de053694f17590581d35,b3a5ceda599c59b5516c7f95d48a53c5a9082ba4573eb87d0f4ebdb816c9918d,40001,22.57345595815105,10.514789,33.064567,33.06116960000001,0.0036382951089751693,22.549777999999996,1.9611696000000052,6.306011575562717 -bergdahl_T2p50_R0p100_h0p200_dt0p0003,2.5,0.1,35.4,0.0003125,165,0.2,12,3,0.4,3000000000.0,1.0,0.0022,0.003654133499998645,1806173748.168327,402155.67857087706,False,0.0,0.3,1e-08,17.5,9898a74d88ffedf8e9585d680862587b7382f129aa1cbf90dcec137bcd6f3f7d,69865be17566563fed41360b3b26602dd059e960ddf492a02bb8474239fe8617,40001,22.64221530362491,4.3028273,38.141965,38.133104,0.007708355790958404,33.8391377,2.7331040000000044,7.720632768361594 -bergdahl_T2p50_R0p125_h0p200_dt0p0003,2.5,0.125,42.5,0.0003125,165,0.2,12,3,0.4,3000000000.0,1.0,0.0022,0.003654133499998645,1806173748.168327,402155.67857087706,False,0.0,0.3,1e-08,17.5,6c1845719020a1b825f0878b9722de394658a468d2576549e8ac44e3854c1943,4606eb29aac566ef9436af19d60063e21915d8e535ee1a29cb8164bf36832ac1,40001,23.063226984025796,0.080218397,43.659712,43.6057238,0.03343434428398325,43.579493602999996,1.1057237999999998,2.601703058823529 -bergdahl_T2p50_R0p150_h0p200_dt0p0003,2.5,0.15,49.0,0.0003125,165,0.2,12,3,0.4,3000000000.0,1.0,0.0022,0.003654133499998645,1806173748.168327,402155.67857087706,False,0.0,0.3,1e-08,17.5,6ebf7ca718808043f57a87bb177c1d5a25f86e13ebcf6a1129e7ef8d9f73fe77,f96b5df08fdfbafbf1a73f3a476ab4bd83f366340e729a555fff4abfbdcb128f,40001,23.947584062742383,0.080218397,48.958646,48.9347036,0.02767322203502985,48.878427603,-0.06529640000000114,-0.1332579591836758 -bergdahl_T2p50_R0p200_h0p200_dt0p0003,2.5,0.2,57.3,0.0003125,165,0.2,12,3,0.4,3000000000.0,1.0,0.0022,0.003654133499998645,1806173748.168327,402155.67857087706,False,0.0,0.3,1e-08,17.5,2d0261069c6689ebe857731f237f70a2883a5980112b9f277246377d0230c9cf,da167b278b0560de961de703952a1e36a22f7e4ff637e7a8453f90eeada7281d,40001,26.2713484617819,0.074387183,59.590532,59.52854119999999,0.03768002434580043,59.516144817000004,2.228541199999995,3.8892516579406546 -bergdahl_T3p00_R0p075_h0p200_dt0p0003,3.0,0.075,29.5,0.0003125,165,0.2,12,3,0.4,3000000000.0,1.0,0.0022,0.003654133499998645,1806173748.168327,402155.67857087706,False,0.0,0.3,1e-08,21.0,302324da0849af35df6392af12635f08555aba2a6e69de515e79fb9705bbab04,d9ad6838f7015b0e7d32a70eb86534166089bd80a096e0a2989cf5cef41dbd05,48001,22.653321671548508,13.201922,31.05484,31.0521838,0.0022818153299513423,17.852918,1.5521838000000017,5.261640000000006 -bergdahl_T3p00_R0p100_h0p200_dt0p0003,3.0,0.1,33.1,0.0003125,165,0.2,12,3,0.4,3000000000.0,1.0,0.0022,0.003654133499998645,1806173748.168327,402155.67857087706,False,0.0,0.3,1e-08,21.0,eb00be510264d4ead391c24cc9a240da7dec29658c898bbc9b481e894d73bd07,8a90048a3f3bab35a054f704a11342f580f746ec87972031da7d49d02217f6cc,48001,22.680061588904394,7.8365592,35.578014,35.5748904,0.0028894399630385627,27.741454800000003,2.4748903999999996,7.477010271903322 -bergdahl_T3p00_R0p125_h0p200_dt0p0003,3.0,0.125,39.3,0.0003125,165,0.2,12,3,0.4,3000000000.0,1.0,0.0022,0.003654133499998645,1806173748.168327,402155.67857087706,False,0.0,0.3,1e-08,21.0,ced08cb707dbc660e07d97949e7422b7326d083dc99d18a5ae84378a21fc84ef,bde9b1a9923f0d4e4c3158d7df37ba31838710c39d672bb8241ec6cab8e55722,48001,22.90067164456157,1.1656807,40.395291,40.388267400000004,0.004843008496790544,39.2296103,1.0882674000000065,2.769128244274826 -bergdahl_T3p00_R0p150_h0p200_dt0p0003,3.0,0.15,45.8,0.0003125,165,0.2,12,3,0.4,3000000000.0,1.0,0.0022,0.003654133499998645,1806173748.168327,402155.67857087706,False,0.0,0.3,1e-08,21.0,47aa51d93408ca527f8a8ac85613ab9b0f7a4f9a2459ec9bca396e62de32dfb2,402811dda2da329a55b8e7816c5134f5aecb0a59bdbefc6b13eeb232cb4fb15b,48001,23.53138338057414,0.080218397,45.358608,45.3498628,0.011396939005714707,45.278389602999994,-0.45013720000000035,-0.9828323144104811 -bergdahl_T3p00_R0p200_h0p200_dt0p0003,3.0,0.2,54.0,0.0003125,165,0.2,12,3,0.4,3000000000.0,1.0,0.0022,0.003654133499998645,1806173748.168327,402155.67857087706,False,0.0,0.3,1e-08,21.0,96e1dda1aa324b9669d601026fb6ad0831cadaf6dcc32492235ee05cd7d7d3b5,f03dc52610fa2de64c497f78321355d34ea6fad14109005aafde665c707b0e35,48001,25.69230404263532,0.080218397,55.69477,55.679851400000004,0.01399851811085599,55.614551602999995,1.679851400000004,3.1108359259259335 -bergdahl_T3p50_R0p075_h0p200_dt0p0003,3.5,0.075,27.8,0.0003125,165,0.2,12,3,0.4,3000000000.0,1.0,0.0022,0.003654133499998645,1806173748.168327,402155.67857087706,False,0.0,0.3,1e-08,24.5,235d4acffaff2133c0833b4dde65d4f746a980e483bf1a184fbda1789d26d32b,832f1074f37014ce95341e0baea190a6c995ca381de72b85ef1d8e4ffbecc7ed,56001,22.741865147425937,15.169385,29.867323,29.866587799999998,0.0007635055337064214,14.697937999999999,2.066587799999997,7.433769064748191 -bergdahl_T3p50_R0p100_h0p200_dt0p0003,3.5,0.1,31.5,0.0003125,165,0.2,12,3,0.4,3000000000.0,1.0,0.0022,0.003654133499998645,1806173748.168327,402155.67857087706,False,0.0,0.3,1e-08,24.5,dfd71b038e2016e837ca8d2976ff4dabbdbc579d663b3e4d6cc02c867bde1e35,d70c6750c97b8271d7f0604166e62a41a1e57b583932f16598c4ebe75de573aa,56001,22.765262908930197,10.483049,33.720301,33.7186382,0.0012345295460219937,23.237251999999998,2.218638200000001,7.043295873015876 -bergdahl_T3p50_R0p125_h0p200_dt0p0003,3.5,0.125,37.5,0.0003125,165,0.2,12,3,0.4,3000000000.0,1.0,0.0022,0.003654133499998645,1806173748.168327,402155.67857087706,False,0.0,0.3,1e-08,24.5,0c91662ea48cc2fa12539fc97fc123c1b3dff743ead2bace86bdf2ac3ac53997,2fe336ce9ff36b4af7c8d698c3e68f372b762b8127ecdda730fb5e07c46f68ea,56001,22.890656535624366,5.6774456,38.03026,38.027284200000004,0.002001978446437134,32.3528144,0.527284200000004,1.4060912000000105 -bergdahl_T3p50_R0p150_h0p200_dt0p0003,3.5,0.15,42.5,0.0003125,165,0.2,12,3,0.4,3000000000.0,1.0,0.0022,0.003654133499998645,1806173748.168327,402155.67857087706,False,0.0,0.3,1e-08,24.5,f2a0f779cd4f722e64114a1d24d297d7b71ce71b3234ebf98d0ee02349768a0e,fd49ce4e3dce2c1d034faeedf52a60633dfb26a3a6cfbc935c66a29ea7297d3c,56001,23.269808068811987,0.37056307,42.730059,42.7063968,0.029921091794918826,42.359495929999994,0.20639680000000027,0.48563952941176536 -bergdahl_T3p50_R0p200_h0p200_dt0p0003,3.5,0.2,50.1,0.0003125,165,0.2,12,3,0.4,3000000000.0,1.0,0.0022,0.003654133499998645,1806173748.168327,402155.67857087706,False,0.0,0.3,1e-08,24.5,7bdf322dbff579b866971969ad11b066c3aa1da0fb8bd19bf7f64c3e05b85e00,de9d5e2bf50d61ca47a1fb69f0cfabab511139a97cff5ccdf79fc257b156f438,56001,25.19107659317866,0.080218397,52.374052,52.3627916,0.009677467375299544,52.293833602999996,2.2627916,4.516550099800399 +bergdahl_T1p25_R0p075_h0p200_dt0p0003,1.25,0.075,42.5,0.0003125,165,0.2,12,3,0.4,3000000000.0,1.0,0.0022,0.003654133499998645,1806173748.168327,402155.67857087706,False,0.0,0.3,1e-08,8.75,9a15c83cd584db2d41b7425c2464d45b951e064312e22d2bd5f2bdc5d62c78be,200c532b956836233ff1706360190a636fa05d658c6e4dc8b0eeda6ac38665d7,20001,22.75729029778711,0.84961577,41.55663,41.518083000000004,0.0364163607119109,40.70701423,-0.9819169999999957,-2.3103929411764605 +bergdahl_T1p25_R0p100_h0p200_dt0p0003,1.25,0.1,46.8,0.0003125,165,0.2,12,3,0.4,3000000000.0,1.0,0.0022,0.003654133499998645,1806173748.168327,402155.67857087706,False,0.0,0.3,1e-08,8.75,35f623bef1aa930eca217ccf056b72d26a2a3003af68a8efbce83fadb8921146,deb435829efdb15fd5c8f0b8db9dd0c83cfa10aab269a24dcd1fae02d0156547,20001,23.423043792491978,0.080218397,47.463795,47.3005878,0.10685080749437453,47.383576602999995,0.5005878000000052,1.0696320512820625 +bergdahl_T1p25_R0p125_h0p200_dt0p0003,1.25,0.125,54.1,0.0003125,165,0.2,12,3,0.4,3000000000.0,1.0,0.0022,0.003654133499998645,1806173748.168327,402155.67857087706,False,0.0,0.3,1e-08,8.75,3db8b8c41f6fd9b122135c92bb6311db9c79ed022cea0e9341c82e382ea2d8c4,350bd646ce87b6afcfec808548ada2624a25186efabbcd00dc72864f1b20fbf0,20001,24.476081125954803,0.080218397,53.264162,53.1698942,0.0748986296049524,53.183943602999996,-0.9301057999999998,-1.7192343807763397 +bergdahl_T1p25_R0p150_h0p200_dt0p0003,1.25,0.15,60.4,0.0003125,165,0.2,12,3,0.4,3000000000.0,1.0,0.0022,0.003654133499998645,1806173748.168327,402155.67857087706,False,0.0,0.3,1e-08,8.75,6db3b6e1e3a34c320567820a2b227905aea57c8940efdebb14afb0b1a4bb6b8b,a8a5c083de018445740094b398496386e405db1c896d75c8e01c6acd0c985d3c,20001,25.732057802401027,0.080218397,58.343019,58.232365200000004,0.0759659228615041,58.262800602999995,-2.1676347999999948,-3.588799337748336 +bergdahl_T1p25_R0p200_h0p200_dt0p0003,1.25,0.2,70.3,0.0003125,165,0.2,12,3,0.4,3000000000.0,1.0,0.0022,0.003654133499998645,1806173748.168327,402155.67857087706,False,0.0,0.3,1e-08,8.75,79b6ad075892ffbad6f63343cb55454aa2380387002b23c95dd63ec99ad89757,a3f02e630a2f80e08b9367d4362b4bb09c37f3fb5935ecdc3f548d38fb0f22da,20001,28.52452245713629,0.047432814,68.254513,67.9673104,0.20436951680913815,68.207080186,-2.332689599999995,-3.3181928876244595 +bergdahl_T1p50_R0p075_h0p200_dt0p0003,1.5,0.075,41.0,0.0003125,165,0.2,12,3,0.4,3000000000.0,1.0,0.0022,0.003654133499998645,1806173748.168327,402155.67857087706,False,0.0,0.3,1e-08,10.5,c84e640a68f2f9a806a08b3afb2b220a49025cf6cf3f75a4439df1e5007eb536,c93b19181604134c73d29a1e343dadd769c4cf5510d2214a929e96ad98bab6d7,24001,22.592768295391856,2.1826476,39.942296,39.862761,0.06165540456034704,37.759648399999996,-1.137239000000001,-2.7737536585365876 +bergdahl_T1p50_R0p100_h0p200_dt0p0003,1.5,0.1,45.3,0.0003125,165,0.2,12,3,0.4,3000000000.0,1.0,0.0022,0.003654133499998645,1806173748.168327,402155.67857087706,False,0.0,0.3,1e-08,10.5,89df9b353f05c33ad5b47160fb17b0ef2fb9aaaddc5f9c1bb6faa1aa651345b0,08aff391d95ba06a6e36de8101f986e34725034f826dcb56c079f6de0e8c63db,24001,23.099262985012874,0.080218397,46.163762,45.9797466,0.12750091794885285,46.083543602999995,0.6797466000000014,1.5005443708609303 +bergdahl_T1p50_R0p125_h0p200_dt0p0003,1.5,0.125,51.5,0.0003125,165,0.2,12,3,0.4,3000000000.0,1.0,0.0022,0.003654133499998645,1806173748.168327,402155.67857087706,False,0.0,0.3,1e-08,10.5,b08f6f7411a4c6bf6c51479886cdd5e5ec05048995f7df56b314f38602a6ac68,8da6cf5077f315d1445f9fa86597eb0c45f4a47ea564b2a14f53dbfcb12d70c0,24001,24.037791008454146,0.080218397,51.738263,51.5905316,0.10014122989208964,51.658044603,0.09053159999999849,0.17578951456310388 +bergdahl_T1p50_R0p150_h0p200_dt0p0003,1.5,0.15,59.0,0.0003125,165,0.2,12,3,0.4,3000000000.0,1.0,0.0022,0.003654133499998645,1806173748.168327,402155.67857087706,False,0.0,0.3,1e-08,10.5,4adab994765aca18aa52757ef82e30d15cd9ad09a908cf44bae00cd890218bcb,d399fa50a0dcd35fa3a55d5e8cfddae96652df14bc08b3707dae3766fb725531,24001,25.22877844669226,0.080218397,56.421491,56.337508400000004,0.07367940691129274,56.341272603,-2.6624915999999956,-4.512697627118636 +bergdahl_T1p50_R0p200_h0p200_dt0p0003,1.5,0.2,68.0,0.0003125,165,0.2,12,3,0.4,3000000000.0,1.0,0.0022,0.003654133499998645,1806173748.168327,402155.67857087706,False,0.0,0.3,1e-08,10.5,4087f2ecb4c0dc5d8d29440397162646e11ea24585c1bff5229079b1c9e4bda0,80096d02b10970eabc9320273215f978a016c2ea4add6012ca7ecd21c68c2851,24001,27.95913363490667,0.049391599,67.036091,66.92867720000001,0.09692043402812402,66.986699401,-1.0713227999999901,-1.5754747058823384 +bergdahl_T2p00_R0p075_h0p200_dt0p0003,2.0,0.075,36.0,0.0003125,165,0.2,12,3,0.4,3000000000.0,1.0,0.0022,0.003654133499998645,1806173748.168327,402155.67857087706,False,0.0,0.3,1e-08,14.0,788d6c963eaccba31443ed29b33d8dd37dcde8e5945ac02f4c63728f4bcede11,06b2ee6b12d716e9c4757c91d6e330d7985b118f411d8673f0e3be1317cd10b7,32001,22.50825846114497,7.1153458,36.047917,36.035346999999994,0.011414748069932139,28.932571199999998,0.035346999999994466,0.09818611111109574 +bergdahl_T2p00_R0p100_h0p200_dt0p0003,2.0,0.1,39.5,0.0003125,165,0.2,12,3,0.4,3000000000.0,1.0,0.0022,0.003654133499998645,1806173748.168327,402155.67857087706,False,0.0,0.3,1e-08,14.0,66b4e4070897810cc0c2db78a9da33350dbf480ff297311b5ade518c36518e72,7cfeecfbc7673140d72af2c7a475ead3ce77736e54552c663e5df1b72cf6afdd,32001,22.725582901798692,0.20156104,41.949945,41.8937148,0.043681995812919115,41.74838396,2.393714799999998,6.060037468354425 +bergdahl_T2p00_R0p125_h0p200_dt0p0003,2.0,0.125,47.5,0.0003125,165,0.2,12,3,0.4,3000000000.0,1.0,0.0022,0.003654133499998645,1806173748.168327,402155.67857087706,False,0.0,0.3,1e-08,14.0,11d53518b7f6d58facee9b5d62e582bbdc94a289098bbf6d3ac61defaf82c7e8,b2a8c64acddab4c852169269cca4e60bb258479eda2a6495d094c99f39cf76d3,32001,23.438071037375487,0.080218397,47.713108,47.5727352,0.1101758711342915,47.632889602999995,0.07273519999999678,0.1531267368420985 +bergdahl_T2p00_R0p150_h0p200_dt0p0003,2.0,0.15,54.1,0.0003125,165,0.2,12,3,0.4,3000000000.0,1.0,0.0022,0.003654133499998645,1806173748.168327,402155.67857087706,False,0.0,0.3,1e-08,14.0,d423c8a5aeb69a63655c03060d6f2b45742420795e5d8004b716da8908cd126d,71ae7988f4e286c2a5c4f8b21cbdf9cf0c5138bb68f74c9e2e7083d2bd8a9c39,32001,24.44123775418168,0.080218397,53.034022,52.9313364,0.08391372617039487,52.953803603,-1.1686636000000021,-2.160191497227361 +bergdahl_T2p00_R0p200_h0p200_dt0p0003,2.0,0.2,62.3,0.0003125,165,0.2,12,3,0.4,3000000000.0,1.0,0.0022,0.003654133499998645,1806173748.168327,402155.67857087706,False,0.0,0.3,1e-08,14.0,a640e7f76fa6bb1ae074d28e43f3958084d3e75bf7d9d368fd414b9849f14e25,5211abe84187c30899ee1759f47f60ddd307427b5aaa577a132c9269b8d0b0f1,32001,26.998362808274205,0.069770449,63.216109,63.1520804,0.03968285901746634,63.146338551,0.8520804000000055,1.3677052969502497 +bergdahl_T2p50_R0p075_h0p200_dt0p0003,2.5,0.075,31.1,0.0003125,165,0.2,12,3,0.4,3000000000.0,1.0,0.0022,0.003654133499998645,1806173748.168327,402155.67857087706,False,0.0,0.3,1e-08,17.5,87645fbd5487107bb7b4710a95d6eebc3da8d0309ba5de053694f17590581d35,b3a5ceda599c59b5516c7f95d48a53c5a9082ba4573eb87d0f4ebdb816c9918d,40001,22.573128677483066,10.591124,33.062585,33.0596916,0.003054553044227603,22.471460999999998,1.9596915999999993,6.301259163987136 +bergdahl_T2p50_R0p100_h0p200_dt0p0003,2.5,0.1,35.4,0.0003125,165,0.2,12,3,0.4,3000000000.0,1.0,0.0022,0.003654133499998645,1806173748.168327,402155.67857087706,False,0.0,0.3,1e-08,17.5,9898a74d88ffedf8e9585d680862587b7382f129aa1cbf90dcec137bcd6f3f7d,69865be17566563fed41360b3b26602dd059e960ddf492a02bb8474239fe8617,40001,22.64237321955451,4.7312149,38.136158,38.1319376,0.002738401960999871,33.404943100000004,2.731937600000002,7.7173378531073515 +bergdahl_T2p50_R0p125_h0p200_dt0p0003,2.5,0.125,42.5,0.0003125,165,0.2,12,3,0.4,3000000000.0,1.0,0.0022,0.003654133499998645,1806173748.168327,402155.67857087706,False,0.0,0.3,1e-08,17.5,6c1845719020a1b825f0878b9722de394658a468d2576549e8ac44e3854c1943,4606eb29aac566ef9436af19d60063e21915d8e535ee1a29cb8164bf36832ac1,40001,23.06203512397165,0.080218397,43.671052,43.619687400000004,0.03978410596331384,43.590833603,1.1196874000000037,2.634558588235303 +bergdahl_T2p50_R0p150_h0p200_dt0p0003,2.5,0.15,49.0,0.0003125,165,0.2,12,3,0.4,3000000000.0,1.0,0.0022,0.003654133499998645,1806173748.168327,402155.67857087706,False,0.0,0.3,1e-08,17.5,6ebf7ca718808043f57a87bb177c1d5a25f86e13ebcf6a1129e7ef8d9f73fe77,f96b5df08fdfbafbf1a73f3a476ab4bd83f366340e729a555fff4abfbdcb128f,40001,23.951691448754932,0.080218397,48.966114,48.918578600000004,0.03350533006552719,48.885895602999994,-0.08142139999999642,-0.1661661224489723 +bergdahl_T2p50_R0p200_h0p200_dt0p0003,2.5,0.2,57.3,0.0003125,165,0.2,12,3,0.4,3000000000.0,1.0,0.0022,0.003654133499998645,1806173748.168327,402155.67857087706,False,0.0,0.3,1e-08,17.5,2d0261069c6689ebe857731f237f70a2883a5980112b9f277246377d0230c9cf,da167b278b0560de961de703952a1e36a22f7e4ff637e7a8453f90eeada7281d,40001,26.27020682526119,0.074341225,59.599114,59.5508086,0.03514053619112935,59.524772775,2.2508086000000063,3.928112739965107 +bergdahl_T3p00_R0p075_h0p200_dt0p0003,3.0,0.075,29.5,0.0003125,165,0.2,12,3,0.4,3000000000.0,1.0,0.0022,0.003654133499998645,1806173748.168327,402155.67857087706,False,0.0,0.3,1e-08,21.0,302324da0849af35df6392af12635f08555aba2a6e69de515e79fb9705bbab04,d9ad6838f7015b0e7d32a70eb86534166089bd80a096e0a2989cf5cef41dbd05,48001,22.653205223224518,13.239237,31.054133,31.053350599999998,0.0007923962392643522,17.814896,1.5533505999999981,5.265595254237282 +bergdahl_T3p00_R0p100_h0p200_dt0p0003,3.0,0.1,33.1,0.0003125,165,0.2,12,3,0.4,3000000000.0,1.0,0.0022,0.003654133499998645,1806173748.168327,402155.67857087706,False,0.0,0.3,1e-08,21.0,eb00be510264d4ead391c24cc9a240da7dec29658c898bbc9b481e894d73bd07,8a90048a3f3bab35a054f704a11342f580f746ec87972031da7d49d02217f6cc,48001,22.68028505046978,7.8264702,35.57996,35.577183000000005,0.0018532568629307379,27.7534898,2.4771830000000037,7.483936555891249 +bergdahl_T3p00_R0p125_h0p200_dt0p0003,3.0,0.125,39.3,0.0003125,165,0.2,12,3,0.4,3000000000.0,1.0,0.0022,0.003654133499998645,1806173748.168327,402155.67857087706,False,0.0,0.3,1e-08,21.0,ced08cb707dbc660e07d97949e7422b7326d083dc99d18a5ae84378a21fc84ef,bde9b1a9923f0d4e4c3158d7df37ba31838710c39d672bb8241ec6cab8e55722,48001,22.90058616806525,1.1527348,40.40689,40.401079200000005,0.005300698180428831,39.2541552,1.101079200000008,2.80172824427483 +bergdahl_T3p00_R0p150_h0p200_dt0p0003,3.0,0.15,45.8,0.0003125,165,0.2,12,3,0.4,3000000000.0,1.0,0.0022,0.003654133499998645,1806173748.168327,402155.67857087706,False,0.0,0.3,1e-08,21.0,47aa51d93408ca527f8a8ac85613ab9b0f7a4f9a2459ec9bca396e62de32dfb2,402811dda2da329a55b8e7816c5134f5aecb0a59bdbefc6b13eeb232cb4fb15b,48001,23.530885720303036,0.080218397,45.358404,45.3450974,0.010693752699590463,45.278185603,-0.45490259999999694,-0.9932371179039235 +bergdahl_T3p00_R0p200_h0p200_dt0p0003,3.0,0.2,54.0,0.0003125,165,0.2,12,3,0.4,3000000000.0,1.0,0.0022,0.003654133499998645,1806173748.168327,402155.67857087706,False,0.0,0.3,1e-08,21.0,96e1dda1aa324b9669d601026fb6ad0831cadaf6dcc32492235ee05cd7d7d3b5,f03dc52610fa2de64c497f78321355d34ea6fad14109005aafde665c707b0e35,48001,25.689062797173765,0.080218397,55.736209,55.698312599999994,0.03162717803250884,55.655990603,1.6983125999999942,3.1450233333333224 +bergdahl_T3p50_R0p075_h0p200_dt0p0003,3.5,0.075,27.8,0.0003125,165,0.2,12,3,0.4,3000000000.0,1.0,0.0022,0.003654133499998645,1806173748.168327,402155.67857087706,False,0.0,0.3,1e-08,24.5,235d4acffaff2133c0833b4dde65d4f746a980e483bf1a184fbda1789d26d32b,832f1074f37014ce95341e0baea190a6c995ca381de72b85ef1d8e4ffbecc7ed,56001,22.741663554740096,15.199221,29.866848,29.8664992,0.0004117046271295802,14.667627000000001,2.066499199999999,7.433450359712226 +bergdahl_T3p50_R0p100_h0p200_dt0p0003,3.5,0.1,31.5,0.0003125,165,0.2,12,3,0.4,3000000000.0,1.0,0.0022,0.003654133499998645,1806173748.168327,402155.67857087706,False,0.0,0.3,1e-08,24.5,dfd71b038e2016e837ca8d2976ff4dabbdbc579d663b3e4d6cc02c867bde1e35,d70c6750c97b8271d7f0604166e62a41a1e57b583932f16598c4ebe75de573aa,56001,22.765204520883554,10.515801,33.721231,33.7197632,0.001419329313444277,23.205430000000003,2.2197632000000027,7.0468673015873105 +bergdahl_T3p50_R0p125_h0p200_dt0p0003,3.5,0.125,37.5,0.0003125,165,0.2,12,3,0.4,3000000000.0,1.0,0.0022,0.003654133499998645,1806173748.168327,402155.67857087706,False,0.0,0.3,1e-08,24.5,0c91662ea48cc2fa12539fc97fc123c1b3dff743ead2bace86bdf2ac3ac53997,2fe336ce9ff36b4af7c8d698c3e68f372b762b8127ecdda730fb5e07c46f68ea,56001,22.890783096641133,5.7432455,38.029771,38.027166,0.002623257802807864,32.286525499999996,0.5271660000000011,1.405776000000003 +bergdahl_T3p50_R0p150_h0p200_dt0p0003,3.5,0.15,42.5,0.0003125,165,0.2,12,3,0.4,3000000000.0,1.0,0.0022,0.003654133499998645,1806173748.168327,402155.67857087706,False,0.0,0.3,1e-08,24.5,f2a0f779cd4f722e64114a1d24d297d7b71ce71b3234ebf98d0ee02349768a0e,fd49ce4e3dce2c1d034faeedf52a60633dfb26a3a6cfbc935c66a29ea7297d3c,56001,23.270828354333318,0.38777922,42.77665,42.75414859999999,0.026079876654231008,42.38887078,0.2541485999999935,0.5979967058823377 +bergdahl_T3p50_R0p200_h0p200_dt0p0003,3.5,0.2,50.1,0.0003125,165,0.2,12,3,0.4,3000000000.0,1.0,0.0022,0.003654133499998645,1806173748.168327,402155.67857087706,False,0.0,0.3,1e-08,24.5,7bdf322dbff579b866971969ad11b066c3aa1da0fb8bd19bf7f64c3e05b85e00,de9d5e2bf50d61ca47a1fb69f0cfabab511139a97cff5ccdf79fc257b156f438,56001,25.18984178717771,0.080218397,52.364122,52.35406759999999,0.00952333220569378,52.283903603,2.254067599999992,4.499136926147688 diff --git a/validation/experiments/bergdahl/provenance.json b/validation/experiments/bergdahl/provenance.json index 1e1fb647..6569d610 100644 --- a/validation/experiments/bergdahl/provenance.json +++ b/validation/experiments/bergdahl/provenance.json @@ -1,9 +1,9 @@ { - "CableDyn_release": "v0.1.1", - "validation_date": "2026-10-09", + "CableDyn_release": "v0.1.1+dev (unreleased)", + "validation_date": "2026-10-16", "executable_name": "cabledyn.exe", - "executable_sha256": "71090e2e28c9e1d99c5180d05a395ebcc891a77cc5294d315a57c691904745ac", - "compiler": "GNU Fortran 15.2.0", + "executable_sha256": "78a3fed9390fd77392a1dcaec244f79f9174d9e2e94e4b3032fb53c7b8bd4395", + "compiler": "GNU Fortran 16.2.0", "build_type": "Release", "platform": "Windows 11 x86-64", "experimental_supplement_sha256": "e119e594e50d7ecf08b397b57b80fd48882484f220b00b4fee54c9cbafc2a254", @@ -12,14 +12,14 @@ "completed_cases": 30, "nonlinear_misses": 0, "refinement_cases": 8, - "maximum_spatial_refinement_difference_percent": 0.4921365643366542, - "maximum_temporal_refinement_difference_percent": 0.2837639065583831, - "force_maxima_sha256": "82637f52b69a01e32c347c9f48c32bb4672f23db65a5543b0cba10c1ada98e59", - "aggregate_metrics_sha256": "3c2d89b85efda5e36814a9f8a253e3bb83110ecc15fa59cab7e6def515261d09", + "maximum_spatial_refinement_difference_percent": 0.5236270564721716, + "maximum_temporal_refinement_difference_percent": 0.18888172026785752, + "force_maxima_sha256": "978889378964c6d6749bc27c11d99d6584956e3c8eac146ae79bf5f7a05e2e95", + "aggregate_metrics_sha256": "35d800fa34137a3a1500cbd0081a490bc1b61cf636cfef5a923b5c18947ba1a7", "case_manifest_sha256": "8da5e7b4a8a92755363807902aba48e0ff42abab04ac44912041853db9e56604", "waveform_T1p25_sha256": "65c8c846636c378b800bb3c7a95ccd2bde766d789af3cdffce26a2e688e1a134", "waveform_T3p50_sha256": "b3ca65ebfc1d61b5510e54876fc11d1604fc18ffcca3eab523dc7d67f50da4d8", "waveform_metrics_sha256": "2803a57cb7726f966a00e00bf6eb070231b9c702ae67a81685da50991d0adb11", - "waveform_note": "Waveform metrics were recomputed with the executable above; the measured phase averages are those of the article supplement's expData.dat, as carried in the waveform CSVs.", - "refinement_summary_sha256": "66dc1760fcd43efa73d00c5b58b693fdf5fa59312971f90b82ff4a375c323767" + "waveform_note": "Waveform metrics were computed with the executable of the 2026-10-09 validation (sha256 71090e2e28c9e1d99c5180d05a395ebcc891a77cc5294d315a57c691904745ac); the force-blended EI = 0 step of this development build was not rerun on them because the article supplement's expData.dat, which reduce_bergdahl_waveforms.py reads, was not available. The measured phase averages are those of expData.dat, as carried in the waveform CSVs.", + "refinement_summary_sha256": "b3ef33659ba852ce8b6667032a9f2c44bf0336d988c29c2a80fddc2ab4053859" } diff --git a/validation/experiments/bergdahl/refinement_summary.csv b/validation/experiments/bergdahl/refinement_summary.csv index c200bacd..ddbd61e6 100644 --- a/validation/experiments/bergdahl/refinement_summary.csv +++ b/validation/experiments/bergdahl/refinement_summary.csv @@ -1,3 +1,3 @@ period_s,radius_m,force_h0p400_dt0p0003125_N,force_h0p200_dt0p0003125_N,force_h0p100_dt0p0003125_N,force_h0p200_dt0p00015625_N,force_h0p200_dt0p000625_N,spatial_difference_h0p400_dt0p0003125_percent,spatial_difference_h0p200_dt0p0003125_percent,temporal_difference_h0p200_dt0p0003125_percent,temporal_difference_h0p200_dt0p000625_percent -1.25,0.2,67.98496359999999,67.993336,68.329611,67.8009414,72.53998779999999,-0.50438952447719,-0.4921365643366542,0.2837639065583831,6.9896469018643925 -3.5,0.2,52.3676382,52.3627916,52.34125759999999,52.3462366,54.1330478,0.05040115811051929,0.041141541085191115,0.03162596028919464,3.4134473002401142 +1.25,0.2,68.15018140000001,67.9673104,68.32507899999999,67.8391746,72.2422804,-0.25597862828666473,-0.5236270564721716,0.18888172026785752,6.490506150704244 +3.5,0.2,52.3714018,52.35406759999999,52.345151599999994,52.3533266,53.9582166,0.0501482930083001,0.01703309614638552,0.0014153828383290867,3.0654976564564618 diff --git a/validation/experiments/bergdahl/refinement_summary.json b/validation/experiments/bergdahl/refinement_summary.json index ff6bf1b5..f5f934c3 100644 --- a/validation/experiments/bergdahl/refinement_summary.json +++ b/validation/experiments/bergdahl/refinement_summary.json @@ -4,34 +4,34 @@ "temporal_reference_time_step_s": 0.00015625, "primary_nominal_element_length_m": 0.2, "primary_time_step_s": 0.0003125, - "maximum_primary_spatial_difference_percent": 0.4921365643366542, - "maximum_primary_temporal_difference_percent": 0.2837639065583831, + "maximum_primary_spatial_difference_percent": 0.5236270564721716, + "maximum_primary_temporal_difference_percent": 0.18888172026785752, "rows": [ { "period_s": 1.25, "radius_m": 0.2, - "force_h0p400_dt0p0003125_N": 67.98496359999999, - "force_h0p200_dt0p0003125_N": 67.993336, - "force_h0p100_dt0p0003125_N": 68.329611, - "force_h0p200_dt0p00015625_N": 67.8009414, - "force_h0p200_dt0p000625_N": 72.53998779999999, - "spatial_difference_h0p400_dt0p0003125_percent": -0.50438952447719, - "spatial_difference_h0p200_dt0p0003125_percent": -0.4921365643366542, - "temporal_difference_h0p200_dt0p0003125_percent": 0.2837639065583831, - "temporal_difference_h0p200_dt0p000625_percent": 6.9896469018643925 + "force_h0p400_dt0p0003125_N": 68.15018140000001, + "force_h0p200_dt0p0003125_N": 67.9673104, + "force_h0p100_dt0p0003125_N": 68.32507899999999, + "force_h0p200_dt0p00015625_N": 67.8391746, + "force_h0p200_dt0p000625_N": 72.2422804, + "spatial_difference_h0p400_dt0p0003125_percent": -0.25597862828666473, + "spatial_difference_h0p200_dt0p0003125_percent": -0.5236270564721716, + "temporal_difference_h0p200_dt0p0003125_percent": 0.18888172026785752, + "temporal_difference_h0p200_dt0p000625_percent": 6.490506150704244 }, { "period_s": 3.5, "radius_m": 0.2, - "force_h0p400_dt0p0003125_N": 52.3676382, - "force_h0p200_dt0p0003125_N": 52.3627916, - "force_h0p100_dt0p0003125_N": 52.34125759999999, - "force_h0p200_dt0p00015625_N": 52.3462366, - "force_h0p200_dt0p000625_N": 54.1330478, - "spatial_difference_h0p400_dt0p0003125_percent": 0.05040115811051929, - "spatial_difference_h0p200_dt0p0003125_percent": 0.041141541085191115, - "temporal_difference_h0p200_dt0p0003125_percent": 0.03162596028919464, - "temporal_difference_h0p200_dt0p000625_percent": 3.4134473002401142 + "force_h0p400_dt0p0003125_N": 52.3714018, + "force_h0p200_dt0p0003125_N": 52.35406759999999, + "force_h0p100_dt0p0003125_N": 52.345151599999994, + "force_h0p200_dt0p00015625_N": 52.3533266, + "force_h0p200_dt0p000625_N": 53.9582166, + "spatial_difference_h0p400_dt0p0003125_percent": 0.0501482930083001, + "spatial_difference_h0p200_dt0p0003125_percent": 0.01703309614638552, + "temporal_difference_h0p200_dt0p0003125_percent": 0.0014153828383290867, + "temporal_difference_h0p200_dt0p000625_percent": 3.0654976564564618 } ] } From 71158d5d28cf2500f7fb475e72395acd425e4b0f Mon Sep 17 00:00:00 2001 From: Jae Hoon Seo Date: Sat, 17 Oct 2026 08:21:04 +0900 Subject: [PATCH 15/31] feat(outputs): equilibrium tension recovery, continuous touchdown, anchor uplift channels (#21) Finite-EI node tension, curvature and bend moment are recovered from nodal equilibrium. They had used the element-mean axial force EA(|r'| - 1), which oscillates between elements wherever the line bends over an element and exceeds the tension by EI kappa^2 on any mesh: on the 87-element lazy wave of the IEA-15 mixed example the interior node tension dropped to -173 N against a true 1.2 kN. Each element's end forces, with its own distributed loads, seabed contact (bathymetry crease rounding included) and inertia, now give the effective tension (the axial component of the section force), the bend moment and the curvature as that moment over EI. The largest interior tension error against the converged equilibrium falls from 1552 N to 60 N on that mesh and from 516 N to 0.3 N on a 1 m mesh. A held end laid on the seabed carries the floor reaction of its half element (a laid anchor reported a spurious 903 N m); a section of very low EI reports the exact geometric curvature. Line-end values, positions and the material-strain checks are unchanged. OutputRecovery element restores the previous definitions, and CD_HermiteCable_Dyn_Curvature_Exact / CD_HFMF_Curvature_Exact keep the geometric curvature. The recovery is cached per element, keyed on the element's own DOFs, time and load configuration, so the channels of an output row share one evaluation and per-node loops stay O(n). The touchdown point is located inside the element by the parabola through the last grounded node and the next two, so it moves continuously (largest step between output rows under a surge: 4.64 m -> 0.08 m with 5 m elements); Fortran and Python agree. New channels for drag-anchor checks: AnchFz and AnchFH, the vertical and horizontal components of the AnchTen end force (equal to Point

Fz/FH for an anchor holding one line), and TDPGrd, the grounded length, on every route; the manual names TDPGrd or AnchIncl as the no-uplift check. The Python validator refuses a coupled finite-EI cable without a Fixed End B, as the native aggregate does. Range graphs and .t.out files written every step cost about 4 % more run time. The T-6 static-profile curvature record moves from 0.056 % to 0.049 %; the one-hour coupled full-turbine curvatures are marked as the geometric definition. Signed-off-by: Jae Hoon Seo --- CHANGELOG.md | 97 +++- CMakeLists.txt | 22 + VALIDATION.md | 6 +- app/cabledyn.f90 | 2 +- doc/conventions.rst | 15 +- doc/driver_format.md | 17 +- doc/modeling.rst | 11 +- doc/openfast.rst | 3 +- doc/options.rst | 15 + doc/outputs.rst | 153 ++++- doc/python.rst | 3 +- doc/python_postprocessing.rst | 9 +- doc/theory.rst | 148 ++++- doc/tutorial_bodies.rst | 11 +- doc/tutorial_dynamics.rst | 8 +- doc/tutorial_lazywave.rst | 2 +- doc/tutorial_motion.rst | 14 +- doc/tutorial_openfast.rst | 4 +- doc/tutorial_python.rst | 4 +- examples/cabledyn_options_reference.dat | 3 +- python/cabledyn/builder.py | 4 +- python/cabledyn/deck_file.py | 44 +- python/cabledyn/results.py | 2 +- python/cabledyn/touchdown.py | 41 +- python/tests/test_builder.py | 7 +- python/tests/test_deck_file.py | 50 +- python/tests/test_deck_native_parity.py | 16 +- python/tests/test_objects.py | 20 +- python/tests/test_results.py | 4 + python/tests/test_touchdown.py | 51 +- src/CableDyn_DeckDriver.f90 | 367 +++++++++--- src/CableDyn_HermiteCableDynamic.f90 | 561 ++++++++++++++++++- src/CableDyn_HermiteCableStatic.f90 | 5 +- src/CableDyn_OpenFAST_Aggregate.f90 | 4 +- src/CableDyn_OpenFAST_HermiteFMF.f90 | 26 +- src/CableDyn_RangeOutput.f90 | 89 ++- tests/test_anchor_uplift.py | 529 +++++++++++++++++ tests/test_cable_statics_matrix.py | 23 +- tests/test_coupled_torsion.f90 | 2 +- tests/test_deck_driver.f90 | 10 + tests/test_deck_hermite_cable.f90 | 9 +- tests/test_flagship_compression_note.f90 | 49 +- tests/test_l3_lazywave_3d_dynamic.f90 | 4 +- tests/test_l3_lazywave_dynamic.f90 | 6 +- tests/test_l3_lazywave_irregular.f90 | 4 +- tests/test_l3_lazywave_touchdown_dynamic.f90 | 4 +- tests/test_l4_lazywave_coupled.f90 | 4 +- tests/test_lazywave_dynamics.f90 | 7 +- tests/test_openfast_aggregate.f90 | 118 +++- tests/test_pinned_touchdown_stability.f90 | 7 +- tests/test_range_tdp.py | 53 ++ tests/test_range_tdp_locator.f90 | 138 +++++ validation/OPENFAST_DLC_VERIFICATION.md | 10 +- 53 files changed, 2547 insertions(+), 268 deletions(-) create mode 100644 tests/test_anchor_uplift.py create mode 100644 tests/test_range_tdp_locator.f90 diff --git a/CHANGELOG.md b/CHANGELOG.md index d476efcb..15818222 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -106,9 +106,92 @@ All notable changes to CableDyn are recorded in this file. The format follows snap peaks are not resolved in time. The standalone driver also prints a note for a dynamic deck with `rhoInf` above 0.95, on the missing numerical dissipation. See the manual's troubleshooting page. +- Anchor uplift channels for the drag-anchor check of a catenary mooring (no vertical load at + the anchor in the intact condition). `AnchFz` and `AnchFH` are the vertical component + (positive upward, the line lifting its anchor) and the horizontal magnitude of the `AnchTen` + end force; for an anchor that holds one line they equal `Point

Fz` and `Point

FH`. + `TDPGrd` is the grounded length, the deformed chord length from the grounded end to the + touchdown point; it varies continuously with the touchdown point and is 0 only when nothing + touches (an anchor node on the seabed beside a node a few millimetres clear of it reads + micrometres to millimetres, so test it against a small tolerance such as 0.01 m). The + channels are available on the static, `EI = 0`, finite-EI, mixed and multibody routes, in the C + API and in coupled OpenFAST and FAST.Farm runs; the two-moving-end finite-EI route rejects + `AnchFz`/`AnchFH` by name. The Python deck reader and builder accept the new names. See the + manual's outputs page (Anchor uplift), which also states the end-node weight share that a laid + `Fixed` anchor carries (slightly negative `AnchFz` on an `EI = 0` line, not uplift; exactly 0 + on a finite-EI line, whose grounded end leaves its node weight to the floor). Because of that + share, `AnchFz` on an `EI = 0` line turns positive only after the anchor segment has started + to lift, so `TDPGrd` is the primary no-uplift check and `AnchFz` the vertical anchor load. +- `OutputRecovery` option (`equilibrium`, the default, or `element`): the definition of the + finite-EI node tension, curvature, bend moment and segment tension (see Changed). `element` + restores the definitions of 0.1.1. The Python deck reader accepts and checks it. +- `CD_HermiteCable_Dyn_Curvature_Exact` and `CD_HFMF_Curvature_Exact`: the exact geometric + nodal curvature of the cubic-Hermite centreline, the larger one-sided trace at a node, which + `CD_HermiteCable_Dyn_Curvature` and `CD_HFMF_Curvature` returned up to 0.1.1. ### Changed +- Finite-EI node tension, curvature and bend moment are recovered from nodal equilibrium. The + `TenN`, `CurvN` and `BendMomN` channels, the `Tension`, `Curvature` and + `BendMoment` columns of the static profile and the range graph, and the `.t.out` segment + tensions of a finite-EI line had used the element-mean axial force `EA(|r'| - 1)` and the + exact one-sided curvature of the element interpolation. With a stiff `EA` that axial force + oscillates between elements wherever the line bends over an element (the nodal seabed + reaction near touchdown, a section junction), and it exceeds the tension by `EI kappa^2` on + any mesh. The outputs now come from the element end forces, each element with its own + distributed loads and inertia: the effective tension is the axial component of the section + force, the bend moment the moment the neighbouring elements carry, and the curvature that + moment over `EI`. The derivation is in the manual's theory page (Node tension, curvature and + bend moment). On the lazy-wave cable of `examples/iea15mw_umaine_mixed_cabledyn.dat` on its + former 87-element mesh the static interior node tension now stays between 1217 N and the + 11.9 kN fairlead tension instead of dropping to -173 N. Against the equilibrium of the + converged line, the largest error falls from 1552 N to 60 N at that mesh, from 2059 N to + 12 N, 1921 N to 1 N and 516 N to 0.3 N at twice, four times and ten times the mesh density, and from 164 N to + 1 N at 0.25 m elements. The largest curvature error falls from 64 % to 30 %, 44 % to 7 %, 19 + % to 4 % and 2.1 % to 0.8 % of the peak. Under an 8 m surge and 2 m heave of the hang-off, + the error of the maximum-tension envelope against a 1 m mesh falls from 2164 N to 857 N, 1488 + N to 283 N and 3049 N to 31 N, and the minimum tension of the run from -719 N to +610 N at + that mesh. A `.t.out` segment tension is now the mean of the axial components of the + element's two end forces instead of the axial resultant at its midpoint. The library + curvature (`CD_HermiteCable_Dyn_Curvature`, `CD_HFMF_Curvature`) follows the same definition + as the channels. A section softer than `max(|w| L0^2)/12` times 1 m (about 1.3 kN m^2 for the + 10 m elements of that cable) takes its curvature from the exact geometric trace, as an + `EI = 0` section does: the recovered moment carries an error of that order whatever `EI` is, + which `Curv = BendMom/EI` would amplify (6.9 1/m against 0.12 1/m at `EI` = 100 N m^2). + Line-end values (`FairTen`, `AnchTen`, the end-node tension; the end reaction, without the + inertia, added mass and seabed friction that the recovered section forces of the interior + nodes include), positions and the material-strain checks (`tensile_safety`, the static + compression notes) are unchanged. At a `Fixed` anchor resting on the seabed the end element + carries the floor-support share of its weight, as in the residual, so the end node reports + the bend moment of the line (0.02 N m, not 903 N m, at the anchor of the 87-element cable of + `examples/iea15mw_umaine_mixed_cabledyn.dat`, and 0.1 N m, not 205 N m, at the next node; on + the example's 248-element mesh 0.1 N m and 1.5 N m, the bend of the laid run sinking into the + penalty seabed beside the anchor held at the seabed depth). On + a line restrained in torsion the condensed torque is left out of the recovery; it moves the + tension by at most 0.45 N of 9.4 kN on `examples/torsion_lazy_wave_hangoff_twist.dat`. Range + graphs and `.t.out` files written every step cost 4 % more run time, plain channels under 2 + %. `OutputRecovery element` restores the previous definitions. The T-6 record of + `VALIDATION.md` (twisted lazy wave against OrcaFlex), which reads the static-profile + curvature, moves from 0.056 % to 0.049 %. The curvatures of the one-hour coupled full-turbine + run in its coupled finite-EI touchdown row (0.156 1/m at the sag bend, 0.109 1/m at the + touchdown) were recorded with the previous definition and are marked as such, as is the + static sag-bend curvature of the Hs = 11 power-cable case of + `validation/OPENFAST_DLC_VERIFICATION.md`, which now also gives the recovered values. The other + records use end tensions or the exact geometric curvature + (`CD_HermiteCable_Dyn_Curvature_Exact`) and are unchanged. +- The touchdown point (`TDP` channels and `cabledyn.touchdown_history`) is located inside + the element by the parabola through the last grounded node and the next two nodes instead of + the linear clearance between the last grounded node and the next. On a stiff seabed the + linear interpolation held the TDP on the last grounded node until the next one grounded, so + the TDP moved in steps of one element and, under a small motion, jumped by an element and + back. The parabola reaches a node exactly when the node grounds or lifts off, so the TDP moves + continuously. On a 450 m finite-EI cable under a 10 m fairlead surge, the largest step between + output rows falls from 4.64 m to 0.08 m with 5 m elements and from 1.98 m to 0.08 m with + 2.5 m elements, and the largest error against a 1 m mesh from 2.96 m to 1.92 m and from + 1.39 m to 1.18 m; under a 0.5 m surge the quasi-static TDP excursion with 1 m elements is + 0.63 m against 0.64 m converged, where the linear interpolation gave 0.23 m. On the + `EI = 0` chain of `examples/chain_range_tdp.dat` the largest step falls from 2.59 m to 1.33 m. + The TDP now lies on the contact-onset height, and `TDPGrd` uses the same location. - Faster wave kinematics of directional and multi-train seas (`wavetrain` rows, spectral `waves` rows, `WaveSpreading`). Each component's phase cosine is now computed once for the surface elevation and the kinematics, and its depth profile with one exponential instead of @@ -145,12 +228,14 @@ All notable changes to CableDyn are recorded in this file. The format follows the static state, solved in the vertical plane of the cable, was unstable out of that plane. The static fairlead tension of the cable changes from 11 898 N to 11 922 N (11 921 N on a 1 m mesh), its anchor tension from 1218 N to 1230 N, and the touchdown curvature from - 0.058 1/m to 0.079 1/m (0.080 1/m on the 1 m mesh). The curvature output moves with the - mesh: `Curv4N20`/`BendMom4N20` (76 m from the hang-off) become `Curv4N38`/`BendMom4N38` - (74 m, the peak of the sag bend). In the one-hour full-turbine run of the validation record - the hang-off tension statistics are unchanged (11.5 ± 1.1 kN), the touchdown curvature peaks - at 0.109 1/m instead of 0.075 1/m, and the anchor tension stays at its static 1.23 kN, where - the coarse mesh showed stick-slip peaks up to 4.1 kN. The validation record and the tutorials + 0.058 1/m to 0.079 1/m (0.080 1/m on the 1 m mesh; the geometric curvature, which + `OutputRecovery element` reports, while the curvature recovered from nodal equilibrium reads + 0.100 1/m on the 87-element mesh and 0.081 1/m on the 248-element one). The curvature output + moves with the mesh: `Curv4N20`/`BendMom4N20` (76 m from the hang-off) become + `Curv4N38`/`BendMom4N38` (74 m, the peak of the sag bend). In the one-hour full-turbine run of + the validation record the hang-off tension statistics are unchanged (11.5 ± 1.1 kN), the + touchdown curvature (geometric) peaks at 0.109 1/m instead of 0.075 1/m, and the anchor + tension stays at its static 1.23 kN, where the coarse mesh showed stick-slip peaks up to 4.1 kN. The validation record and the tutorials are updated. - Faster tension-only (`EI = 0`) line steps. In every Newton evaluation the element kernels of the line loads (axial damping, Morison drag, Froude-Krylov, buoyancy recovery, added mass) no diff --git a/CMakeLists.txt b/CMakeLists.txt index a6dbf325..7c2e0b0f 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -688,6 +688,11 @@ target_link_libraries(test_bathymetry PRIVATE cabledyn_core) add_test(NAME bathymetry COMMAND test_bathymetry) set_tests_properties(bathymetry PROPERTIES LABELS "fortran;unit;seabed") +add_executable(test_range_tdp_locator tests/test_range_tdp_locator.f90) +target_link_libraries(test_range_tdp_locator PRIVATE cabledyn_core) +add_test(NAME range_tdp_locator COMMAND test_range_tdp_locator) +set_tests_properties(range_tdp_locator PROPERTIES LABELS "fortran;unit;seabed") + add_executable(test_hydro tests/test_hydro.f90) target_link_libraries(test_hydro PRIVATE cabledyn_core) add_test(NAME hydro COMMAND test_hydro) @@ -1470,6 +1475,23 @@ if(Python3_Interpreter_FOUND) message(STATUS "range_graph_tdp: skipped (numpy not importable in ${Python3_EXECUTABLE})") endif() + # Anchor uplift channels (AnchFz/AnchFH, TDPGrd): the analytic laid and suspended elastic + # catenaries, the Point

F identity on every standalone route, and a surge that lifts the + # anchor of a catenary (needs numpy). + if(_range_tdp_numpy_rc EQUAL 0) + add_test(NAME anchor_uplift_channels + COMMAND ${Python3_EXECUTABLE} ${CMAKE_CURRENT_SOURCE_DIR}/tests/test_anchor_uplift.py + --exe $ + --examples ${CMAKE_CURRENT_SOURCE_DIR}/examples + --output ${CMAKE_BINARY_DIR}/anchor_uplift_channels) + set_tests_properties(anchor_uplift_channels PROPERTIES + LABELS "python;integration;static;dynamic;validation" + TIMEOUT 600 + ENVIRONMENT "${_cabledyn_python_test_environment}") + else() + message(STATUS "anchor_uplift_channels: skipped (numpy not importable in ${Python3_EXECUTABLE})") + endif() + # The arbiter imports numpy + scipy at load time; only register the test when they are # importable, so an image with python3 but without those packages does not fail the # validation suite with ModuleNotFoundError before any CableDyn gate runs. diff --git a/VALIDATION.md b/VALIDATION.md index cd0fe35a..df910349 100644 --- a/VALIDATION.md +++ b/VALIDATION.md @@ -93,7 +93,7 @@ article's methods, are compared in | **T-3** | Greenhill onset, clamped, `TL²/EI` −20 to 1600 | van der Heijden et al. (2003) eq. 33 | ≤3.9e-5 (32 elements); ≤6.5e-6 (128) | <1e-4; <1e-3 | Pass | | **T-4** | Onset, bending-pinned torsional (semi-tangential) end | `tan x = −x/3` | 6.4e-7 / 4.5e-7 | <1e-4 | Pass | | **T-5** | Onsets against OrcaFlex 11.6d (clamped and pinned) | OrcaFlex, extrapolated to zero segment length | ≤3.0e-5 | <2e-4 | Pass | -| **T-6** | Lazy-wave cable twisted 0–5 turns at the hang-off | OrcaFlex 11.6d | torque ≤0.019%, peak curvature ≤0.056%, offset ≤27 mm, tension ≤0.091% | 1% / 1% / 0.1 m / 0.5% | Pass | +| **T-6** | Lazy-wave cable twisted 0–5 turns at the hang-off | OrcaFlex 11.6d | torque ≤0.019%, peak curvature ≤0.049%, offset ≤27 mm, tension ≤0.091% | 1% / 1% / 0.1 m / 0.5% | Pass | | **T-7** | Kirchhoff helix, four turns | helical equilibrium | end force 1.5e-4, end moment 6.5e-5 | <5e-3 | Pass | | **T-8** | Cross-check with the Cosserat rod path | Cosserat path | shape 4.2e-4 L, torque 5.2e-5 | <1% | Pass | | **T-9** | Bordered Newton step on post-buckled states | predicted linear rate without the rank-one term | 3 iterations; rate 0.055 / 0.217 vs 0.055 / 0.218 | ≤4; within 25% | Pass | @@ -740,7 +740,7 @@ stop with a named error. | Active tension (`CtrlChan`) | Pass verified | CONTROL parsing, last-segment length/rate modulation, and exact unit tests; coupled A/B in which a ServoDyn cable-control DLL drives the same pay-out/haul-in `DeltaL` schedule into `=5` (CableDyn) and `=3` (stock MoorDyn) in one binary: hold tensions agree to <0.03% and the tension responses to <0.6% (controlled fairleads) / <0.7% (anchors) ([`validation/scripts/activetension/`](https://github.com/SMI-Lab-Inha/CableDyn/tree/main/validation/scripts/activetension), [`validation/scripts/openfast_activetension_ab.py`](https://github.com/SMI-Lab-Inha/CableDyn/blob/main/validation/scripts/openfast_activetension_ab.py)) | | Coupled `Rigid6` bodies + `Point3` buoys | Pass verified | 6-DOF `Rigid6` motion with hydrostatic (`C33`/`C44`/`C55`) restoring, checkpoint state (bit-identical `openfast -restart` of a 13.9 MN-swinging tethered body), and SeaState drag / Froude–Krylov / added mass. `Point3` buoys take buoyancy and drag/added-mass/FK; a submerged volume-only buoy takes FK. Tests: `case_coupled_rigid6`/`_mirror`/`_fluid`, `case_coupled_point3_buoy`/`_fluid` | | Coupled rigid rods | Pass verified | host-driven `RodA/B` endpoints, correction rewind, bit-identical 24-scalar-per-rod checkpoint state, and two Gauss fluid nodes per rod with SeaState drag/Froude–Krylov/added mass; `case_coupled_rod`, `_mirror`, and `_fluid` pass, and the OpenFAST module compiles with rod decks enabled | -| Coupled finite-EI touchdown/contact | Pass verified | flat `WtrDpth` and equivalent constant structured bathymetry initialise and step with matching loads; friction and checkpoint restore are tested. The IEA-15 mixed example (its power cable on 248 elements, each at most half the bending length) has 149 grounded nodes and completes a 20 s aggregate trajectory at `dtM=0.025 s` with 2 m surge, 1 m heave, and 0.5 m/s host current, without fallback or stall recovery, at most 12 Newton iterations. A full-turbine run of the same model (one hour after a 200 s transient; TurbSim normal turbulence, 10.6 m/s, 17 % TI; JONSWAP Hs 8 m, Tp 12 s, aligned with the wind and the cable; AeroDyn with the rotor held at 7.55 rpm, no controller, rigid blades and tower; SeaState grid covering the lines) completes without recoveries or non-finite values. The cable's hang-off tension is 11.5 ± 1.1 kN (static 11.9 kN, maximum 17.9 kN). The 149 nodes grounded at the static state stay grounded, joined by one more once the platform has drifted (the touchdown moves 2.5 m toward the platform). The peak curvature is 0.156 1/m at the sag bend, 72 m from the hang-off, and 0.109 1/m at the touchdown. On the former 87-element mesh (10 m elements along the laid section) the peak was 0.160 1/m and the touchdown curvature 0.075 1/m, under-resolved by about 30 %. The chain-only twin of the run matches stock MoorDyn over 1200 s to 0.3 % in platform motion and fairlead tension statistics. The anchor tension of the laid cable stays at its static 1.23 kN (maximum 1.24 kN): the seabed friction of the 370 m laid section holds the tension changes at the touchdown. On the former mesh it read 1.39 kN (median) with wave-frequency stick-slip peaks up to 4.1 kN lasting under 1 s, which the resolved mesh does not show, and before the anchor-end correction of this release it locked at about 2.75 kN for the whole run. The run takes 27.1 min of wall time (18.8 min on the former mesh) | +| Coupled finite-EI touchdown/contact | Pass verified | flat `WtrDpth` and equivalent constant structured bathymetry initialise and step with matching loads; friction and checkpoint restore are tested. The IEA-15 mixed example (its power cable on 248 elements, each at most half the bending length) has 149 grounded nodes and completes a 20 s aggregate trajectory at `dtM=0.025 s` with 2 m surge, 1 m heave, and 0.5 m/s host current, without fallback or stall recovery, at most 12 Newton iterations. A full-turbine run of the same model (one hour after a 200 s transient; TurbSim normal turbulence, 10.6 m/s, 17 % TI; JONSWAP Hs 8 m, Tp 12 s, aligned with the wind and the cable; AeroDyn with the rotor held at 7.55 rpm, no controller, rigid blades and tower; SeaState grid covering the lines) completes without recoveries or non-finite values. The cable's hang-off tension is 11.5 ± 1.1 kN (static 11.9 kN, maximum 17.9 kN). The 149 nodes grounded at the static state stay grounded, joined by one more once the platform has drifted (the touchdown moves 2.5 m toward the platform). The peak curvature is 0.156 1/m at the sag bend, 72 m from the hang-off, and 0.109 1/m at the touchdown. On the former 87-element mesh (10 m elements along the laid section) the peak was 0.160 1/m and the touchdown curvature 0.075 1/m, under-resolved by about 30 %. These curvatures were recorded before the `Curv` channels took the curvature recovered from nodal equilibrium: they are the geometric curvature of the centreline (the larger one-sided trace at a node), which `OutputRecovery element` reproduces. The chain-only twin of the run matches stock MoorDyn over 1200 s to 0.3 % in platform motion and fairlead tension statistics. The anchor tension of the laid cable stays at its static 1.23 kN (maximum 1.24 kN): the seabed friction of the 370 m laid section holds the tension changes at the touchdown. On the former mesh it read 1.39 kN (median) with wave-frequency stick-slip peaks up to 4.1 kN lasting under 1 s, which the resolved mesh does not show, and before the anchor-end correction of this release it locked at about 2.75 kN for the whole run. The run takes 27.1 min of wall time (18.8 min on the former mesh) | | `WaterKin` from file | Pass verified | See [WaterKin and SeaState modes](#waterkin-and-seastate-modes) | | Syrope polyester (`SYROPE:` syntax; [Falkenberg et al., 2017](https://cabledyn.readthedocs.io/en/latest/references.html#ref-falkenberg2017)) | Pass verified | MoorDyn-F/C `BA_s|BA_d` rate and force equations; analytic position/velocity tangents with finite-difference checks; projected, bracketed backward-Euler slow-state update with a strong-unloading boundary test; OWC running maximum; `SYROPE IC` `Tmax0/Tmean0` history with range/order checks; both states carried through every lifecycle stage and the coupled checkpoint. `BA_s` is kept separate from line axial damping (`BA`) and tested against double counting. Composite, hydrodynamic, finite-EI, current, and wave combinations stop with a named error | | VIV (`compVIV`) | Not supported | outside CableDyn's scope | @@ -864,7 +864,7 @@ in parentheses). orientation and twisted 1 to 5 turns at the hang-off. Against OrcaFlex at 0.375 m segments, the hang-off torque agrees to ≤0.019%, the geometric twist `Θ` to ≤1.8e-4 turn per imposed turn (`Θ` = 0.188 turn at 5 turns, so the torque is 3.8% below `GJ Φ/L`), the peak interior - curvature to ≤0.056% (0.1197 against 0.1196 1/m at 5 turns), the out-of-plane offset to ≤27 mm + curvature to ≤0.049% (0.1197 against 0.1196 1/m at 5 turns), the out-of-plane offset to ≤27 mm of 6.8 m and the hang-off tension to ≤0.091%. The torque is uniform along the line. At zero twist the restrained deck reproduces the same cable without torsion columns (positions identical, tensions to 1.1e-8), the zero-twist parity case. diff --git a/app/cabledyn.f90 b/app/cabledyn.f90 index 1f20b569..8cf7357d 100644 --- a/app/cabledyn.f90 +++ b/app/cabledyn.f90 @@ -772,7 +772,7 @@ END SUBROUTINE write_mixed_header SUBROUTINE write_mixed_row(unit, time, aggregate, stat, msg) INTEGER, INTENT(IN) :: unit REAL(wp), INTENT(IN) :: time - TYPE(CD_AGG_ModuleType), INTENT(IN) :: aggregate + TYPE(CD_AGG_ModuleType), INTENT(INOUT) :: aggregate INTEGER, INTENT(OUT) :: stat CHARACTER(*), INTENT(OUT) :: msg INTEGER :: i, ios diff --git a/doc/conventions.rst b/doc/conventions.rst index 7de88530..5b5b8b80 100644 --- a/doc/conventions.rst +++ b/doc/conventions.rst @@ -137,12 +137,15 @@ Tension definitions - CableDyn models lines as solid members with no internal contents, and applies buoyancy as a distributed load (the Archimedes resultant of the pressure field), not as a pressure term in the tension. Under this convention the **reported tension is the effective tension**, - :math:`T_e = EA\,\varepsilon` plus any axial damping or constitutive-state contribution. This - is the quantity in the interior node tension channels, and the quantity compared with - OrcaFlex effective tension in :doc:`validation`. Node tensions are segment tensions: the mean - of the two neighbouring element tensions (on a finite-EI line, the element-mean axial forces - weighted by element length), like OrcaFlex mid-segment tension. The continuous element field - is reported separately in ``.elements.out``. ``FairTen``, ``AnchTen``, and the end-node + :math:`T_e = EA\,\varepsilon` plus any axial damping or constitutive-state contribution on an + ``EI = 0`` line, and the axial component :math:`\mathbf{F}\cdot\mathbf{t}` of the section + force recovered from nodal equilibrium on a finite-EI line, which differs from + :math:`EA\,\varepsilon` by :math:`EI\kappa^2` (:ref:`theory-output-recovery`). This is the + quantity in the interior node tension channels, and the quantity compared with OrcaFlex + effective tension in :doc:`validation`. On an ``EI = 0`` line node tensions are segment + tensions, the mean of the two neighbouring element tensions, like OrcaFlex mid-segment tension. + The continuous element field :math:`EA\,\varepsilon` of a finite-EI line is reported + separately in ``.elements.out``. ``FairTen``, ``AnchTen``, and the end-node tension channels report the line-end force instead: the actual force on the attachment, the end element force (axial damping included) plus the end node's share of weight, seabed contact, and drag at the actual velocity, without the end node's inertia (:doc:`outputs`). diff --git a/doc/driver_format.md b/doc/driver_format.md index 944eb78f..105bf385 100644 --- a/doc/driver_format.md +++ b/doc/driver_format.md @@ -1006,6 +1006,7 @@ syntax form. The most frequently edited keywords are: | `cable_load_feedback` | coupled finite-EI cable reaction switch. `True` returns cable force and moment to the host. `False` marches the cable with the same moving boundary and host fluid field and keeps its output channels, but returns zero force and moment; use it for a one-way comparison, not as a physical model | `True` | | `adaptive_mesh` | `True`/`False`; allow finite-EI mesh refinement when the static resolution check is fragile | `False` | | `cable_statics` | `continuation` or `sequenced`: which finite-EI static route runs first (the other is its fallback); both results are audited | `continuation` | +| `OutputRecovery` / `output_recovery` | `equilibrium` or `element`: definition of the finite-EI node tension, curvature, bend moment and segment tension. `equilibrium` recovers them from nodal equilibrium (the effective tension F·t, the moment the neighbouring elements carry, curvature = moment / EI); `element` reports the length-weighted element-mean axial force EA(\|r'\| − 1), the larger one-sided exact curvature, and the element-midpoint axial resultant as segment tension. End forces, positions and TDP channels are the same under both | `equilibrium` | | `alpha_force_blend` | `True`/`False`; generalised-α blend of the finite-EI and `EI = 0` dynamics: forces (`True`) or the configuration `q_αf` (`False`), which biases the mean tension of a rotating finite-EI line at large `dtM` and lets `EI = 0` segments that go slack report spurious tension spikes | `True` | | `tensile_safety` | `False`, `warn`, or `True`; audits the element-mean axial force (three-point Gauss mean of the signed axial resultant, averaged over an element and its two neighbours). `True` rejects. `warn` commits the state, counts accepted-step events, and reports the worst force, threshold, element and time (the printed `xi` is always 0.5, the element centre) | `False` | | `tensile_strain_tolerance` | non-negative strain band for the dynamic tensile audit | `2e-6` | @@ -1227,6 +1228,8 @@ bending moment. None of these channels is mandatory. |---------|---------|------| | `FairTen` | line L fairlead (End A) line-end tension: the magnitude of the force the line actually exerts on its End-A point (end element force with axial damping, including the bending shear of a finite-EI line, plus the end node's share of the submerged weight, seabed contact and drag at the actual velocity; without the end node's inertia), the static end reaction at rest. Route differences (seabed friction, the two-moving-end route) are in [Outputs](outputs.rst) | N | | `AnchTen` | line L anchor (End B) line-end tension, as `FairTen` | N | +| `AnchFz` | line L vertical component of the `AnchTen` end force, positive upward (the line lifts its End-B point). Not available on the two-moving-end finite-EI route, which rejects it by name | N | +| `AnchFH` | line L horizontal magnitude of the `AnchTen` end force (same availability as `AnchFz`) | N | | `FairIncl` | line L fairlead (End A) signed inclination below horizontal (0 = horizontal; positive = downward) | deg | | `AnchIncl` | line L anchor (End B) signed inclination below horizontal (0 = horizontal; positive = downward) | deg | | `FairDecl` | line L fairlead (End A) declination from +GZ (0 = up, 90 = horizontal, 180 = down) | deg | @@ -1236,18 +1239,19 @@ bending moment. None of these channels is mandatory. | `Con

p{x,y,z}` | alias of `Point

p{x,y,z}` (MoorDyn v1 spelling) | m | | `Body…`, `Rod…` | Rigid6 body and rod channels in the MoorDyn-F names: position, attitude, velocity and acceleration (`P`, `R`, `V`, `RV`, `A`, `RA`), net force and moment (`F`, `M`), rod end tensions (`TenA`, `TenB`), submerged fraction (`Sub`) and rod node positions (`RodNP`). Available on every route that carries bodies or rods, OpenFAST included; the full list and units are in [Outputs](outputs.rst) | see Outputs | | `Point

F{x,y,z}`, `Point

FH` | resultant of the line-end and cable end forces on point P (each the `FairTen`/`AnchTen` end force): the anchor load of a Fixed point shared by several lines, the line load a free point balances; `FH` is its horizontal magnitude. Available on every route (static, `EI = 0`, finite-EI, multibody and OpenFAST) except the two-moving-end finite-EI route, which rejects it by name | N | -| `TenN` | line L tension at node J (interior nodes average the adjacent elements; end nodes report the line-end force of `FairTen`/`AnchTen`) | N | -| `CurvN` | line L geometric curvature at node J. `EI = 0` lines: circle through the node and its two neighbours (end nodes take the adjacent interior value). Cubic-Hermite lines: exact curvature of the continuous centreline, the larger one-sided element value at an interior node | 1/m | -| `BendMomN` | line L bend moment = EI × curvature **relative to the stress-free reference shape** (≈ 0 at the reference; equals EI × geometric curvature because the finite-EI reference is straight; 0 on EI = 0 lines) | N·m | +| `TenN` | line L effective tension at node J. EI = 0 lines: the mean of the two adjacent segment tensions. Finite-EI lines: the axial component of the section force recovered from nodal equilibrium (`OutputRecovery element`: the length-weighted mean of the adjacent element-mean axial forces). End nodes report the line-end force of `FairTen`/`AnchTen` | N | +| `CurvN` | line L curvature at node J. `EI = 0` lines: geometric curvature of the circle through the node and its two neighbours (end nodes take the adjacent interior value). Cubic-Hermite lines: `BendMomN` / EI, the larger of the two sides at a section junction (`OutputRecovery element`: exact curvature of the continuous centreline, the larger one-sided element value at an interior node) | 1/m | +| `BendMomN` | line L bend moment = EI × curvature **relative to the stress-free reference shape** (≈ 0 at the reference; the finite-EI reference is straight). Finite-EI lines: recovered from nodal equilibrium, the moment the neighbouring elements carry (`OutputRecovery element`: EI × the larger one-sided exact curvature); 0 on EI = 0 lines | N·m | | `LNp{x,y,z}` | line L node J position component | m | | `LNv{x,y,z}` | line L node J velocity component (0 in static-only runs) | m/s | | `LNa{x,y,z}` | line L node J acceleration component (0 in static-only runs) | m/s² | | `LNDec` | line L declination of the axial tangent at node J (from +GZ; 0 = up, 90 = horizontal, 180 = down) | deg | | `LNAzi` | line L azimuth of the axial tangent at node J (from +GX toward +GY, in [0, 360)) | deg | -| `TDPs` | line L touchdown point (TDP): arc length from End A, interpolated between the last grounded node and the next where the centreline crosses the contact-onset height (1e-6 m above the seabed) | m | +| `TDPs` | line L touchdown point (TDP): arc length from End A, between the last grounded node and the next, where the parabola through the last grounded node and the next two nodes crosses the contact-onset height (1e-6 m above the seabed); continuous as nodes ground and lift off ([Outputs](outputs.rst)) | m | | `TDPx`, `TDPy`, `TDPz` | line L TDP position | m | | `TDPLay` | line L layback: horizontal distance from the TDP to the suspended end | m | | `TDPExc` | line L TDP excursion: horizontal TDP displacement from its initial position, along the initial direction toward the suspended end | m | +| `TDPGrd` | line L grounded length: deformed chord length along the nodes from the grounded end to the TDP; continuous with the TDP, 0 only when nothing touches (the grounded end has lifted off) | m | | `TorqN` | line L torque at node J (uniform along the line); positive for a right-handed twist of End B relative to End A about the End A → End B tangent. Only on a line restrained in torsion at both ends | N·m | | `TwistN` | line L material twist accumulated from End A to node J, `M × Σ L/GJ` over the elements in between; 0 at End A, without the end-spring windup. Only on a line restrained in torsion at both ends | deg | | `Twist` | line L total twist `Phi − Theta = M C`, end-spring windup included. Only on a line restrained in torsion at both ends | deg | @@ -1265,6 +1269,11 @@ bending moment. None of these channels is mandatory. - `TDP` channels need a seabed (`WtrDpth` or `bathymetryFile`) and a line that rests on the seabed at exactly one end in its initial state; otherwise the run stops with exit code 1 naming the line. They are available on every route, OpenFAST included. +- The anchor uplift check of a drag-embedment anchor (no vertical load at the anchor in the + intact condition) reads `TDPGrd` (greater than a small tolerance such as 0.01 m + throughout); `AnchFz` is the vertical anchor load. On an `EI = 0` line it includes the + anchor node's lumped weight, so its sign change lags the anchor segment's lift-off; see + [Outputs](outputs.rst) (Anchor uplift). - In an OpenFAST `CompMooring = 5` run, channel headers in the OpenFAST output and in `.CD.out` use OpenFAST's 20-character width (`ChanLen`). A longer channel name stops coupled initialisation with an error naming the channel; keep coupled channel names diff --git a/doc/modeling.rst b/doc/modeling.rst index b68537c8..2ce56278 100644 --- a/doc/modeling.rst +++ b/doc/modeling.rst @@ -92,10 +92,13 @@ section change, keep the element length at most half the bending length power cable with :math:`EI = 2\times10^4` N m² and :math:`w = 158` N/m that is 2.5 m. A longer element cannot follow the bend: it stays stiff in bending, and its stiff axial term absorbs the mismatch, so the pointwise axial force oscillates about the element mean, by tens of kN on a -lazy wave of 1–2 kN tension at 10 m elements. The ``.t.out`` segment tensions, evaluated at the -element midpoints, show these spikes and negative values near touchdown and at section changes; -they shrink as the mesh is refined, and the element-mean force (what enters equilibrium, see -``tensile_safety`` in :doc:`theory`) is far smoother. The compressed Gauss points also lower the +lazy wave of 1–2 kN tension at 10 m elements. The tension outputs (node ``Ten`` channels, +``.t.out`` segment tensions) are recovered from the element end forces and do not carry it (see +Node tension, curvature and bend moment in :doc:`theory`); under ``OutputRecovery element`` the +``.t.out`` segment tensions, evaluated at the element midpoints, show these spikes and negative +values near touchdown and at section changes. They shrink as the mesh is refined, and the +element-mean force (what the material-strain checks judge, see ``tensile_safety`` in +:doc:`theory`) is far smoother. The compressed Gauss points also lower the out-of-plane stiffness: a line solved in 3D (restrained in torsion, or with an end connection direction or a current out of its vertical plane) can read as an unstable equilibrium on such a mesh. The static solve then refines that state to the rule above, whichever route reached it and diff --git a/doc/openfast.rst b/doc/openfast.rst index 2d7b6870..c8cfbe3b 100644 --- a/doc/openfast.rst +++ b/doc/openfast.rst @@ -140,7 +140,8 @@ closed by ``END`` — not in the ``.fst`` ``OutList``: END The channel vocabulary (tensions, end angles, node tension, curvature, bend moment, position, -velocity, acceleration, declination, azimuth) and units are in :doc:`outputs`. +velocity, acceleration, declination, azimuth, the touchdown point, and the anchor uplift +channels ``AnchFz``, ``AnchFH`` and ``TDPGrd``) and units are in :doc:`outputs`. .. list-table:: :header-rows: 1 diff --git a/doc/options.rst b/doc/options.rst index 6129c06d..27253d99 100644 --- a/doc/options.rst +++ b/doc/options.rst @@ -410,6 +410,21 @@ Finite-EI cable controls tolerance (see :doc:`theory`) - both (finite-EI lines) - ``sequenced cable_statics`` + * - ``OutputRecovery`` / ``output_recovery`` + - mode + - ``equilibrium`` + - definition of the finite-EI node outputs (``Ten``, ``Curv``, ``BendMom`` channels, the + static-profile and range-graph columns, ``.t.out`` segment tensions). + ``equilibrium`` recovers them from nodal equilibrium: the effective tension + :math:`\mathbf F\cdot\mathbf t`, the moment the neighbouring elements carry, and + curvature = moment / ``EI`` (see :ref:`theory-output-recovery`). ``element`` reports the + length-weighted element-mean axial force :math:`EA(\lvert\mathbf r'\rvert - 1)`, the + larger one-sided exact curvature, and the axial resultant at the element midpoint as the + segment tension, the definitions up to CableDyn 0.1.1. End forces, positions, ``TDP`` + channels and the material-strain checks (``tensile_safety``, compression notes) are the + same under both + - both (finite-EI lines) + - ``element OutputRecovery`` * - ``axial_quadrature_order`` / ``axialquadratureorder`` / ``axial_quadrature`` - integer, – - ``4`` diff --git a/doc/outputs.rst b/doc/outputs.rst index f4e411a5..9f06152e 100644 --- a/doc/outputs.rst +++ b/doc/outputs.rst @@ -214,7 +214,7 @@ on every route: - node position in the global frame (Z up, ``Z = 0`` at the still-water line) * - ``Tension`` - ``(N)`` - - nodal effective tension, the segment tension (same definition as ``TenN``) + - nodal effective tension (same definition as ``TenN``) * - ``Curvature`` - ``(1/m)`` - nodal curvature (same definition as ``CurvN``) @@ -236,15 +236,19 @@ Plot ``Curvature`` or ``Tension`` against ``ArcLength`` for a fatigue or strengt .. note:: - Node tensions are segment tensions; ``.elements.out`` holds pointwise field values. On a - finite-EI line the ``Tension`` column and ``TenN`` report, at an interior node, the - length-weighted average of the element-mean axial forces of the two neighbouring elements - (the tension that enters equilibrium, as the segment tension of an ``EI = 0`` line). The - ``MinimumAxialResultant`` and ``MaximumAxialResultant`` columns of ``.elements.out`` are - extrema of the pointwise field :math:`EA\,(|\mathbf r'| - 1)`. With a stiff ``EA`` that - field oscillates about the element mean wherever an element cannot follow the line -- at a - nodal seabed-contact kink near touchdown and at a section junction -- and can dip below - zero there while the line is tensile. Curvature and bend moment are pointwise in both files. + On a finite-EI line the ``Tension``, ``Curvature`` and ``BendMoment`` columns and the + ``Ten``/``Curv``/``BendMom`` channels are recovered from nodal equilibrium + (:ref:`theory-output-recovery`): the effective tension :math:`\mathbf F\cdot\mathbf t` + is the axial component of the section force that balances the loads, and the bend moment + is the moment the elements on either side of the node carry. ``.elements.out`` holds the + pointwise element fields instead: the ``MinimumAxialResultant`` and + ``MaximumAxialResultant`` columns are extrema of the material axial force + :math:`EA\,(|\mathbf r'| - 1)`, which exceeds the effective tension by + :math:`EI\kappa^2` and, with a stiff ``EA``, oscillates about the element mean wherever an + element cannot follow the line -- at a nodal seabed-contact kink near touchdown and at a + section junction -- and can dip below zero there while the line is tensile. ``OPTIONS`` + ``OutputRecovery element`` reports the element definitions in the node columns and channels + (:doc:`options`). ``.elements.out`` — Hermite element extrema ----------------------------------------------------- @@ -322,7 +326,9 @@ channels instead) and accept ``r``. - node positions, End A → End B * - ``t`` - ``.Line.t.out`` - - segment (element) tensions, End A → End B + - segment (element) tensions, End A → End B; on a finite-EI line the mean of the axial + components of the element's own two equilibrium end forces (``OutputRecovery element``: + the axial resultant at the element midpoint) * - ``r`` - ``.Line.range.out`` - range graph: minimum, maximum and mean over the run of the node tension, curvature, bend @@ -493,8 +499,18 @@ Line-end channels - line-end tension at End B (anchor) of line ``L``, defined as for ``FairTen``. On a grounded run it is close to the horizontal tension. A ``Fixed`` anchor at the seabed depth sits slightly above the grounded chain, which sinks into the penalty seabed, so the - anchor also carries part of its end node's weight (for example 192.4 kN against a - horizontal tension of 191.5 kN in :doc:`tutorial_catenary`) + anchor also carries its end node's weight (for example 192.4 kN against a horizontal + tension of 191.5 kN in :doc:`tutorial_catenary`; see `Anchor uplift`_) + - N + * - ``AnchFz`` + - vertical component of the ``AnchTen`` end force, the force line ``L`` exerts on its + End-B point: positive upward (the line lifts the anchor), negative downward. On every + route that reports ``AnchTen`` except the two-moving-end finite-EI route, which rejects it + by name; for an anchor that holds one line it equals ``Point

Fz`` + - N + * - ``AnchFH`` + - horizontal magnitude of the same end force, :math:`\sqrt{F_x^2 + F_y^2}`, with the same + availability; for an anchor that holds one line it equals ``Point

FH`` - N * - ``FairIncl`` / ``AnchIncl`` - signed inclination of the End-A / End-B tangent below horizontal @@ -510,6 +526,50 @@ Line-end channels A grounded anchor segment reads ``AnchIncl ≈ 0``; the small non-zero value reports the actual orientation of the last element, which CableDyn does not force to horizontal. +Anchor uplift +~~~~~~~~~~~~~ + +A drag-embedment anchor is designed for a horizontal pull and loses holding capacity under a +vertical one, so design practice for catenary moorings (DNV-OS-E301, API RP 2SK) requires no +vertical uplift at the anchor in the intact condition: some chain stays laid on the seabed. The +primary check for line ``L`` is the grounded length: + +* the minimum of ``TDPGrd`` (`Touchdown channels`_) over the run is greater than a small + tolerance (0.01 m is a centimetre, far below an element). ``TDPGrd`` is continuous with + the touchdown point, so an anchor node held on the seabed beside a node a few millimetres + clear of it reads micrometres to millimetres, not exactly 0. ``AnchIncl`` departing from 0 + (the anchor segment rising from the seabed) shows the same onset. + +``AnchFz`` is the anchor reaction itself (equal to ``Point

Fz`` of a one-line anchor), the +quantity to compare with the anchor's vertical capacity. It is not an exact uplift indicator on +an ``EI = 0`` line: the reaction includes the anchor node's lumped weight (below), so it stays +negative for a while after the anchor segment starts to lift and turns positive only once the +line's pull exceeds that weight. When a surge pulls the chain off its anchor the sign change +lags the grounded length reaching 0 (by under a second in the regression suite's surge case), +so ``max AnchFz <= 0`` alone can pass a run in which the anchor segment already lifts by an +angle of order :math:`w\,\Delta L/(2H)`. Use ``TDPGrd`` (or ``AnchIncl``) for the +no-uplift criterion and ``AnchFz`` for the vertical load. + +On a laid ``EI = 0`` line ``AnchFz`` is a small negative value, not 0. The anchor node of a +``Fixed`` point at the seabed depth is held at the seabed elevation, while the penalty seabed +lets the grounded line sink by :math:`\delta = w/(k_\text{Bot}\,d)` (:math:`w` the submerged +weight per unit length, :math:`d` the line diameter, see :doc:`conventions`). The anchor +therefore carries the end node's lumped submerged weight, :math:`w\,\Delta L/2` for an anchor +segment of unstretched length :math:`\Delta L`, and the downward pull of the anchor segment +toward the sunk line, about :math:`H\delta/\Delta L` for a horizontal tension :math:`H`: + +.. math:: + + \mathtt{AnchFz} \approx -\left(\frac{w\,\Delta L}{2} + \frac{H\,\delta}{\Delta L}\right). + +In :doc:`tutorial_catenary` (:math:`w` = 3.18 kN/m, :math:`\Delta L` = 10 m, +:math:`\delta` = 0.13 m) this estimate is −18.4 kN, and the run reports ``AnchFz1`` = −18.2 kN +beside ``AnchFH1`` = 191.5 kN (the horizontal tension) and ``AnchTen1`` = 192.4 kN. The share +belongs to the lumped anchor node: it scales with the anchor segment length, vanishes as the mesh +is refined, and is not uplift. A finite-EI (cubic-Hermite) end resting on the seabed leaves its +end node's weight to the floor and reads ``AnchFz`` = 0 there. Read the vertical anchor load from +``AnchFz``, not from the difference between ``AnchTen`` and ``AnchFH``. + Line-node channels ~~~~~~~~~~~~~~~~~~ @@ -521,23 +581,38 @@ Line-node channels - Meaning - Unit * - ``TenN`` - - effective tension at node ``J``: an interior node takes the mean of its two neighbouring - element (segment) tensions -- on a finite-EI line their element-mean axial forces, - weighted by element length; an end node reports the line-end force of ``FairTen`` / - ``AnchTen``. On the two-moving-end finite-EI route every value is the chord-stretch - tension of ``FairTen`` there: the adjacent element at an end node and the unweighted - mean of the two neighbouring elements at an interior node + - effective tension at node ``J``. ``EI = 0`` lines: an interior node takes the mean of + its two neighbouring element (segment) tensions. Finite-EI lines: the axial component + :math:`\mathbf F\cdot\mathbf t` of the section force recovered from nodal equilibrium, + the mean of the end forces of the two neighbouring elements, each with its own + distributed loads and inertia (:ref:`theory-output-recovery`); ``OutputRecovery + element``: the length-weighted mean of the element-mean axial forces + :math:`EA(|\mathbf r'| - 1)`. An end node reports the line-end force of ``FairTen`` / + ``AnchTen``, the end reaction on the support or platform, which excludes inertia, added + mass and seabed friction (the interior values are the recovered section force, whose + element end forces include inertia and added mass). On the two-moving-end finite-EI route + every value is the chord-stretch tension of ``FairTen`` there: the adjacent element at an + end node and the unweighted mean of the two neighbouring elements at an interior node - N * - ``CurvN`` - curvature at node ``J``. ``EI = 0`` lines: discrete curvature of the circle through the node and its two neighbours (end nodes take the adjacent interior value). - Cubic-Hermite lines: exact curvature of the continuous centreline, taking the larger of - the two one-sided element values at an interior node + Cubic-Hermite lines: ``BendMomN`` / ``EI``, the larger of the two sides at a + section junction, and the exact geometric curvature where ``EI`` is below + ``max(|w| L0^2)/12`` times 1 m (:ref:`theory-output-recovery`) (``OutputRecovery + element``: exact curvature of the continuous + centreline, the larger of the two one-sided element values at an interior node). The + library routines ``CD_HermiteCable_Dyn_Curvature`` and ``CD_HFMF_Curvature`` return the + same value; ``CD_HermiteCable_Dyn_Curvature_Exact`` and ``CD_HFMF_Curvature_Exact`` the + exact geometric traces - 1/m * - ``BendMomN`` - - bend moment ``EI × κ`` measured relative to the stress-free reference shape. The - cubic-Hermite reference is straight, so there it equals ``EI × CurvN`` - (larger one-sided value at an interior node); 0 on ``EI = 0`` lines + - bend moment ``EI × κ`` measured relative to the stress-free reference shape (the + cubic-Hermite reference is straight). Finite-EI lines: the component normal to the tangent + of the moment recovered from nodal equilibrium, the mean of the two neighbouring elements + (one-sided at a line end, where it is the end connection moment); + ``OutputRecovery element``: ``EI`` times the larger one-sided exact curvature. 0 on + ``EI = 0`` lines - N·m * - ``LNpx`` / ``py`` / ``pz`` - node position component @@ -578,9 +653,16 @@ Touchdown channels For a line that rests on the seabed at one end, the touchdown point (TDP) at every output time. A node is grounded when its centreline is at most 1e-6 m (the height at which the seabed contact law engages) above the seabed; the grounded end is the end grounded in the initial state. Walking -from that end, the TDP lies between the last grounded node and the next one, where the centreline -crosses that height (linear interpolation of the clearance). The definitions are those of -:func:`cabledyn.touchdown_history` with ``tolerance = 1e-6``. +from that end, the TDP lies between the last grounded node and the next one, where the parabola +through the last grounded node and the next two nodes (clearance against chord arc) crosses that +height, the crossing nearest the suspended node; the TDP sits on that height. With fewer than two +suspended nodes, or no crossing inside the element, the clearance is interpolated linearly. The +crossing reaches a node exactly when the node reaches the onset height, so the TDP moves +continuously as nodes ground and lift off, and between nodes it follows the lift-off of the line +instead of resting on the last grounded node until the next one grounds: on a 450 m cable with +5 m elements in a 10 m surge the largest step between output rows falls from 4.6 m (a whole +element) to 0.08 m, and the error against a 1 m mesh from 3.0 m to 1.9 m. The definitions are +those of :func:`cabledyn.touchdown_history` with ``tolerance = 1e-6``. .. list-table:: :header-rows: 1 @@ -603,12 +685,21 @@ crosses that height (linear interpolation of the clearance). The definitions are projected on the initial horizontal direction from the TDP to the suspended end (positive toward the suspended end) - m + * - ``TDPGrd`` + - grounded length: deformed chord length along the nodes from the grounded end to the TDP + (``TDPs`` measured from the grounded end instead of End A). It varies continuously with + the TDP: it grows from 0 as the TDP leaves the grounded end node, so a line whose + neighbour of the anchor is just above the seabed reads a fraction of the first element, and + it is 0 only when nothing touches (the grounded end node itself is off the seabed, or the + TDP sits at that node). The whole line length when every node is grounded + - m The channels are available on every route, OpenFAST included, when the deck has a seabed (``WtrDpth`` or ``bathymetryFile``). A line whose initial state is grounded at both ends or at neither stops the run with exit code 1 naming the line. When the grounded end later lifts off, -the channels report that end node; when the whole line rests on the seabed, the suspended end -node. +the channels report that end node (and ``TDPGrd`` reads 0); when the whole line rests on the +seabed, the suspended end node. ``TDPGrd`` is the grounded length of the `Anchor uplift`_ +check. Point channels ~~~~~~~~~~~~~~ @@ -708,8 +799,8 @@ with exit code 1. A name is rejected when: * it matches none of the forms above, or carries trailing text (``Point2px_raw``, ``Point2pzz``, ``FairTen1x``); * it references an unknown line or point id, or a node number larger than the line's node - count, or is a ``TDP`` name with a suffix other than ``s``, ``x``, ``y``, ``z``, ``Lay`` or - ``Exc``; + count, or is a ``TDP`` name with a suffix other than ``s``, ``x``, ``y``, ``z``, ``Lay``, + ``Exc`` or ``Grd``; * it is a ``TorqN``, ``TwistN`` or ``Twist`` channel of a line that is not restrained in torsion at both ends (``... carries no torque``); * on a mixed ``EI = 0`` + finite-EI deck (and in OpenFAST), it is a ``Point

`` channel of a diff --git a/doc/python.rst b/doc/python.rst index c6def699..276ce877 100644 --- a/doc/python.rst +++ b/doc/python.rst @@ -832,7 +832,8 @@ state at the time of the call through the same evaluator as the deck ``OUTPUTS`` length and the end tensions; ``Point`` its position, velocity and the resultant line force; ``Body`` its pose, velocity, acceleration and net wrench about the reference point; ``Rod`` its node positions, End A pose, velocity and wrench. :meth:`~cabledyn.CableDyn.channel` evaluates -any ``OUTPUTS`` token (``L2N5px``, ``Curv1N3``, ``Point4Fz``, ``Body1Pz``, ``Rod2TenA``, ...). +any ``OUTPUTS`` token (``L2N5px``, ``Curv1N3``, ``Point4Fz``, ``AnchFz1``, ``Body1Pz``, +``Rod2TenA``, ...). Views are cheap and hold no state; re-initialising or closing the model makes them stale, and a stale view raises :class:`cabledyn.CableDynError`. diff --git a/doc/python_postprocessing.rst b/doc/python_postprocessing.rst index c9bd0a82..5f041ba0 100644 --- a/doc/python_postprocessing.rst +++ b/doc/python_postprocessing.rst @@ -396,13 +396,18 @@ Touchdown time histories every output time, from a CableDyn ``.Line.p.out`` file, a MoorDyn-F line file, or the ``LNpx``/``py``/``pz`` channels of a main output. A node is grounded as in :meth:`~cabledyn.LineGeometry.touchdown`. Between the last grounded node and the next, the TDP is -placed where the chord crosses ``seabed_z + tolerance``. The :class:`~cabledyn.TouchdownHistory` +placed where the parabola through the last grounded node and the next two nodes crosses +``seabed_z + tolerance`` (the crossing nearest the suspended node; the chord crossing when there +is none), so it moves continuously as nodes ground and lift off. The :class:`~cabledyn.TouchdownHistory` holds the TDP arc length from End A, its coordinates, the layback, and two excursions from a reference TDP (a static profile, or the first sample): the horizontal excursion, positive towards the suspended end, and the arc-length excursion. Samples without a touchdown are ``nan``. The driver computes the same quantities during the run as the ``TDPs``/``x``/``y``/``z``/ ``Lay``/``Exc`` channels (see :doc:`outputs`), with ``tolerance`` equal to the contact-onset -height of 1e-6 m. +height of 1e-6 m. Its ``TDPGrd`` channel adds the grounded length from the grounded end to the +TDP (with End B grounded, the deformed line length less the TDP arc length). It varies continuously +with the TDP and is 0 only when the grounded end node itself is off the seabed or the TDP sits at +that node, for the anchor uplift check. .. code-block:: python diff --git a/doc/theory.rst b/doc/theory.rst index c71717d6..20a6de90 100644 --- a/doc/theory.rst +++ b/doc/theory.rst @@ -107,8 +107,9 @@ strain energy \quad \mathbf{a} = \mathbf{r}',\ \mathbf{b} = \mathbf{r}'' . Using :math:`\kappa^2` directly, rather than :math:`\kappa`, keeps the energy smooth through -the straight state. The stress-free reference is straight, and the reported bending moment is -:math:`M = EI\,\kappa`. +the straight state. The stress-free reference is straight, and the bending moment is +:math:`M = EI\,\kappa`; the node outputs recover it from nodal equilibrium +(:ref:`theory-output-recovery`). At each Gauss point, :math:`\mathbf{a}` and :math:`\mathbf{b}` are fixed linear maps of the 12 element DOFs. The gradient and Hessian of the energy density with respect to @@ -139,6 +140,138 @@ The element follows the geometrically exact Kirchhoff-rod formulation of interpolation of :ref:`Meier, Popp & Wall (2015) `, reduced to a torsion-free cable. Torsion enters only through the condensed line term below. +.. _theory-output-recovery: + +Node tension, curvature and bend moment +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + +**Section force.** For the energy density :math:`W(\mathbf{a}, \mathbf{b})` of the element, the +force across a section (exerted by the part of the line beyond :math:`s` on the part before it) +and the conjugate of the material tangent are + +.. math:: + + \mathbf{F} = \frac{\partial W}{\partial \mathbf{a}} - \left(\frac{\partial W}{\partial \mathbf{b}}\right)', + \qquad + \mathbf{m} = \frac{\partial W}{\partial \mathbf{b}} + = EI\,\frac{(\mathbf{a}\times\mathbf{b})\times\mathbf{a}}{\lvert\mathbf{a}\rvert^{6}} . + +On a stiff-``EA`` cable :math:`\lvert\mathbf{a}\rvert = 1 + \varepsilon` with +:math:`\varepsilon \ll 1`, :math:`\mathbf{a}\cdot\mathbf{b} = O(\varepsilon)` and +:math:`\mathbf{b} = \kappa\,\mathbf{n}`, so that +:math:`\partial W/\partial\mathbf{a} = (EA\,\varepsilon - 2EI\kappa^2)\,\mathbf{t}` plus normal +terms, :math:`\mathbf{m} = EI\,\kappa\,\mathbf{n}`, and +:math:`(\partial W/\partial\mathbf{b})'\cdot\mathbf{t} = EI\,\mathbf{b}'\cdot\mathbf{t} = -EI\kappa^2`. +The axial internal force of the rod, the effective tension that balances the loads, and the +bend moment are therefore + +.. math:: + + N = \mathbf{F}\cdot\mathbf{t} = EA\,\varepsilon - EI\,\kappa^2, + \qquad + M = \lvert \mathbf{m} - (\mathbf{m}\cdot\mathbf{t})\,\mathbf{t} \rvert = EI\,\kappa . + +The bending energy measures the curvature per deformed length, and its dependence on the +stretch puts :math:`-EI\kappa^2` into the axial force: :math:`EA(\lvert\mathbf{r}'\rvert - 1)` +is a formulation quantity, not the tension, and exceeds :math:`N` by :math:`EI\kappa^2` on any +mesh (161 N on a 1.2 kN tension at the sag bend of the lazy-wave cable of +``iea15mw_umaine_mixed_cabledyn.dat``, :math:`\kappa = 0.09` 1/m). Global equilibrium fixes +:math:`N` whatever the formulation: on a suspended run the horizontal component of +:math:`\mathbf{F}` is constant and the vertical one changes by the submerged weight, so :math:`N` +is what any code converges to, the OrcaFlex effective tension and the MoorDyn segment tension +on a fine mesh among them. + +**Pointwise oscillation.** With a stiff ``EA`` the cubic interpolation cannot keep +:math:`\lvert\mathbf{r}'\rvert` constant where the line must bend over an element (a nodal +seabed reaction, a section junction): the pointwise axial resultant oscillates about the element +mean by several times the tension, and the element means alternate between neighbours. On that +cable on the example's former 87-element mesh (10 m on the grounded run, tension 1.2 kN) the +pointwise resultant spans -41.5 to +91.8 kN and the length-weighted element means at the nodes +reach -173 N; at 1 m elements the pointwise field still spans -5.9 to +11.9 kN. + +**Recovery from nodal equilibrium.** The node outputs are recovered from the element end +forces, the classical recovery of the finite-element nodal forces. For element :math:`e` the +end residual + +.. math:: + + \mathbf{g}_e = \mathbf{f}_{\text{int},e} + \mathbf{f}_{\text{damp},e} - \mathbf{f}_{\text{ext},e} + + \mathbf{M}_e\,\mathbf{a}_e + +holds only the element's own distributed loads: consistent submerged weight, the buoyancy lost +above the free surface, drag, Froude-Krylov force, structural and added-mass inertia, and the +seabed reaction of its end nodes, each nodal reaction spread uniformly over the node's tributary +length (the distributed floor reaction it stands for; without it a line resting on the floor +would report the fixed-end moment :math:`w L_0^2/12` of its own weight; at a held line end whose +end element lies on the floor, the reaction of the end half is the floor-support share of the +weight, the share that the static and dynamic residuals carry on the end tangent rows). +:math:`\mathbf{g}_e` +is the generalised force the two end nodes exert on the element: its position rows at the +End-B side of the internal arc are the section force :math:`\mathbf{F}_j^-` just before node +:math:`j`, minus its rows at the other end the section force :math:`\mathbf{F}_j^+` just after +it, and its tangent rows are :math:`\mathbf{m}` there. An interior node reports + +.. math:: + + N_j = \mathbf{t}_j\cdot\tfrac{1}{2}\left(\mathbf{F}_j^- + \mathbf{F}_j^+\right), + \qquad + M_j = \lvert \mathbf{m}_j - (\mathbf{m}_j\cdot\mathbf{t}_j)\,\mathbf{t}_j \rvert, + \qquad + \kappa_j = M_j / EI , + +with :math:`\mathbf{t}_j` the unit nodal tangent, :math:`\mathbf{m}_j` the mean of the two +one-sided values, and at a section junction the larger of :math:`M_j/EI` on the two sides. The +recovered moment carries an error that does not depend on :math:`EI`, of the order of the largest +consistent-load moment :math:`w L_0^2/12` of an element (a section junction leaves a jump of that +order between the two one-sided moments), so over a soft section dividing by :math:`EI` amplifies +it. A section whose :math:`EI` is below :math:`\max_e(\lvert w_e\rvert L_{0,e}^2)/12` times 1 m, +the stiffness whose elastic moment at a 1 m bend radius equals that error, takes its curvature +from the exact geometric trace instead, as an element with :math:`EI = 0` does (on the 87-element +lazy-wave cable with :math:`EI` lowered to 100 N m\ :sup:`2` the +recovered curvature reaches 6.9 1/m against a geometric peak of 0.12 1/m; the bend moment of such a +section remains the recovered one, with that error). The +difference of the two one-sided forces is the point load left at the node (seabed friction, an +attachment) plus, where the nodal seabed reaction varies from node to node (the touchdown, a +rounded crease of the bathymetry), the difference between its spread and its nodal form, about +0.094 times its second difference along the line. The seabed reaction spread here is the one the +residual applies, with the crease increment of the penalty potential inside a rounded crease. At +the converged static state the nodal section forces satisfy the discrete +equilibrium exactly. In a dynamic run the recovery is the balance at the output time +:math:`t_{n+1}`, with the position, velocity and acceleration the step committed there: the +inertia term :math:`\mathbf{M}_e\mathbf{a}_e` uses the step's acceleration +:math:`\mathbf{a}_{n+1}` at :math:`\mathbf{q}_{n+1}`. The integrator balances the generalised-alpha +combination of the :math:`t_n` and :math:`t_{n+1}` states, so the recovered forces differ from +the integrator's balance by :math:`O(\Delta t)`; the recovered forces carry none of the pointwise +oscillation. A line end reports the ``FairTen``/``AnchTen`` end force and its one-sided moment; +the segment tension of an element is the mean of the axial components of its own two end forces. +The recovery costs one element evaluation per element and output row. + +The end node tension and the interior node tension are therefore different quantities. The end +value is the end reaction, the force on the support or the platform: it holds the end element's +internal force and the end node's share of the weight, buoyancy, drag and contact, but not +inertia, added mass or seabed friction, which stay in the coupled load. The interior value is the +recovered section force, built from end forces that include those terms. At rest and in a +quasi-static march the two agree; under acceleration the interior values carry the inertia and +added-mass terms of the two neighbouring elements, and the end values do not. + +On the 87-element lazy wave the interior node tension departs from the equilibrium of the +converged line by at most 60 N (1552 N for the element means), 12 N at twice the mesh density +and 0.3 N at 1 m elements (516 N); the largest curvature error falls from 64 % to 30 % of the +peak at 87 elements and from 2.1 % to 0.8 % at 1 m. The peak curvature at a +touchdown meshed coarser than the bending length is limited by the solution itself, not by the +recovery. + +The condensed torque of a line restrained in torsion is not part of :math:`\mathbf{g}_e`: it adds +a shear normal to the tangent and does no work on bending rotations. Including its element terms +on ``torsion_lazy_wave_hangoff_twist.dat`` (two turns, torque 3.5 kN m) moves the tension by +at most 0.45 N of 9.4 kN and moves the bend moment away from :math:`EI\kappa`. + +``OPTIONS`` ``OutputRecovery element`` restores the element definitions: the length-weighted +mean of the element-mean axial forces :math:`EA(\lvert\mathbf{r}'\rvert - 1)` at an interior +node, the larger one-sided exact curvature, and the midpoint axial resultant as the segment +tension. The material-strain checks (``tensile_safety``, the static compression notes) judge +:math:`EA\varepsilon` under either setting. + .. _theory-torsion: Condensed torsion @@ -1102,8 +1235,8 @@ mesh-sequenced route described below first and this route as its fallback): when the polish on the split mesh does not converge, or at an element budget. The report is judged on element-mean forces: the mean over each element and its two neighbours (length-weighted) beyond the - admissible band, or a node tension (the segment tension, :doc:`outputs`) in compression by - more than a tenth of the peak tension. + admissible band, or a nodal material axial force (the length-weighted mean of the two + adjacent element means) in compression by more than a tenth of the peak tension. The nodal seabed-contact reaction kinks the line at the touchdown node, and the element there can carry a small negative mean between tensile neighbours at any mesh; that dip does not enter equilibrium and is not reported. A failing route falls back to the @@ -1921,9 +2054,10 @@ Commands that would make the element length non-positive are rejected. Tension and coupled loads ------------------------- -An interior node tension is the segment tension: the average of the two adjacent element -tensions (``EI = 0``), or the length-weighted average of the element-mean axial forces of the -two adjacent elements (Hermite), including axial damping and constitutive-state contributions. +An interior node tension is the segment tension, the average of the two adjacent element +tensions, on an ``EI = 0`` line, and the effective tension recovered from nodal equilibrium +(:ref:`theory-output-recovery`) on a Hermite line, including axial damping and +constitutive-state contributions. ``FairTen``, ``AnchTen`` and the end-node tension channels report the line-end force instead (:doc:`conventions`, :doc:`outputs`). By the convention in :doc:`conventions` the reported tension is the effective tension. The diff --git a/doc/tutorial_bodies.rst b/doc/tutorial_bodies.rst index 683a6168..0c5be0e1 100644 --- a/doc/tutorial_bodies.rst +++ b/doc/tutorial_bodies.rst @@ -184,12 +184,13 @@ and clamps it there at 60° below horizontal: The direction is given in the body frame and turns with the buoy. The clamp moment, ``BendMom4N1``, acts on the body in the static solve and in the dynamics, and is part of -``Body1M*``. At rest the clamp carries 9.53 kN·m (a pinned cable would leave at 82°) and +``Body1M*``. At rest the clamp carries 9.63 kN·m (a pinned cable would leave at 82°) and ``Body1My`` is zero; the moment tilts the buoy to a static pitch of 0.15° instead of 0.30° -pinned. In 1 m, 14 s swell the clamp moment ranges from 8.6 to 10.8 kN·m and the buoy pitches -between −1.35° and +1.07°. With ``Pinned`` the end moment stays below 0.5 N·m. The first 10 m of -cable use 0.25 m elements to resolve the bending near the clamp; halving them changes the moment -by 0.8 %. A finite ``Stiffness`` in N·m/rad models a compliant hang-off. +pinned. In 1 m, 14 s swell the clamp moment ranges from 8.7 to 11.0 kN·m and the buoy pitches +between −1.35° and +1.07°. With ``Pinned`` the end moment stays below 0.1 N·m. The first 10 m of +cable use 0.25 m elements to resolve the bending near the clamp; ``BendMom4N1`` is the moment the +end element carries in equilibrium, so halving them changes it by under 0.01 % (0.5 % for twice +the elements' length). A finite ``Stiffness`` in N·m/rad models a compliant hang-off. A spar with pinned rods ----------------------- diff --git a/doc/tutorial_dynamics.rst b/doc/tutorial_dynamics.rst index 039c5ed0..18bd8164 100644 --- a/doc/tutorial_dynamics.rst +++ b/doc/tutorial_dynamics.rst @@ -255,19 +255,19 @@ current loads the run across its axis, so the lateral coefficient decides: - Sway at s = 160 m (m) * - 0.3 / 1.0 (deck) - 59.0 - - 109.8 + - 109.6 - 0.01 * - 1.0 isotropic - 59.0 - - 109.8 + - 109.6 - 0.01 * - 0.3 isotropic - 64.3 - - 117.5 + - 117.1 - 11.8 * - none - 73.9 - - 128.0 + - 127.9 - 19.6 A single coefficient equal to the axial value lets the laid run slide up to 16 m sideways and diff --git a/doc/tutorial_lazywave.rst b/doc/tutorial_lazywave.rst index 7141884b..40790dbb 100644 --- a/doc/tutorial_lazywave.rst +++ b/doc/tutorial_lazywave.rst @@ -84,7 +84,7 @@ Run it # CableDyn driver output (finite-EI dynamic; production cubic-Hermite route) Time(s) FairTen1 AnchTen1 FairIncl1 AnchIncl1 Curv1N383 BendMom1N383 - 0.0... 9.3201701E+003 1.3269019E+003 8.1600621E+001 -3.6937724E-001 9.6834389E-002 1.9270043E+003 + 0.0... 9.3201701E+003 1.3269019E+003 8.1600621E+001 -3.6920305E-001 9.6829202E-002 1.9269011E+003 Read the shape -------------- diff --git a/doc/tutorial_motion.rst b/doc/tutorial_motion.rst index 73c5a489..37e0bc3a 100644 --- a/doc/tutorial_motion.rst +++ b/doc/tutorial_motion.rst @@ -111,13 +111,13 @@ full-amplitude heave cycle): - 1 578 - 1 326 * - ``Curv1N25`` (1/m) - - 0.0911 - - 0.1034 - - 0.0969 + - 0.0915 + - 0.1041 + - 0.0973 * - ``BendMom1N25`` (N·m) - - 1 813 - - 2 058 - - 1 929 + - 1 820 + - 2 073 + - 1 937 A 3 m heave swings the hang-off tension by ±40 % about its static value and changes the sag-bend curvature by about ±6 %. Plot ``FairTen1`` against ``Time(s)``: the first 12 s show the smooth @@ -156,7 +156,7 @@ connection moment: .\CableDyn_driver.exe .\examples\lazy_wave_vessel_motion.dat .\results\vessel80 At rest the hang-off tension is 9320 N and the end moment is below 1 N·m. Over the last 24 s the -fairlead tension ranges from 7485 to 10969 N and the end moment peaks at 2953 N·m (a curvature of +fairlead tension ranges from 7485 to 10969 N and the end moment peaks at 2955 N·m (a curvature of 0.148 1/m, a bend radius of about 6.7 m). With the hang-off pinned, the end tangent swings between 71.5° and 89.2°; the clamp holds it to the vessel pitch, so the cable bends near the vessel instead. The peak moment changes by less than 0.1 % at ``dtM = 0.025`` s or with twice diff --git a/doc/tutorial_openfast.rst b/doc/tutorial_openfast.rst index a04334e7..425ad77d 100644 --- a/doc/tutorial_openfast.rst +++ b/doc/tutorial_openfast.rst @@ -319,8 +319,8 @@ seabed. Copy it into the case folder and point a copy of the ``.fst`` at it: force [Fx, Fy, Fz]: [1230, 0, -11858] N, inclination=84.078 deg line tangent: inclination=83.943 deg, declination=173.94 deg, azimuth=0 deg ... - Curv4N38 = 9.06020E-02 (1/m) - BendMom4N38 = 1803 (N.m) + Curv4N38 = 9.01821E-02 (1/m) + BendMom4N38 = 1794.6 (N.m) CableDyn found the cable's touchdown and lazy-wave shape by itself: in ``Mixed_CableDyn.CD.static.out``, 149 of line 4's 249 nodes lie on the seabed. Node 38, 74 m diff --git a/doc/tutorial_python.rst b/doc/tutorial_python.rst index b6090cb4..0abe6f5d 100644 --- a/doc/tutorial_python.rst +++ b/doc/tutorial_python.rst @@ -202,8 +202,8 @@ node. The fairlead tension ranges from 524 to 2815 kN (mean 1332 kN, static 1006 ``python C:\CableDyn\examples\plot_range_envelope.py results\range --save range.png`` plots the band and the mean against arc length. The ``TDP1s``, ``TDP1Lay`` and ``TDP1Exc`` channels track the touchdown -point: at rest it lies 159.9 m of arc from the fairlead with a 149.7 m layback, and during the -surge it moves between 109.9 and 286.6 m of arc, an excursion of −126.3 to +49.9 m. +point: at rest it lies 159.7 m of arc from the fairlead with a 149.5 m layback, and during the +surge it moves between 109.7 and 285.4 m of arc, an excursion of −125.2 to +49.9 m. Python API for GUIs and scripting --------------------------------- diff --git a/examples/cabledyn_options_reference.dat b/examples/cabledyn_options_reference.dat index 79ae9cbf..2d264baf 100644 --- a/examples/cabledyn_options_reference.dat +++ b/examples/cabledyn_options_reference.dat @@ -40,6 +40,7 @@ False modified_newton - Tangent-reuse mode {False=full Newton; True=guarded True cable_load_feedback - Return finite-EI cable reactions to OpenFAST {False; True} [default: True] False adaptive_mesh - Automatic finite-EI refinement {False; True} [default: False] continuation cable_statics - Finite-EI static route order {continuation; sequenced} [default: continuation] +equilibrium OutputRecovery - Finite-EI node tension/curvature/moment {equilibrium; element} [default: equilibrium] True alpha_force_blend - Generalised-alpha force blend, finite-EI and EI=0 lines {True; False=configuration blend} [default: True] False tensile_safety - Element-mean axial-force audit {False; warn; True=reject} [default: False] 2.0e-6 tensile_strain_tolerance - Dynamic audit strain band [default: 2.0e-6] @@ -100,7 +101,7 @@ none waves - Wave model and parameters (m, s, deg) {none; airy; -- staticsFriction = statics_friction = staticsSeabedFrictionPolicy = seabedFrictionPolicy -- layAzimuth = lay_azimuth; asLaidTension = as_laid_tension -- dtM = dt; rhoInf = rho_inf; modified_newton = modifiedNewton; adaptive_mesh = adaptiveMesh --- cable_statics = cableStatics; alpha_force_blend = alphaForceBlend +-- cable_statics = cableStatics; alpha_force_blend = alphaForceBlend; OutputRecovery = output_recovery -- maxStrain = max_strain; WaveSeed = wave_seed; rampTime = ramp_time = tRamp -- RangeStart = range_start -- cable_load_feedback = cableLoadFeedback; tensile_safety = tensileSafety diff --git a/python/cabledyn/builder.py b/python/cabledyn/builder.py index d2223602..3e81cf8a 100644 --- a/python/cabledyn/builder.py +++ b/python/cabledyn/builder.py @@ -103,12 +103,12 @@ ( "line", re.compile( - r"(fairten|anchten|fairangle|anchangle|fairdecl|anchdecl|fairincl|anchincl)" + r"(fairten|anchten|anchfz|anchfh|fairangle|anchangle|fairdecl|anchdecl|fairincl|anchincl)" r"([0-9]+)()", re.IGNORECASE, ), ), - ("line", re.compile(r"(tdp)([0-9]+)(s|x|y|z|lay|exc)", re.IGNORECASE)), + ("line", re.compile(r"(tdp)([0-9]+)(s|x|y|z|lay|exc|grd)", re.IGNORECASE)), ("line", re.compile(r"(ten|curv|bendmom|torq)([0-9]+)(n[0-9]+)", re.IGNORECASE)), ("line", re.compile(r"(twist)([0-9]+)(n[0-9]+|)", re.IGNORECASE)), ("line", re.compile(r"(l)([0-9]+)(n[0-9]+(?:[pva][xyz]|dec|azi))", re.IGNORECASE)), diff --git a/python/cabledyn/deck_file.py b/python/cabledyn/deck_file.py index be7f0813..f7163bf1 100644 --- a/python/cabledyn/deck_file.py +++ b/python/cabledyn/deck_file.py @@ -248,6 +248,8 @@ "lay_azimuth": "lay_azimuth", "aslaidtension": "as_laid_tension", "as_laid_tension": "as_laid_tension", + "outputrecovery": "output_recovery", + "output_recovery": "output_recovery", } # Per-line static friction rows (native apply_option): ``layAzimuth`` and ``asLaidTension`` # with the LINE id appended; the id is a plain decimal suffix, and leading zeros name the same line. @@ -718,6 +720,9 @@ def _channel_identity_key(channel: str) -> str: if lowered.startswith(("fairten", "anchten")): line_id = _native_id_suffix(lowered[7:]) return f"{lowered[:7]}:{line_id}" if line_id > 0 else lowered + if lowered.startswith(("anchfz", "anchfh")): + line_id = _native_id_suffix(lowered[6:]) + return f"{lowered[:6]}:{line_id}" if line_id > 0 else lowered if lowered.startswith( ("fairangle", "anchangle", "fairdecl", "anchdecl", "fairincl", "anchincl") ): @@ -740,9 +745,9 @@ def _channel_identity_key(channel: str) -> str: else 0 ) return f"point:{point_id}:{component}" if point_id > 0 and component > 0 else lowered - touchdown = re.fullmatch(r"tdp([0-9]{1,9})(s|x|y|z|lay|exc)", lowered) + touchdown = re.fullmatch(r"tdp([0-9]{1,9})(s|x|y|z|lay|exc|grd)", lowered) if touchdown is not None and int(touchdown.group(1)) > 0: - component = ("s", "x", "y", "z", "lay", "exc").index(touchdown.group(2)) + 1 + component = ("s", "x", "y", "z", "lay", "exc", "grd").index(touchdown.group(2)) + 1 return f"tdp:{int(touchdown.group(1))}:{component}" if lowered.startswith(("ten", "curv", "bendmom", "l", "torq", "twist")): line_id, node_id, kind, component = _parse_line_node_channel(lowered) @@ -1221,6 +1226,12 @@ def _scalar_option_value_error(keyword: str, value: str) -> str | None: if value.lower() in {"continuation", "sequenced"} else "must be continuation or sequenced" ) + if key == "output_recovery": + return ( + None + if value.lower() in {"equilibrium", "element"} + else "must be equilibrium or element" + ) if key in {"axial_quadrature_order", "bending_quadrature_order"}: try: numeric = _native_float(value) @@ -2883,6 +2894,26 @@ def end_key(token: str) -> str: ) mixed_route = any(finite_lines) and not all(finite_lines) and not has_objects mixed_static = mixed_route and not has_tmax + finite_line_ids = [ + line_id + for line_id, section_types in section_types_by_line.items() + if any(line_type_meta[line_type][3] > 0.0 for line_type in section_types) + ] + # Native build_one_hermite_cable, which builds every finite-EI line of the coupled + # aggregate (OpenFAST, FAST.Farm, the C API and the standalone mixed deck): the cable + # is held at a Fixed End B (the anchor) and driven at End A. A finite-EI line shared by + # two turbines is refused here, before its end-force channels (AnchFz, AnchFH) could be + # accepted for an end the aggregate cannot hold. (A standalone line's moving End B is + # refused by the static LINE checks above.) + if self.caller_driven or mixed_route: + for line_id in finite_line_ids: + end_b = normalized_line_endpoints[line_id][1] + end_b_type = point_types.get(end_b, end_b) + if end_b_type != "fixed": + raise DeckFormatError( + f"{self._label}: line {line_id}: finite-EI coupled cable requires End B " + f'(the anchor) to be a Fixed point; got "{end_b_type}"' + ) for line_type in used_type_names: _, _, ea_static, ei = line_type_meta[line_type] if ea_static <= 0.0: @@ -3682,8 +3713,8 @@ def is_body_kind(kind: str, pinned: bool) -> bool: for channel in channels: lowered = channel.lower() endpoint_channel = re.fullmatch( - r"(?:fairten|anchten|fairangle|anchangle|fairdecl|anchdecl|fairincl|anchincl)" - r"([0-9]+)", + r"(?:fairten|anchten|anchfz|anchfh|fairangle|anchangle|fairdecl|anchdecl" + r"|fairincl|anchincl)([0-9]+)", lowered, ) # Con

p{x,y,z} is the native alias of Point

p{x,y,z} (MoorDyn v1 spelling). @@ -3743,8 +3774,9 @@ def is_body_kind(kind: str, pinned: bool) -> bool: f"{self._label}: OUTPUT {channel!r} references an unknown point" ) continue - # TDP{s,x,y,z,Lay,Exc}: the touchdown point of line L (native CD_Parse_TDP_Channel) - touchdown_channel = re.fullmatch(r"tdp([0-9]{1,9})(?:s|x|y|z|lay|exc)", lowered) + # TDP{s,x,y,z,Lay,Exc,Grd}: the touchdown point of line L (native + # CD_Parse_TDP_Channel) + touchdown_channel = re.fullmatch(r"tdp([0-9]{1,9})(?:s|x|y|z|lay|exc|grd)", lowered) if touchdown_channel: if _channel_id(touchdown_channel.group(1)) not in line_ids: raise DeckFormatError( diff --git a/python/cabledyn/results.py b/python/cabledyn/results.py index 934874b7..6366013a 100644 --- a/python/cabledyn/results.py +++ b/python/cabledyn/results.py @@ -53,7 +53,7 @@ def _native_channel_unit(channel: str) -> str | None: Ids may carry leading zeros (``Ten01N01``), as the native channel parser accepts. """ patterns = ( - (r"(?:FairTen|AnchTen)0*[1-9][0-9]*", "N"), + (r"(?:FairTen|AnchTen|AnchFz|AnchFH)0*[1-9][0-9]*", "N"), (r"(?:FairIncl|AnchIncl|FairDecl|AnchDecl|FairAngle|AnchAngle)0*[1-9][0-9]*", "deg"), (r"Ten0*[1-9][0-9]*N0*[1-9][0-9]*", "N"), (r"Curv0*[1-9][0-9]*N0*[1-9][0-9]*", "1/m"), diff --git a/python/cabledyn/touchdown.py b/python/cabledyn/touchdown.py index 54173a24..738685d9 100644 --- a/python/cabledyn/touchdown.py +++ b/python/cabledyn/touchdown.py @@ -14,9 +14,16 @@ A node is grounded when ``z <= seabed_z + tolerance``, and the grounded run must start at one end of the line (as for :meth:`cabledyn.LineGeometry.touchdown`). Between the last grounded node and the next one the touchdown point (TDP) is -placed where the chord crosses ``seabed_z + tolerance``, so it moves smoothly -rather than jumping from node to node. Arc length is the cumulative deformed -chord length from End A through the available nodes. +placed where the parabola through the last grounded node and the next two +nodes (height against chord arc) crosses ``seabed_z + tolerance``, the crossing +nearest the suspended node; with fewer than two suspended nodes, or no crossing +inside the element, where the chord crosses that height. The crossing reaches a +node exactly when the node reaches that height, so the TDP moves continuously as +nodes ground and lift off, and the parabola follows a tangential lift-off between +nodes instead of holding the TDP at the last grounded node (the behaviour of the +chord crossing on a stiff seabed). It is the location of the driver's ``TDP`` +channels. Arc length is the cumulative deformed chord length from End A through +the available nodes. The excursion is the horizontal TDP displacement from a reference position, projected on the horizontal direction from the grounded end to the suspended @@ -290,13 +297,41 @@ def _locate( rise = high[:, 2] - low[:, 2] with np.errstate(divide="ignore", invalid="ignore"): fraction = np.clip(np.where(rise > 0.0, (level - low[:, 2]) / rise, 0.0), 0.0, 1.0) + n = xyz.shape[1] + quadratic = touching & (last + 2 < n) + for row in np.nonzero(quadratic)[0]: + fraction[row] = _quadratic_fraction(xyz[row], int(last[row]), level, fraction[row]) point = low + fraction[:, None] * (high - low) + point[touching, 2] = level tdp_arc = arc[rows, last] + fraction * chords[rows, np.minimum(last, chords.shape[1] - 1)] if end == "B": tdp_arc = arc[:, -1] - tdp_arc return touching, tdp_arc, point, xyz[:, -1, :2] +def _quadratic_fraction(xyz: npt.NDArray[Any], last: int, level: float, linear: float) -> float: + """Crossing of ``level`` by the quadratic height through the last grounded node and the + first two suspended nodes, nearest the suspended node, as a fraction of the first chord + (the linear fraction when the quadratic has no crossing in the element).""" + g0, g1, g2 = (xyz[last + k, 2] - level for k in range(3)) + l1 = float(np.linalg.norm(xyz[last + 1] - xyz[last])) + l2 = float(np.linalg.norm(xyz[last + 2] - xyz[last + 1])) + if not (l1 > 0.0 and l2 > 0.0): + return linear + d1 = (g1 - g0) / l1 + qa = ((g2 - g1) / l2 - d1) / (l1 + l2) + qb = d1 - qa * l1 + if abs(qa) * l1 <= 1e-12 * max(abs(qb), np.finfo(float).tiny): + return float(np.clip(-g0 / qb / l1, 0.0, 1.0)) if qb != 0.0 else linear + disc = qb * qb - 4.0 * qa * g0 + if disc < 0.0: + return linear + x1 = (-qb - math.sqrt(disc)) / (2.0 * qa) if qb >= 0.0 else (-qb + math.sqrt(disc)) / (2.0 * qa) + x2 = g0 / (qa * x1) if x1 != 0.0 else 0.0 + inside = [x for x in (x1, x2) if -1e-9 * l1 <= x <= l1 * (1.0 + 1e-9)] + return float(np.clip(max(inside) / l1, 0.0, 1.0)) if inside else linear + + def touchdown_history( source: TimeHistory, *, diff --git a/python/tests/test_builder.py b/python/tests/test_builder.py index 8ee00ec9..e5e5f161 100644 --- a/python/tests/test_builder.py +++ b/python/tests/test_builder.py @@ -246,7 +246,9 @@ def test_edit_fields_in_place_and_revalidate() -> None: def test_rename_propagates_to_rows_and_output_channels() -> None: model = _chain_model() - model.outputs.add("Ten1N3", "L1N2px", "TDP1s", "Point2FH", "Con1py") + model.outputs.add( + "Ten1N3", "L1N2px", "TDP1s", "TDP1Grd", "AnchFz1", "AnchFH1", "Point2FH", "Con1py" + ) model.rename(model.lines[1], 7) model.rename(model.points[1], 11) model.rename(model.line_types["chain"], "R3chain") @@ -257,6 +259,9 @@ def test_rename_propagates_to_rows_and_output_channels() -> None: "Ten7N3", "L7N2px", "TDP7s", + "TDP7Grd", + "AnchFz7", + "AnchFH7", "Point2FH", "Con11py", ] diff --git a/python/tests/test_deck_file.py b/python/tests/test_deck_file.py index 74a5d40c..2760d72a 100644 --- a/python/tests/test_deck_file.py +++ b/python/tests/test_deck_file.py @@ -665,6 +665,7 @@ def test_unknown_scalar_option_keyword_fails_closed(tmp_path): ("1.5", "wave_seed", "must be an integer"), ("maybe", "alpha_force_blend", "native boolean"), ("relaxed", "cable_statics", "continuation or sequenced"), + ("nodal", "OutputRecovery", "equilibrium or element"), ], ) def test_invalid_scalar_option_values_fail_closed(tmp_path, value, keyword, message): @@ -738,6 +739,8 @@ def test_zero_e_exponent_waterkin_mode_is_accepted(tmp_path): "True alphaForceBlend", "continuation cable_statics", "sequenced cableStatics", + "equilibrium OutputRecovery", + "element output_recovery", ], ) def test_native_scalar_option_vocabulary_is_accepted(tmp_path, row): @@ -1986,6 +1989,10 @@ def test_static_line_endpoint_topology_matches_native_normalization(tmp_path): "TDP1z", "TDP1Lay", "TDP1Exc", + "TDP1Grd", + "AnchFz1", + "AnchFH1", + "anchfz01", ], ) def test_output_channel_vocabulary_matches_native_parser(tmp_path, channel): @@ -2008,6 +2015,11 @@ def test_output_channel_vocabulary_matches_native_parser(tmp_path, channel): ("TDP2s", "unknown line"), ("TDP1q", "unsupported OUTPUT"), ("TDP1sx", "unsupported OUTPUT"), + ("TDP1Grdx", "unsupported OUTPUT"), + ("AnchFz2", "unknown line"), + ("AnchFH0", "unknown line"), + ("AnchFz1x", "unsupported OUTPUT"), + ("AnchFy1", "unsupported OUTPUT"), ], ) def test_invalid_output_channels_fail_before_case_generation(tmp_path, channel, message): @@ -2020,6 +2032,32 @@ def test_invalid_output_channels_fail_before_case_generation(tmp_path, channel, DeckFile.read(path) +@pytest.mark.parametrize("channel", ["FairTen1", "AnchFz1", "AnchFH1"]) +def test_finite_ei_cable_shared_by_two_turbines_is_refused(tmp_path, channel): + # native build_one_hermite_cable: the coupled aggregate holds a finite-EI cable at a Fixed + # anchor, so a cable between two turbines (End B moving) is refused, end-force channels + # included + path = _chain_variant( + tmp_path, + ("1.607e9 -1.0 0.0 ", "1.607e9 -1.0 2.0e5 "), + ("1 Fixed 500.0", "1 Turbine2 500.0"), + ("2 Coupled 0.0", "2 Turbine1 0.0"), + ('"FairTen1"', f'"{channel}"'), + ) + with pytest.raises(DeckFormatError, match=r"requires End B \(the anchor\) to be a Fixed point"): + DeckFile.read(path, caller_driven=True) + + +def test_ei0_line_shared_by_two_turbines_keeps_its_end_force_channels(tmp_path): + path = _chain_variant( + tmp_path, + ("1 Fixed 500.0", "1 Turbine2 500.0"), + ("2 Coupled 0.0", "2 Turbine1 0.0"), + ('"FairTen1"', '"AnchFz1"'), + ) + assert "AnchFz1" in DeckFile.read(path, caller_driven=True).outputs + + def test_case_generation_records_changes_hashes_and_working_directory(tmp_path): source = ROOT / "examples/chain_catenary_r3_100m.dat" cases = generate_deck_cases( @@ -3628,6 +3666,9 @@ def unqueryable(first, second): ("L1N3va", "L1N3va"), ("TDP1s", "tdp01S"), ("TDP1Lay", "TDP1LAY"), + ("TDP1Grd", "tdp01GRD"), + ("AnchFz1", "anchfz01"), + ("AnchFH1", "ANCHFH1"), ], ) def test_duplicate_output_channels_fail_like_native(first, second): @@ -3653,8 +3694,8 @@ def test_duplicate_output_channel_on_one_row_and_across_sections_fails(): def test_distinct_output_channels_are_not_collapsed(): channels = ( - "FairTen1 AnchTen1 FairIncl1 AnchIncl1 FairDecl1 AnchDecl1 Point1px Point1py " - "Point2px Ten1N1 Ten1N2 Curv1N1 BendMom1N1 L1N1px L1N1vx L1N1ax L1N1Dec L1N1Azi" + "FairTen1 AnchTen1 AnchFz1 AnchFH1 FairIncl1 AnchIncl1 FairDecl1 AnchDecl1 Point1px " + "Point1py Point2px Ten1N1 Ten1N2 Curv1N1 BendMom1N1 L1N1px L1N1vx L1N1ax L1N1Dec L1N1Azi" ) deck = DeckFile.from_text(_edit(_STATIC, ("FairTen1\n", channels + "\n"))) assert deck.outputs == tuple(channels.split()) @@ -3696,6 +3737,11 @@ def test_distinct_output_channels_are_not_collapsed(): ("TDP2s", "tdp:2:1"), ("TDP0s", "tdp0s"), ("TDP1", "tdp1"), + ("TDP3Grd", "tdp:3:7"), + ("AnchFz01", "anchfz:1"), + ("AnchFH2", "anchfh:2"), + ("AnchFz", "anchfz"), + ("AnchFz0", "anchfz0"), ("Lxyz", "lxyz"), ("Other1", "other1"), ], diff --git a/python/tests/test_deck_native_parity.py b/python/tests/test_deck_native_parity.py index e10149e8..70afcd07 100644 --- a/python/tests/test_deck_native_parity.py +++ b/python/tests/test_deck_native_parity.py @@ -206,13 +206,25 @@ def test_attachment_arc_length_lies_on_the_line(arc, accepted): @pytest.mark.parametrize( - "channel", ["FairTen01", "AnchIncl001", "TDP01s", "L01N1px", "Ten01N01", "Point01px", "Con01pz"] + "channel", + [ + "FairTen01", + "AnchIncl001", + "AnchFz01", + "AnchFH001", + "TDP01s", + "TDP01Grd", + "L01N1px", + "Ten01N01", + "Point01px", + "Con01pz", + ], ) def test_line_and_point_channel_ids_may_have_leading_zeros(channel): DeckFile.from_text(_edit(_HELD, ("FairTen1\n", f"{channel}\n"))) -@pytest.mark.parametrize("channel", ["TDP1q", "Point1pq", "Ten9N0"]) +@pytest.mark.parametrize("channel", ["TDP1q", "Point1pq", "Ten9N0", "AnchFz1z", "TDP1Grd1"]) def test_malformed_line_and_point_channels_fail_closed(channel): _rejects(_edit(_HELD, ("FairTen1\n", f"FairTen1\n{channel}\n")), "unsupported OUTPUT") diff --git a/python/tests/test_objects.py b/python/tests/test_objects.py index 1eadb457..e360af3d 100644 --- a/python/tests/test_objects.py +++ b/python/tests/test_objects.py @@ -315,6 +315,12 @@ def test_views_equal_the_channel_evaluator_bit_for_bit(tmp_path): force = fixed.force() assert force[0] == model.channel("Point1Fx") assert np.linalg.norm(force) == pytest.approx(line.anchor_tension(), rel=1.0e-12) + # the anchor holds one line: AnchFz/AnchFH are components of the same end force + assert model.channel("AnchFz1") == model.channel("Point1Fz") == force[2] + assert model.channel("AnchFH1") == model.channel("Point1FH") + assert model.channel("AnchFH1") == pytest.approx(np.hypot(force[0], force[1]), rel=1.0e-14) + # a grounded anchor carries part of its end node's weight: a small downward force + assert -0.05 * line.anchor_tension() < model.channel("AnchFz1") < 0.0 assert model.bodies == () and model.rods == () @@ -399,7 +405,19 @@ def test_rod_views(tmp_path): def test_channel_errors_and_stale_views(tmp_path): deck = _held_chain(tmp_path) model = CableDyn(deck) - for bad in ("", "x" * 65, "L1N99px", "Line1", "FairTen9", "L1N5q", "Body1Pz", "TDP1s"): + for bad in ( + "", + "x" * 65, + "L1N99px", + "Line1", + "FairTen9", + "AnchFz9", + "AnchFz1x", + "L1N5q", + "Body1Pz", + "TDP1s", + "TDP1Grd", + ): with pytest.raises((CableDynError, ValueError)): model.channel(bad) with pytest.raises(TypeError): diff --git a/python/tests/test_results.py b/python/tests/test_results.py index 02ec705a..f213c8ca 100644 --- a/python/tests/test_results.py +++ b/python/tests/test_results.py @@ -298,6 +298,9 @@ def test_time_must_be_strictly_increasing(tmp_path): ("channel", "unit"), [ ("FairTen1", "N"), + ("AnchFz1", "N"), + ("AnchFH2", "N"), + ("anchfh02", "N"), ("AnchIncl2", "deg"), ("Ten3N4", "N"), ("Curv3N4", "1/m"), @@ -324,6 +327,7 @@ def test_time_must_be_strictly_increasing(tmp_path): # an all-zero id is no channel ("Twist0", None), ("Torq0N1", None), + ("AnchFz0", None), ("Unknown", None), ], ) diff --git a/python/tests/test_touchdown.py b/python/tests/test_touchdown.py index 14f17198..c710fa71 100644 --- a/python/tests/test_touchdown.py +++ b/python/tests/test_touchdown.py @@ -32,14 +32,22 @@ def _frames(kinks=None) -> np.ndarray: def _expected(xyz: np.ndarray) -> tuple[float, np.ndarray]: - """Straightforward scalar TDP: last grounded node from End A, chord crossing.""" + """Straightforward scalar TDP: last grounded node from End A, then the crossing of the + level by the parabola through that node and the next two, in chord arc (on a straight + rise this is the chord crossing).""" level = SEABED + TOLERANCE last = int(np.argmax(xyz[:, 2] > level)) - 1 low, high = xyz[last], xyz[last + 1] - fraction = (level - low[2]) / (high[2] - low[2]) chords = np.linalg.norm(np.diff(xyz, axis=0), axis=1) + arcs = np.array([0.0, chords[last], chords[last] + chords[last + 1]]) + coefficients = np.polyfit(arcs, xyz[last : last + 3, 2] - level, 2) + roots = [r.real for r in np.roots(coefficients) if abs(r.imag) < 1e-12] + inside = [r for r in roots if -1e-9 <= r <= chords[last] * (1.0 + 1e-9)] + fraction = max(inside) / chords[last] arc = float(np.sum(chords[:last]) + fraction * chords[last]) - return arc, low + fraction * (high - low) + point = low + fraction * (high - low) + point[2] = level + return arc, point def _write_line(path, frames, times=TIMES): @@ -114,6 +122,43 @@ def test_touchdown_history_grounded_at_end_b(tmp_path): np.testing.assert_allclose(backward.layback, forward.layback) +def test_touchdown_on_a_convex_stencil_lies_just_before_the_barely_lifted_node(tmp_path): + # Clearance above the onset height -0.005, 0.01, 1.0, 2.0 m on 1 m spacing: node 2 is barely off + # the seabed and the line rises sharply beyond it, so the line leaves the seabed just before + # node 2. The chord crossing (a third of the way) would put the TDP a node behind. The + # parabola through the first three nodes crosses zero once inside the element, at 0.97 chord. + level = SEABED + TOLERANCE + z = level + np.array([-0.005, 0.01, 1.0, 2.0]) + frame = np.column_stack([np.arange(4.0), np.zeros(4), z])[None, :, :] + history = touchdown_history( + _write_line(tmp_path / "convex.p.out", frame, times=[0.0]), + seabed_z=SEABED, + tolerance=TOLERANCE, + ) + arc, point = _expected(frame[0]) + assert history.arc_length[0] == pytest.approx(arc) + np.testing.assert_allclose(history.coordinates[0], point) + assert 0.95 < history.coordinates[0, 0] < 1.0 + # the same stencil with node 1 exactly at the onset height: the second crossing, still inside + z = level + np.array([0.0, 0.01, 1.0, 2.0]) + frame = np.column_stack([np.arange(4.0), np.zeros(4), z])[None, :, :] + history = touchdown_history( + _write_line(tmp_path / "onset.p.out", frame, times=[0.0]), + seabed_z=SEABED, + tolerance=TOLERANCE, + ) + assert 0.95 < history.coordinates[0, 0] < 1.0 + # a node reaching the onset height maps to that node + z = level + np.array([-0.5, 1e-12, 1.0, 2.0]) + frame = np.column_stack([np.arange(4.0), np.zeros(4), z])[None, :, :] + history = touchdown_history( + _write_line(tmp_path / "node.p.out", frame, times=[0.0]), + seabed_z=SEABED, + tolerance=TOLERANCE, + ) + assert history.coordinates[0, 0] == pytest.approx(1.0, abs=1e-6) + + def test_touchdown_history_from_main_output_node_channels(tmp_path): frames = _frames() times = np.linspace(0.0, 10.0, 201) diff --git a/src/CableDyn_DeckDriver.f90 b/src/CableDyn_DeckDriver.f90 index a4d79fbe..fd34c926 100644 --- a/src/CableDyn_DeckDriver.f90 +++ b/src/CableDyn_DeckDriver.f90 @@ -97,6 +97,8 @@ MODULE CableDyn_DeckDriver CD_HCDYN_TENSILE_ERROR, & CD_HermiteCable_Axial_Damping_Resultant, & CD_HermiteCable_Axial_Damping_Element, CD_HermiteCable_Dyn_End_Force, & + CD_HermiteCable_Dyn_Node_Values, CD_HermiteCable_Dyn_Node_Recovery, & + CD_HermiteCable_Dyn_Set_Output_Recovery, & CD_HermiteCable_Dyn_Set_ForceBlend, CD_HC_FORCE_BLEND_DEFAULT, & CD_HermiteCable_Dyn_Set_Friction_Anchors, & CD_HermiteCable_Dyn_Set_Friction_Axial, & @@ -605,6 +607,10 @@ MODULE CableDyn_DeckDriver ! catenary-seeded EI continuation first and the mesh-sequenced route as its fallback; ! 'sequenced' runs the mesh-sequenced route first. LOGICAL :: cable_statics_sequenced = .FALSE. + ! Finite-EI node output definitions (OutputRecovery): 'equilibrium' (default) recovers the + ! effective tension, curvature and bend moment from nodal equilibrium; 'element' reports the + ! element-mean axial force EA (|r'| - 1) and the exact one-sided curvature traces. + LOGICAL :: output_element_recovery = .FALSE. INTEGER :: tensile_mode = CD_HCDYN_TENSILE_OFF REAL(wp) :: tensile_strain_tolerance = 2.0e-6_wp ! HOST-DRIVEN AMBIENT FLUID (not a deck keyword): set by CD_Init_Deck_Aggregate when @@ -2959,6 +2965,8 @@ RECURSIVE SUBROUTINE build_one_hermite_cable(ln, sections, types, points, opts, IF (es /= CD_HCDYN_OK) THEN CALL fail(ErrStat, ErrMsg, 'finite-EI cable alpha_force_blend wiring failed: '//TRIM(em)); RETURN END IF + ! OPTIONS OutputRecovery selects the definition of the node tension, curvature and bend moment. + CALL CD_HermiteCable_Dyn_Set_Output_Recovery(cable%line, opts%output_element_recovery) CONTAINS SUBROUTINE torsion_stage(est, emt) @@ -5731,8 +5739,9 @@ SUBROUTINE audit_hermite_static(l0, q, ea, ei, w, diam, endconn_mode, physical, ! the pointwise resultant, and a single element mean between tensile neighbours, dip ! next to a nodal seabed-contact reaction (a kink no element can follow, at every ! mesh) while the line in equilibrium stays tensile. Compression is reported when the - ! 3-element smoothed mean exceeds the admissible band, or when the node Tension - ! channel (the segment tension) falls below a tenth of the peak tension. + ! 3-element smoothed mean exceeds the admissible band, or when the nodal material + ! axial force (the length-weighted mean of the two adjacent element means) falls below a + ! tenth of the peak tension. hl_max = CD_ZERO DO e = 1, ne IF (ABS(w(e)) > CD_ZERO .AND. ei(e) > CD_ZERO) & @@ -12975,6 +12984,15 @@ SUBROUTINE apply_option(line, opts, ErrStat, ErrMsg) CASE DEFAULT CALL fail(ErrStat, ErrMsg, 'OPTION cable_statics "'//TRIM(val)//'" must be continuation or sequenced') END SELECT + CASE ('outputrecovery', 'output_recovery') + SELECT CASE (TRIM(to_lower(val))) + CASE ('equilibrium') + opts%output_element_recovery = .FALSE. + CASE ('element') + opts%output_element_recovery = .TRUE. + CASE DEFAULT + CALL fail(ErrStat, ErrMsg, 'OPTION OutputRecovery "'//TRIM(val)//'" must be equilibrium or element') + END SELECT CASE ('cable_load_feedback', 'cableloadfeedback') CALL rd_bool(val, opts%cable_load_feedback, ErrStat, ErrMsg) CASE ('tensile_safety', 'tensilesafety') @@ -13432,7 +13450,7 @@ END SUBROUTINE append_channel FUNCTION channel_identity_key(ch) RESULT(key) !! Canonical identity of an OUTPUTS channel, for duplicate detection: names compare - !! case-insensitively, numeric ids by value (FairTen01 = FairTen1), and alias + !! case-insensitively, numeric ids by value (FairTen01 = FairTen1, AnchFz01 = AnchFz1), and alias !! spellings of one quantity collapse (Con

p{x,y,z} = Point

p{x,y,z}; !! FairAngle = FairDecl, AnchAngle = AnchDecl). Names outside the parsed !! families keep their lowercased spelling. @@ -13446,6 +13464,9 @@ FUNCTION channel_identity_key(ch) RESULT(key) IF (starts_with(lo, 'fairten') .OR. starts_with(lo, 'anchten')) THEN a = int_suffix(ch, 8) IF (a > 0) key = lo(1:7)//':'//TRIM(int_to_str(a)) + ELSE IF (is_anchor_force_channel(lo)) THEN + a = anchor_force_line_id(ch) + IF (a > 0) key = lo(1:6)//':'//TRIM(int_to_str(a)) ELSE IF (is_endpoint_angle_channel(lo)) THEN a = endpoint_angle_line_id(ch) IF (a <= 0) RETURN @@ -19719,7 +19740,7 @@ END FUNCTION mb_cable_group SUBROUTINE mb_point_force(mb, ch, val, ErrStat, ErrMsg) !! Point

F{x,y,z,H} on the multibody march: the resultant of the forces the attached EI=0 !! lines and finite-EI cables exert on point P. - TYPE(MultibodyMarch), INTENT(IN) :: mb + TYPE(MultibodyMarch), INTENT(INOUT) :: mb CHARACTER(*), INTENT(IN) :: ch REAL(wp), INTENT(OUT) :: val INTEGER, INTENT(OUT) :: ErrStat @@ -24947,7 +24968,8 @@ SUBROUTINE write_hermite_dynamic_out(out_root, channels, lines, points, opts, ca IF (ErrStat == CD_DECKDRV_OK) & CALL write_hermite_static_profile(out_root, lines, cables, ErrStat, ErrMsg) IF (ErrStat == CD_DECKDRV_OK) & - CALL write_dynamic_hermite_line_outputs(CD_ZERO, lines, cables, pos_units, ten_units, ErrStat, ErrMsg) + CALL write_dynamic_hermite_line_outputs(CD_ZERO, lines, cables, pos_units, ten_units, ErrStat, ErrMsg, & + ranges=ranges) IF (ErrStat /= CD_DECKDRV_OK) THEN CLOSE (unit); CALL close_dynamic_line_outputs(pos_units, ten_units); RETURN END IF @@ -24999,7 +25021,8 @@ SUBROUTINE write_hermite_dynamic_out(out_root, channels, lines, points, opts, ca motion=motion, motion_time_index=MERGE(step + 1, 0, opts%has_motion_file), & has_motion=opts%has_motion_file, ranges=ranges) IF (ErrStat == CD_DECKDRV_OK) & - CALL write_dynamic_hermite_line_outputs(t, lines, cables, pos_units, ten_units, ErrStat, ErrMsg) + CALL write_dynamic_hermite_line_outputs(t, lines, cables, pos_units, ten_units, ErrStat, ErrMsg, & + ranges=ranges) IF (ErrStat /= CD_DECKDRV_OK) EXIT CALL CD_Profile_Enter(CD_PROF_PROGRESS) CALL update_driver_progress(progress, step, t) @@ -25095,7 +25118,7 @@ SUBROUTINE write_hermite_static_profile(out_root, lines, cables, ErrStat, ErrMsg !! every node is available for touchdown, curvature, and tension inspection. CHARACTER(*), INTENT(IN) :: out_root TYPE(DeckLine), INTENT(IN) :: lines(:) - TYPE(CD_HFMF_ModuleType), INTENT(IN) :: cables(:) + TYPE(CD_HFMF_ModuleType), INTENT(INOUT) :: cables(:) INTEGER, INTENT(OUT) :: ErrStat CHARACTER(*), INTENT(OUT) :: ErrMsg @@ -25337,7 +25360,7 @@ SUBROUTINE write_hermite_model_row(unit, time, channels, lines, points, cables, CHARACTER(NAMELEN), INTENT(IN) :: channels(:) TYPE(DeckLine), INTENT(IN) :: lines(:) TYPE(DeckPoint), INTENT(IN) :: points(:) - TYPE(CD_HFMF_ModuleType), INTENT(IN) :: cables(:) + TYPE(CD_HFMF_ModuleType), INTENT(INOUT) :: cables(:) TYPE(MotionTable), INTENT(IN) :: motion LOGICAL, INTENT(IN) :: has_motion INTEGER, INTENT(OUT) :: ErrStat @@ -25407,6 +25430,8 @@ SUBROUTINE write_hermite_model_row(unit, time, channels, lines, points, cables, ELSE IF (starts_with(lo, 'fairten') .OR. starts_with(lo, 'anchten')) THEN line_id = int_suffix(channels(i), 8) + ELSE IF (is_anchor_force_channel(lo)) THEN + line_id = anchor_force_line_id(channels(i)) ELSE IF (is_endpoint_angle_channel(lo)) THEN line_id = endpoint_angle_line_id(channels(i)) ELSE @@ -25471,13 +25496,17 @@ SUBROUTINE open_dynamic_hermite_line_outputs(out_root, lines, cables, pos_units, END DO END SUBROUTINE open_dynamic_hermite_line_outputs - SUBROUTINE write_dynamic_hermite_line_outputs(time, lines, cables, pos_units, ten_units, ErrStat, ErrMsg) + SUBROUTINE write_dynamic_hermite_line_outputs(time, lines, cables, pos_units, ten_units, ErrStat, ErrMsg, ranges) + !! One row of the per-line position and segment-tension files. ranges, when given, is the + !! range set sampled for this row by write_hermite_model_row: a line with a range graph + !! then reuses the segment tensions of that sample's recovery pass (range_sample_cable). REAL(wp), INTENT(IN) :: time TYPE(DeckLine), INTENT(IN) :: lines(:) TYPE(CD_HFMF_ModuleType), INTENT(IN) :: cables(:) INTEGER, INTENT(IN) :: pos_units(:), ten_units(:) INTEGER, INTENT(OUT) :: ErrStat CHARACTER(*), INTENT(OUT) :: ErrMsg + TYPE(CD_RangeSet), INTENT(IN), OPTIONAL :: ranges INTEGER :: i, node, inode, seg, k ErrStat = CD_DECKDRV_OK; ErrMsg = '' DO i = 1, SIZE(lines) @@ -25502,8 +25531,19 @@ SUBROUTINE write_dynamic_hermite_line_outputs(time, lines, cables, pos_units, te IF (ten_units(i) /= 0) THEN BLOCK REAL(wp) :: tension(cables(i)%line%ne) + LOGICAL :: shared + shared = .FALSE. + IF (PRESENT(ranges)) THEN + IF (CD_Range_Needs_Sample(ranges, i)) shared = ranges%lines(i)%want_range .AND. & + .NOT. cables(i)%line%output_element_recovery + END IF + IF (shared) THEN + tension = ranges%lines(i)%ten_e(cables(i)%line%ne:1:-1) + ELSE + CALL cable_segment_tensions(cables(i), tension, ErrStat, ErrMsg) + IF (ErrStat /= CD_DECKDRV_OK) RETURN + END IF DO seg = 1, cables(i)%line%ne - tension(seg) = cable_element_tension(cables(i), cables(i)%line%ne - seg + 1) IF (.NOT. IEEE_IS_FINITE(tension(seg))) THEN WRITE (ten_units(i), ROW_VALUES_FMT, ADVANCE='NO') time, (char_tab(), tension(k), k=1, seg - 1) CALL fail_solve(ErrStat, ErrMsg, 'non-finite Hermite line tension output'); RETURN @@ -27070,7 +27110,7 @@ SUBROUTINE build_plan() work%ch_kind(j) = CH_TDP work%ch_line(j) = il work%ch_comp(j) = comp - ELSE IF (is_point_force_channel(lo) .OR. is_object_channel(lo)) THEN + ELSE IF (is_point_force_channel(lo) .OR. is_object_channel(lo) .OR. is_anchor_force_channel(lo)) THEN CYCLE ! evaluated channel-at-a-time (CH_LEGACY) ELSE IF (is_point_channel(lo)) THEN CALL parse_point_channel(channels(j), pidx, comp) @@ -27311,6 +27351,15 @@ SUBROUTINE system_channel_value(ch, lines, points, system, work, val, ErrStat, E ErrMsg = 'CableDyn_DeckDriver: system dynamic end-tension recovery failed: '//TRIM(em) RETURN END IF + ELSE IF (is_anchor_force_channel(lo)) THEN + ! a component of the AnchTen end force (End B = internal first node) + li = find_line(lines, anchor_force_line_id(ch)) + CALL line_model_anchor_force(system%lines(li), lo, val, es, em) + IF (es /= CD_DECKDRV_OK) THEN + ErrStat = CD_DECKDRV_SOLVEFAIL + ErrMsg = 'CableDyn_DeckDriver: system dynamic end-force recovery failed: '//TRIM(em) + RETURN + END IF ELSE IF (is_endpoint_angle_channel(lo)) THEN li = find_line(lines, endpoint_angle_line_id(ch)) ndof = CD_System_Line_NDOF(system, li, es, em) @@ -27433,6 +27482,12 @@ SUBROUTINE finite_model_channel_value(ch, lines, points, models, work, val, ErrS 'two-moving-end finite-EI route (use FairTen/AnchTen)') RETURN END IF + ! this route reports the axial chord-stretch tension of the end elements, not an end-force vector + IF (is_anchor_force_channel(lo)) THEN + CALL fail(ErrStat, ErrMsg, 'OUTPUT "'//TRIM(ch)//'": AnchFz/AnchFH channels are not available on the '// & + 'two-moving-end finite-EI route (use AnchTen and AnchIncl)') + RETURN + END IF IF (starts_with(lo, 'fairten') .OR. starts_with(lo, 'anchten')) THEN li = find_line(lines, int_suffix(ch, 8)) CALL ensure_model_output_workspace(work, 0, models(li)%n_elem) @@ -27618,6 +27673,15 @@ SUBROUTINE model_channel_value(ch, lines, points, models, work, val, ErrStat, Er ErrMsg = 'CableDyn_DeckDriver: dynamic end-tension recovery failed: '//TRIM(em) RETURN END IF + ELSE IF (is_anchor_force_channel(lo)) THEN + ! a component of the AnchTen end force (End B = internal first node) + li = find_line(lines, anchor_force_line_id(ch)) + CALL line_model_anchor_force(models(li), lo, val, es, em) + IF (es /= CD_DECKDRV_OK) THEN + ErrStat = CD_DECKDRV_SOLVEFAIL + ErrMsg = 'CableDyn_DeckDriver: dynamic end-force recovery failed: '//TRIM(em) + RETURN + END IF ELSE IF (is_endpoint_angle_channel(lo)) THEN li = find_line(lines, endpoint_angle_line_id(ch)) ndof = CD_Model_NDOF(models(li), es, em) @@ -29250,6 +29314,17 @@ REAL(wp) FUNCTION channel_value(ch, lines, points, ne, q_all, q_off, ten_all, te ELSE v = ten_all(ten_off(li) + 1) ! deck End B anchor = internal first element END IF + ELSE IF (is_anchor_force_channel(lo)) THEN + ! a component of the AnchTen end force; without end_force, of the anchor element's pull + ! on the anchor node (its tension along the element, toward the internal second node) + li = find_line(lines, anchor_force_line_id(ch)) + IF (PRESENT(end_force)) THEN + fsum = end_force(:, 1, li) + ELSE + fsum = q_all(q_off(li) + 4:q_off(li) + 6) - q_all(q_off(li) + 1:q_off(li) + 3) + IF (NORM2(fsum) > CD_ZERO) fsum = ten_all(ten_off(li) + 1)*fsum/NORM2(fsum) + END IF + v = anchor_force_component(lo, fsum) ELSE IF (is_endpoint_angle_channel(lo)) THEN li = find_line(lines, endpoint_angle_line_id(ch)) IF (is_fair_endpoint_angle(lo)) THEN @@ -29339,6 +29414,10 @@ SUBROUTINE check_channel(ch, lines, points, sections, ErrStat, ErrMsg, bodies, r IF (find_line(lines, int_suffix(ch, 8)) == 0) THEN CALL fail(ErrStat, ErrMsg, 'OUTPUT "'//TRIM(ch)//'": unknown line id'); RETURN END IF + ELSE IF (is_anchor_force_channel(lo)) THEN + IF (find_line(lines, anchor_force_line_id(ch)) == 0) THEN + CALL fail(ErrStat, ErrMsg, 'OUTPUT "'//TRIM(ch)//'": unknown line id'); RETURN + END IF ELSE IF (is_endpoint_angle_channel(lo)) THEN IF (find_line(lines, endpoint_angle_line_id(ch)) == 0) THEN CALL fail(ErrStat, ErrMsg, 'OUTPUT "'//TRIM(ch)//'": unknown line id'); RETURN @@ -29352,7 +29431,7 @@ SUBROUTINE check_channel(ch, lines, points, sections, ErrStat, ErrMsg, bodies, r CALL CD_Parse_TDP_Channel(ch, line_id, comp) IF (comp < 1) THEN CALL fail(ErrStat, ErrMsg, 'OUTPUT "'//TRIM(ch)//'": bad touchdown channel (use TDPs, TDPx, '// & - 'TDPy, TDPz, TDPLay or TDPExc)'); RETURN + 'TDPy, TDPz, TDPLay, TDPExc or TDPGrd)'); RETURN END IF IF (find_line(lines, line_id) == 0) THEN CALL fail(ErrStat, ErrMsg, 'OUTPUT "'//TRIM(ch)//'": unknown line id'); RETURN @@ -29399,12 +29478,12 @@ SUBROUTINE check_channel(ch, lines, points, sections, ErrStat, ErrMsg, bodies, r END IF ELSE CALL fail(ErrStat, ErrMsg, 'OUTPUT channel "'//TRIM(ch)// & - '" not supported (use FairTen, AnchTen, FairIncl, AnchIncl, '// & + '" not supported (use FairTen, AnchTen, AnchFz, AnchFH, FairIncl, AnchIncl, '// & 'FairDecl, AnchDecl (FairAngle/AnchAngle aliases), '// & 'Point

p{x,y,z} (alias Con

p{x,y,z}), Point

F{x,y,z,H}, '// & 'TenN, CurvN, BendMomN, TorqN, TwistN, Twist, '// & 'LNp{x,y,z}, LNv{x,y,z}, LNa{x,y,z}, LNDec, LNAzi, '// & - 'TDP{s,x,y,z,Lay,Exc}, or the Body/Rod channels)'); RETURN + 'TDP{s,x,y,z,Lay,Exc,Grd}, or the Body/Rod channels)'); RETURN END IF END SUBROUTINE check_channel @@ -29436,6 +29515,55 @@ LOGICAL FUNCTION is_point_channel(lo) RESULT(is_point) IF (starts_with(lo, 'con') .AND. LEN(lo) >= 4) is_point = VERIFY(lo(4:4), '0123456789') == 0 END FUNCTION is_point_channel + LOGICAL FUNCTION is_anchor_force_channel(lo) RESULT(yes) + !! AnchFz / AnchFH (lower case): the vertical component and the horizontal magnitude + !! of the AnchTen end force, the force line L exerts on its End-B point. + CHARACTER(*), INTENT(IN) :: lo + yes = starts_with(lo, 'anchfz') .OR. starts_with(lo, 'anchfh') + END FUNCTION is_anchor_force_channel + + INTEGER FUNCTION anchor_force_line_id(ch) RESULT(line_id) + !! Deck line id of an AnchFz / AnchFH name; 0 when the suffix is not a positive id. + CHARACTER(*), INTENT(IN) :: ch + line_id = int_suffix(ch, 7) + END FUNCTION anchor_force_line_id + + REAL(wp) FUNCTION anchor_force_component(lo, force) RESULT(v) + !! AnchFz (force(3), positive upward: the line lifts its anchor) or AnchFH (horizontal + !! magnitude) of the global end-B force vector `force` the line exerts on its anchor. + CHARACTER(*), INTENT(IN) :: lo + REAL(wp), INTENT(IN) :: force(3) + IF (starts_with(lo, 'anchfz')) THEN + v = force(3) + ELSE + v = SQRT(force(1)**2 + force(2)**2) + END IF + END FUNCTION anchor_force_component + + SUBROUTINE line_model_anchor_force(model, lo, val, ErrStat, ErrMsg) + !! AnchFz / AnchFH of an EI=0 line model: a component of the force the line exerts on the + !! point holding its internal first node (deck End B), the vector whose norm is AnchTen. + TYPE(CD_ModelType), INTENT(IN) :: model + CHARACTER(*), INTENT(IN) :: lo + REAL(wp), INTENT(OUT) :: val + INTEGER, INTENT(OUT) :: ErrStat + CHARACTER(*), INTENT(OUT) :: ErrMsg + REAL(wp) :: f_first(3), f_last(3) + INTEGER :: es + CHARACTER(160) :: em + + val = CD_ZERO + ErrStat = CD_DECKDRV_OK + ErrMsg = '' + CALL CD_Get_Model_EndForces(model, f_first, f_last, es, em) + IF (es /= CD_MODEL_OK) THEN + ErrStat = CD_DECKDRV_SOLVEFAIL + ErrMsg = em + RETURN + END IF + val = anchor_force_component(lo, f_first) + END SUBROUTINE line_model_anchor_force + LOGICAL FUNCTION is_point_force_channel(lo) RESULT(yes) !! Point

F{x,y,z} / Point

FH: the resultant of the line-end forces on point P. CHARACTER(*), INTENT(IN) :: lo @@ -30444,10 +30572,12 @@ SUBROUTINE range_sample_fmodel(fmodel, rl, ErrStat, ErrMsg) END SUBROUTINE range_sample_fmodel SUBROUTINE range_sample_cable(cable, rl, ErrStat, ErrMsg) - !! Sample a cubic-Hermite cable with the evaluators of eval_cable_channel: end-force - !! tension at the ends and the length-weighted element-mean axial force inside, the - !! larger one-sided exact curvature and EI * curvature traces, and the declination of - !! the cable-local state; positions are rotated into the deck's global frame. + !! Sample a cubic-Hermite cable with the definitions of eval_cable_channel: the node + !! tension, curvature and bend moment recovered from nodal equilibrium in one pass + !! (OutputRecovery element: end-force tension at the ends, the length-weighted element-mean + !! axial force inside, the larger one-sided exact curvature and EI * curvature traces), and + !! the declination of the cable-local state; positions are rotated into the deck's global + !! frame. TYPE(CD_HFMF_ModuleType), INTENT(IN) :: cable TYPE(CD_RangeLine), INTENT(INOUT) :: rl INTEGER, INTENT(OUT) :: ErrStat @@ -30479,38 +30609,20 @@ SUBROUTINE range_sample_cable(cable, rl, ErrStat, ErrMsg) END DO END DO IF (.NOT. rl%want_range) RETURN ! a touchdown-only line needs the positions alone - ! element traces: mean axial force, curvature at xi = 0 (vs) and xi = 1 (as) - DO e = 1, ne - rl%ten_e(e) = cable_element_mean_tension(cable, e) - CALL cable_element_curvature(cable, e, CD_ZERO, rl%vs(e), es, em) - IF (es == CD_HCABLE_OK) CALL cable_element_curvature(cable, e, CD_ONE, rl%as(e), es, em) - IF (es /= CD_HCABLE_OK) THEN - CALL fail_solve(ErrStat, ErrMsg, 'range-graph curvature sample failed: '//TRIM(em)); RETURN - END IF - END DO - DO j = 1, nn - inode = nn + 1 - j - IF (inode == 1 .OR. inode == nn) THEN - CALL cable_end_tension(cable, inode, rl%val(CD_RQ_TENSION, j), ErrStat, ErrMsg) - IF (ErrStat /= CD_DECKDRV_OK) RETURN - ELSE - rl%val(CD_RQ_TENSION, j) = (cable%line%l0(inode - 1)*rl%ten_e(inode - 1) + & - cable%line%l0(inode)*rl%ten_e(inode))/ & - (cable%line%l0(inode - 1) + cable%line%l0(inode)) - END IF - curv = CD_ZERO - bend = CD_ZERO - IF (inode > 1) THEN - curv = MAX(curv, rl%as(inode - 1)) - bend = MAX(bend, cable%line%EI(inode - 1)*rl%as(inode - 1)) - END IF - IF (inode <= ne) THEN - curv = MAX(curv, rl%vs(inode)) - bend = MAX(bend, cable%line%EI(inode)*rl%vs(inode)) + IF (.NOT. cable%line%output_element_recovery) THEN + ! equilibrium node values, one pass over the elements straight into the public-order rows + ! (internal node i is public node nn + 1 - i); the segment tensions (internal order) stay + ! in rl%ten_e for the .t.out row + CALL CD_HermiteCable_Dyn_Node_Recovery(cable%line, es, em, tension=rl%val(CD_RQ_TENSION, nn:1:-1), & + curvature=rl%val(CD_RQ_CURVATURE, nn:1:-1), & + bend_moment=rl%val(CD_RQ_BEND, nn:1:-1), segment_tension=rl%ten_e) + IF (es /= CD_HCDYN_OK) THEN + CALL fail_solve(ErrStat, ErrMsg, 'range-graph node-value recovery failed: '//TRIM(em)); RETURN END IF - rl%val(CD_RQ_CURVATURE, j) = curv - rl%val(CD_RQ_BEND, j) = bend - END DO + ELSE + CALL range_sample_cable_element(ErrStat, ErrMsg) + IF (ErrStat /= CD_DECKDRV_OK) RETURN + END IF IF (rl%has_torsion .AND. cable%line%torsion%active) THEN ! condensed torsion: the committed torque (uniform) and the cable's own twist from End A ! (public node 1, the last internal node), as the TorqN and TwistN channels @@ -30522,6 +30634,49 @@ SUBROUTINE range_sample_cable(cable, rl, ErrStat, ErrMsg) cable%line%l0(inode)/cable%line%torsion%gj(inode)*45.0_wp/QUARTER_PI END DO END IF + + CONTAINS + + SUBROUTINE range_sample_cable_element(ErrStat, ErrMsg) + !! OutputRecovery element: end-force tension at the ends and the length-weighted + !! element-mean axial force inside, the larger one-sided exact curvature and EI * curvature. + INTEGER, INTENT(OUT) :: ErrStat + CHARACTER(*), INTENT(OUT) :: ErrMsg + ErrStat = CD_DECKDRV_OK + ErrMsg = '' + ! element traces: mean axial force, curvature at xi = 0 (vs) and xi = 1 (as) + DO e = 1, ne + rl%ten_e(e) = cable_element_mean_tension(cable, e) + CALL cable_element_curvature(cable, e, CD_ZERO, rl%vs(e), es, em) + IF (es == CD_HCABLE_OK) CALL cable_element_curvature(cable, e, CD_ONE, rl%as(e), es, em) + IF (es /= CD_HCABLE_OK) THEN + CALL fail_solve(ErrStat, ErrMsg, 'range-graph curvature sample failed: '//TRIM(em)); RETURN + END IF + END DO + DO j = 1, nn + inode = nn + 1 - j + IF (inode == 1 .OR. inode == nn) THEN + CALL cable_end_tension(cable, inode, rl%val(CD_RQ_TENSION, j), ErrStat, ErrMsg) + IF (ErrStat /= CD_DECKDRV_OK) RETURN + ELSE + rl%val(CD_RQ_TENSION, j) = (cable%line%l0(inode - 1)*rl%ten_e(inode - 1) + & + cable%line%l0(inode)*rl%ten_e(inode))/ & + (cable%line%l0(inode - 1) + cable%line%l0(inode)) + END IF + curv = CD_ZERO + bend = CD_ZERO + IF (inode > 1) THEN + curv = MAX(curv, rl%as(inode - 1)) + bend = MAX(bend, cable%line%EI(inode - 1)*rl%as(inode - 1)) + END IF + IF (inode <= ne) THEN + curv = MAX(curv, rl%vs(inode)) + bend = MAX(bend, cable%line%EI(inode)*rl%vs(inode)) + END IF + rl%val(CD_RQ_CURVATURE, j) = curv + rl%val(CD_RQ_BEND, j) = bend + END DO + END SUBROUTINE range_sample_cable_element END SUBROUTINE range_sample_cable SUBROUTINE aggregate_line_positions(system, cables, line_is_cable, line_obj_index, line_id, r, ErrStat, ErrMsg) @@ -30726,7 +30881,7 @@ SUBROUTINE CD_Eval_Aggregate_Channel(ch, has_sys, system, cables, line_is_cable, TYPE(CD_SystemType), INTENT(IN) :: system ! ALLOCATABLE so a pure-mooring deck that declares channels (ncable = 0, cables unallocated) ! can pass its cables store: only a channel resolving to a cable dereferences it. - TYPE(CD_HFMF_ModuleType), ALLOCATABLE, INTENT(IN) :: cables(:) + TYPE(CD_HFMF_ModuleType), ALLOCATABLE, INTENT(INOUT) :: cables(:) LOGICAL, INTENT(IN) :: line_is_cable(:) INTEGER, INTENT(IN) :: line_obj_index(:) REAL(wp), INTENT(OUT) :: val @@ -30830,7 +30985,8 @@ SUBROUTINE CD_Eval_Aggregate_Channel(ch, has_sys, system, cables, line_is_cable, RETURN END IF - ! TDP{s,x,y,z,Lay,Exc}: the touchdown point of the current configuration. + ! TDP{s,x,y,z,Lay,Exc,Grd}: the touchdown point of the current configuration and the + ! grounded length behind it. IF (CD_Is_TDP_Channel(lo)) THEN IF (.NOT. PRESENT(ranges)) THEN CALL fail(ErrStat, ErrMsg, 'OUTPUT "'//TRIM(ch)//'": touchdown channels are not available here'); RETURN @@ -30870,6 +31026,8 @@ SUBROUTINE CD_Eval_Aggregate_Channel(ch, has_sys, system, cables, line_is_cable, ! Resolve the channel's deck line id; every other line-node token uses its own parser. IF (starts_with(lo, 'fairten') .OR. starts_with(lo, 'anchten')) THEN line_id = int_suffix(ch, 8) + ELSE IF (is_anchor_force_channel(lo)) THEN + line_id = anchor_force_line_id(ch) ELSE IF (is_endpoint_angle_channel(lo)) THEN line_id = endpoint_angle_line_id(ch) ELSE @@ -30903,8 +31061,10 @@ SUBROUTINE CD_Eval_Aggregate_Segment_Tensions(line_id, has_sys, system, cables, tension, ErrStat, ErrMsg) !! Segment (element) tensions of deck line line_id in public order End A -> End B, the !! values the standalone driver writes to .Line.t.out: the EI=0 element tensions of - !! CD_Get_Model_Tension, or the Hermite element-midpoint axial tension of a finite-EI cable. - !! tension must hold exactly the line's element count. + !! CD_Get_Model_Tension, or the segment tensions of a finite-EI cable (cable_segment_tensions: + !! the mean axial component of the element's two equilibrium end forces, or under OPTIONS + !! OutputRecovery element the axial resultant at the element midpoint). tension must hold + !! exactly the line's element count. INTEGER, INTENT(IN) :: line_id LOGICAL, INTENT(IN) :: has_sys TYPE(CD_SystemType), INTENT(IN) :: system @@ -30915,7 +31075,7 @@ SUBROUTINE CD_Eval_Aggregate_Segment_Tensions(line_id, has_sys, system, cables, INTEGER, INTENT(OUT) :: ErrStat CHARACTER(*), INTENT(OUT) :: ErrMsg - INTEGER :: obj, ne, seg, es + INTEGER :: obj, ne, es CHARACTER(200) :: em ErrStat = CD_DECKDRV_OK @@ -30939,9 +31099,7 @@ SUBROUTINE CD_Eval_Aggregate_Segment_Tensions(line_id, has_sys, system, cables, IF (SIZE(tension) /= ne) THEN CALL fail(ErrStat, ErrMsg, 'segment tensions: output size does not match the element count'); RETURN END IF - DO seg = 1, ne - tension(seg) = cable_element_tension(cables(obj), ne - seg + 1) - END DO + CALL cable_segment_tensions(cables(obj), tension, ErrStat, ErrMsg) RETURN END IF IF (.NOT. has_sys) THEN @@ -31035,6 +31193,8 @@ LOGICAL FUNCTION CD_Channel_Token_Parses(ch) RESULT(ok) ok = LEN_TRIM(lo) > 7 IF (ok) ok = VERIFY(lo(8:LEN_TRIM(lo)), '0123456789') == 0 IF (ok) ok = int_suffix(ch, 8) > 0 + ELSE IF (is_anchor_force_channel(lo)) THEN + ok = anchor_force_line_id(ch) > 0 ELSE IF (is_endpoint_angle_channel(lo)) THEN ok = endpoint_angle_line_id(ch) > 0 ELSE @@ -31109,6 +31269,14 @@ SUBROUTINE eval_system_line_channel(system, li, ch, val, ErrStat, ErrMsg) END IF RETURN END IF + IF (is_anchor_force_channel(lo)) THEN + ! a component of the AnchTen end force (End B = internal first node) + CALL line_model_anchor_force(system%lines(li), lo, val, es, em) + IF (es /= CD_DECKDRV_OK) THEN + CALL sys_solvefail(ch, em, ErrStat, ErrMsg); RETURN + END IF + RETURN + END IF ndof = CD_System_Line_NDOF(system, li, es, em) IF (es /= CD_SYSTEM_OK) THEN CALL sys_solvefail(ch, em, ErrStat, ErrMsg); RETURN @@ -31188,7 +31356,7 @@ SUBROUTINE eval_cable_channel(cable, ch, val, ErrStat, ErrMsg) !! -> fairlead (node nn, the coupled endpoint), so deck End A = internal node nn. Bend moment is !! EI(node) * |kvec_current - kvec_reference|; the built cable's reference is straight !! (kvec_reference = 0), so it reduces to EI * geometric curvature magnitude. - TYPE(CD_HFMF_ModuleType), INTENT(IN) :: cable + TYPE(CD_HFMF_ModuleType), INTENT(INOUT) :: cable CHARACTER(*), INTENT(IN) :: ch REAL(wp), INTENT(OUT) :: val INTEGER, INTENT(OUT) :: ErrStat @@ -31196,6 +31364,7 @@ SUBROUTINE eval_cable_channel(cable, ch, val, ErrStat, ErrMsg) CHARACTER(NAMELEN) :: lo INTEGER :: line_id, node, kind, comp, nnode, nelem, inode, es + REAL(wp) :: sec_ten, sec_curv, sec_bend CHARACTER(200) :: em ErrStat = CD_DECKDRV_OK @@ -31213,6 +31382,19 @@ SUBROUTINE eval_cable_channel(cable, ch, val, ErrStat, ErrMsg) ELSE IF (starts_with(lo, 'anchten')) THEN CALL cable_end_tension(cable, 1, val, ErrStat, ErrMsg) RETURN + ELSE IF (is_anchor_force_channel(lo)) THEN + ! a component of the AnchTen end force; Fz and the horizontal magnitude do not depend on + ! the cable's frame heading about +z + BLOCK + REAL(wp) :: force(3) + CALL CD_HermiteCable_Dyn_End_Force(cable%line, 1, force, es, em) + IF (es /= CD_HCDYN_OK) THEN + CALL fail_solve(ErrStat, ErrMsg, 'OUTPUT "'//TRIM(ch)//'": finite-EI end-force recovery failed: '// & + TRIM(em)); RETURN + END IF + val = anchor_force_component(lo, force) + END BLOCK + RETURN ELSE IF (is_endpoint_angle_channel(lo)) THEN IF (is_fair_endpoint_angle(lo)) THEN val = line_geom_value(7, 1, nnode, cable%line%q(1:6*nnode), 6) @@ -31233,15 +31415,16 @@ SUBROUTINE eval_cable_channel(cable, ch, val, ErrStat, ErrMsg) IF (inode == 1 .OR. inode == nnode) THEN ! a line end: the same support-reaction tension as FairTen/AnchTen CALL cable_end_tension(cable, inode, val, ErrStat, ErrMsg) - ELSE - ! Segment tension, as the EI=0 nodal channel: the length-weighted average of - ! the two adjacent element-mean axial forces. The pointwise resultant at the - ! node is not reported: with a stiff EA it oscillates about the element mean - ! wherever an element cannot follow the line (a nodal seabed-contact kink, a - ! section junction), by up to several times the line tension at any mesh. + ELSE IF (cable%line%output_element_recovery) THEN + ! OutputRecovery element: the length-weighted average of the two adjacent + ! element-mean axial forces EA (|r'| - 1) val = (cable%line%l0(inode - 1)*cable_element_mean_tension(cable, inode - 1) + & cable%line%l0(inode)*cable_element_mean_tension(cable, inode))/ & (cable%line%l0(inode - 1) + cable%line%l0(inode)) + ELSE + ! effective tension from nodal equilibrium (CD_HermiteCable_Dyn_Node_Recovery) + CALL cable_node_values(cable, inode, val, sec_curv, sec_bend, ErrStat, ErrMsg) + IF (ErrStat /= CD_DECKDRV_OK) RETURN END IF END BLOCK CASE (1) ! position (cable-local state rotated to the deck's global frame) @@ -31250,12 +31433,20 @@ SUBROUTINE eval_cable_channel(cable, ch, val, ErrStat, ErrMsg) val = cable_global_component(cable, cable%line%v(6*(inode - 1) + 1:6*(inode - 1) + 3), comp) CASE (4) ! acceleration val = cable_global_component(cable, cable%line%a(6*(inode - 1) + 1:6*(inode - 1) + 3), comp) - CASE (5) ! exact Hermite curvature, retaining the larger interface trace + CASE (5) ! curvature: recovered bend moment / EI, or the larger exact one-sided trace + IF (.NOT. cable%line%output_element_recovery) THEN + CALL cable_node_values(cable, inode, sec_ten, val, sec_bend, ErrStat, ErrMsg) + RETURN + END IF CALL cable_nodal_curvature(cable, inode, val, es, em) IF (es /= CD_HCABLE_OK) THEN CALL fail_solve(ErrStat, ErrMsg, 'OUTPUT "'//TRIM(ch)//'": '//TRIM(em)); RETURN END IF - CASE (6) ! exact |EI*kappa|, retaining the larger interface trace + CASE (6) ! bend moment: recovered from nodal equilibrium, or EI times the larger exact trace + IF (.NOT. cable%line%output_element_recovery) THEN + CALL cable_node_values(cable, inode, sec_ten, sec_curv, val, ErrStat, ErrMsg) + RETURN + END IF CALL cable_nodal_bend_moment(cable, inode, val, es, em) IF (es /= CD_HCABLE_OK) THEN CALL fail_solve(ErrStat, ErrMsg, 'OUTPUT "'//TRIM(ch)//'": '//TRIM(em)); RETURN @@ -31411,6 +31602,44 @@ SUBROUTINE cable_end_tension(cable, inode, tension, ErrStat, ErrMsg) tension = NORM2(force) END SUBROUTINE cable_end_tension + SUBROUTINE cable_node_values(cable, inode, tension, curvature, bend_moment, ErrStat, ErrMsg) + !! Equilibrium node values of a finite-EI cable at internal node inode + !! (CD_HermiteCable_Dyn_Node_Values): effective tension, curvature and bend moment. + TYPE(CD_HFMF_ModuleType), INTENT(INOUT) :: cable + INTEGER, INTENT(IN) :: inode + REAL(wp), INTENT(OUT) :: tension, curvature, bend_moment + INTEGER, INTENT(OUT) :: ErrStat + CHARACTER(*), INTENT(OUT) :: ErrMsg + INTEGER :: es + CHARACTER(200) :: em + ErrStat = CD_DECKDRV_OK; ErrMsg = '' + CALL CD_HermiteCable_Dyn_Node_Values(cable%line, inode, tension, curvature, bend_moment, es, em) + IF (es /= CD_HCDYN_OK) CALL fail_solve(ErrStat, ErrMsg, 'finite-EI node-value recovery failed: '//TRIM(em)) + END SUBROUTINE cable_node_values + + SUBROUTINE cable_segment_tensions(cable, tension, ErrStat, ErrMsg) + !! Segment tensions of a finite-EI cable in public order (segment 1 at End A): the mean of + !! the axial components of each element's own equilibrium end forces, in one pass + !! (CD_HermiteCable_Dyn_Node_Recovery); OutputRecovery element: the axial resultant at the + !! element midpoint. + TYPE(CD_HFMF_ModuleType), INTENT(IN) :: cable + REAL(wp), INTENT(OUT) :: tension(:) + INTEGER, INTENT(OUT) :: ErrStat + CHARACTER(*), INTENT(OUT) :: ErrMsg + INTEGER :: ne, e, es + CHARACTER(200) :: em + ErrStat = CD_DECKDRV_OK; ErrMsg = '' + ne = cable%line%ne + IF (cable%line%output_element_recovery) THEN + DO e = 1, ne + tension(e) = cable_element_tension(cable, ne - e + 1) + END DO + RETURN + END IF + CALL CD_HermiteCable_Dyn_Node_Recovery(cable%line, es, em, segment_tension=tension(ne:1:-1)) + IF (es /= CD_HCDYN_OK) CALL fail_solve(ErrStat, ErrMsg, 'finite-EI segment-tension recovery failed: '//TRIM(em)) + END SUBROUTINE cable_segment_tensions + SUBROUTINE cable_nodal_curvature(cable, inode, curvature, ErrStat, ErrMsg) !! Exact one-sided Hermite curvature traces at an internal line node. Curvature !! need not be continuous across a material interface because the interpolation @@ -31487,8 +31716,8 @@ END SUBROUTINE cable_element_curvature FUNCTION CD_Channel_Unit(ch) RESULT(unit) !! OrcaFlex-vocabulary output unit for a channel token, by kind: tension (FairTen/AnchTen/Ten) - !! -> (N); curvature (Curv) -> (1/m); bend moment (BendMom) -> (N.m); endpoint orientation/ - !! Dec/Azi -> (deg); torque (Torq) -> (N.m); twist (Twist) -> (deg); position (Point/...p) -> (m); + !! and anchor force (AnchFz/AnchFH) -> (N); curvature (Curv) -> (1/m); bend moment (BendMom) + !! -> (N.m); endpoint orientation/Dec/Azi -> (deg); torque (Torq) -> (N.m); twist (Twist) -> (deg); position (Point/...p) -> (m); !! velocity (...v) -> (m/s); !! acceleration (...a) -> (m/s2). CHARACTER(*), INTENT(IN) :: ch @@ -31510,7 +31739,7 @@ FUNCTION CD_Channel_Unit(ch) RESULT(unit) CASE (22:24); unit = '(N.m)' CASE DEFAULT; unit = '(-)' END SELECT - ELSE IF (starts_with(lo, 'fairten') .OR. starts_with(lo, 'anchten')) THEN + ELSE IF (starts_with(lo, 'fairten') .OR. starts_with(lo, 'anchten') .OR. is_anchor_force_channel(lo)) THEN unit = '(N)' ELSE IF (is_endpoint_angle_channel(lo)) THEN unit = '(deg)' diff --git a/src/CableDyn_HermiteCableDynamic.f90 b/src/CableDyn_HermiteCableDynamic.f90 index c039dd69..43d8195d 100644 --- a/src/CableDyn_HermiteCableDynamic.f90 +++ b/src/CableDyn_HermiteCableDynamic.f90 @@ -121,6 +121,10 @@ MODULE CableDyn_HermiteCableDynamic PUBLIC :: CD_HermiteCable_Dyn_Energy PUBLIC :: CD_HermiteCable_Dyn_Curvature PUBLIC :: CD_HermiteCable_Dyn_Reaction + PUBLIC :: CD_HermiteCable_Dyn_Curvature_Exact + PUBLIC :: CD_HermiteCable_Dyn_Set_Output_Recovery + PUBLIC :: CD_HermiteCable_Dyn_Node_Recovery + PUBLIC :: CD_HermiteCable_Dyn_Node_Values PUBLIC :: CD_HermiteCable_Dyn_End_Force PUBLIC :: CD_HermiteCable_Dyn_Set_ForceBlend PUBLIC :: CD_HermiteCable_Dyn_Max_Step_Rotation @@ -412,6 +416,26 @@ MODULE CableDyn_HermiteCableDynamic REAL(wp) :: tensile_worst_force = CD_ZERO, tensile_worst_threshold = CD_ZERO REAL(wp) :: tensile_worst_xi = CD_ZERO, tensile_worst_time = CD_ZERO INTEGER :: recovery_event_count = 0, recovery_max_substeps_used = 0 + ! Node output definitions (CD_HermiteCable_Dyn_Set_Output_Recovery): equilibrium recovery + ! by default, the element-mean axial force and exact curvature traces when set. + LOGICAL :: output_element_recovery = .FALSE. + ! Smallest bending stiffness [N m^2] whose recovered bend moment resolves a curvature: the largest + ! consistent-load moment w L0^2/12 of an element over a 1 m bend radius. The moment recovered + ! from nodal equilibrium carries an error of that order, independent of EI, so over a softer + ! section it cannot give the curvature (node_values then takes the exact geometric trace). + REAL(wp) :: ei_resolve = CD_ZERO + ! Cache of the element end residuals behind the node outputs (CD_HermiteCable_Dyn_Node_Values). + ! Element e's entry rc_g(:, e) is valid for the time and configuration epoch the cache was + ! keyed at (rc_t, rc_key_epoch) and for the element's own 12 q, v and a DOFs it was evaluated + ! at (rc_q/rc_v/rc_a(:, e)), the only state its residual depends on, so a node query costs two + ! element comparisons and the channels of one output row share one evaluation per element. + ! Allocated once at initialisation; rc_epoch counts the loads configured after it (drag, + ! axial damping, waves, added mass, held fluid, contact). + INTEGER :: rc_epoch = 0, rc_key_epoch = -1 + LOGICAL :: rc_key_ok = .FALSE. + REAL(wp) :: rc_t = CD_ZERO + REAL(wp), ALLOCATABLE :: rc_q(:, :), rc_v(:, :), rc_a(:, :), rc_g(:, :) + LOGICAL, ALLOCATABLE :: rc_have(:) LOGICAL :: initialized = .FALSE. END TYPE CD_HermiteCableDynType @@ -536,6 +560,7 @@ SUBROUTINE CD_HermiteCable_Dyn_Init(model, l0, EA, EI, rho_a, w, seed, fixed_dof model%seabed_z = seabed_z; model%kn = kn ALLOCATE (model%l0(ne), model%EA(ne), model%EI(ne), model%rho_a(ne), model%w(ne)) model%l0 = l0; model%EA = EA; model%EI = EI; model%rho_a = rho_a; model%w = w + model%ei_resolve = MAXVAL(ABS(w)*l0*l0)/12.0_wp ! gen-alpha constants rho = rho_inf @@ -600,6 +625,9 @@ SUBROUTINE CD_HermiteCable_Dyn_Init(model, l0, EA, EI, rho_a, w, seed, fixed_dof ! state: at-rest seed, v = 0, consistent a0 ALLOCATE (model%q(ndof), model%v(ndof), model%a(ndof)) + ALLOCATE (model%rc_q(12, ne), model%rc_v(12, ne), model%rc_a(12, ne), model%rc_g(12, ne), model%rc_have(ne)) + model%rc_have = .FALSE. + model%rc_key_ok = .FALSE. model%q = seed model%v = CD_ZERO model%a = CD_ZERO @@ -646,6 +674,7 @@ SUBROUTINE CD_HermiteCable_Dyn_Set_Contact(model, kn_node, cn_node, mu, ErrStat, CHARACTER(200) :: em ErrStat = CD_HCDYN_OK; ErrMsg = '' + model%rc_epoch = model%rc_epoch + 1 ! A load-configuration change invalidates the cached committed force F_n. model%fc_valid = .FALSE. model%tr_valid = .FALSE. @@ -1699,6 +1728,7 @@ SUBROUTINE CD_HermiteCable_Dyn_Set_Drag(model, rho_w, diam, cdn, cdt, waterline_ LOGICAL :: had_drag ErrStat = CD_HCDYN_OK; ErrMsg = '' + model%rc_epoch = model%rc_epoch + 1 ! A load-configuration change invalidates the cached committed force F_n. model%fc_valid = .FALSE. model%tr_valid = .FALSE. @@ -1797,6 +1827,7 @@ SUBROUTINE CD_HermiteCable_Dyn_Set_Axial_Damping(model, BA, ErrStat, ErrMsg) CHARACTER(300) :: em ErrStat = CD_HCDYN_OK + model%rc_epoch = model%rc_epoch + 1 ! A load-configuration change invalidates the cached committed force F_n. model%fc_valid = .FALSE. model%tr_valid = .FALSE. @@ -1867,6 +1898,7 @@ SUBROUTINE CD_HermiteCable_Dyn_Set_AddedMass(model, rho_w, diam, can, cat, water LOGICAL :: had_am ErrStat = CD_HCDYN_OK; ErrMsg = '' + model%rc_epoch = model%rc_epoch + 1 ! A load-configuration change invalidates the cached committed force F_n. model%fc_valid = .FALSE. model%tr_valid = .FALSE. @@ -1962,6 +1994,7 @@ SUBROUTINE CD_HermiteCable_Dyn_Set_Waves(model, height, period, direction_deg, d CHARACTER(200) :: em2 ErrStat = CD_HCDYN_OK; ErrMsg = '' + model%rc_epoch = model%rc_epoch + 1 ! A load-configuration change invalidates the cached committed force F_n. model%fc_valid = .FALSE. model%tr_valid = .FALSE. @@ -2081,6 +2114,7 @@ SUBROUTINE CD_HermiteCable_Dyn_Set_Irregular_Waves(model, amplitude, period, pha CHARACTER(200) :: em2 ErrStat = CD_HCDYN_OK; ErrMsg = '' + model%rc_epoch = model%rc_epoch + 1 ! A load-configuration change invalidates the cached committed force F_n. model%fc_valid = .FALSE. model%tr_valid = .FALSE. @@ -2217,6 +2251,7 @@ SUBROUTINE CD_HermiteCable_Dyn_Set_Held_Fluid(model, fluid_velocity, fluid_accel LOGICAL :: had_field CHARACTER(240) :: em ErrStat = CD_HCDYN_OK; ErrMsg = '' + model%rc_epoch = model%rc_epoch + 1 ! A load-configuration change invalidates the cached committed force F_n. The carried step ! factor stays usable (a per-step field update only perturbs the drag and inertia tangent; ! the first field's consistent-acceleration solve drops it). @@ -4417,7 +4452,32 @@ SUBROUTINE CD_HermiteCable_Dyn_Energy(model, kinetic, strain, ErrStat, ErrMsg, c END SUBROUTINE CD_HermiteCable_Dyn_Energy SUBROUTINE CD_HermiteCable_Dyn_Curvature(model, curv_out, ErrStat, ErrMsg) - !! Per-node centreline curvature at the current state (element-midpoint / endpoint maxima). + !! Per-node curvature at the current state, the definition of the CurvN channels: the + !! bend moment recovered from nodal equilibrium over EI (CD_HermiteCable_Dyn_Node_Recovery), + !! or, under CD_HermiteCable_Dyn_Set_Output_Recovery(.TRUE.), the exact one-sided traces of + !! CD_HermiteCable_Dyn_Curvature_Exact. + TYPE(CD_HermiteCableDynType), INTENT(IN) :: model + REAL(wp), INTENT(OUT) :: curv_out(:) + INTEGER, INTENT(OUT) :: ErrStat + CHARACTER(*), INTENT(OUT) :: ErrMsg + ErrStat = CD_HCDYN_OK; ErrMsg = '' + IF (model%output_element_recovery) THEN + CALL CD_HermiteCable_Dyn_Curvature_Exact(model, curv_out, ErrStat, ErrMsg) + RETURN + END IF + IF (.NOT. model%initialized) THEN + ErrStat = CD_HCDYN_BADINPUT; ErrMsg = 'CD_HermiteCable_Dyn_Curvature: model not initialised'; RETURN + END IF + IF (SIZE(curv_out) /= model%nn) THEN + ErrStat = CD_HCDYN_BADINPUT; ErrMsg = 'CD_HermiteCable_Dyn_Curvature: curv_out must be nn'; RETURN + END IF + CALL CD_HermiteCable_Dyn_Node_Recovery(model, ErrStat, ErrMsg, curvature=curv_out) + END SUBROUTINE CD_HermiteCable_Dyn_Curvature + + SUBROUTINE CD_HermiteCable_Dyn_Curvature_Exact(model, curv_out, ErrStat, ErrMsg) + !! Per-node geometric curvature of the cubic-Hermite centreline at the current state: the + !! exact curvature of the element interpolation at the node, the larger of the two + !! one-sided traces at an interior node (the curvature is discontinuous there). TYPE(CD_HermiteCableDynType), INTENT(IN) :: model REAL(wp), INTENT(OUT) :: curv_out(:) INTEGER, INTENT(OUT) :: ErrStat @@ -4427,10 +4487,10 @@ SUBROUTINE CD_HermiteCable_Dyn_Curvature(model, curv_out, ErrStat, ErrMsg) CHARACTER(200) :: em2 ErrStat = CD_HCDYN_OK; ErrMsg = '' IF (.NOT. model%initialized) THEN - ErrStat = CD_HCDYN_BADINPUT; ErrMsg = 'CD_HermiteCable_Dyn_Curvature: model not initialised'; RETURN + ErrStat = CD_HCDYN_BADINPUT; ErrMsg = 'CD_HermiteCable_Dyn_Curvature_Exact: model not initialised'; RETURN END IF IF (SIZE(curv_out) /= model%nn) THEN - ErrStat = CD_HCDYN_BADINPUT; ErrMsg = 'CD_HermiteCable_Dyn_Curvature: curv_out must be nn'; RETURN + ErrStat = CD_HCDYN_BADINPUT; ErrMsg = 'CD_HermiteCable_Dyn_Curvature_Exact: curv_out must be nn'; RETURN END IF DO a = 1, model%nn curv_out(a) = CD_ZERO @@ -4441,7 +4501,7 @@ SUBROUTINE CD_HermiteCable_Dyn_Curvature(model, curv_out, ErrStat, ErrMsg) CALL gather_elem(model, a, qe) CALL CD_HermiteCable_Curvature(qe, model%l0(a), CD_ZERO, kR, es, em2) IF (es /= CD_HCABLE_OK) THEN - ErrStat = CD_HCDYN_NOCONVERGE; ErrMsg = 'CD_HermiteCable_Dyn_Curvature: '//TRIM(em2); RETURN + ErrStat = CD_HCDYN_NOCONVERGE; ErrMsg = 'CD_HermiteCable_Dyn_Curvature_Exact: '//TRIM(em2); RETURN END IF curv_out(a) = kR END IF @@ -4449,12 +4509,12 @@ SUBROUTINE CD_HermiteCable_Dyn_Curvature(model, curv_out, ErrStat, ErrMsg) CALL gather_elem(model, a - 1, qe) CALL CD_HermiteCable_Curvature(qe, model%l0(a - 1), CD_ONE, kL, es, em2) IF (es /= CD_HCABLE_OK) THEN - ErrStat = CD_HCDYN_NOCONVERGE; ErrMsg = 'CD_HermiteCable_Dyn_Curvature: '//TRIM(em2); RETURN + ErrStat = CD_HCDYN_NOCONVERGE; ErrMsg = 'CD_HermiteCable_Dyn_Curvature_Exact: '//TRIM(em2); RETURN END IF curv_out(a) = MAX(curv_out(a), kL) END IF END DO - END SUBROUTINE CD_HermiteCable_Dyn_Curvature + END SUBROUTINE CD_HermiteCable_Dyn_Curvature_Exact SUBROUTINE CD_HermiteCable_Dyn_Reaction(model, node, freac, ErrStat, ErrMsg) !! Constraint reaction at a fixed/prescribed node: the force the LINE exerts ON its @@ -4682,6 +4742,493 @@ SUBROUTINE CD_HermiteCable_Dyn_End_Force(model, node, force, ErrStat, ErrMsg) force(3) = MAX(force(3), CD_ZERO) END SUBROUTINE CD_HermiteCable_Dyn_End_Force + SUBROUTINE CD_HermiteCable_Dyn_Set_Output_Recovery(model, element_recovery) + !! Definition of the node tension, curvature and bend moment (OPTIONS OutputRecovery). + !! .FALSE. (equilibrium, the default): recovered from nodal equilibrium + !! (CD_HermiteCable_Dyn_Node_Recovery). .TRUE. (element): the element-mean axial force + !! EA (|r'| - 1) and the exact one-sided curvature traces of the element interpolation. + TYPE(CD_HermiteCableDynType), INTENT(INOUT) :: model + LOGICAL, INTENT(IN) :: element_recovery + model%output_element_recovery = element_recovery + END SUBROUTINE CD_HermiteCable_Dyn_Set_Output_Recovery + + SUBROUTINE CD_HermiteCable_Dyn_Node_Values(model, node, tension, curvature, bend_moment, ErrStat, ErrMsg) + !! Equilibrium node values at one node (internal order), from the two adjacent elements; + !! the same values as CD_HermiteCable_Dyn_Node_Recovery returns for that node. The element end + !! residuals are kept in the model for the element state they were evaluated at (see the rc_ + !! fields), so the tension, curvature and bend moment of a node, and of neighbouring nodes, + !! share one evaluation per element; a changed time, load configuration or element state + !! refreshes them. A query compares the two adjacent elements' states only, so a loop over + !! every node of a line costs O(nn). No allocation. + TYPE(CD_HermiteCableDynType), INTENT(INOUT) :: model + INTEGER, INTENT(IN) :: node + REAL(wp), INTENT(OUT) :: tension, curvature, bend_moment + INTEGER, INTENT(OUT) :: ErrStat + CHARACTER(*), INTENT(OUT) :: ErrMsg + REAL(wp) :: g(12), fm(3), mm(3), fp(3), mp(3) + + ErrStat = CD_HCDYN_OK; ErrMsg = '' + tension = CD_ZERO; curvature = CD_ZERO; bend_moment = CD_ZERO + IF (.NOT. model%initialized) THEN + ErrStat = CD_HCDYN_BADINPUT; ErrMsg = 'CD_HermiteCable_Dyn_Node_Values: model not initialised'; RETURN + END IF + IF (node < 1 .OR. node > model%nn) THEN + ErrStat = CD_HCDYN_BADINPUT; ErrMsg = 'CD_HermiteCable_Dyn_Node_Values: node out of range'; RETURN + END IF + ! the cached residuals belong to the time and load configuration they were computed at, and + ! each to its element's state (exact comparisons; a NaN never matches and is recomputed) + IF (.NOT. (model%rc_key_ok .AND. model%rc_key_epoch == model%rc_epoch .AND. model%rc_t == model%t)) THEN + model%rc_t = model%t; model%rc_key_epoch = model%rc_epoch + model%rc_key_ok = .TRUE. + model%rc_have = .FALSE. + END IF + fm = CD_ZERO; mm = CD_ZERO; fp = CD_ZERO; mp = CD_ZERO + IF (node > 1) THEN + CALL cached_end_residual(node - 1, g) + IF (ErrStat /= CD_HCDYN_OK) RETURN + fm = g(7:9); mm = g(10:12) + END IF + IF (node < model%nn) THEN + CALL cached_end_residual(node, g) + IF (ErrStat /= CD_HCDYN_OK) RETURN + fp = -g(1:3); mp = -g(4:6) + END IF + CALL node_values(model, node, fm, mm, fp, mp, tension, curvature, bend_moment, ErrStat, ErrMsg) + + CONTAINS + + SUBROUTINE cached_end_residual(e, ge) + INTEGER, INTENT(IN) :: e + REAL(wp), INTENT(OUT) :: ge(12) + REAL(wp) :: gl(12) + INTEGER :: i0 + ! the element's residual depends on its own two nodes' q, v and a only (element_end_residual) + i0 = 6*(e - 1) + IF (model%rc_have(e)) THEN + IF (ALL(model%rc_q(:, e) == model%q(i0 + 1:i0 + 12)) .AND. ALL(model%rc_v(:, e) == model%v(i0 + 1:i0 + 12)) & + .AND. ALL(model%rc_a(:, e) == model%a(i0 + 1:i0 + 12))) THEN + ge = model%rc_g(:, e); RETURN + END IF + END IF + model%rc_have(e) = .FALSE. + CALL element_end_residual(model, e, gl, ErrStat, ErrMsg) + IF (ErrStat /= CD_HCDYN_OK) THEN + ge = CD_ZERO; RETURN + END IF + model%rc_q(:, e) = model%q(i0 + 1:i0 + 12) + model%rc_v(:, e) = model%v(i0 + 1:i0 + 12) + model%rc_a(:, e) = model%a(i0 + 1:i0 + 12) + model%rc_g(:, e) = gl + model%rc_have(e) = .TRUE. + ge = gl + END SUBROUTINE cached_end_residual + END SUBROUTINE CD_HermiteCable_Dyn_Node_Values + + SUBROUTINE CD_HermiteCable_Dyn_Node_Recovery(model, ErrStat, ErrMsg, tension, curvature, bend_moment, & + segment_tension) + !! Effective tension, curvature and bend moment at every node (internal order) recovered + !! from nodal equilibrium, in one pass over the elements. + !! + !! For element e the end residual g_e = f_int + f_damp - f_ext + M_e a_e holds the element's + !! own distributed loads (consistent submerged weight, dry-part buoyancy, drag, + !! Froude-Krylov force, the seabed contact of its end nodes spread over their tributary + !! lengths, and the structural and added-mass inertia): it is the generalized force the two + !! end nodes exert on the element. Its position rows on the End-B side (internal node e+1) + !! are the section force just before that node, minus its rows on the End-A side the + !! section force just after node e; its tangent rows are the conjugate of the material + !! tangent, EI r'' at the node. An interior node reports the mean of its two one-sided + !! values, whose difference is the point load left at the node, so the nodal section + !! forces satisfy the discrete equilibrium exactly and do not carry the pointwise + !! oscillation of the stiff-EA axial strain. + !! + !! tension(j) = t_j . F_j (t_j the unit nodal tangent; a line end reports the end force + !! magnitude of CD_HermiteCable_Dyn_End_Force), bend_moment(j) = |m_j - (m_j . t_j) t_j|, + !! curvature(j) = bend_moment(j)/EI, the larger of the two sides at a section junction (the + !! exact geometric trace on an element without bending stiffness, or with EI below ei_resolve, + !! where the recovered moment error w L0^2/12 exceeds the elastic moment of a 1 m bend radius). + !! segment_tension(e) is the + !! mean of the axial components of element e's own two end forces. Every output is + !! optional (node arrays nn, segment_tension ne); the routine allocates nothing. + !! + !! The condensed torque of a line restrained in torsion is not part of g_e: it adds a shear + !! normal to the tangent and does no work on bending rotations, so tension and bend moment + !! are its axial and normal parts without it. Read-only. + TYPE(CD_HermiteCableDynType), INTENT(IN) :: model + INTEGER, INTENT(OUT) :: ErrStat + CHARACTER(*), INTENT(OUT) :: ErrMsg + REAL(wp), INTENT(OUT), OPTIONAL :: tension(:), curvature(:), bend_moment(:), segment_tension(:) + REAL(wp) :: g(12), fm(3), mm(3), fp(3), mp(3), ta(3), tb(3) + INTEGER :: e, nn + LOGICAL :: want_nodes + + ErrStat = CD_HCDYN_OK; ErrMsg = '' + IF (.NOT. model%initialized) THEN + ErrStat = CD_HCDYN_BADINPUT; ErrMsg = 'CD_HermiteCable_Dyn_Node_Recovery: model not initialised'; RETURN + END IF + nn = model%nn + IF (.NOT. (size_ok(tension, nn) .AND. size_ok(curvature, nn) .AND. size_ok(bend_moment, nn) .AND. & + size_ok(segment_tension, model%ne))) THEN + ErrStat = CD_HCDYN_BADINPUT + ErrMsg = 'CD_HermiteCable_Dyn_Node_Recovery: node arrays must be nn, segment_tension ne'; RETURN + END IF + want_nodes = PRESENT(tension) .OR. PRESENT(curvature) .OR. PRESENT(bend_moment) + fm = CD_ZERO; mm = CD_ZERO + DO e = 1, model%ne + CALL element_end_residual(model, e, g, ErrStat, ErrMsg) + IF (ErrStat /= CD_HCDYN_OK) RETURN + fp = -g(1:3); mp = -g(4:6) + IF (want_nodes) THEN + CALL store_node(e) + IF (ErrStat /= CD_HCDYN_OK) RETURN + END IF + IF (PRESENT(segment_tension)) THEN + ta = unit_tangent(model, e) + tb = unit_tangent(model, e + 1) + segment_tension(e) = 0.5_wp*(DOT_PRODUCT(ta, fp) + DOT_PRODUCT(tb, g(7:9))) + END IF + fm = g(7:9); mm = g(10:12) + END DO + fp = CD_ZERO; mp = CD_ZERO + IF (want_nodes) CALL store_node(nn) + + CONTAINS + + SUBROUTINE store_node(node) + INTEGER, INTENT(IN) :: node + REAL(wp) :: t_n, k_n, b_n + CALL node_values(model, node, fm, mm, fp, mp, t_n, k_n, b_n, ErrStat, ErrMsg) + IF (PRESENT(tension)) tension(node) = t_n + IF (PRESENT(curvature)) curvature(node) = k_n + IF (PRESENT(bend_moment)) bend_moment(node) = b_n + END SUBROUTINE store_node + + PURE LOGICAL FUNCTION size_ok(x, n) RESULT(ok) + REAL(wp), INTENT(IN), OPTIONAL :: x(:) + INTEGER, INTENT(IN) :: n + ok = .TRUE. + IF (PRESENT(x)) ok = SIZE(x) == n + END FUNCTION size_ok + END SUBROUTINE CD_HermiteCable_Dyn_Node_Recovery + + SUBROUTINE node_values(model, node, fm, mm, fp, mp, tension, curvature, bend_moment, ErrStat, ErrMsg) + !! Node values from the one-sided section force and moment before (fm, mm) and after + !! (fp, mp) the node; a line end uses its only side (see CD_HermiteCable_Dyn_Node_Recovery). + TYPE(CD_HermiteCableDynType), INTENT(IN) :: model + INTEGER, INTENT(IN) :: node + REAL(wp), INTENT(IN) :: fm(3), mm(3), fp(3), mp(3) + REAL(wp), INTENT(OUT) :: tension, curvature, bend_moment + INTEGER, INTENT(OUT) :: ErrStat + CHARACTER(*), INTENT(OUT) :: ErrMsg + REAL(wp) :: t(3), f(3), m(3), fend(3), qe(12), trace + INTEGER :: e, side + CHARACTER(200) :: em2 + + ErrStat = CD_HCDYN_OK; ErrMsg = '' + t = unit_tangent(model, node) + IF (node == 1) THEN + f = fp; m = mp + ELSE IF (node == model%nn) THEN + f = fm; m = mm + ELSE + f = 0.5_wp*(fm + fp); m = 0.5_wp*(mm + mp) + END IF + IF (node == 1 .OR. node == model%nn) THEN + CALL CD_HermiteCable_Dyn_End_Force(model, node, fend, ErrStat, ErrMsg) + IF (ErrStat /= CD_HCDYN_OK) RETURN + tension = NORM2(fend) + ELSE + tension = DOT_PRODUCT(t, f) + END IF + bend_moment = NORM2(m - DOT_PRODUCT(m, t)*t) + curvature = CD_ZERO + DO side = 0, 1 + e = node - 1 + side + IF (e < 1 .OR. e > model%ne) CYCLE + IF (model%EI(e) > CD_ZERO .AND. model%EI(e) >= model%ei_resolve) THEN + curvature = MAX(curvature, bend_moment/model%EI(e)) + ELSE + CALL gather_elem(model, e, qe) + CALL CD_HermiteCable_Curvature(qe, model%l0(e), REAL(1 - side, wp), trace, ErrStat, em2) + IF (ErrStat /= CD_HCABLE_OK) THEN + ErrStat = CD_HCDYN_NOCONVERGE; ErrMsg = 'CD_HermiteCable_Dyn_Node_Recovery: '//TRIM(em2); RETURN + END IF + curvature = MAX(curvature, trace) + END IF + END DO + END SUBROUTINE node_values + + PURE FUNCTION unit_tangent(model, node) RESULT(t) + !! Unit material tangent of a node (internal arc direction); zero when degenerate. + TYPE(CD_HermiteCableDynType), INTENT(IN) :: model + INTEGER, INTENT(IN) :: node + REAL(wp) :: t(3), tn + t = model%q(6*(node - 1) + 4:6*(node - 1) + 6) + tn = NORM2(t) + IF (tn > CD_ZERO) THEN + t = t/tn + ELSE + t = CD_ZERO + END IF + END FUNCTION unit_tangent + + SUBROUTINE node_contact_normal(model, node, fc, ErrStat, ErrMsg) + !! Frictionless seabed contact force on a node at the committed state, exactly as + !! assemble_contact applies it: the normal force with its damping and, in a rounded crease + !! of the bathymetry, the elastic increment of the penalty potential (crease_contact_increment). + TYPE(CD_HermiteCableDynType), INTENT(IN) :: model + INTEGER, INTENT(IN) :: node + REAL(wp), INTENT(OUT) :: fc(3) + INTEGER, INTENT(OUT) :: ErrStat + CHARACTER(*), INTENT(OUT) :: ErrMsg + REAL(wp) :: z_floor, gx, gy, xg, yg, gxg, gyg, sfac, nvec(3), gap, normal, normal_gap, vn, gate, gate_gap + REAL(wp) :: curv_g(3), fcrease(3), kcrease(3, 3) + INTEGER :: iz, es + LOGICAL :: creased + CHARACTER(200) :: em2 + ErrStat = CD_HCDYN_OK; ErrMsg = '' + fc = CD_ZERO + iz = 6*(node - 1) + 3 + IF (model%has_contact) THEN + z_floor = model%seabed_z + gx = CD_ZERO; gy = CD_ZERO + creased = .FALSE. + IF (model%has_contact_bathymetry) THEN + xg = model%contact_frame_c*model%q(iz - 2) - model%contact_frame_s*model%q(iz - 1) + yg = model%contact_frame_s*model%q(iz - 2) + model%contact_frame_c*model%q(iz - 1) + CALL CD_Bathymetry_Floor_Gradient(model%contact_bathymetry, xg, yg, z_floor, gxg, gyg, es, em2, & + crease_curvature=curv_g) + IF (es /= CD_BATHY_OK) THEN + ErrStat = CD_HCDYN_NOCONVERGE; ErrMsg = 'node_contact_normal: '//TRIM(em2); RETURN + END IF + gx = model%contact_frame_c*gxg + model%contact_frame_s*gyg + gy = -model%contact_frame_s*gxg + model%contact_frame_c*gyg + creased = ANY(ABS(curv_g) > CD_ZERO) + END IF + sfac = SQRT(CD_ONE + gx*gx + gy*gy) + nvec = [-gx, -gy, CD_ONE]/sfac + gap = (z_floor - model%q(iz))/sfac + CALL CD_Seabed_Normal_Law(gap, model%contact_kn(node), normal, normal_gap) + CALL CD_Seabed_Contact_Gate(gap, gate, gate_gap) + IF (normal <= CD_ZERO .AND. gate <= CD_ZERO) RETURN + vn = DOT_PRODUCT(model%v(iz - 2:iz), nvec) + IF (ALLOCATED(model%contact_cn) .AND. vn < CD_ZERO) normal = normal - model%contact_cn(node)*gate*vn + fc = normal*nvec + IF (creased) THEN + CALL crease_contact_increment(z_floor - model%q(iz), gx, gy, model%contact_kn(node), & + CD_Bathymetry_Rotate_Curvature(curv_g, [model%contact_frame_c, & + model%contact_frame_s]), & + fcrease, kcrease) + fc = fc + fcrease + END IF + ELSE IF (model%kn > CD_ZERO) THEN + gap = model%seabed_z - model%q(iz) + IF (gap > CD_ZERO) fc(3) = model%kn*gap*model%trib(node) + END IF + END SUBROUTINE node_contact_normal + + SUBROUTINE added_mass_force(qe, ae, l0, waterline_z, rho, diam, can, cat, f, ErrStat, ErrMsg) + !! Added-mass inertia force Ma(qe) ae of one element without forming Ma: the quadrature, + !! wet/dry culling and deformed length measure of CD_HermiteCable_AddedMass_Element. + REAL(wp), INTENT(IN) :: qe(12), ae(12), l0, waterline_z, rho, diam, can, cat + REAL(wp), INTENT(OUT) :: f(12) + INTEGER, INTENT(OUT) :: ErrStat + CHARACTER(*), INTENT(OUT) :: ErrMsg + INTEGER, PARAMETER :: NGP = 4 + REAL(wp), PARAMETER :: PI_L = 3.14159265358979323846_wp + REAL(wp) :: gp(NGP), gw(NGP), H(4), dH(4), rpos(3), rp(3), acc(3), speed, tangent(3), fa(3), area + INTEGER :: g, sh, c + + ErrStat = CD_HCDYN_OK; ErrMsg = '' + f = CD_ZERO + area = 0.25_wp*PI_L*diam*diam + gp = [0.5_wp*(CD_ONE - 0.8611363115940526_wp), 0.5_wp*(CD_ONE - 0.3399810435848563_wp), & + 0.5_wp*(CD_ONE + 0.3399810435848563_wp), 0.5_wp*(CD_ONE + 0.8611363115940526_wp)] + gw = 0.5_wp*[0.3478548451374538_wp, 0.6521451548625461_wp, & + 0.6521451548625461_wp, 0.3478548451374538_wp] + DO g = 1, NGP + CALL CD_HermiteCable_Shapes(gp(g), l0, H, dH) + DO c = 1, 3 + rpos(c) = H(1)*qe(c) + H(2)*qe(3 + c) + H(3)*qe(6 + c) + H(4)*qe(9 + c) + rp(c) = dH(1)*qe(c) + dH(2)*qe(3 + c) + dH(3)*qe(6 + c) + dH(4)*qe(9 + c) + acc(c) = H(1)*ae(c) + H(2)*ae(3 + c) + H(3)*ae(6 + c) + H(4)*ae(9 + c) + END DO + IF (rpos(3) > waterline_z) CYCLE ! dry Gauss point: no added mass + speed = SQRT(rp(1)**2 + rp(2)**2 + rp(3)**2) + IF (speed <= 1.0e-12_wp) THEN + ErrStat = CD_HCDYN_NOCONVERGE + ErrMsg = 'added-mass force: degenerate centreline (|dr/dxi| ~ 0)'; RETURN + END IF + tangent = rp/speed + fa = gw(g)*speed*rho*area*(can*acc + (cat - can)*DOT_PRODUCT(tangent, acc)*tangent) + DO sh = 1, 4 + f(3*(sh - 1) + 1:3*sh) = f(3*(sh - 1) + 1:3*sh) + H(sh)*fa + END DO + END DO + END SUBROUTINE added_mass_force + + SUBROUTINE element_end_residual(model, e, g, ErrStat, ErrMsg) + !! g = f_int + f_damp - f_ext + M_e a_e of element e alone at the committed state, with the + !! element's own distributed loads (see CD_HermiteCable_Dyn_Node_Recovery). + TYPE(CD_HermiteCableDynType), INTENT(IN) :: model + INTEGER, INTENT(IN) :: e + REAL(wp), INTENT(OUT) :: g(12) + INTEGER, INTENT(OUT) :: ErrStat + CHARACTER(*), INTENT(OUT) :: ErrMsg + REAL(wp), PARAMETER :: PI_L = 3.14159265358979323846_wp + INTEGER, PARAMETER :: ZS(4) = [3, 6, 9, 12] + REAL(wp) :: qe(12), ve(12), ae(12), fe(12), fx(12), energy, fdry(4), kdry(4, 4) + REAL(wp) :: dry_wl, dry_b, dry_r, hf_mid(3), l0, fca(3), fcb(3), c, a4(4), m4(4, 4) + REAL(wp) :: support(3), dsupport(3), nin(3) + INTEGER :: es, k, inode + LOGICAL :: dry + CHARACTER(200) :: em2 + + ErrStat = CD_HCDYN_OK; ErrMsg = ''; em2 = '' + g = CD_ZERO + l0 = model%l0(e) + qe(1:6) = model%q(6*(e - 1) + 1:6*e); qe(7:12) = model%q(6*e + 1:6*(e + 1)) + ve(1:6) = model%v(6*(e - 1) + 1:6*e); ve(7:12) = model%v(6*e + 1:6*(e + 1)) + CALL CD_HermiteCable_Element(qe, l0, model%EA(e), model%EI(e), energy, fe, ErrStat=es, ErrMsg=em2, & + axial_quadrature_order=model%axial_quadrature_order, & + bending_quadrature_order=model%bending_quadrature_order) + IF (es /= CD_HCABLE_OK) GOTO 900 + g = fe + IF (model%has_axial_damping) THEN + CALL CD_HermiteCable_Axial_Damping_Element(qe, ve, l0, model%BA(e), fx, ErrStat=es, ErrMsg=em2, & + quadrature_order=model%axial_quadrature_order) + IF (es /= CD_HCDYN_OK) GOTO 900 + g = g + fx + END IF + ! consistent submerged weight (as assemble_residual) + g(3) = g(3) + model%w(e)*0.5_wp*l0 + g(6) = g(6) + model%w(e)*l0*l0/12.0_wp + g(9) = g(9) + model%w(e)*0.5_wp*l0 + g(12) = g(12) - model%w(e)*l0*l0/12.0_wp + IF (model%has_drag .OR. model%has_am) THEN + IF (model%has_drag) THEN + dry_wl = model%waterline_z + dry_b = model%rho_w*model%gravity*0.25_wp*PI_L*model%diam(e)**2 + dry_r = 0.5_wp*model%diam(e) + ELSE + dry_wl = model%am_wl + dry_b = model%am_rho*model%gravity*0.25_wp*PI_L*model%am_diam(e)**2 + dry_r = 0.5_wp*model%am_diam(e) + END IF + IF (model%has_held_field) dry_wl = 0.5_wp*(model%hf_wl(e) + model%hf_wl(e + 1)) + CALL CD_HermiteCable_Dry_Buoyancy(qe(ZS), l0, dry_b, dry_wl, fdry, kdry, dry, radius=dry_r) + IF (dry) g(ZS) = g(ZS) + fdry + END IF + IF (model%has_drag) THEN + IF (model%has_wave .AND. model%wv_ncomp > 0) THEN + CALL CD_HermiteCable_Drag_Element(qe, ve, l0, model%current, model%waterline_z, & + model%rho_w, model%diam(e), model%cdn(e), model%cdt(e), & + fx, ErrStat=es, ErrMsg=em2, & + wv_depth=model%wv_depth, wv_dir=model%wv_dir, wv_t=model%t, & + wvc_amp=model%wv_ampc, wvc_om=model%wv_omc, & + wvc_k=model%wv_kc, wvc_ph=model%wv_phc, & + wvc_e2kd=model%wv_e2kd) + ELSE IF (model%has_wave) THEN + CALL CD_HermiteCable_Drag_Element(qe, ve, l0, model%current, model%waterline_z, & + model%rho_w, model%diam(e), model%cdn(e), model%cdt(e), & + fx, ErrStat=es, ErrMsg=em2, & + wv_h=model%wv_h, wv_om=model%wv_om, wv_k=model%wv_k, & + wv_depth=model%wv_depth, wv_dir=model%wv_dir, wv_t=model%t) + ELSE IF (model%has_held_field) THEN + CALL CD_HermiteCable_Drag_Element(qe, ve, l0, & + model%current + 0.5_wp*(model%hf_u(:, e) + model%hf_u(:, e + 1)), & + 0.5_wp*(model%hf_wl(e) + model%hf_wl(e + 1)), & + model%rho_w, model%diam(e), model%cdn(e), model%cdt(e), & + fx, ErrStat=es, ErrMsg=em2) + ELSE + CALL CD_HermiteCable_Drag_Element(qe, ve, l0, model%current, model%waterline_z, & + model%rho_w, model%diam(e), model%cdn(e), model%cdt(e), & + fx, ErrStat=es, ErrMsg=em2) + END IF + IF (es /= CD_HCDYN_OK) GOTO 900 + g = g - fx + END IF + IF (model%has_am .AND. (model%has_wave .OR. model%has_held_field)) THEN + IF (model%has_held_field) THEN + hf_mid = 0.5_wp*(model%hf_ud(:, e) + model%hf_ud(:, e + 1)) + CALL CD_HermiteCable_FK_Element(qe, l0, 0.5_wp*(model%hf_wl(e) + model%hf_wl(e + 1)), & + model%am_rho, model%am_diam(e), model%am_can(e), model%am_cat(e), & + wv_depth=CD_ZERO, wv_dir=CD_ZERO, wv_t=CD_ZERO, & + ffk=fx, ErrStat=es, ErrMsg=em2, hf_a=hf_mid) + ELSE IF (model%wv_ncomp > 0) THEN + CALL CD_HermiteCable_FK_Element(qe, l0, model%am_wl, model%am_rho, model%am_diam(e), & + model%am_can(e), model%am_cat(e), & + wv_depth=model%wv_depth, wv_dir=model%wv_dir, wv_t=model%t, & + ffk=fx, ErrStat=es, ErrMsg=em2, & + wvc_amp=model%wv_ampc, wvc_om=model%wv_omc, & + wvc_k=model%wv_kc, wvc_ph=model%wv_phc, wvc_e2kd=model%wv_e2kd) + ELSE + CALL CD_HermiteCable_FK_Element(qe, l0, model%am_wl, model%am_rho, model%am_diam(e), & + model%am_can(e), model%am_cat(e), & + wv_h=model%wv_h, wv_om=model%wv_om, wv_k=model%wv_k, & + wv_depth=model%wv_depth, wv_dir=model%wv_dir, wv_t=model%t, & + ffk=fx, ErrStat=es, ErrMsg=em2) + END IF + IF (es /= CD_HCDYN_OK) GOTO 900 + g = g - fx + END IF + ! Seabed contact acts at the nodes; spread over each node's tributary length it is the + ! distributed floor reaction it stands for. Its consistent share is taken out of the element, + ! so a line resting on the floor carries no fixed-end moment of its own weight. + IF (model%has_contact .OR. model%kn > CD_ZERO) THEN + CALL node_contact_normal(model, e, fca, es, em2) + IF (es /= CD_HCDYN_OK) GOTO 900 + CALL node_contact_normal(model, e + 1, fcb, es, em2) + IF (es /= CD_HCDYN_OK) GOTO 900 + IF (model%trib(e) > CD_ZERO) fca = fca*l0/model%trib(e) + IF (model%trib(e + 1) > CD_ZERO) fcb = fcb*l0/model%trib(e + 1) + ! A held end whose end element lies on the floor (assemble_residual): the seabed carries the + ! element's weight with its consistent end moment, which the held end node's own contact + ! (a point reaction at an anchor sitting on the floor) cannot. The floor reaction of the + ! end half of that element is the support share of its weight, uniform with the reaction + ! of the neighbouring node, so that a laid end element carries no fixed-end moment. + IF (e == 1) THEN + IF (held_end_floor_support(model, model%q, 1, support, dsupport, inode, nin)) & + fca = (model%w(1)*l0)*support + END IF + IF (e == model%ne) THEN + IF (held_end_floor_support(model, model%q, 2, support, dsupport, inode, nin)) & + fcb = (model%w(e)*l0)*support + END IF + ! integrals of the four shapes over xi in [0, 1/2] (fca) and [1/2, 1] (fcb) + g(1:3) = g(1:3) - (0.40625_wp*fca + 0.09375_wp*fcb) + g(4:6) = g(4:6) - l0*(0.0572916666666666667_wp*fca + 0.0260416666666666667_wp*fcb) + g(7:9) = g(7:9) - (0.09375_wp*fca + 0.40625_wp*fcb) + g(10:12) = g(10:12) + l0*(0.0260416666666666667_wp*fca + 0.0572916666666666667_wp*fcb) + END IF + ae(1:6) = model%a(6*(e - 1) + 1:6*e); ae(7:12) = model%a(6*e + 1:6*(e + 1)) + IF (ANY(ABS(ae) > CD_ZERO)) THEN + ! consistent structural mass, closed form of CD_HermiteCable_Mass: per component the + ! 4 x 4 cubic-Hermite block on [r1, m1, r2, m2] + c = model%rho_a(e)*l0/420.0_wp + m4 = RESHAPE([156.0_wp, 22.0_wp*l0, 54.0_wp, -13.0_wp*l0, & + 22.0_wp*l0, 4.0_wp*l0*l0, 13.0_wp*l0, -3.0_wp*l0*l0, & + 54.0_wp, 13.0_wp*l0, 156.0_wp, -22.0_wp*l0, & + -13.0_wp*l0, -3.0_wp*l0*l0, -22.0_wp*l0, 4.0_wp*l0*l0], [4, 4]) + DO k = 1, 3 + a4 = [ae(k), ae(3 + k), ae(6 + k), ae(9 + k)] + a4 = c*MATMUL(m4, a4) + g(k) = g(k) + a4(1); g(3 + k) = g(3 + k) + a4(2) + g(6 + k) = g(6 + k) + a4(3); g(9 + k) = g(9 + k) + a4(4) + END DO + IF (model%has_am) THEN + dry_wl = model%am_wl + IF (model%has_held_field) dry_wl = 0.5_wp*(model%hf_wl(e) + model%hf_wl(e + 1)) + CALL added_mass_force(qe, ae, l0, dry_wl, model%am_rho, model%am_diam(e), model%am_can(e), & + model%am_cat(e), fx, es, em2) + IF (es /= CD_HCDYN_OK) GOTO 900 + g = g + fx + END IF + END IF + RETURN +900 ErrStat = CD_HCDYN_NOCONVERGE + ErrMsg = 'CD_HermiteCable_Dyn_Node_Recovery: element '//TRIM(em2) + END SUBROUTINE element_end_residual + PURE REAL(wp) FUNCTION CD_HermiteCable_Dyn_Max_Step_Rotation(model) RESULT(angle) !! Largest angle [rad] through which a nodal tangent turned over one committed step !! since initialisation: the time-step resolution of the tangent rotation. @@ -5183,6 +5730,8 @@ SUBROUTINE CD_HermiteCable_Dyn_End(model) model%ws_elem_Kwave, model%ws_elem_Kheld, & model%ws_elem_es, model%ws_elem_em) END IF + IF (ALLOCATED(model%rc_q)) DEALLOCATE (model%rc_q, model%rc_v, model%rc_a, model%rc_g, model%rc_have) + model%rc_key_ok = .FALSE. IF (ALLOCATED(model%freemask)) DEALLOCATE (model%freemask) IF (ALLOCATED(model%solve_mask)) DEALLOCATE (model%solve_mask) IF (ALLOCATED(model%fmap)) DEALLOCATE (model%fmap) diff --git a/src/CableDyn_HermiteCableStatic.f90 b/src/CableDyn_HermiteCableStatic.f90 index 446ba6df..626c2efe 100644 --- a/src/CableDyn_HermiteCableStatic.f90 +++ b/src/CableDyn_HermiteCableStatic.f90 @@ -237,7 +237,7 @@ MODULE CableDyn_HermiteCableStatic REAL(wp) :: smoothed_axial_min = CD_ZERO !! minimum 3-element length-weighted mean axial force [N] LOGICAL :: smoothed_compressed = .FALSE. !! smoothed compression beyond compression_limit INTEGER :: smoothed_min_elem = 0 !! centre element of smoothed_axial_min - REAL(wp) :: nodal_axial_min = CD_ZERO !! minimum interior-node segment tension [N] + REAL(wp) :: nodal_axial_min = CD_ZERO !! minimum interior-node material axial force [N] INTEGER :: nodal_min_node = 0 !! interior node carrying nodal_axial_min REAL(wp) :: h_kappa_peak = CD_ZERO INTEGER :: h_kappa_elem = 0 @@ -5454,7 +5454,8 @@ SUBROUTINE CD_HermiteCable_Branch_Audit(l0, q, EA, audit, ErrStat, ErrMsg, end_z !! tensile neighbours (a mesh-local kink, e.g. next to a nodal seabed-contact reaction) !! is excluded by it; a run of three or more compressed elements never is. !! audit%nodal_axial_min is the minimum over interior nodes of the length-weighted - !! average of the two adjacent element means: the node Tension output channel. + !! average of the two adjacent element means: the nodal material axial force (the node + !! Tension output channel under OPTIONS OutputRecovery element). REAL(wp), INTENT(IN) :: l0(:), q(:), EA(:) TYPE(CD_HermiteBranchAuditType), INTENT(OUT) :: audit INTEGER, INTENT(OUT) :: ErrStat diff --git a/src/CableDyn_OpenFAST_Aggregate.f90 b/src/CableDyn_OpenFAST_Aggregate.f90 index bf713e6b..3eb67ebc 100644 --- a/src/CableDyn_OpenFAST_Aggregate.f90 +++ b/src/CableDyn_OpenFAST_Aggregate.f90 @@ -1965,7 +1965,7 @@ SUBROUTINE CD_AGG_EvalChannel(self, i, value, ErrStat, ErrMsg) !! module reports the SAME value the standalone driver computes for that channel on the same !! configuration. Resolve to the EI=0 system's line/point state or a finite-EI cable's state !! through the retained deck-line-id map. - TYPE(CD_AGG_ModuleType), INTENT(IN) :: self + TYPE(CD_AGG_ModuleType), INTENT(INOUT) :: self INTEGER, INTENT(IN) :: i REAL(wp), INTENT(OUT) :: value INTEGER, INTENT(OUT) :: ErrStat @@ -2043,7 +2043,7 @@ SUBROUTINE CD_AGG_WriteStaticProfile(self, path, ErrStat, ErrMsg) !! effective tension, curvature, bend moment, declination, signed inclination below the !! horizontal, and azimuth. The channel evaluator remains the single source of truth for !! every reported physical quantity, so standalone and coupled results share conventions. - TYPE(CD_AGG_ModuleType), INTENT(IN) :: self + TYPE(CD_AGG_ModuleType), INTENT(INOUT) :: self CHARACTER(*), INTENT(IN) :: path INTEGER, INTENT(OUT) :: ErrStat CHARACTER(*), INTENT(OUT) :: ErrMsg diff --git a/src/CableDyn_OpenFAST_HermiteFMF.f90 b/src/CableDyn_OpenFAST_HermiteFMF.f90 index fe28b36f..a9dbec8e 100644 --- a/src/CableDyn_OpenFAST_HermiteFMF.f90 +++ b/src/CableDyn_OpenFAST_HermiteFMF.f90 @@ -37,7 +37,7 @@ MODULE CableDyn_OpenFAST_HermiteFMF CD_HermiteCable_Dyn_Step, CD_HermiteCable_Dyn_Step_Recovering, & CD_HermiteCable_Dyn_Reaction, & CD_HermiteCable_Dyn_EndConnection_Moment, & - CD_HermiteCable_Dyn_Curvature, & + CD_HermiteCable_Dyn_Curvature, CD_HermiteCable_Dyn_Curvature_Exact, & CD_HermiteCable_Dyn_Snapshot, CD_HermiteCable_Dyn_Restore, & CD_HermiteCable_Dyn_End, CD_HCDYN_OK, & CD_HermiteCable_Dyn_Set_Torsion, CD_HermiteCable_Dyn_Set_Torsion_Drive, & @@ -78,7 +78,7 @@ MODULE CableDyn_OpenFAST_HermiteFMF PUBLIC :: CD_HFMF_SetCoupledKinematics PUBLIC :: CD_HFMF_GetCoupledKinematics PUBLIC :: CD_HFMF_CalcOutput - PUBLIC :: CD_HFMF_Curvature + PUBLIC :: CD_HFMF_Curvature, CD_HFMF_Curvature_Exact PUBLIC :: CD_HFMF_MinSpanZ PUBLIC :: CD_HFMF_MirrorSize PUBLIC :: CD_HFMF_FrictionMirrorSize @@ -1379,7 +1379,8 @@ PURE FUNCTION frame_to_global(self, v) RESULT(vg) END FUNCTION frame_to_global SUBROUTINE CD_HFMF_Curvature(self, curv_out, ErrStat, ErrMsg) - !! Nodal centreline curvature at the current state (the fatigue report channel). + !! Nodal curvature at the current state, the definition of the CurvN channels + !! (CD_HermiteCable_Dyn_Curvature: recovered from nodal equilibrium by default). TYPE(CD_HFMF_ModuleType), INTENT(INOUT) :: self REAL(wp), INTENT(OUT) :: curv_out(:) INTEGER, INTENT(OUT) :: ErrStat @@ -1396,6 +1397,25 @@ SUBROUTINE CD_HFMF_Curvature(self, curv_out, ErrStat, ErrMsg) END IF END SUBROUTINE CD_HFMF_Curvature + SUBROUTINE CD_HFMF_Curvature_Exact(self, curv_out, ErrStat, ErrMsg) + !! Nodal geometric curvature of the cubic-Hermite centreline at the current state, the larger + !! one-sided trace at an interior node (CD_HermiteCable_Dyn_Curvature_Exact). + TYPE(CD_HFMF_ModuleType), INTENT(INOUT) :: self + REAL(wp), INTENT(OUT) :: curv_out(:) + INTEGER, INTENT(OUT) :: ErrStat + CHARACTER(*), INTENT(OUT) :: ErrMsg + INTEGER :: es + CHARACTER(300) :: em + ErrStat = CD_HFMF_OK; ErrMsg = '' + IF (.NOT. self%initialized) THEN + ErrStat = CD_HFMF_BADINPUT; ErrMsg = 'CD_HFMF_Curvature_Exact: module not initialised'; RETURN + END IF + CALL CD_HermiteCable_Dyn_Curvature_Exact(self%line, curv_out, es, em) + IF (es /= CD_HCDYN_OK) THEN + ErrStat = CD_HFMF_BADINPUT; ErrMsg = 'CD_HFMF_Curvature_Exact: '//TRIM(em) + END IF + END SUBROUTINE CD_HFMF_Curvature_Exact + REAL(wp) FUNCTION CD_HFMF_MinSpanZ(self) RESULT(zmin) !! Minimum global z along the cubic-Hermite CENTRELINE (its static-seeded shape), computed !! EXACTLY per element from the cubic's stationary points -- NOT by fixed sampling. On each diff --git a/src/CableDyn_RangeOutput.f90 b/src/CableDyn_RangeOutput.f90 index 24e30059..53059acd 100644 --- a/src/CableDyn_RangeOutput.f90 +++ b/src/CableDyn_RangeOutput.f90 @@ -15,10 +15,16 @@ MODULE CableDyn_RangeOutput !! centreline is at most CD_SEABED_CONTACT_BLEND above the seabed (the height at which !! the normal contact law activates). The grounded end is the end grounded in the !! initial state; walking from it, the TDP lies between the last grounded node and the - !! next one, where the centreline crosses that height. Arc length is the deformed chord + !! next one, where the parabola through the last grounded node and the next two (clearance + !! against chord arc) crosses that height, the crossing nearest the suspended node; it + !! reaches a node exactly when the node does, so the TDP moves continuously as nodes ground + !! and lift off (linear clearance when there is no such crossing). The TDP sits on that + !! height. Arc length is the deformed chord !! length from End A, layback the horizontal distance from the TDP to the suspended end, - !! and the excursion the horizontal TDP displacement from its initial position projected - !! on the initial horizontal direction from the TDP to the suspended end. + !! the excursion the horizontal TDP displacement from its initial position projected + !! on the initial horizontal direction from the TDP to the suspended end, and the grounded + !! length the deformed chord length from the grounded end to the TDP (0 while no node + !! beyond the grounded end node is grounded). USE CableDyn_Precision, ONLY: wp, CD_ZERO, CD_ONE USE CableDyn_Bathymetry, ONLY: CD_BathymetryType, CD_Bathymetry_Floor, CD_Bathymetry_Is_Initialized, & CD_BATHY_OK @@ -38,9 +44,9 @@ MODULE CableDyn_RangeOutput INTEGER, PARAMETER, PUBLIC :: CD_RQ_TENSION = 1, CD_RQ_CURVATURE = 2, CD_RQ_BEND = 3, & CD_RQ_DECLINATION = 4, CD_RQ_CLEARANCE = 5, CD_RQ_TORQUE = 6, CD_RQ_TWIST = 7, & CD_RQ_N = 7 - ! Components of the TDP channels (TDPs, x, y, z, Lay, Exc). + ! Components of the TDP channels (TDPs, x, y, z, Lay, Exc, Grd). INTEGER, PARAMETER, PUBLIC :: CD_TDP_S = 1, CD_TDP_X = 2, CD_TDP_Y = 3, CD_TDP_Z = 4, CD_TDP_LAY = 5, & - CD_TDP_EXC = 6, CD_TDP_N = 6 + CD_TDP_EXC = 6, CD_TDP_GRD = 7, CD_TDP_N = 7 TYPE :: CD_RangeLine INTEGER :: line_id = 0 @@ -286,17 +292,20 @@ SUBROUTINE CD_Range_Commit_Sample(set, il, time, ErrStat, ErrMsg) END DO END SUBROUTINE CD_Range_Commit_Sample - PURE SUBROUTINE tdp_locate(r, clearance, grounded_end, touching, arc, point, suspended_xy) + PURE SUBROUTINE tdp_locate(r, clearance, grounded_end, touching, arc, point, suspended_xy, grounded) !! Touchdown point of one configuration for a given grounded end (1 = A, 2 = B), the !! algorithm of cabledyn.touchdown_history. `touching` is false when the grounded end !! has lifted off (the TDP is then reported at that end) or every node is grounded (the - !! TDP is then reported at the suspended end). + !! TDP is then reported at the suspended end). `grounded` is the deformed chord length + !! from the grounded end to the TDP, so it varies continuously with the TDP: the whole + !! line when every node is grounded, and 0 only when the grounded end node itself is off + !! the seabed or the TDP sits at that node. REAL(wp), INTENT(IN) :: r(:, :), clearance(:) INTEGER, INTENT(IN) :: grounded_end LOGICAL, INTENT(OUT) :: touching - REAL(wp), INTENT(OUT) :: arc, point(3), suspended_xy(2) + REAL(wp), INTENT(OUT) :: arc, point(3), suspended_xy(2), grounded INTEGER :: nn, k, j, jn, last - REAL(wp) :: g_low, g_high, fraction, chord, s_scan, s_total + REAL(wp) :: g_low, g_high, fraction, chord, s_scan, s_total, z_floor LOGICAL :: grounded_first, all_grounded nn = SIZE(r, 2) @@ -319,6 +328,7 @@ PURE SUBROUTINE tdp_locate(r, clearance, grounded_end, touching, arc, point, sus g_low = clearance(node_of(last)) - CD_SEABED_CONTACT_BLEND g_high = clearance(node_of(last + 1)) - CD_SEABED_CONTACT_BLEND IF (g_high > g_low) fraction = MIN(CD_ONE, MAX(CD_ZERO, -g_low/(g_high - g_low))) + CALL quadratic_fraction(fraction) END IF s_scan = CD_ZERO s_total = CD_ZERO @@ -333,7 +343,14 @@ PURE SUBROUTINE tdp_locate(r, clearance, grounded_end, touching, arc, point, sus jn = node_of(last + 1) point = r(:, j) + fraction*(r(:, jn) - r(:, j)) s_scan = s_scan + fraction*NORM2(r(:, jn) - r(:, j)) + ! the TDP sits at the contact-onset height: floor (z - clearance) interpolated along the + ! chord, plus the onset height + IF (touching) THEN + z_floor = (CD_ONE - fraction)*(r(3, j) - clearance(j)) + fraction*(r(3, jn) - clearance(jn)) + point(3) = z_floor + CD_SEABED_CONTACT_BLEND + END IF END IF + grounded = s_scan arc = s_scan IF (grounded_end == 2) arc = s_total - s_scan suspended_xy = r(1:2, node_of(nn)) @@ -345,6 +362,46 @@ PURE INTEGER FUNCTION node_of(k_scan) RESULT(node) node = k_scan IF (grounded_end == 2) node = nn + 1 - k_scan END FUNCTION node_of + + PURE SUBROUTINE quadratic_fraction(f) + !! Quadratic clearance g(x) through the last grounded node (x = 0) and the first two + !! suspended nodes (x = l1, l1 + l2), g measured from the contact-onset height; the + !! touchdown is its crossing nearest the suspended node inside the element [0, l1]. The + !! crossing reaches a node exactly when that node reaches the onset height, so the + !! location is continuous as nodes ground and lift off. Keeps f (linear) when the line + !! has fewer than two suspended nodes or the quadratic has no crossing in the element. + REAL(wp), INTENT(INOUT) :: f + REAL(wp) :: g0, g1, g2, l1, l2, d1, qa, qb, disc, x1, x2, xc + IF (last + 2 > nn) RETURN + g0 = clearance(node_of(last)) - CD_SEABED_CONTACT_BLEND + g1 = clearance(node_of(last + 1)) - CD_SEABED_CONTACT_BLEND + g2 = clearance(node_of(last + 2)) - CD_SEABED_CONTACT_BLEND + l1 = NORM2(r(:, node_of(last + 1)) - r(:, node_of(last))) + l2 = NORM2(r(:, node_of(last + 2)) - r(:, node_of(last + 1))) + IF (.NOT. (l1 > CD_ZERO) .OR. .NOT. (l2 > CD_ZERO)) RETURN + d1 = (g1 - g0)/l1 + qa = ((g2 - g1)/l2 - d1)/(l1 + l2) + qb = d1 - qa*l1 + ! qa x^2 + qb x + g0 = 0 + IF (ABS(qa)*l1 <= 1.0e-12_wp*MAX(ABS(qb), TINY(CD_ONE))) THEN + IF (ABS(qb) > CD_ZERO) f = MIN(CD_ONE, MAX(CD_ZERO, (-g0/qb)/l1)) + RETURN + END IF + disc = qb*qb - 4.0_wp*qa*g0 + IF (disc < CD_ZERO) RETURN + ! numerically stable pair of roots + IF (qb >= CD_ZERO) THEN + x1 = (-qb - SQRT(disc))/(2.0_wp*qa) + ELSE + x1 = (-qb + SQRT(disc))/(2.0_wp*qa) + END IF + x2 = CD_ZERO + IF (ABS(x1) > CD_ZERO) x2 = g0/(qa*x1) + xc = -HUGE(CD_ONE) + IF (x1 >= -1.0e-9_wp*l1 .AND. x1 <= l1*(CD_ONE + 1.0e-9_wp)) xc = MAX(xc, x1) + IF (x2 >= -1.0e-9_wp*l1 .AND. x2 <= l1*(CD_ONE + 1.0e-9_wp)) xc = MAX(xc, x2) + IF (xc > -HUGE(CD_ONE)) f = MIN(CD_ONE, MAX(CD_ZERO, xc/l1)) + END SUBROUTINE quadratic_fraction END SUBROUTINE tdp_locate SUBROUTINE CD_Range_TDP_Reference(line, r, clearance, ErrStat, ErrMsg) @@ -354,7 +411,7 @@ SUBROUTINE CD_Range_TDP_Reference(line, r, clearance, ErrStat, ErrMsg) INTEGER, INTENT(OUT) :: ErrStat CHARACTER(*), INTENT(OUT) :: ErrMsg LOGICAL :: ga, gb, touching - REAL(wp) :: arc, point(3), suspended_xy(2), span + REAL(wp) :: arc, point(3), suspended_xy(2), span, grounded INTEGER :: nn ErrStat = CD_RANGE_OK @@ -378,7 +435,7 @@ SUBROUTINE CD_Range_TDP_Reference(line, r, clearance, ErrStat, ErrMsg) RETURN END IF line%tdp_end = MERGE(1, 2, ga) - CALL tdp_locate(r, clearance, line%tdp_end, touching, arc, point, suspended_xy) + CALL tdp_locate(r, clearance, line%tdp_end, touching, arc, point, suspended_xy, grounded) span = NORM2(suspended_xy - point(1:2)) IF (.NOT. touching .OR. .NOT. (span > CD_ZERO)) THEN ErrStat = CD_RANGE_BADINPUT @@ -402,20 +459,21 @@ END SUBROUTINE CD_Range_TDP_Reference PURE SUBROUTINE CD_Range_TDP_Evaluate(line, r, clearance, tdp) !! Touchdown channels of one configuration against the line's fixed reference: - !! tdp = [arc from End A, x, y, z, layback, excursion]. + !! tdp = [arc from End A, x, y, z, layback, excursion, grounded length]. TYPE(CD_RangeLine), INTENT(IN) :: line REAL(wp), INTENT(IN) :: r(:, :), clearance(:) REAL(wp), INTENT(OUT) :: tdp(CD_TDP_N) LOGICAL :: touching - REAL(wp) :: arc, point(3), suspended_xy(2) + REAL(wp) :: arc, point(3), suspended_xy(2), grounded tdp = CD_ZERO IF (.NOT. line%tdp_ready) RETURN - CALL tdp_locate(r, clearance, line%tdp_end, touching, arc, point, suspended_xy) + CALL tdp_locate(r, clearance, line%tdp_end, touching, arc, point, suspended_xy, grounded) tdp(CD_TDP_S) = arc tdp(CD_TDP_X:CD_TDP_Z) = point tdp(CD_TDP_LAY) = NORM2(suspended_xy - point(1:2)) tdp(CD_TDP_EXC) = DOT_PRODUCT(point(1:2) - line%ref_xy, line%ref_dir) + tdp(CD_TDP_GRD) = grounded END SUBROUTINE CD_Range_TDP_Evaluate SUBROUTINE CD_Range_Write_Files(set, out_root, ErrStat, ErrMsg) @@ -512,7 +570,7 @@ PURE LOGICAL FUNCTION CD_Is_TDP_Channel(lo) RESULT(yes) END FUNCTION CD_Is_TDP_Channel PURE SUBROUTINE CD_Parse_TDP_Channel(ch, line_id, comp) - !! TDPs / x / y / z / Lay / Exc (case-insensitive, leading zeros allowed) -> deck line + !! TDPs / x / y / z / Lay / Exc / Grd (case-insensitive, leading zeros allowed) -> deck line !! id and component CD_TDP_*; comp = 0 (and line_id = 0) when malformed. CHARACTER(*), INTENT(IN) :: ch INTEGER, INTENT(OUT) :: line_id, comp @@ -543,6 +601,7 @@ PURE SUBROUTINE CD_Parse_TDP_Channel(ch, line_id, comp) CASE ('z'); comp = CD_TDP_Z CASE ('lay'); comp = CD_TDP_LAY CASE ('exc'); comp = CD_TDP_EXC + CASE ('grd'); comp = CD_TDP_GRD END SELECT IF (comp == 0 .OR. line_id < 1) THEN comp = 0 diff --git a/tests/test_anchor_uplift.py b/tests/test_anchor_uplift.py new file mode 100644 index 00000000..b6be0c29 --- /dev/null +++ b/tests/test_anchor_uplift.py @@ -0,0 +1,529 @@ +#!/usr/bin/env python3 +# SPDX-License-Identifier: Apache-2.0 +# Copyright (c) 2026 Jae Hoon Seo, SMI Lab, Inha University +"""Anchor uplift channels of the driver: AnchFz, AnchFH and TDPGrd. + +Gates, each on the driver's own output files: + +* laid catenary: on a grounded R3 chain ``AnchFH`` is the horizontal tension of the analytic + elastic catenary and equals the fairlead's horizontal force, ``TDPGrd`` is the analytic + grounded length and ``TDPs + TDPGrd`` the deformed line length, and ``AnchFz`` is the + small negative end-node share the documentation states (the anchor node's lumped weight plus + the pull of the anchor segment toward the chain sunk into the penalty seabed); +* suspended line: on a taut chain with no laid length ``AnchFz``/``AnchFH`` are the anchor + forces of the analytic suspended elastic catenary, consistent with ``AnchTen`` and + ``AnchIncl``, and ``TDPGrd`` is 0; +* consistency: for an anchor holding one line ``AnchFz`` = ``Point

Fz`` and + ``AnchFH`` = ``Point

FH`` exactly, and ``AnchTen`` is the norm of the two, on the static, + ``EI = 0`` dynamic, point-system, cubic-Hermite, mixed aggregate and multibody routes; +* dynamics: a fairlead surge lifts the anchor of a catenary; at every output time the channels + are finite and consistent, ``TDPGrd > 0`` implies ``AnchFz < 0`` and ``AnchFz > 0`` implies + ``TDPGrd = 0``, and the held end state is the suspended elastic catenary; +* fail-closed contracts: unknown lines and the two-moving-end finite-EI route reject the names. + +usage: test_anchor_uplift.py --exe --examples --output

+""" + +from __future__ import annotations + +import argparse +import math +import os +import re +import shutil +import subprocess +import sys +from pathlib import Path + +import numpy as np + +sys.path.insert(0, str(Path(__file__).resolve().parents[1] / "python")) +from cabledyn import read_output # noqa: E402 + +FAILURES: list[str] = [] +G = 9.80665 +RHO = 1025.0 +# TDPGrd is continuous with the touchdown point: an anchor node held on the seabed with the next node +# a few millimetres clear of it reads the contact-onset height times the chord over that clearance +# (micrometres to millimetres), not exactly 0. Laid means more than a centimetre. +GRD_TOL = 1.0e-2 + + +def check(ok: bool, message: str) -> None: + print(("PASS: " if ok else "FAIL: ") + message) + if not ok: + FAILURES.append(message) + + +# ----------------------------------------------------------------------------- decks + + +def table_rows(text: str, name: str) -> tuple[int, int]: + """Line index range of the data rows of a deck table (after its two header rows).""" + lines = text.splitlines() + start = next(i for i, line in enumerate(lines) if re.match(r"^-+\s*" + name + r"\b", line, re.I)) + end = next(i for i in range(start + 1, len(lines)) if lines[i].startswith("---")) + return start + 3, end + + +def set_option(text: str, key: str, value: str) -> str: + lines = text.splitlines() + a, b = table_rows(text, "OPTIONS") + a -= 2 + for i in range(a, b): + tok = lines[i].split() + if len(tok) >= 2 and tok[1].lower() == key.lower(): + lines[i] = f"{value} {key}" + return "\n".join(lines) + "\n" + lines.insert(a, f"{value} {key}") + return "\n".join(lines) + "\n" + + +def set_line_flag(text: str, line_id: int, flags: str) -> str: + lines = text.splitlines() + a, b = table_rows(text, "LINES") + for i in range(a, b): + tok = lines[i].split() + if tok and tok[0] == str(line_id): + tok[3] = flags + lines[i] = " ".join(tok) + return "\n".join(lines) + "\n" + + +def set_outputs(text: str, names: list[str]) -> str: + lines = text.splitlines() + start = next(i for i, line in enumerate(lines) if re.match(r"^-+\s*OUTPUTS\b", line, re.I)) + end = next(i for i in range(start + 1, len(lines)) if lines[i].startswith("---")) + return "\n".join(lines[: start + 1] + [f'"{n}"' for n in names] + lines[end:]) + "\n" + + +def line_sections(text: str, line_id: int) -> list[tuple[str, float, int]]: + """(type, length, segments) of each SECTIONS row of one line, End A first.""" + lines = text.splitlines() + a, b = table_rows(text, "SECTIONS") + rows = [lines[i].split() for i in range(a, b)] + return [(tok[1], float(tok[2]), int(tok[3])) for tok in rows if tok and tok[0] == str(line_id)] + + +def anchor_channels(line_id: int, point_id: int) -> list[str]: + return [f"AnchTen{line_id}", f"AnchFz{line_id}", f"AnchFH{line_id}", f"Point{point_id}Fz", + f"Point{point_id}FH"] + + +def run(exe: str, deck: Path, root: Path, env: dict) -> None: + proc = subprocess.run([exe, str(deck), str(root)], capture_output=True, text=True, env=env, cwd=deck.parent) + if proc.returncode != 0: + raise SystemExit(f"{deck.name}: driver exit {proc.returncode}\n{proc.stdout[-2000:]}\n{proc.stderr[-2000:]}") + + +def out_strings(path: Path) -> tuple[list[str], list[list[str]]]: + """Header and the verbatim value fields of every data row of a driver .out file.""" + lines = path.read_text(encoding="utf-8").splitlines() + header = lines[1].split("\t") + return header, [row.split("\t") for row in lines[2:] if row.strip()] + + +def check_anchor_point(label: str, root: Path, line_id: int, point_id: int) -> None: + """AnchFz/AnchFH equal the Point

resultant of a one-line anchor (the printed text, every + row), and AnchTen is their norm to the 8 printed digits.""" + header, rows = out_strings(root.with_suffix(".out")) + col = {name.lower(): k for k, name in enumerate(header)} + fz, fh = col[f"anchfz{line_id}"], col[f"anchfh{line_id}"] + pz, ph = col[f"point{point_id}fz"], col[f"point{point_id}fh"] + same = all(r[fz] == r[pz] and r[fh] == r[ph] for r in rows) + check(same, f"{label}: AnchFz{line_id}/AnchFH{line_id} = Point{point_id}Fz/FH at all {len(rows)} rows") + hist = read_output(root.with_suffix(".out")) + ten = hist.column(f"AnchTen{line_id}") + norm = np.hypot(hist.column(f"AnchFz{line_id}"), hist.column(f"AnchFH{line_id}")) + worst = float(np.max(np.abs(norm - ten) / np.maximum(ten, 1e-30))) + check(worst < 2e-7, f"{label}: AnchTen{line_id} = |(AnchFH, AnchFz)| (max relative difference {worst:.1e})") + + +def line_lengths(path: Path) -> np.ndarray: + """Deformed chord length of a line at every row of a dynamic .Line.p.out file.""" + lines = path.read_text(encoding="utf-8").splitlines() + data = np.array([[float(v) for v in row.split()] for row in lines[2:] if row.strip()]) + xyz = data[:, 1:].reshape(data.shape[0], -1, 3) + return np.linalg.norm(np.diff(xyz, axis=1), axis=2).sum(axis=1) + + +def static_line_length(path: Path) -> float: + """Deformed chord length of a line from a static .Line.p.out table (Node X Y Z).""" + lines = path.read_text(encoding="utf-8").splitlines() + data = np.array([[float(v) for v in row.split()] for row in lines[2:] if row.strip()]) + return float(np.linalg.norm(np.diff(data[:, 1:4], axis=0), axis=1).sum()) + + +# ----------------------------------------------------------------------------- analytic catenaries + + +def newton2(residual, x0: np.ndarray, scale: np.ndarray) -> np.ndarray: + """Newton iteration on two unknowns (the first a positive tension), with step halving.""" + x = np.array(x0, dtype=float) + f = np.array(residual(x)) + for _ in range(200): + jac = np.empty((2, 2)) + for k in range(2): + dx = np.zeros(2) + dx[k] = 1e-7 * scale[k] + jac[:, k] = (np.array(residual(x + dx)) - f) / dx[k] + step = np.linalg.solve(jac, -f) + for _ in range(60): + trial = x + step + if trial[0] > 0.0: + f_trial = np.array(residual(trial)) + if np.all(np.isfinite(f_trial)) and np.linalg.norm(f_trial) < max(np.linalg.norm(f), 1e-300): + break + step = 0.5 * step + x, f = trial, f_trial + if np.all(np.abs(step) < 1e-12 * scale): + return x + raise RuntimeError("catenary Newton iteration did not converge") + + +def laid_catenary(length: float, span: float, depth: float, w: float, ea: float) -> tuple[float, float, float]: + """Elastic catenary with a grounded run on a frictionless seabed: (horizontal tension H, + deformed grounded length, deformed suspended length).""" + + def residual(x: np.ndarray) -> tuple[float, float]: + h, ls = x + a = h / w + xs = a * math.asinh(ls / a) + h * ls / ea + (length - ls) * (1.0 + h / ea) + zs = a * (math.sqrt(1.0 + (ls / a) ** 2) - 1.0) + w * ls * ls / (2.0 * ea) + return xs - span, zs - depth + + h, ls = newton2(residual, np.array([1.0e5, 1.5 * depth]), np.array([1.0e5, depth])) + a = h / w + u = ls / a + suspended = ls + (h / (2.0 * w * ea)) * h * (u * math.sqrt(1.0 + u * u) + math.asinh(u)) + return h, (length - ls) * (1.0 + h / ea), suspended + + +def suspended_catenary(length: float, span: float, rise: float, w: float, ea: float) -> tuple[float, float]: + """Elastic catenary lifted at its lower (anchor) end: (H, V) of the force the line exerts + on the anchor, V positive upward.""" + + def residual(x: np.ndarray) -> tuple[float, float]: + h, v = x + top = (v + w * length) / h + xs = (h / w) * (math.asinh(top) - math.asinh(v / h)) + h * length / ea + zs = (h / w) * (math.sqrt(1.0 + top * top) - math.sqrt(1.0 + (v / h) ** 2)) + ( + v * length + 0.5 * w * length * length) / ea + return xs - span, zs - rise + + h, v = newton2(residual, np.array([w * length, 0.5 * w * length]), np.array([w * length, w * length])) + return h, v + + +# ----------------------------------------------------------------------------- the chain decks + + +R3 = dict(diam=0.2466, mass=373.5, ea=1.607e9) +R4 = dict(diam=0.2791, mass=480.93, ea=2.058e9) + + +def submerged_weight(line: dict) -> float: + return (line["mass"] - RHO * math.pi / 4.0 * line["diam"] ** 2) * G + + +CHAIN = """--------------------- CableDyn Input File ------------------------------------ +Anchor uplift gate: one chain leg from a Coupled fairlead (End A) to a Fixed anchor (End B) +--------------------- 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 {diam} {mass} {ea} -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) (-) +1 Fixed {xa} 0.0 {za} 0 0 0 0 +2 Coupled 0.0 0.0 {zf} 0 0 0 0 +--------------------- LINES -------------------------------------------- +ID NodeA NodeB Outputs +(-) (-) (-) (-) +1 2 1 p +--------------------- SECTIONS ----------------------------------------- +LineID LineType Length NumSegs +(-) (-) (m) (-) +1 chain {length} {nseg} +--------------------- OPTIONS ------------------------------------------ +9.80665 g +1025.0 rhoW +{depth} WtrDpth +{kbot} kBot +--------------------- OUTPUTS ------------------------------------------ +"FairTen1" +--------------------- need this line ----------------------------------- +""" + +CHANNELS = ["FairTen1", "Point2FH", "AnchIncl1", "TDP1s", "TDP1Grd", *anchor_channels(1, 1)] + + +def chain_deck(line: dict, length: float, nseg: int, span: float, depth: float, fair_z: float, kbot: str) -> str: + deck = CHAIN.format(diam=line["diam"], mass=line["mass"], ea=line["ea"], xa=span, za=-depth, zf=fair_z, + length=length, nseg=nseg, depth=depth, kbot=kbot) + return set_outputs(deck, CHANNELS) + + +def surge_motion(path: Path, dt: float, tmax: float, offset: float, ramp: float) -> None: + """Fairlead (point 2) surge from x = 0 to x = offset with a quintic ramp, then held.""" + rows = ["# time id x y z vx vy vz ax ay az"] + for i in range(int(round(tmax / dt)) + 1): + t = i * dt + tau = min(t / ramp, 1.0) + s = 10 * tau**3 - 15 * tau**4 + 6 * tau**5 + ds = (30 * tau**2 - 60 * tau**3 + 30 * tau**4) / ramp if t < ramp else 0.0 + dds = (60 * tau - 180 * tau**2 + 120 * tau**3) / ramp**2 if t < ramp else 0.0 + rows.append("%.6f 2 %.12e 0 0 %.12e 0 0 %.12e 0 0" % (t, offset * s, offset * ds, offset * dds)) + path.write_text("\n".join(rows) + "\n", encoding="utf-8", newline="\n") + + +def main() -> int: + ap = argparse.ArgumentParser() + ap.add_argument("--exe", required=True) + ap.add_argument("--examples", required=True) + ap.add_argument("--output", required=True) + args = ap.parse_args() + out = Path(args.output) + if out.exists(): + shutil.rmtree(out) + out.mkdir(parents=True) + examples = Path(args.examples) + env = dict(os.environ) + + # --- (a) laid catenary: R3 chain, 550 m on a 500 m span at 100 m depth (the tutorial leg). The + # analytic catenary rests on a rigid seabed, so its gates use a stiff one (kBot 1e9 Pa/m: the + # chain sinks 13 microns); the tutorial's soft seabed (1e5 Pa/m) gates the end-node share. + w3 = submerged_weight(R3) + h_ref, grd_ref, _ = laid_catenary(550.0, 500.0, 100.0, w3, R3["ea"]) + for nseg, kbot in ((55, "1.0e9"), (110, "1.0e9"), (55, "1.0e5"), (110, "1.0e5")): + label = f"laid catenary, {550.0 / nseg:g} m segments, kBot {kbot}" + name = f"laid{nseg}_{kbot.replace('.', '').replace('+', '')}" + (out / f"{name}.dat").write_text(chain_deck(R3, 550.0, nseg, 500.0, 100.0, 0.0, kbot), encoding="utf-8", + newline="\n") + run(args.exe, out / f"{name}.dat", out / name, env) + hist = read_output(out / f"{name}.out") + fz, fh = float(hist.column("AnchFz1")[0]), float(hist.column("AnchFH1")[0]) + grd, s = float(hist.column("TDP1Grd")[0]), float(hist.column("TDP1s")[0]) + ds = 550.0 / nseg + if kbot == "1.0e9": + # discretisation: -2.2e-3 on 10 m segments, +5e-5 on 5 m segments + check(abs(fh - h_ref) < (3e-3 if nseg == 55 else 5e-4) * h_ref, + f"{label}: AnchFH1 {fh / 1e3:.2f} kN vs analytic horizontal tension {h_ref / 1e3:.2f} kN " + f"({(fh - h_ref) / h_ref:+.1e})") + check(abs(grd - grd_ref) < 0.5 * ds, + f"{label}: TDP1Grd {grd:.2f} m vs analytic grounded length {grd_ref:.2f} m " + f"(error {grd - grd_ref:+.2f} m, bound half a segment {0.5 * ds:g} m)") + fair_h = float(hist.column("Point2FH")[0]) + check(abs(fh - fair_h) < 1e-6 * fh, f"{label}: AnchFH1 equals the fairlead horizontal force Point2FH " + f"({(fh - fair_h) / fh:+.1e}, frictionless seabed)") + total = static_line_length(Path(f"{out / name}.Line1.p.out")) + check(abs(s + grd - total) < 1e-4, + f"{label}: TDP1s + TDP1Grd = deformed line length {total:.4f} m (difference {s + grd - total:+.1e} m)") + # the documented end-node share: -(w dL/2 + H delta/dL), delta = w/(kBot d) the sink depth + delta = w3 / (float(kbot) * R3["diam"]) + share = w3 * ds / 2.0 + fh * delta / ds + check(-1.05 * share < fz < -0.9 * w3 * ds / 2.0, + f"{label}: AnchFz1 {fz / 1e3:.2f} kN is the laid anchor's end-node share, estimate " + f"-{share / 1e3:.2f} kN (node weight -{w3 * ds / 2e3:.2f} kN): downward, not uplift") + check_anchor_point(label, out / name, 1, 1) + + # --- (b) suspended line: R4 chain 262 m on a 262.5 m chord at 200 m depth, no laid length + w4 = submerged_weight(R4) + (out / "taut.dat").write_text(chain_deck(R4, 262.0, 45, 200.0, 200.0, -30.0, "2.0e6"), encoding="utf-8", + newline="\n") + run(args.exe, out / "taut.dat", out / "taut", env) + hist = read_output(out / "taut.out") + fz, fh, ten = (float(hist.column(c)[0]) for c in ("AnchFz1", "AnchFH1", "AnchTen1")) + incl = math.radians(float(hist.column("AnchIncl1")[0])) + h_t, v_t = suspended_catenary(262.0, 200.0, 170.0, w4, R4["ea"]) + check(abs(fh - h_t) < 1e-3 * ten and abs(fz - v_t) < 1e-3 * ten, + f"suspended line: AnchFH1/AnchFz1 {fh / 1e6:.4f}/{fz / 1e6:.4f} MN vs analytic elastic catenary " + f"{h_t / 1e6:.4f}/{v_t / 1e6:.4f} MN (differences {(fh - h_t) / ten:+.1e}, {(fz - v_t) / ten:+.1e} of AnchTen)") + node_w = w4 * (262.0 / 45) / 2.0 + check(abs(fz + node_w - fh * math.tan(incl)) < 2e-4 * ten, + f"suspended line: AnchFz1 + end-node weight = AnchFH1 tan(AnchIncl1) (difference " + f"{(fz + node_w - fh * math.tan(incl)) / ten:+.1e} of AnchTen): the end force is the anchor " + "segment's pull plus the anchor node's weight") + grd_taut = float(hist.column("TDP1Grd")[0]) + check(fz > 0.5 * ten and grd_taut < GRD_TOL, + f"suspended line: AnchFz1 = {fz / 1e6:.3f} MN uplift and TDP1Grd = {grd_taut:.1e} m (only the anchor " + "node touches: the TDP sits within the contact-onset height of it)") + check_anchor_point("suspended line", out / "taut", 1, 1) + + # --- (d) dynamics: a 42 m fairlead surge away from the anchor lifts the laid chain off it + dt, tmax, offset, ramp = 0.05, 100.0, -42.0, 60.0 + surge_motion(out / "surge.txt", dt, tmax, offset, ramp) + deck = chain_deck(R3, 550.0, 55, 500.0, 100.0, 0.0, "1.0e5") + deck = set_option(deck, "dtM", str(dt)) + deck = set_option(deck, "TMax", str(tmax)) + deck = set_option(deck, "motionFile", "surge.txt") + (out / "lift.dat").write_text(deck, encoding="utf-8", newline="\n") + run(args.exe, out / "lift.dat", out / "lift", env) + hist = read_output(out / "lift.out") + fz, grd, s = hist.column("AnchFz1"), hist.column("TDP1Grd"), hist.column("TDP1s") + finite = all(bool(np.all(np.isfinite(hist.column(c)))) for c in CHANNELS) + check(finite and hist.time.size == 2001, f"surge: every channel is finite at all {hist.time.size} rows") + check_anchor_point("surge", out / "lift", 1, 1) + total = line_lengths(Path(f"{out / 'lift'}.Line1.p.out")) + laid = grd > GRD_TOL + worst = float(np.max(np.abs(s + grd - total))) + check(worst < 2e-4, f"surge: TDP1s + TDP1Grd = deformed line length at every row, laid or lifted (max " + f"difference {worst:.1e} m over {hist.time.size} rows, {int(np.count_nonzero(laid))} of them laid)") + check(bool(np.all(fz[laid] < 0.0)) and bool(np.all(grd[fz > 0.0] < GRD_TOL)), + f"surge: TDP1Grd > {GRD_TOL:g} m implies AnchFz1 < 0, and AnchFz1 > 0 implies TDP1Grd <= {GRD_TOL:g} m, " + "at every row") + lift, bare = int(np.argmax(fz > 0.0)), int(np.argmax(grd < GRD_TOL)) + check(fz[0] < 0.0 and grd[0] > 390.0 and fz[-1] > 0.0 and grd[-1] < GRD_TOL and bool(np.all(fz[lift:] > 0.0)) + and bool(np.all(grd[bare:] < GRD_TOL)) and 0.0 <= hist.time[lift] - hist.time[bare] < 1.0, + f"surge: AnchFz1 {fz[0] / 1e3:.1f} -> {fz[-1] / 1e3:.1f} kN and TDP1Grd {grd[0]:.1f} -> {grd[-1]:.1e} m; " + f"the grounded length reaches 0 at t = {hist.time[bare]:.2f} s and the anchor lifts (AnchFz1 > 0) at " + f"t = {hist.time[lift]:.2f} s, both for the rest of the run") + h_end, v_end = suspended_catenary(550.0, 500.0 - offset, 100.0, w3, R3["ea"]) + fz_end, fh_end = float(np.mean(fz[hist.time >= 80.0])), float(np.mean(hist.column("AnchFH1")[hist.time >= 80.0])) + check(abs(fh_end - h_end) < 5e-3 * h_end and abs(fz_end - v_end) < 3e-3 * h_end, + f"surge: held state AnchFH1/AnchFz1 {fh_end / 1e6:.4f} MN/{fz_end / 1e3:.1f} kN vs suspended elastic catenary " + f"{h_end / 1e6:.4f} MN/{v_end / 1e3:.1f} kN") + + # --- (e) finite-EI lazy wave (cubic-Hermite route) under prescribed heave, End B on the seabed + src = (examples / "lozon_gomex80_power_cable_motion.dat").read_text(encoding="utf-8") + shutil.copytree(examples / "data", out / "data") + motion = out / "data" / "lozon" / "gomex80_heave_3m_12s_dt005.txt" + rows = [r for r in motion.read_text(encoding="utf-8").splitlines() if r.startswith("#") or float(r.split()[0]) <= 3.0001] + (out / "heave3.txt").write_text("\n".join(rows) + "\n", encoding="utf-8", newline="\n") + deck = set_line_flag(src, 1, "p") + deck = set_option(deck, "TMax", "3.0") + deck, n_motion = re.subn(r"^\S+\s+motionFile.*$", "heave3.txt motionFile", deck, flags=re.M) + if n_motion != 1: + raise RuntimeError("expected one motionFile row in the lazy-wave deck, found %d" % n_motion) + deck = set_outputs(deck, ["FairTen1", "TDP1s", "TDP1Grd", *anchor_channels(1, 2)]) + (out / "lazywave.dat").write_text(deck, encoding="utf-8", newline="\n") + run(args.exe, out / "lazywave.dat", out / "lazywave", env) + hist = read_output(out / "lazywave.out") + check_anchor_point("cubic-Hermite lazy wave", out / "lazywave", 1, 2) + total = line_lengths(Path(f"{out / 'lazywave'}.Line1.p.out")) + grd = hist.column("TDP1Grd") + worst = float(np.max(np.abs(hist.column("TDP1s") + grd - total))) + check(bool(np.all(grd > 30.0)) and worst < 2e-4, + f"cubic-Hermite lazy wave: TDP1Grd {grd.min():.2f}..{grd.max():.2f} m and TDP1s + TDP1Grd = line length " + f"(max difference {worst:.1e} m)") + fz = hist.column("AnchFz1") + check(bool(np.all(np.abs(fz) <= 1e-9 * hist.column("AnchTen1"))), + f"cubic-Hermite lazy wave: the grounded end leaves its node weight to the floor (|AnchFz1| <= " + f"{np.max(np.abs(fz)):.1e} N)") + + # --- (c) the other routes: point system (Free clump weight), mixed aggregate, multibody march + src = (examples / "clump_weight_free_point.dat").read_text(encoding="utf-8") + deck = set_outputs(set_option(src, "TMax", "0.5"), ["FairTen1", *anchor_channels(1, 2)]) + (out / "freepoint.dat").write_text(deck, encoding="utf-8", newline="\n") + run(args.exe, out / "freepoint.dat", out / "freepoint", env) + check_anchor_point("Free point (point system)", out / "freepoint", 1, 2) + hist = read_output(out / "freepoint.out") + check(bool(np.all(hist.column("AnchFz1") > 0.0)), + "Free point (point system): the hanging line pulls its clump weight upward (AnchFz1 > 0)") + + src = (examples / "iea15mw_umaine_mixed_cabledyn.dat").read_text(encoding="utf-8") + deck = set_option(src, "TMax", "0.5") + # the cable's anchor (End B) node and its laid end section, from the example's own mesh + sections = line_sections(src, 4) + n_anchor = sum(nseg for _, _, nseg in sections) + 1 + end_type, end_length, end_nseg = sections[-1] + check(end_type == "bare", f"mixed example: the cable's anchor section is the bare type ({end_type})") + l0_end = end_length / end_nseg + names = ["TDP1s", "TDP1Grd", "TDP4s", "TDP4Grd", *anchor_channels(1, 2), *anchor_channels(4, 8), + f"BendMom4N{n_anchor}", f"BendMom4N{n_anchor - 1}", f"Curv4N{n_anchor}"] + deck = set_outputs(deck, names) + (out / "mixed.dat").write_text(deck, encoding="utf-8", newline="\n") + run(args.exe, out / "mixed.dat", out / "mixed", env) + check_anchor_point("mixed aggregate, EI = 0 chain", out / "mixed", 1, 2) + check_anchor_point("mixed aggregate, finite-EI cable", out / "mixed", 4, 8) + hist = read_output(out / "mixed.out") + check(bool(np.all(hist.column("TDP1Grd") > 0.0)) and bool(np.all(hist.column("AnchFz1") < 0.0)) and + bool(np.all(hist.column("TDP4Grd") > 0.0)), + f"mixed aggregate: laid chain (TDP1Grd {hist.column('TDP1Grd')[0]:.1f} m, AnchFz1 " + f"{hist.column('AnchFz1')[0] / 1e3:.2f} kN) and laid cable (TDP4Grd {hist.column('TDP4Grd')[0]:.1f} m)") + # the cable's 'bare' type laid on the seabed: the recovered bend moment at the Fixed anchor node and + # its neighbour carries no fixed-end moment of the element's weight w l0^2 / 12. The line does bend + # there: the anchor node is held at the seabed depth and the laid run sinks delta = w/(kBot d) into + # the penalty seabed, a bend of about 2 delta / l0^2 over the anchor element (EI 2 delta / l0^2 = + # 2.1 N.m on 2.5 m elements), which the bound allows on top of 2 % of the weight moment + bare_row = re.search(r"^bare\s+(\S+)\s+(\S+)\s+\S+\s+\S+\s+(\S+)", src, re.MULTILINE) + kbot_row = re.search(r"^(\S+)\s+kBot\b", src, re.MULTILINE) + check(bare_row is not None and kbot_row is not None, "mixed example: bare LINE TYPES row and kBot option") + assert bare_row is not None and kbot_row is not None + d_bare, mass_bare, ei_bare = (float(v) for v in bare_row.groups()) + kbot = float(kbot_row.group(1)) + w_bare = (mass_bare - RHO * math.pi / 4.0 * d_bare**2) * G + m_end = w_bare * l0_end**2 / 12.0 + m_sink = ei_bare * 2.0 * w_bare / (kbot * d_bare) / l0_end**2 + bound = 0.02 * m_end + m_sink + bm_anchor, bm_next = hist.column(f"BendMom4N{n_anchor}"), hist.column(f"BendMom4N{n_anchor - 1}") + check(bool(np.all(np.abs(bm_anchor) < bound)) and bool(np.all(np.abs(bm_next) < bound)) and + bool(np.all(hist.column(f"Curv4N{n_anchor}") < bound / ei_bare)) and bound < 0.1 * m_end, + f"mixed aggregate, laid anchor: end-node BendMom4 {np.max(np.abs(bm_anchor)):.2e} N.m and next node " + f"{np.max(np.abs(bm_next)):.2e} N.m, below {bound:.1f} N.m and far below the element weight moment " + f"w l0^2/12 = {m_end:.0f} N.m") + + src = (examples / "rigid6_buoy.dat").read_text(encoding="utf-8") + deck = set_outputs(set_option(src, "TMax", "0.2"), [*anchor_channels(1, 4), *anchor_channels(2, 5)]) + (out / "rigid6.dat").write_text(deck, encoding="utf-8", newline="\n") + run(args.exe, out / "rigid6.dat", out / "rigid6", env) + check_anchor_point("multibody march, line 1", out / "rigid6", 1, 4) + check_anchor_point("multibody march, line 2", out / "rigid6", 2, 5) + + # --- fail-closed contracts + bad = set_outputs(chain_deck(R3, 550.0, 55, 500.0, 100.0, 0.0, "1.0e5"), ["AnchFz2"]) + (out / "bad_line.dat").write_text(bad, encoding="utf-8", newline="\n") + proc = subprocess.run([args.exe, str(out / "bad_line.dat"), str(out / "bad_line")], capture_output=True, + text=True, env=env) + check(proc.returncode == 1 and "unknown line id" in proc.stderr, "AnchFz of an unknown line is rejected") + bad = set_outputs(chain_deck(R3, 550.0, 55, 500.0, 100.0, 0.0, "1.0e5").replace( + "0.0 0.0 0.0 ", "0.0 0.0 -100.0"), ["TDP1Grd"]) + (out / "bad_tdp.dat").write_text(bad, encoding="utf-8", newline="\n") + proc = subprocess.run([args.exe, str(out / "bad_tdp.dat"), str(out / "bad_tdp")], capture_output=True, + text=True, env=env) + check(proc.returncode != 0 and "exactly one end" in proc.stderr, + "TDP1Grd of a line grounded at both ends is rejected, as the other TDP channels") + # a finite-EI line shared by two turbines: both ends move (the two-moving-end route) + two_end = """two-moving-end finite-EI line +--- LINE TYPES --- +Name Diam Mass EA BA EI Cdn Cdt Can Cat +(-) (m) (kg/m) (N) (-) (Nm2) (-) (-) (-) (-) +pcable 0.20 250 8.0e8 0.0 2.0e5 1.0 0.0 1.0 0.0 +--- TURBINES --- +J X0 Y0 Z0 PtfmSurge PtfmSway PtfmHeave PtfmRoll PtfmPitch PtfmYaw +1 0.0 0.0 0 0 0 0 0 0 0 +2 60.0 0.0 0 0 0 0 0 0 0 +--- POINTS --- +ID Type X Y Z Mass Vol CdA Ca +(-) (-) (m) (m) (m) (kg) (m3) (m2) (-) +1 Turbine1 0 0 -20 0 0 0 0 +2 Turbine2 0 0 -20 0 0 0 0 +--- LINES --- +ID NodeA NodeB Outputs +(-) (-) (-) (-) +1 1 2 - +--- SECTIONS --- +LineID LineType Length NumSegs +(-) (-) (m) (-) +1 pcable 75 5 +--- OPTIONS --- +9.80665 g +1025.0 rhoW +0.005 dtM +0.01 TMax +--- OUTPUTS --- +AnchTen1 AnchFz1 +--- need this line --- +""" + (out / "two_end.dat").write_text(two_end, encoding="utf-8", newline="\n") + proc = subprocess.run([args.exe, str(out / "two_end.dat"), str(out / "two_end")], capture_output=True, + text=True, env=env) + check(proc.returncode != 0 and "AnchFz/AnchFH channels are not available on the two-moving-end" in + proc.stdout + proc.stderr, "the two-moving-end finite-EI route rejects AnchFz by name") + + print(f"{len(FAILURES)} failure(s)") + return 1 if FAILURES else 0 + + +if __name__ == "__main__": + sys.exit(main()) diff --git a/tests/test_cable_statics_matrix.py b/tests/test_cable_statics_matrix.py index b1be2c32..ad2b0f5f 100644 --- a/tests/test_cable_statics_matrix.py +++ b/tests/test_cable_statics_matrix.py @@ -122,16 +122,29 @@ def run_measured(cmd: list, cwd: str, env: dict, wall_limit: float): def read_static(path: Path) -> dict: - """Node rows of the static profile per line: [s, x, y, z, T].""" + """Node rows of the static profile per line: [s, x, y, z, T, curvature, bend moment].""" out: dict = {} for ln in path.read_text(encoding="utf-8").splitlines()[3:]: f = ln.split() - if len(f) < 7: + if len(f) < 9: continue - out.setdefault(int(f[0]), []).append([float(v) for v in f[2:7]]) + out.setdefault(int(f[0]), []).append([float(v) for v in f[2:9]]) return out +def material_axial_force(row: list) -> float: + """Material axial force EA (|r'| - 1) at a profile node. + + Why: the Tension column is the effective tension N = F . t recovered from nodal + equilibrium. The cubic-Hermite bending energy EI/2 |r''|^2 makes the material axial force + EA (|r'| - 1) = N + EI kappa^2 = Tension + BendMoment * Curvature, and the compression + notes judge material strain (element-mean EA (|r'| - 1)), so the matrix holds the notes to + the same quantity. At a tight bend N alone can be compressive while the material is in + tension (SW_1003: an end clamped into the seabed, kappa = 1.12 1/m). + """ + return row[4] + row[6] * row[5] + + def read_end_forces(path: Path, every_row: bool = False): """FairTen/AnchTen channels of the first output row (t = 0), or of every row.""" rows = path.read_text(encoding="utf-8").splitlines() @@ -249,8 +262,8 @@ def check_case(case: dict, res: dict) -> list: continue if self_intersects([r[1:4] for r in rows]): errs.append("line %s crosses itself" % lid) - tmin = min(r[4] for r in rows) - tmax = max(r[4] for r in rows) + tmin = min(material_axial_force(r) for r in rows) + tmax = max(material_axial_force(r) for r in rows) # only the compression notes waive nodal compression ("line N carries element-mean axial # compression ..." and the "line N: mesh too coarse for its bends" variant) noted = ("Note: line %s carries element-mean axial compression" % lid) in log or ( diff --git a/tests/test_coupled_torsion.f90 b/tests/test_coupled_torsion.f90 index fe2aaea2..285d0f2c 100644 --- a/tests/test_coupled_torsion.f90 +++ b/tests/test_coupled_torsion.f90 @@ -163,7 +163,7 @@ FUNCTION yaw_dcm(psi) RESULT(r) END FUNCTION yaw_dcm SUBROUTINE channels(agg, torq_a, torq_b, twist) - TYPE(CD_AGG_ModuleType), INTENT(IN) :: agg + TYPE(CD_AGG_ModuleType), INTENT(INOUT) :: agg REAL(wp), INTENT(OUT) :: torq_a, torq_b, twist INTEGER :: es CHARACTER(256) :: em diff --git a/tests/test_deck_driver.f90 b/tests/test_deck_driver.f90 index cafe53cf..75ff7106 100644 --- a/tests/test_deck_driver.f90 +++ b/tests/test_deck_driver.f90 @@ -1842,6 +1842,16 @@ SUBROUTINE check_parser_hardening() CALL require(tok_ok(1) .AND. tok_ok(2), 'channel gate admits well-formed TDP tokens') CALL require(.NOT. tok_ok(3) .AND. .NOT. tok_ok(4), 'channel gate rejects a malformed TDP suffix') END BLOCK + ! ... and the anchor uplift channels: AnchFz, AnchFH, TDPGrd + BLOCK + LOGICAL :: tok_ok(7) + tok_ok = [CD_Channel_Token_Parses('AnchFz1'), CD_Channel_Token_Parses('ANCHFH012'), & + CD_Channel_Token_Parses('TDP3Grd'), CD_Channel_Token_Parses('AnchFz'), & + CD_Channel_Token_Parses('AnchFz0'), CD_Channel_Token_Parses('AnchFz1x'), & + CD_Channel_Token_Parses('TDP1Grdx')] + CALL require(ALL(tok_ok(1:3)), 'channel gate admits AnchFz, AnchFH and TDPGrd tokens') + CALL require(.NOT. ANY(tok_ok(4:7)), 'channel gate rejects malformed anchor uplift tokens') + END BLOCK ! the synthesised sea is bounded in total components, not only per factor BLOCK CHARACTER(1) :: nl diff --git a/tests/test_deck_hermite_cable.f90 b/tests/test_deck_hermite_cable.f90 index 6ab57782..652e30f0 100644 --- a/tests/test_deck_hermite_cable.f90 +++ b/tests/test_deck_hermite_cable.f90 @@ -12,7 +12,8 @@ PROGRAM test_deck_hermite_cable USE CableDyn_Precision, ONLY: wp USE CableDyn_DeckDriver, ONLY: CD_Init_Deck_HermiteCable, CD_DECKDRV_OK, CD_DECKDRV_BADINPUT USE CableDyn_OpenFAST_HermiteFMF, ONLY: CD_HFMF_ModuleType, CD_HFMF_UpdateStates, CD_HFMF_CalcOutput, & - CD_HFMF_Curvature, CD_HFMF_GetCoupledKinematics, & + CD_HFMF_Curvature, CD_HFMF_Curvature_Exact, & + CD_HFMF_GetCoupledKinematics, & CD_HFMF_MinSpanZ, CD_HFMF_Snapshot, CD_HFMF_Restore, & CD_HFMF_End, CD_HFMF_OK USE CableDyn_EndConnection, ONLY: CD_ENDCONN_RIGID @@ -112,7 +113,9 @@ SUBROUTINE case_build_and_drive() ! Curvature must stay SMOOTH: a lazy-wave sag/arch bend is O(0.1 /m); a value near 1 /m would ! be a sub-element kink (the slack-catenary buckling mode this lazy-wave gate avoids). Bound ! well below that so the gate actually fails on a kinked response, not just a non-finite one. - CALL CD_HFMF_Curvature(cable, curv, es, em) + ! A kink is a defect of the centreline shape, so the gate reads its geometric trace + ! (CD_HFMF_Curvature_Exact), not the Curv channel's equilibrium moment over EI. + CALL CD_HFMF_Curvature_Exact(cable, curv, es, em) CALL require(es == CD_HFMF_OK .AND. .NOT. ANY(IEEE_IS_NAN(curv)) .AND. nan_max_abs(curv) < 1.0_wp, & 'curvature finite, bounded, and smooth (no kink)') WRITE (*, '(A,F9.1,A,F9.2,A,ES10.3)') 'deck-Hermite cable: steady |Fair| = ', ymag*1.0e-3_wp, & @@ -189,7 +192,7 @@ SUBROUTINE case_adaptive_mesh_refines() END DO IF (stepped_ok) THEN ALLOCATE (curv(nn_adapt)) - CALL CD_HFMF_Curvature(adapt, curv, es, em) + CALL CD_HFMF_Curvature_Exact(adapt, curv, es, em) ! geometric trace: a kink is a shape defect CALL require(es == CD_HFMF_OK .AND. .NOT. ANY(IEEE_IS_NAN(curv)) .AND. nan_max_abs(curv) < 1.0_wp, & 'adaptive-mesh: refined cable curvature finite, bounded, smooth') WRITE (*, '(A,I0,A,I0,A)') 'adaptive-mesh: coupled cable refined ', nn_plain, ' -> ', nn_adapt, ' nodes' diff --git a/tests/test_flagship_compression_note.f90 b/tests/test_flagship_compression_note.f90 index ba4329c3..47ab8401 100644 --- a/tests/test_flagship_compression_note.f90 +++ b/tests/test_flagship_compression_note.f90 @@ -10,9 +10,11 @@ PROGRAM test_flagship_compression_note !! positive, and that is the quantity the static note is gated on. !! !! The node Tension channel Ten4N (static profile, standalone and coupled outputs) is - !! the segment tension: at interior nodes the length-weighted average of the two adjacent - !! element-mean axial forces, recomputed here independently; at the ends the end force. - !! It stays within the end tensions instead of the pointwise spikes at the touchdown. + !! the effective tension recovered from nodal equilibrium; at the ends the end force. On the + !! suspended part it is checked here against the statics of the free body between the node + !! and the fairlead: the fairlead force less the submerged weight of the elements in between, + !! projected on the nodal tangent. It stays within the end tensions instead of the pointwise + !! spikes at the touchdown. !! !! A deck whose finite-EI elements are shorter than sqrt(EI/EA) (the conditioning limit !! of the static Newton system) carries the fine-mesh note; the flagship does not. @@ -21,6 +23,7 @@ PROGRAM test_flagship_compression_note USE CableDyn_HermiteCableStatic, ONLY: CD_HermiteCable_Branch_Audit, CD_HermiteBranchAuditType, CD_HCSTAT_OK USE CableDyn_HermiteCable, ONLY: CD_HermiteCable_Axial_Resultant USE CableDyn_DeckDriver, ONLY: CD_Eval_Aggregate_Channel + USE CableDyn_HermiteCableDynamic, ONLY: CD_HermiteCable_Dyn_End_Force, CD_HCDYN_OK IMPLICIT NONE TYPE(CD_AGG_ModuleType) :: agg @@ -29,7 +32,8 @@ PROGRAM test_flagship_compression_note CHARACTER(512) :: em INTEGER :: es, i, nfail, nn, j, inode, k REAL(wp), ALLOCATABLE :: ten(:), emean(:) - REAL(wp) :: qe(12), ng, expect, dev_max, t_end + REAL(wp) :: qe(12), ng, expect, dev_max, t_end, fair(3), sec(3), tan_j(3) + INTEGER :: first_free, n_checked CHARACTER(32) :: ch REAL(wp), PARAMETER :: G3X(3) = [0.5_wp - 0.5_wp*SQRT(0.6_wp), 0.5_wp, 0.5_wp + 0.5_wp*SQRT(0.6_wp)] REAL(wp), PARAMETER :: G3W(3) = [5.0_wp/18.0_wp, 8.0_wp/18.0_wp, 5.0_wp/18.0_wp] @@ -81,21 +85,46 @@ PROGRAM test_flagship_compression_note emean(j) = emean(j) + G3W(k)*ng END DO END DO - dev_max = 0.0_wp + WRITE (*, '(A,2ES12.4)') ' element-mean axial force min, max [N]: ', MINVAL(emean), MAXVAL(emean) DO j = 1, nn WRITE (ch, '(A,I0)') 'Ten4N', j CALL CD_Eval_Aggregate_Channel(TRIM(ch), agg%has_sys, agg%sys%fast%system, agg%cables, & agg%line_is_cable, agg%line_obj_index, ten(j), es, em) IF (es /= 0) CALL check(.FALSE., 'node Tension channel '//TRIM(ch)//': '//TRIM(em)) - inode = nn - j + 1 - IF (inode > 1 .AND. inode < nn) THEN - expect = (ln%l0(inode - 1)*emean(inode - 1) + ln%l0(inode)*emean(inode))/(ln%l0(inode - 1) + ln%l0(inode)) - dev_max = MAX(dev_max, ABS(ten(j) - expect)) + END DO + ! Suspended run next to the fairlead (internal nodes first_free .. nn): no node from + ! first_free - 1 on touches the seabed (1 cm clearance), so the only loads between an + ! interior node and the fairlead, and in the element before it, are the consistent + ! submerged weights of the elements (the reaction of a grounded node is spread over its + ! tributary length, into the element after it). + first_free = 2 + DO k = nn, 1, -1 + IF (ln%q(6*(k - 1) + 3) <= ln%seabed_z + 0.01_wp) THEN + first_free = k + 2 + EXIT END IF END DO + CALL CD_HermiteCable_Dyn_End_Force(ln, nn, fair, es, em) + CALL check(es == CD_HCDYN_OK, 'fairlead end force evaluated: '//TRIM(em)) + sec = -fair ! force of the fairlead on the line + dev_max = 0.0_wp + n_checked = 0 + DO inode = nn - 1, first_free, -1 + sec(3) = sec(3) - ln%w(inode)*ln%l0(inode) + tan_j = ln%q(6*(inode - 1) + 4:6*(inode - 1) + 6) + expect = DOT_PRODUCT(sec, tan_j)/NORM2(tan_j) + dev_max = MAX(dev_max, ABS(ten(nn - inode + 1) - expect)) + n_checked = n_checked + 1 + END DO t_end = MAX(ten(1), ten(nn)) WRITE (*, '(A,3ES12.4)') ' node Tension min, max, max end tension [N]: ', MINVAL(ten), MAXVAL(ten), t_end - CALL check(dev_max <= 1.0e-6_wp*t_end, 'interior node Tension is the length-weighted element-mean average') + WRITE (*, '(A,I0,A,ES12.4)') ' suspended nodes checked against the free-body statics: ', n_checked, & + '; largest difference [N]: ', dev_max + CALL check(n_checked > 40, 'the suspended run spans the sag and hog bends') + ! The initialised state keeps a consistent acceleration of order 1e-4 m/s^2, whose inertia + ! the recovery includes and the free-body statics leave out (0.03 N here): 1e-5 of the + ! end tension bounds it; the element-mean axial force dips to -1.98 kN at the touchdown. + CALL check(dev_max <= 1.0e-5_wp*t_end, 'interior node Tension is the free-body effective tension') CALL check(MINVAL(ten) > -0.1_wp*MAXVAL(ten), 'node Tension carries no compression beyond a tenth of the peak') CALL check(MAXVAL(ten) <= 1.001_wp*t_end, 'node Tension peaks at the line end, not at the touchdown') END ASSOCIATE diff --git a/tests/test_l3_lazywave_3d_dynamic.f90 b/tests/test_l3_lazywave_3d_dynamic.f90 index 194fa006..007f144e 100644 --- a/tests/test_l3_lazywave_3d_dynamic.f90 +++ b/tests/test_l3_lazywave_3d_dynamic.f90 @@ -37,7 +37,7 @@ PROGRAM test_l3_lazywave_3d_dynamic USE CableDyn_HermiteCableStatic, ONLY: CD_HermiteCable_Static_Solve, CD_HCSTAT_OK USE CableDyn_HermiteCableDynamic, ONLY: CD_HermiteCableDynType, CD_HermiteCable_Dyn_Init, & CD_HermiteCable_Dyn_Set_Drag, CD_HermiteCable_Dyn_Set_AddedMass, & - CD_HermiteCable_Dyn_Step, CD_HermiteCable_Dyn_Curvature, & + CD_HermiteCable_Dyn_Step, CD_HermiteCable_Dyn_Curvature_Exact, & CD_HermiteCable_Dyn_End, CD_HCDYN_OK IMPLICIT NONE @@ -213,7 +213,7 @@ PROGRAM test_l3_lazywave_3d_dynamic END IF steps_done = steps_done + 1 IF (t >= T_SCORE) THEN - CALL CD_HermiteCable_Dyn_Curvature(model, cdyn, es, em) + CALL CD_HermiteCable_Dyn_Curvature_Exact(model, cdyn, es, em) DO i = 1, nn arc_i = REAL(i - 1, wp)*l0e IF (arc_i >= 0.03_wp*Lsus .AND. arc_i <= 0.97_wp*Lsus) THEN diff --git a/tests/test_l3_lazywave_dynamic.f90 b/tests/test_l3_lazywave_dynamic.f90 index b18d7ad1..703c4fd6 100644 --- a/tests/test_l3_lazywave_dynamic.f90 +++ b/tests/test_l3_lazywave_dynamic.f90 @@ -56,7 +56,7 @@ PROGRAM test_l3_lazywave_dynamic CD_HermiteCable_Dyn_Set_Drag, CD_HermiteCable_Dyn_Set_AddedMass, & CD_HermiteCable_Dyn_Step, CD_HermiteCable_Dyn_Step_Recovering, & CD_HermiteCable_Dyn_Recovery_Count, CD_HermiteCable_Dyn_Recovery_Reset, & - CD_HermiteCable_Dyn_Curvature, & + CD_HermiteCable_Dyn_Curvature_Exact, & CD_HermiteCable_Dyn_End, CD_HCDYN_OK IMPLICIT NONE @@ -360,7 +360,7 @@ SUBROUTINE run_site(is) IF (t >= T_SCORE) THEN cycle_index = MIN(3, MAX(1, INT((t - T_SCORE + 1.0e-9_wp)/PER) + 1)) step_peak = 0.0_wp - CALL CD_HermiteCable_Dyn_Curvature(model, cdyn, es, em) + CALL CD_HermiteCable_Dyn_Curvature_Exact(model, cdyn, es, em) DO e = 1, ne qr(1:6) = model%q(6*(e - 1) + 1:6*e) qr(7:12) = model%q(6*e + 1:6*(e + 1)) @@ -786,7 +786,7 @@ SUBROUTINE refined_dynamic_response(l0, q0, eav, eiv, w, rhoa, diam, cdn, cdt, c minimum_axial = MIN(minimum_axial, axial_now) IF (k > peak) THEN; peak = k; peak_arc = arc; END IF cycle_peak(cycle_index) = MAX(cycle_peak(cycle_index), k) - CALL CD_HermiteCable_Dyn_Curvature(dyn, nodal_curvature, es, em) + CALL CD_HermiteCable_Dyn_Curvature_Exact(dyn, nodal_curvature, es, em) IF (es /= CD_HCDYN_OK) THEN; CALL CD_HermiteCable_Dyn_End(dyn); RETURN; END IF curvature_profile = MAX(curvature_profile, nodal_curvature) mnorm = NORM2(dyn%q(4:6)); tension = EA*(mnorm - 1.0_wp)/1000.0_wp diff --git a/tests/test_l3_lazywave_irregular.f90 b/tests/test_l3_lazywave_irregular.f90 index 3f603c2b..33240044 100644 --- a/tests/test_l3_lazywave_irregular.f90 +++ b/tests/test_l3_lazywave_irregular.f90 @@ -37,7 +37,7 @@ PROGRAM test_l3_lazywave_irregular USE CableDyn_HermiteCableDynamic, ONLY: CD_HermiteCableDynType, CD_HermiteCable_Dyn_Init, & CD_HermiteCable_Dyn_Set_Drag, CD_HermiteCable_Dyn_Set_AddedMass, & CD_HermiteCable_Dyn_Set_Irregular_Waves, & - CD_HermiteCable_Dyn_Step, CD_HermiteCable_Dyn_Curvature, & + CD_HermiteCable_Dyn_Step, CD_HermiteCable_Dyn_Curvature_Exact, & CD_HermiteCable_Dyn_End, CD_HCDYN_OK IMPLICIT NONE @@ -239,7 +239,7 @@ PROGRAM test_l3_lazywave_irregular END IF steps_done = steps_done + 1 IF (t >= T_SCORE) THEN - CALL CD_HermiteCable_Dyn_Curvature(model, cdyn, es, em) + CALL CD_HermiteCable_Dyn_Curvature_Exact(model, cdyn, es, em) DO i = 1, nn arc_i = REAL(i - 1, wp)*l0e IF (arc_i >= 0.03_wp*Lsus .AND. arc_i <= 0.97_wp*Lsus) kdyn = MAX(kdyn, cdyn(i)) diff --git a/tests/test_l3_lazywave_touchdown_dynamic.f90 b/tests/test_l3_lazywave_touchdown_dynamic.f90 index b2639f94..25a7dd24 100644 --- a/tests/test_l3_lazywave_touchdown_dynamic.f90 +++ b/tests/test_l3_lazywave_touchdown_dynamic.f90 @@ -33,7 +33,7 @@ PROGRAM test_l3_lazywave_touchdown_dynamic USE CableDyn_HermiteCableStatic, ONLY: CD_HermiteCable_Static_Solve_Sequenced, CD_HCSTAT_OK USE CableDyn_HermiteCableDynamic, ONLY: CD_HermiteCableDynType, CD_HermiteCable_Dyn_Init, & CD_HermiteCable_Dyn_Set_Drag, CD_HermiteCable_Dyn_Set_AddedMass, & - CD_HermiteCable_Dyn_Step, CD_HermiteCable_Dyn_Curvature, & + CD_HermiteCable_Dyn_Step, CD_HermiteCable_Dyn_Curvature_Exact, & CD_HermiteCable_Dyn_End, CD_HCDYN_OK IMPLICIT NONE @@ -183,7 +183,7 @@ PROGRAM test_l3_lazywave_touchdown_dynamic END IF steps_done = steps_done + 1 IF (t >= T_SCORE) THEN - CALL CD_HermiteCable_Dyn_Curvature(model, cdyn, es, em) + CALL CD_HermiteCable_Dyn_Curvature_Exact(model, cdyn, es, em) DO i = 1, nn arc_i = REAL(i - 1, wp)*l0e IF (arc_i >= 0.03_wp*LTOT .AND. arc_i <= 0.97_wp*LTOT) kdyn = MAX(kdyn, cdyn(i)) diff --git a/tests/test_l4_lazywave_coupled.f90 b/tests/test_l4_lazywave_coupled.f90 index 635c75c2..85db726d 100644 --- a/tests/test_l4_lazywave_coupled.f90 +++ b/tests/test_l4_lazywave_coupled.f90 @@ -31,7 +31,7 @@ PROGRAM test_l4_lazywave_coupled USE CableDyn_HermiteCableStatic, ONLY: CD_HermiteCable_Static_Solve, CD_HCSTAT_OK USE CableDyn_HermiteCableDynamic, ONLY: CD_HermiteCableDynType, CD_HermiteCable_Dyn_Init, & CD_HermiteCable_Dyn_Set_Drag, CD_HermiteCable_Dyn_Set_AddedMass, & - CD_HermiteCable_Dyn_Step, CD_HermiteCable_Dyn_Curvature, & + CD_HermiteCable_Dyn_Step, CD_HermiteCable_Dyn_Curvature_Exact, & CD_HermiteCable_Dyn_End, CD_HCDYN_OK IMPLICIT NONE @@ -301,7 +301,7 @@ SUBROUTINE run_site(is) CALL require(.FALSE., TRIM(names(is))//' dynamic step stalled: '//TRIM(em)); EXIT END IF IF (t >= T_SCORE) THEN - CALL CD_HermiteCable_Dyn_Curvature(model, cdyn, es, em) + CALL CD_HermiteCable_Dyn_Curvature_Exact(model, cdyn, es, em) DO i = 1, nn arc_i = REAL(i - 1, wp)*l0e IF (arc_i >= 0.03_wp*Lsus .AND. arc_i <= 0.97_wp*Lsus) kdyn_max = MAX(kdyn_max, cdyn(i)) diff --git a/tests/test_lazywave_dynamics.f90 b/tests/test_lazywave_dynamics.f90 index b41ac1a3..d746ec2f 100644 --- a/tests/test_lazywave_dynamics.f90 +++ b/tests/test_lazywave_dynamics.f90 @@ -30,7 +30,7 @@ PROGRAM test_lazywave_dynamics USE CableDyn_HermiteCableDynamic, ONLY: CD_HermiteCableDynType, CD_HermiteCable_Dyn_Init, & CD_HermiteCable_Dyn_Set_Drag, CD_HermiteCable_Dyn_Set_AddedMass, & CD_HermiteCable_Dyn_Set_Waves, & - CD_HermiteCable_Dyn_Step, CD_HermiteCable_Dyn_Curvature, & + CD_HermiteCable_Dyn_Step, CD_HermiteCable_Dyn_Curvature_Exact, & CD_HermiteCable_Dyn_End, CD_HCDYN_OK IMPLICIT NONE @@ -172,7 +172,8 @@ PROGRAM test_lazywave_dynamics IF (es /= CD_HCDYN_OK) THEN CALL require(.FALSE., 'heave-driven step stalled: '//TRIM(em)); EXIT END IF - CALL CD_HermiteCable_Dyn_Curvature(model, cdyn, es, em) + ! the geometric curvature, the quantity of the static reference kstat + CALL CD_HermiteCable_Dyn_Curvature_Exact(model, cdyn, es, em) k_now = MAXVAL(cdyn) kdyn_max = MAX(kdyn_max, k_now); kdyn_min = MIN(kdyn_min, k_now) maxpos = MAX(maxpos, nan_max_abs(model%q - q_static)) ! max excursion from the static shape @@ -226,7 +227,7 @@ PROGRAM test_lazywave_dynamics IF (es /= CD_HCDYN_OK) THEN CALL require(.FALSE., 'full-hydro step stalled: '//TRIM(em)); EXIT END IF - CALL CD_HermiteCable_Dyn_Curvature(model, cdyn, es, em) + CALL CD_HermiteCable_Dyn_Curvature_Exact(model, cdyn, es, em) k_now = MAXVAL(cdyn) kdyn_max = MAX(kdyn_max, k_now); kdyn_min = MIN(kdyn_min, k_now) maxpos = MAX(maxpos, nan_max_abs(model%q - q_static)) diff --git a/tests/test_openfast_aggregate.f90 b/tests/test_openfast_aggregate.f90 index fe58f15a..56f52f54 100644 --- a/tests/test_openfast_aggregate.f90 +++ b/tests/test_openfast_aggregate.f90 @@ -42,12 +42,13 @@ PROGRAM test_openfast_aggregate CD_FMF_GetMovingPointMesh, CD_FMF_Step_Moving, CD_FMF_CalcOutput, & CD_FMF_End, CD_FMF_OK USE CableDyn_OpenFAST_HermiteFMF, ONLY: CD_HFMF_Restore, CD_HFMF_MinSpanZ, CD_HFMF_Curvature, CD_HFMF_CalcOutput, & - CD_HFMF_OK, & + CD_HFMF_OK, CD_HFMF_Curvature_Exact, & CD_HFMF_MirrorSize, CD_HFMF_PackMirror, CD_HFMF_UnpackMirror ! Public driver-side evaluators, used to cross-check the shell channel path against the ! standalone driver's channel definitions on the aggregate's own static configuration. USE CableDyn_DeckDriver, ONLY: tangent_declination_deg - USE CableDyn_HermiteCableDynamic, ONLY: CD_HermiteCable_Dyn_Reset_Profile, CD_HermiteCable_Dyn_Get_Profile + USE CableDyn_HermiteCableDynamic, ONLY: CD_HermiteCable_Dyn_Reset_Profile, CD_HermiteCable_Dyn_Get_Profile, & + CD_HermiteCable_Dyn_Set_Output_Recovery USE CableDyn_Model, ONLY: CD_Get_Model_EndForces, CD_MODEL_OK USE CableDyn_System, ONLY: CD_System_NSystemCoupledDOF, CD_Get_System_CoupledMotion, & CD_Update_System_CoupledMotion, & @@ -114,6 +115,7 @@ PROGRAM test_openfast_aggregate CALL case_pure_mooring_equals_fmf() CALL case_mixed_deck_composition() CALL case_touchdown_cable_end_tension() + CALL case_anchor_uplift_channels() CALL case_output_channels() CALL case_pure_cable_deck() CALL case_cable_load_feedback() @@ -805,16 +807,30 @@ SUBROUTINE case_output_channels() END BLOCK CALL require(vFairTen2 > 1.0e3_wp, 'chan:FairTen2-physical') - ! (b) cable Curv1N5 is the exact one-sided Hermite curvature at deck node 5, - ! conservatively retaining the larger adjacent-element trace. The channel and - ! public HFMF recovery must share that definition. + ! (b) cable Curv1N5 and the public HFMF nodal curvature share one definition at deck node 5: + ! the bend moment recovered from nodal equilibrium over EI by default, and under + ! OutputRecovery element the exact one-sided Hermite curvature, the larger adjacent-element + ! trace (CD_HFMF_Curvature_Exact). The channel follows the cable's setting. nnode = agg%cables(1)%line%nn ALLOCATE (exact_curvature(nnode)) CALL CD_HFMF_Curvature(agg%cables(1), exact_curvature, es, em) - CALL require(es == CD_HFMF_OK, 'chan:exact-Hermite-curvature: '//TRIM(em)) + CALL require(es == CD_HFMF_OK, 'chan:recovered-curvature: '//TRIM(em)) kexp = exact_curvature(nnode - 5 + 1) CALL require(ABS(vCurv1N5 - kexp) <= 1.0e-9_wp + 1.0e-6_wp*ABS(kexp), 'chan:Curv1N5-matches-driver') CALL require(vCurv1N5 > 0.0_wp, 'chan:Curv1N5-nonzero') + CALL CD_HFMF_Curvature_Exact(agg%cables(1), exact_curvature, es, em) + CALL require(es == CD_HFMF_OK, 'chan:exact-Hermite-curvature: '//TRIM(em)) + CALL CD_HermiteCable_Dyn_Set_Output_Recovery(agg%cables(1)%line, .TRUE.) + BLOCK + REAL(wp) :: k_element(nnode), v_element + CALL CD_HFMF_Curvature(agg%cables(1), k_element, es, em) + CALL require(es == CD_HFMF_OK .AND. MAXVAL(ABS(k_element - exact_curvature)) <= 0.0_wp, & + 'chan:element-recovery-curvature-is-the-exact-trace') + CALL CD_AGG_EvalChannel(agg, 3, v_element, es, em) + CALL require(es == CD_AGG_OK .AND. ABS(v_element - exact_curvature(nnode - 5 + 1)) <= & + 1.0e-9_wp + 1.0e-6_wp*ABS(exact_curvature(nnode - 5 + 1)), 'chan:Curv1N5-element-matches-driver') + END BLOCK + CALL CD_HermiteCable_Dyn_Set_Output_Recovery(agg%cables(1)%line, .FALSE.) ! (c) cable FairAngle1 == declination of the End-A one-sided tangent (deck nodes 1,2). base = 6*(nnode - 1); r1 = agg%cables(1)%line%q(base + 1:base + 3) @@ -4259,13 +4275,80 @@ SUBROUTINE case_touchdown_cable_end_tension() !! grounded run's tension H (~1.2 kN). The node-sampled stretch EA*(|dr/ds| - 1) at the held !! anchor read 78 kN; the element end force equals H. TYPE(CD_AGG_ModuleType) :: agg - INTEGER :: u, ios, es, k + INTEGER :: es, k REAL(wp) :: v(3) CHARACTER(512) :: em REAL(wp), PARAMETER :: DT = 0.025_wp - OPEN (NEWUNIT=u, FILE='agg_touchdown_cable.dat', STATUS='REPLACE', ACTION='WRITE', IOSTAT=ios) - CALL require(ios == 0, 'touchdown: create deck') + CALL write_touchdown_cable_deck('agg_touchdown_cable.dat', 'FairTen2 AnchTen2 Ten2N70') + CALL CD_AGG_Init_From_Deck(agg, 'agg_touchdown_cable.dat', DT, es, em) + CALL require(es == CD_AGG_OK, 'touchdown: init: '//TRIM(em)) + IF (es /= CD_AGG_OK) RETURN + CALL CD_AGG_CalcOutput(agg, es, em) + CALL require(es == CD_AGG_OK, 'touchdown: calc: '//TRIM(em)) + DO k = 1, 3 + CALL CD_AGG_EvalChannel(agg, k, v(k), es, em) + CALL require(es == CD_AGG_OK, 'touchdown: eval: '//TRIM(em)) + END DO + CALL require(v(3) > 1.0e3_wp .AND. v(3) < 1.5e3_wp, 'touchdown: grounded-run tension is the horizontal tension H') + CALL require(ABS(v(2) - v(3)) < 0.05_wp*v(3), 'touchdown: cable AnchTen equals the grounded-run tension H') + CALL require(v(1) > 1.1e4_wp .AND. v(1) < 1.25e4_wp, 'touchdown: cable FairTen carries the suspended weight') + CALL CD_AGG_End(agg, es, em) + END SUBROUTINE case_touchdown_cable_end_tension + + SUBROUTINE case_anchor_uplift_channels() + !! The anchor uplift channels through the shell accessor CD_AGG_EvalChannel, on the + !! touchdown deck: an EI=0 chain (line 1, anchor point 2) and a finite-EI power cable + !! (line 2, anchor point 4), both laid at the anchor. AnchFz/AnchFH are the components of the + !! AnchTen end force and equal the Point

F resultant of the one-line anchor; the chain's + !! anchor node carries its share of the chain weight (AnchFz < 0), the cable's grounded end + !! leaves it to the floor (AnchFz = 0); TDPs + TDPGrd is the deformed line length. + TYPE(CD_AGG_ModuleType) :: agg + INTEGER :: es, k + REAL(wp) :: v(14) + CHARACTER(512) :: em + REAL(wp), PARAMETER :: DT = 0.025_wp + + CALL write_touchdown_cable_deck('agg_anchor_uplift.dat', & + 'AnchTen1 AnchFz1 AnchFH1 Point2Fz Point2FH TDP1s TDP1Grd'//NEW_LINE('a')// & + 'AnchTen2 AnchFz2 AnchFH2 Point4Fz Point4FH TDP2s TDP2Grd') + CALL CD_AGG_Init_From_Deck(agg, 'agg_anchor_uplift.dat', DT, es, em) + CALL require(es == CD_AGG_OK, 'uplift: init: '//TRIM(em)) + IF (es /= CD_AGG_OK) RETURN + CALL require(CD_AGG_NumChannels(agg) == 14, 'uplift: fourteen channels') + CALL CD_AGG_CalcOutput(agg, es, em) + CALL require(es == CD_AGG_OK, 'uplift: calc: '//TRIM(em)) + v = 0.0_wp + DO k = 1, MIN(14, CD_AGG_NumChannels(agg)) + CALL CD_AGG_EvalChannel(agg, k, v(k), es, em) + CALL require(es == CD_AGG_OK .AND. IEEE_IS_FINITE(v(k)), 'uplift: eval: '//TRIM(em)) + END DO + WRITE (*, '(A,3ES13.5,A,2ES13.5)') 'uplift: chain AnchTen/Fz/FH = ', v(1:3), ', TDP s/Grd = ', v(6:7) + WRITE (*, '(A,3ES13.5,A,2ES13.5)') 'uplift: cable AnchTen/Fz/FH = ', v(8:10), ', TDP s/Grd = ', v(13:14) + ! EI=0 chain (system line) + CALL require(v(2) == v(4) .AND. v(3) == v(5), 'uplift: chain AnchFz1/AnchFH1 equal Point2Fz/Point2FH') + CALL require(ABS(HYPOT(v(2), v(3)) - v(1)) <= 1.0e-12_wp*v(1), 'uplift: chain AnchTen1 is |(AnchFH1, AnchFz1)|') + CALL require(v(2) < 0.0_wp .AND. -v(2) < 0.1_wp*v(1), 'uplift: laid chain anchor carries a small downward share') + CALL require(v(7) > 100.0_wp .AND. ABS(v(6) + v(7) - 850.0_wp) < 0.005_wp*850.0_wp, & + 'uplift: chain grounded length, TDP1s + TDP1Grd = deformed length') + ! finite-EI cable + CALL require(v(9) == v(11) .AND. v(10) == v(12), 'uplift: cable AnchFz2/AnchFH2 equal Point4Fz/Point4FH') + CALL require(ABS(HYPOT(v(9), v(10)) - v(8)) <= 1.0e-12_wp*v(8), 'uplift: cable AnchTen2 is |(AnchFH2, AnchFz2)|') + CALL require(ABS(v(9)) <= 1.0e-9_wp*v(8), 'uplift: grounded cable end leaves its node weight to the floor') + CALL require(v(14) > 100.0_wp .AND. ABS(v(13) + v(14) - 600.0_wp) < 0.01_wp*600.0_wp, & + 'uplift: cable grounded length, TDP2s + TDP2Grd = deformed length') + CALL CD_AGG_End(agg, es, em) + END SUBROUTINE case_anchor_uplift_channels + + SUBROUTINE write_touchdown_cable_deck(path, outputs_row) + !! IEA-15MW mooring chain (line 1, Fixed anchor point 2) + touchdown power cable (line 2, + !! Fixed anchor point 4) on a 200 m seabed, with the given OUTPUTS row(s). + CHARACTER(*), INTENT(IN) :: path, outputs_row + INTEGER :: u, ios + + OPEN (NEWUNIT=u, FILE=path, STATUS='REPLACE', ACTION='WRITE', IOSTAT=ios) + CALL require(ios == 0, 'touchdown: create deck '//path) + IF (ios /= 0) RETURN WRITE (u, '(A)') 'IEA-15MW mooring chain + touchdown power cable' WRITE (u, '(A)') '--- LINE TYPES ---' WRITE (u, '(A)') 'Name Diam Mass EA BA EI Cdn Cdt Can Cat' @@ -4300,24 +4383,11 @@ SUBROUTINE case_touchdown_cable_end_tension() WRITE (u, '(A)') '3.0e5 cBot' WRITE (u, '(A)') '0.35 frictionMu' WRITE (u, '(A)') '--- OUTPUTS ---' - WRITE (u, '(A)') 'FairTen2 AnchTen2 Ten2N70' + WRITE (u, '(A)') outputs_row WRITE (u, '(A)') 'END' WRITE (u, '(A)') '--- need this line ---' CLOSE (u) - CALL CD_AGG_Init_From_Deck(agg, 'agg_touchdown_cable.dat', DT, es, em) - CALL require(es == CD_AGG_OK, 'touchdown: init: '//TRIM(em)) - IF (es /= CD_AGG_OK) RETURN - CALL CD_AGG_CalcOutput(agg, es, em) - CALL require(es == CD_AGG_OK, 'touchdown: calc: '//TRIM(em)) - DO k = 1, 3 - CALL CD_AGG_EvalChannel(agg, k, v(k), es, em) - CALL require(es == CD_AGG_OK, 'touchdown: eval: '//TRIM(em)) - END DO - CALL require(v(3) > 1.0e3_wp .AND. v(3) < 1.5e3_wp, 'touchdown: grounded-run tension is the horizontal tension H') - CALL require(ABS(v(2) - v(3)) < 0.05_wp*v(3), 'touchdown: cable AnchTen equals the grounded-run tension H') - CALL require(v(1) > 1.1e4_wp .AND. v(1) < 1.25e4_wp, 'touchdown: cable FairTen carries the suspended weight') - CALL CD_AGG_End(agg, es, em) - END SUBROUTINE case_touchdown_cable_end_tension + END SUBROUTINE write_touchdown_cable_deck SUBROUTINE write_mixed_deck(path, finite_end_connection, rigid_end_connection) !! MIXED deck: one EI=0 catenary chain (mooring) + one finite-EI lazy-wave power cable. diff --git a/tests/test_pinned_touchdown_stability.f90 b/tests/test_pinned_touchdown_stability.f90 index df9e714f..b0037cc4 100644 --- a/tests/test_pinned_touchdown_stability.f90 +++ b/tests/test_pinned_touchdown_stability.f90 @@ -13,7 +13,7 @@ PROGRAM test_pinned_touchdown_stability USE CableDyn_OpenFAST_Aggregate, ONLY: CD_AGG_ModuleType, CD_AGG_Init_From_Deck, & CD_AGG_GetMovingPointMesh, CD_AGG_Step_Moving, & CD_AGG_End, CD_AGG_OK - USE CableDyn_OpenFAST_HermiteFMF, ONLY: CD_HFMF_Curvature, CD_HFMF_OK + USE CableDyn_OpenFAST_HermiteFMF, ONLY: CD_HFMF_Curvature_Exact, CD_HFMF_OK IMPLICIT NONE REAL(wp), PARAMETER :: DT = 0.05_wp, T_END = 30.0_wp, RAMP_TIME = 10.0_wp @@ -63,7 +63,10 @@ PROGRAM test_pinned_touchdown_stability CALL require(.FALSE., 'held dynamic step at t='//TRIM(real_text(REAL(s, wp)*DT))//' s: '//TRIM(em)) EXIT END IF - CALL CD_HFMF_Curvature(agg%cables(1), curvature, hs, em) + ! The geometric trace of the centreline at the pinned hang-off: a collapsing endpoint tangent + ! shows here. The recovered curvature (CD_HFMF_Curvature) is the equilibrium moment over EI, + ! which a pinned end does not carry, so it cannot detect the collapse. + CALL CD_HFMF_Curvature_Exact(agg%cables(1), curvature, hs, em) IF (hs /= CD_HFMF_OK) THEN CALL require(.FALSE., 'curvature evaluation: '//TRIM(em)) EXIT diff --git a/tests/test_range_tdp.py b/tests/test_range_tdp.py index 60abcd22..e8c99716 100644 --- a/tests/test_range_tdp.py +++ b/tests/test_range_tdp.py @@ -165,6 +165,57 @@ def check_tdp_vs_python(label: str, root: Path, line_id: int, seabed_z: float, t check(worst < tol, f"{label}: TDP channels agree with touchdown_history (max difference {worst:.1e} m)") +def check_output_recovery(exe: str, deck: str, out: Path, env: dict, nodes: list[int]) -> None: + """OPTIONS OutputRecovery on the lazy-wave run: the element definitions change only the + interior node tension, curvature and bend moment; the end forces (also the end-node + Tension), positions and TDP are unchanged; an unknown value stops the run.""" + element = set_option(deck, "OutputRecovery", "element") + (out / "lazywave_element.dat").write_text(element, encoding="utf-8", newline="\n") + run(exe, out / "lazywave_element.dat", out / "lazywave_element", env) + eq = read_output(out / "lazywave.out") + el = read_output(out / "lazywave_element.out") + same = ["FairTen1", *tdp_channels(1), f"Ten1N{nodes[0]}", f"Ten1N{nodes[-1]}"] + same += [f"L1N{j}p{c}" for j in nodes for c in "xyz"] + check(all(np.array_equal(eq.column(n), el.column(n)) for n in same), + "OutputRecovery element: end forces, end-node Tension, positions and TDP channels are unchanged") + changed = all( + not np.array_equal(eq.column(f"{p}1N{j}"), el.column(f"{p}1N{j}")) + for j in nodes[1:-1] + for p in ("Ten", "Curv", "BendMom") + ) + check(changed, "OutputRecovery element: every interior Ten, Curv and BendMom channel takes the element definition") + bad = set_option(deck, "OutputRecovery", "nodal") + (out / "lazywave_bad.dat").write_text(bad, encoding="utf-8", newline="\n") + proc = subprocess.run([exe, str(out / "lazywave_bad.dat"), str(out / "lazywave_bad")], capture_output=True, + text=True, env=env, cwd=out) + check(proc.returncode == 1 and "must be equilibrium or element" in proc.stdout + proc.stderr, + "OutputRecovery: an unknown value stops the run by name") + + +def check_soft_section_curvature(exe: str, deck: str, out: Path, env: dict, nodes: list[int]) -> None: + """A section softer than max(|w| L0^2)/12 times 1 m (1.3 kN m^2 on this cable) cannot resolve a + curvature from the recovered moment, whose error does not scale with EI: Curv takes the exact + geometric trace (the OutputRecovery element value) instead of an amplified moment error. With + EI = 100 N m^2 the recovered curvature would exceed 6 1/m against a peak trace of 0.12 1/m.""" + soft, count = re.subn(r"1\.99e4", "1.0e2", deck) + if count != 2: + raise RuntimeError("expected two EI entries in the lazy-wave line types, found %d" % count) + names = [f"Curv1N{j}" for j in nodes] + soft = set_outputs(soft, names) + (out / "lazywave_soft.dat").write_text(soft, encoding="utf-8", newline="\n") + run(exe, out / "lazywave_soft.dat", out / "lazywave_soft", env) + element = set_option(soft, "OutputRecovery", "element") + (out / "lazywave_soft_element.dat").write_text(element, encoding="utf-8", newline="\n") + run(exe, out / "lazywave_soft_element.dat", out / "lazywave_soft_element", env) + eq = read_output(out / "lazywave_soft.out") + el = read_output(out / "lazywave_soft_element.out") + worst = max(float(np.max(np.abs(eq.column(n) - el.column(n)))) for n in names) + peak = max(float(np.max(el.column(n))) for n in names) + check(worst == 0.0 and 0.0 < peak < 1.0, + f"soft section (EI = 100 N m^2): Curv takes the exact geometric trace (peak {peak:.3f} 1/m, " + f"difference to OutputRecovery element {worst:.1e})") + + def catenary_tdp(length: float, span: float, depth: float, w: float, ea: float) -> tuple[float, float, float]: """Elastic catenary resting on a frictionless seabed: (TDP deformed arc from the fairlead, TDP horizontal distance from the fairlead, horizontal tension).""" @@ -349,6 +400,8 @@ def main() -> int: run(args.exe, out / "lazywave.dat", out / "lazywave", env) check_envelopes("cubic-Hermite", out / "lazywave", 1, nodes, 1.0, -80.0) check_tdp_vs_python("cubic-Hermite", out / "lazywave", 1, -80.0, 5e-3) + check_output_recovery(args.exe, deck, out, env, nodes) + check_soft_section_curvature(args.exe, deck, out, env, nodes) # --- Free point (point-system route) src = (examples / "clump_weight_free_point.dat").read_text(encoding="utf-8") diff --git a/tests/test_range_tdp_locator.f90 b/tests/test_range_tdp_locator.f90 new file mode 100644 index 00000000..f1d2b678 --- /dev/null +++ b/tests/test_range_tdp_locator.f90 @@ -0,0 +1,138 @@ +! File: tests/test_range_tdp_locator.f90 +! SPDX-License-Identifier: Apache-2.0 +! Copyright (c) 2026 Jae Hoon Seo, SMI Lab, Inha University +PROGRAM test_range_tdp_locator + !! Unit tests of the touchdown locator of CableDyn_RangeOutput on prescribed node + !! configurations: the quadratic crossing inside the element on convex and concave stencils, a + !! node reaching the onset height maps to that node, and the grounded length TDPGrd is + !! continuous with the touchdown point. + USE CableDyn_Precision, ONLY: wp + USE CableDyn_RangeOutput, ONLY: CD_RangeLine, CD_Range_TDP_Evaluate, CD_TDP_S, CD_TDP_X, CD_TDP_GRD, CD_TDP_N + USE CableDyn_SeabedContact, ONLY: CD_SEABED_CONTACT_BLEND + IMPLICIT NONE + + INTEGER :: nfail + nfail = 0 + + CALL case_convex_stencil() + CALL case_concave_stencil() + CALL case_node_at_onset() + CALL case_grounded_length_continuity() + CALL case_end_b() + + IF (nfail > 0) THEN + WRITE (*, '(A,I0,A)') 'FAIL: ', nfail, ' assertion(s) failed' + ERROR STOP 1 + END IF + WRITE (*, '(A)') 'PASS: CableDyn_RangeOutput touchdown locator' + +CONTAINS + + SUBROUTINE expect(got, want, tol, label) + REAL(wp), INTENT(IN) :: got, want, tol + CHARACTER(*), INTENT(IN) :: label + IF (.NOT. (ABS(got - want) <= tol)) THEN + WRITE (*, '(A,A,A,ES23.15,A,ES23.15)') 'MISMATCH [', label, ']: got ', got, ' want ', want + nfail = nfail + 1 + END IF + END SUBROUTINE expect + + SUBROUTINE locate(clearance, grounded_end, tdp) + !! Nodes on the x axis at unit spacing, heights = clearance (floor at z = 0). + REAL(wp), INTENT(IN) :: clearance(:) + INTEGER, INTENT(IN) :: grounded_end + REAL(wp), INTENT(OUT) :: tdp(CD_TDP_N) + TYPE(CD_RangeLine) :: line + REAL(wp) :: r(3, SIZE(clearance)) + INTEGER :: j + r = 0.0_wp + DO j = 1, SIZE(clearance) + r(1, j) = REAL(j - 1, wp) + r(3, j) = clearance(j) + END DO + line%tdp_ready = .TRUE. + line%tdp_end = grounded_end + line%ref_xy = 0.0_wp + line%ref_dir = [1.0_wp, 0.0_wp] + CALL CD_Range_TDP_Evaluate(line, r, clearance, tdp) + END SUBROUTINE locate + + SUBROUTINE case_convex_stencil() + !! Clearances from the onset height -0.005, 0.01, 1.0 on unit spacing: node 2 is barely off the + !! floor and the line rises sharply beyond it, so the line leaves the floor just before node 2. + !! The parabola crosses once inside the element, at 0.97 chord; the chord crossing (a third of + !! the way) would put the TDP a node behind. + REAL(wp) :: tdp(CD_TDP_N), c(4) + c = CD_SEABED_CONTACT_BLEND + [-0.005_wp, 0.01_wp, 1.0_wp, 2.0_wp] + CALL locate(c, 1, tdp) + IF (.NOT. (tdp(CD_TDP_X) > 0.95_wp .AND. tdp(CD_TDP_X) < 1.0_wp)) THEN + WRITE (*, '(A,ES23.15)') 'MISMATCH [convex: TDP just before the barely lifted node]: x = ', tdp(CD_TDP_X) + nfail = nfail + 1 + END IF + CALL expect(tdp(CD_TDP_GRD), tdp(CD_TDP_S), 1.0e-12_wp, 'convex: grounded length equals the arc from End A') + ! the same with the first node exactly at the onset height: the crossing stays inside the element + c(1) = CD_SEABED_CONTACT_BLEND + CALL locate(c, 1, tdp) + IF (.NOT. (tdp(CD_TDP_X) > 0.95_wp .AND. tdp(CD_TDP_X) < 1.0_wp)) THEN + WRITE (*, '(A,ES23.15)') 'MISMATCH [convex, node at onset: TDP inside the element]: x = ', tdp(CD_TDP_X) + nfail = nfail + 1 + END IF + END SUBROUTINE case_convex_stencil + + SUBROUTINE case_concave_stencil() + !! A stencil with the line rising more gently: g = -0.5, 0.5, 1.0, 1.5. + REAL(wp) :: tdp(CD_TDP_N), c(4) + c = CD_SEABED_CONTACT_BLEND + [-0.5_wp, 0.5_wp, 1.0_wp, 1.5_wp] + CALL locate(c, 1, tdp) + ! the parabola crosses before the linear crossing (x = 0.5) + IF (.NOT. (tdp(CD_TDP_X) > 0.4_wp .AND. tdp(CD_TDP_X) < 0.49_wp)) THEN + WRITE (*, '(A,ES23.15)') 'MISMATCH [concave: quadratic crossing before the linear one]: x = ', tdp(CD_TDP_X) + nfail = nfail + 1 + END IF + END SUBROUTINE case_concave_stencil + + SUBROUTINE case_node_at_onset() + !! A suspended node that reaches the onset height maps to that node. + REAL(wp) :: tdp(CD_TDP_N), c(4) + c = CD_SEABED_CONTACT_BLEND + [-0.5_wp, 1.0e-12_wp, 1.0_wp, 2.0_wp] + CALL locate(c, 1, tdp) + CALL expect(tdp(CD_TDP_X), 1.0_wp, 1.0e-6_wp, 'node reaching onset: TDP at that node') + END SUBROUTINE case_node_at_onset + + SUBROUTINE case_grounded_length_continuity() + !! Node 2 grounds while node 1 rests: Grd and the arc from End A are continuous (no jump + !! from 0 to a chord) and equal each other. + REAL(wp) :: tdp(CD_TDP_N), c(5), h, prev + INTEGER :: k + prev = 0.0_wp + DO k = 0, 12 + h = 0.5_wp*0.5_wp**k + c = CD_SEABED_CONTACT_BLEND + [-1.0e-3_wp, h, 1.0_wp, 2.0_wp, 3.0_wp] + CALL locate(c, 1, tdp) + CALL expect(tdp(CD_TDP_GRD), tdp(CD_TDP_S), 1.0e-12_wp, 'continuity: Grd equals the arc from End A') + IF (k > 0 .AND. ABS(tdp(CD_TDP_GRD) - prev) > 0.5_wp) THEN + WRITE (*, '(A,I0)') 'MISMATCH [continuity: jump of Grd while node 2 approaches the seabed] k = ', k + nfail = nfail + 1 + END IF + prev = tdp(CD_TDP_GRD) + END DO + ! node 2 on the seabed: Grd runs on to the next element, from a value below one chord + c = CD_SEABED_CONTACT_BLEND + [-1.0e-3_wp, 0.0_wp, 1.0_wp, 2.0_wp, 3.0_wp] + CALL locate(c, 1, tdp) + CALL expect(tdp(CD_TDP_GRD), 1.0_wp, 1.0e-5_wp, 'continuity: node 2 at the onset height') + ! the grounded end itself lifted off: nothing touches + c = CD_SEABED_CONTACT_BLEND + [1.0e-3_wp, 0.5_wp, 1.0_wp, 2.0_wp, 3.0_wp] + CALL locate(c, 1, tdp) + CALL expect(tdp(CD_TDP_GRD), 0.0_wp, 0.0_wp, 'lifted end: Grd = 0') + END SUBROUTINE case_grounded_length_continuity + + SUBROUTINE case_end_b() + !! The mirrored configuration gives the same grounded length. + REAL(wp) :: tdp_a(CD_TDP_N), tdp_b(CD_TDP_N), c(4) + c = CD_SEABED_CONTACT_BLEND + [-0.005_wp, 0.01_wp, 1.0_wp, 2.0_wp] + CALL locate(c, 1, tdp_a) + CALL locate(c(4:1:-1), 2, tdp_b) + CALL expect(tdp_b(CD_TDP_GRD), tdp_a(CD_TDP_GRD), 1.0e-12_wp, 'End B: grounded length of the mirrored line') + END SUBROUTINE case_end_b + +END PROGRAM test_range_tdp_locator diff --git a/validation/OPENFAST_DLC_VERIFICATION.md b/validation/OPENFAST_DLC_VERIFICATION.md index 8dab5f4e..903c7ba2 100644 --- a/validation/OPENFAST_DLC_VERIFICATION.md +++ b/validation/OPENFAST_DLC_VERIFICATION.md @@ -177,9 +177,13 @@ with 248 elements to resolve its bending length, and the one-hour full-turbine r coupled finite-EI touchdown row in [`VALIDATION.md`](../VALIDATION.md) uses that mesh. The run completed (exit 0, all 2400 steps, 0 NaN/Inf), and its output contains the finite-EI curvature and bending-moment channels of the sag bend, which confirms that the cable ran on the finite-EI -element. At the static initial state the standalone driver gives 0.0915 1/m and 1821 N·m on -that mesh (`Curv4N20`, `BendMom4N20`), and 0.0906 1/m and 1803 N·m on the current one -(`Curv4N38`, `BendMom4N38`). This case has no MoorDyn-F twin and establishes completion only; cable accuracy is established against OrcaFlex in cases L3-4, L3-5, L3-6 and +element. With the geometric curvature of the centreline, which these channels reported when the +case was run and which `OutputRecovery element` reproduces, the standalone driver gives at the +static initial state 0.0915 1/m and 1821 N·m on that mesh (`Curv4N20`, `BendMom4N20`) and +0.0906 1/m and 1803 N·m on the current one (`Curv4N38`, `BendMom4N38`). The curvature and bend moment +recovered from nodal equilibrium, the channels' definition now, are 0.0838 1/m and 1667 N·m at +node 20 of the former mesh (0.0914 1/m at node 19, the recovered peak) and 0.0902 1/m and +1795 N·m at node 38 of the current one. This case has no MoorDyn-F twin and establishes completion only; cable accuracy is established against OrcaFlex in cases L3-4, L3-5, L3-6 and L4-1c of [`VALIDATION.md`](../VALIDATION.md). ### Coupled rod between two fairleads, still water From 73bd063667c5256d236f544c5ce8c4eafa5655f2 Mon Sep 17 00:00:00 2001 From: Jae Hoon Seo Date: Sat, 17 Oct 2026 18:10:45 +0900 Subject: [PATCH 16/31] feat(rods): pinned and coupled-pinned rods on the coupled route (#22) The coupled aggregate (CompMooring = 5) refused Pinned rods, and every deck refused MoorDyn-F's CoupledPinned/VesselPinned rods. Both now run on the coupled route. - A pinned rod's step advances its rotation about the pin, with the pin acceleration in the rotation equation (as MoorDyn-F) and the force the rod puts on its pin. A CoupledPinned rod takes its pin's position, velocity and acceleration from the host and returns a force and no moment; an output probe re-solves its angular acceleration at the probed pin acceleration, with the coupled-end mass of the frozen line interior. The pin moves linearly within a sub-step from the committed start values, so restarts are bit-identical; PtfmInit and the static initial condition carry CoupledPinned rods. A bare end of a Pinned or CoupledPinned rod needs no RodA/B point; CoupledPinned is refused standalone and in the C API, rods in FAST.Farm and in linearisation. - The explicit sub-step estimate for rods and bodies now bounds every stiffness acting within a step: a pinned rod's swing about its pin (weight, buoyancy, pin acceleration, both pin poses of a host pin), seabed contact (reach from the full station motion, the highest floor on its path), the waterplane of surface-piercing rods, finite-EI cables in the staggered multibody march, and the pin acceleration of a rod pinned to a body. Line-free decks and the staggered march are sub-stepped too, and a step that needs more than the 256 cap warns. - Seabed friction on rods and bodies is applied implicitly through its secant damping coefficient; it was an explicit stiff damper that made a resting rod chatter (a rod held in a cross current now creeps at 1.3e-4 m/s, against 5.3e-3 m/s before). Every shipped example output is byte-identical. Tests: the compound pendulum against the elliptic period, a held CoupledPinned node against the Pinned rod and the analytic pin reaction, pin acceleration and base excitation, sub-cycling, the probe force, snapshot/probe/restart bit identity, PtfmInit, and one test per sub-step source (pendulum without a line, surface crossing, stiff seabed, bathymetry ramp, floating rod, friction hold, cable on a rod) that fails without its term. In OpenFAST (IEA-15 MW, line 1 on a 4 m CoupledPinned rod, JONSWAP Hs 6 m), a checkpoint restart and NumCrctn = 1 are bit-identical. Signed-off-by: Jae Hoon Seo --- CHANGELOG.md | 71 ++ CMakeLists.txt | 12 + VALIDATION.md | 1 + doc/capabilities.rst | 7 +- doc/capi.rst | 8 +- doc/coupling.rst | 3 +- doc/driver_format.md | 23 +- doc/migrating.rst | 5 +- doc/openfast.rst | 24 +- doc/options.rst | 13 +- doc/outputs.rst | 5 +- doc/theory.rst | 116 +- python/cabledyn/deck_file.py | 23 +- python/tests/test_deck_native_parity.py | 27 +- src/CableDyn_Bathymetry.f90 | 37 + src/CableDyn_DeckDriver.f90 | 1310 ++++++++++++++++---- src/CableDyn_Model.f90 | 46 + src/CableDyn_OpenFAST_Aggregate.f90 | 34 +- src/CableDyn_System.f90 | 34 +- src/openfast/CableDyn_OF.f90 | 5 +- tests/test_bodies_rods.f90 | 167 ++- tests/test_body_rod_physics.f90 | 224 ++++ tests/test_c_api.f90 | 57 +- tests/test_openfast_aggregate.f90 | 37 +- tests/test_openfast_pinned_rod.f90 | 1471 +++++++++++++++++++++++ 25 files changed, 3463 insertions(+), 297 deletions(-) create mode 100644 tests/test_openfast_pinned_rod.f90 diff --git a/CHANGELOG.md b/CHANGELOG.md index 15818222..7bc9d957 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -128,6 +128,28 @@ All notable changes to CableDyn are recorded in this file. The format follows - `CD_HermiteCable_Dyn_Curvature_Exact` and `CD_HFMF_Curvature_Exact`: the exact geometric nodal curvature of the cubic-Hermite centreline, the larger one-sided trace at a node, which `CD_HermiteCable_Dyn_Curvature` and `CD_HFMF_Curvature` returned up to 0.1.1. +- `Pinned` and `CoupledPinned`/`VesselPinned` rods in coupled OpenFAST (`CompMooring = 5`) runs. + A `Pinned` rod turns about its fixed End A, which the coupled route previously refused. A + `CoupledPinned` rod (MoorDyn-F's coupled pinned rod) is a node of the coupling mesh at its + End A that takes the platform position only: the rod turns about it with its own rotation, + the pin acceleration loading that rotation through the rod's inertia, and the node returns + the rod's net force less its inertia with zero moment. The angular acceleration in that force + is solved for the node's current acceleration, so an output probe sees the rod's effective + inertia about the pin. `PtfmInit` moves the rod with the platform, the static initial + condition balances it about its pin (a pinned rod that carries no line keeps its deck + orientation), sub-cycled steps move the pin along the host path interpolated linearly as for + every other host node, the sub-step count resolves the rod's own swing about its pin under + its weight, buoyancy and pin acceleration (`|W d_g - B d_b|` and the pin-acceleration load + over the inertia about the pin) as well as its lines, so a short pinned rod that carries no + line stays stable at a coupling step beyond its explicit limit (a `CoupledPinned` rod takes + the stiffer of its step-start and end-of-step wetting, so a pin that crosses the free surface + within a step is covered), and checkpoint restarts and correction iterations reproduce the + run bit for bit with the existing rod state mirror. An end of a `Pinned` or `CoupledPinned` rod that + carries no line needs no `RodA`/`RodB` POINT row on the coupled route; other rods still + need one at both ends. The C API runs `Pinned` rods, as its manual page already stated. The + standalone driver and the C API refuse `CoupledPinned` rods by name; FAST.Farm decks still + refuse rods, OpenFAST linearisation still refuses rods, and `CoupledPinned` bodies remain + unsupported. See the manual's OpenFAST page (Lifecycle features). ### Changed @@ -251,6 +273,55 @@ All notable changes to CableDyn are recorded in this file. The format follows ### Fixed +- Seabed contact in the explicit object sub-step estimate. The staggered march of free and + pinned rods and Rigid6 bodies (the coupled OpenFAST and C API routes, standalone rod decks and + `bodyScheme staggered`) applies the seabed penalty springs explicitly, but sized its sub-steps + from the lines, hydrostatics and (pinned rods) the swing only, so a rod or body resting on a + stiff seabed at a large coupling step could exceed the central-difference limit and be thrown + off the bed. The estimate now adds the contact springs that can act within the step + (`kBot d dl` per rod contact station, `kBot` over 1 m² at a body's reference point), in + heave, roll and pitch about the reference point, or about the pin of a pinned rod at both pin + poses. A station counts from its complete rigid-body motion: its reach + `dt |v + w x s| + dt² (|a| + |alpha x s| + |w|² |s| + g)/2` bounds its travel in every + direction, and it counts when its height above the highest floor within that horizontal + distance (the depth on a flat seabed; on a `bathymetryFile` grid the highest node of the + overlapped cells, raised for the crease rounding by the new `CD_Bathymetry_Max_Floor`) is at + most the reach plus the rod radius, so a rod sliding or turning towards a shallower bed is + covered as well as one landing. The monolithic scheme, which carries the contact in its + Jacobian, is unchanged. No shipped example or existing test changes its sub-step count. +- Line-free explicit object marches without a sub-step estimate. A standalone deck without lines + marched its bodies and rods by the explicit central difference at `dtM` with no sub-steps, and + the `bodyScheme staggered` multibody march skipped the bodies (and rods) when no `EI = 0` line + was present (finite-EI cables only), so a short pinned rod or a body on a stiff seabed could + exceed the explicit limit there. Both now take the estimate from the objects' own terms + (hydrostatic restoring, seabed contact, a pinned rod's swing about its pin), and the staggered + multibody march sizes a pinned rod as the coupled route does: its line springs through their + arms from the pin on its inertia about the pin, plus its swing and contact about the pin. A 1 m + dry pinned rod at `dtM = 0.6 s` (`omega0 dt = 2.29`) now takes 6 sub-steps on both routes and + equals a `dtM = 0.1 s` run at every row, where it previously turned over. No shipped example + or existing test changes its sub-step count. +- Further terms of the explicit object sub-step estimate (coupled and C API routes, standalone + rod decks, decks without lines and `bodyScheme staggered`; the monolithic scheme is + unchanged): a rod near the free surface adds its waterplane stiffness (`rhoW g D dl` at each + station whose section can cross the surface within the step, `rhoW g pi D^2/4` where its axis + can cross it) and takes its dry inertia, for free and pinned rods and the rods fixed to a + Rigid6 body, so a floating rod (a 5 cm rod at `omega dt = 2.2`) no longer grows; a finite-EI + cable on a body or rod of the staggered march adds its attachment spring (`EA/L` along its end + force, `T/L` across), as the explicit cable end force needs; a rod pinned to a body takes the + body's pin acceleration and a reduced-mass lower bound of its inertia about the pin; a step + that would need more than the 256-sub-step cap is warned about once per run. Of the existing + tests, only the staggered pinned-cable deck of `clamped_cable_ends` changes (10 steps now + sub-cycled 2 to 5 times; printed results unchanged); no shipped example changes. +- Seabed friction of rods and Rigid6 bodies is applied implicitly. The regularised friction + `-mu N v/sqrt(v^2 + vreg^2)` (`vreg = 1e-3 m/s`) is a damper of up to `mu N/vreg`, far stiffer + than any practical step, and was evaluated explicitly, so a rod or body resting on a + frictional bed chattered (velocity and friction flipping every step). It now enters the + implicit velocity derivative of the step as its secant coefficient `mu N/sqrt(v^2 + vreg^2)`, + as the line nodes treat it implicitly: a rod held in a cross current holds still (creep at + `vreg F/(mu N)`) where it slid back and forth at a few mm/s. This changes the results of decks + with rods or bodies on a frictional seabed; none of the shipped examples or existing tests has + one. + - Tension spikes of tension-only (`EI = 0`) lines that go slack. The generalised-α step evaluated the axial force and the dynamic loads at the blended configuration `q_α = (1 − α_f) q_{n+1} + α_f q_n`. A segment that was slack at the start of a step and diff --git a/CMakeLists.txt b/CMakeLists.txt index 7c2e0b0f..fd3bdce1 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -1044,6 +1044,17 @@ set_tests_properties(openfast_aggregate_touchdown PROPERTIES set_tests_properties(openfast_aggregate openfast_aggregate_touchdown PROPERTIES RESOURCE_LOCK openfast_aggregate_files) +# Pinned and CoupledPinned rods on the coupled aggregate: the compound-pendulum period, a held +# host equal to a fixed pin, constant and harmonic pin accelerations against closed forms, +# sub-cycling, snapshot/restore, the output probe, restart, PtfmInit with the static start, a +# step without the staged rods, and rod ends without a line. +add_executable(test_openfast_pinned_rod tests/test_openfast_pinned_rod.f90) +target_link_libraries(test_openfast_pinned_rod PRIVATE cabledyn_core) +file(MAKE_DIRECTORY ${CMAKE_BINARY_DIR}/openfast_pinned_rod) +add_test(NAME openfast_pinned_rod COMMAND test_openfast_pinned_rod + WORKING_DIRECTORY ${CMAKE_BINARY_DIR}/openfast_pinned_rod) +set_tests_properties(openfast_pinned_rod PROPERTIES LABELS "fortran;dynamic;openfast;validation") + # Maintained IEA-15 MW mixed deck: the finite-EI power cable has a genuine multi-node # grounded run and marches through the OpenFAST aggregate at 40 Hz with host current. add_executable(test_openfast_touchdown tests/test_openfast_touchdown.f90) @@ -2395,6 +2406,7 @@ if(CABLEDYN_ENABLE_COVERAGE) test_openfast_shell test_hermite_fmf test_openfast_aggregate + test_openfast_pinned_rod test_of_mooring_counters test_ei0_mesh_scaling_counters test_c_api diff --git a/VALIDATION.md b/VALIDATION.md index df910349..7d7ce2b9 100644 --- a/VALIDATION.md +++ b/VALIDATION.md @@ -740,6 +740,7 @@ stop with a named error. | Active tension (`CtrlChan`) | Pass verified | CONTROL parsing, last-segment length/rate modulation, and exact unit tests; coupled A/B in which a ServoDyn cable-control DLL drives the same pay-out/haul-in `DeltaL` schedule into `=5` (CableDyn) and `=3` (stock MoorDyn) in one binary: hold tensions agree to <0.03% and the tension responses to <0.6% (controlled fairleads) / <0.7% (anchors) ([`validation/scripts/activetension/`](https://github.com/SMI-Lab-Inha/CableDyn/tree/main/validation/scripts/activetension), [`validation/scripts/openfast_activetension_ab.py`](https://github.com/SMI-Lab-Inha/CableDyn/blob/main/validation/scripts/openfast_activetension_ab.py)) | | Coupled `Rigid6` bodies + `Point3` buoys | Pass verified | 6-DOF `Rigid6` motion with hydrostatic (`C33`/`C44`/`C55`) restoring, checkpoint state (bit-identical `openfast -restart` of a 13.9 MN-swinging tethered body), and SeaState drag / Froude–Krylov / added mass. `Point3` buoys take buoyancy and drag/added-mass/FK; a submerged volume-only buoy takes FK. Tests: `case_coupled_rigid6`/`_mirror`/`_fluid`, `case_coupled_point3_buoy`/`_fluid` | | Coupled rigid rods | Pass verified | host-driven `RodA/B` endpoints, correction rewind, bit-identical 24-scalar-per-rod checkpoint state, and two Gauss fluid nodes per rod with SeaState drag/Froude–Krylov/added mass; `case_coupled_rod`, `_mirror`, and `_fluid` pass, and the OpenFAST module compiles with rod decks enabled | +| Coupled pinned rods (`Pinned`, `CoupledPinned`/`VesselPinned`) | Pass verified | `openfast_pinned_rod` on the aggregate: a dry rod (10 m, 500 kg) released at 30° swings with the elliptic-integral compound-pendulum period to 1.6e-4 at `dt = T/100`, End A on the pin to 0 m; a held `CoupledPinned` node reproduces the `Pinned` rod to round-off (1e-12), returns zero moment, and its force equals the analytic pin reaction to 2.0e-13 of `mg`; a pin accelerating at 2 m/s² gives the mean angle `atan(a/g)` to 1e-6 rad and the period of `sqrt(g² + a²)` to 1.6e-4; a harmonic pin motion follows the linear base-excitation solution to 1.5e-3 / 3.7e-4 of the amplitude at `T0/100` / `T0/200` (ratio 4.03); a 0.1 s step sub-cycled 7 times reproduces a run at the sub-step size to 1e-14 rad and 4e-10 N for a drifting pin; a 1 m `Pinned` rod that carries no line (dry and hanging, or buoyant and upright under water) at a 0.6 s step (`omega0 dt` 2.29 / 3.42, beyond the explicit limit 2) sub-cycles it 6 / 9 times from its own swing stiffness `|W d_g - B d_b|`, equals the run at the sub-step size bit for bit, stays within its release angle and keeps the elliptic-integral period to 6.0e-3 / 5.9e-3 (taken whole, the step turns the rod over); a `CoupledPinned` pin crossing the free surface within one step at constant velocity (a 1 kg/m rod lifted from submerged to dry in 0.1 s, `omega dt` 2.13 wet; a 33 kg/m rod lowered from dry to submerged in 0.6 s, 2.29 dry) takes at least 6 sub-steps from its step-start wetting (more from the waterplane near the surface) and ends within 5e-5 / 3e-4 rad of a run at a sixtieth of the step, where the end-of-step wetting alone gives one sub-step and an angle error of 0.20 / 0.69 rad; on a stiff seabed (`kBot` 1e7 N/m³) a `Pinned` rod whose far end rests on the bed (0.1 s step) and a `Free` rod lying on it (0.05 s step) sub-cycle their contact mode (34–36 and 26 sub-steps), stay at rest on the bed over 5 s (angle change 3.8e-3 / 4e-15 rad, the undamped static settlement) and end within 1.9e-6 / 8e-8 of a run at a tenth of the step, where the sub-steps of the lines and swing alone (1 and 4) throw them off the bed (4.2 rad, 0.8 m); an output probe returns `-m (I_c/I_p) a_p` within 1e-10 of `mg` (not `-m a_p`), and its pin force moves by 2e-11 N when the held end acceleration of the attached tethers changes their end load by 8 N; snapshot/restore, probe restore and restart overlay are bit-identical, the restored state's loads before the next step included; a step without the staged rods (the step-start pin carried by the rod) is bit-identical to the staged one; a `Free` or `Coupled` rod with an end without a line is refused by name; with `PtfmInit` the static start leaves 1.4e-8 N·m about the pin. OpenFAST (IEA-15 UMaine, JONSWAP Hs 6 m, 60 s, `dtM = DT = 0.025 s`) with line 1 hung from a 4 m `CoupledPinned` rod at its fairlead: `openfast -restart` at 30 s reproduces every later OpenFAST output row bit for bit (`NumCrctn` 0 and 1), `NumCrctn = 1` equals `NumCrctn = 0` bit for bit, and surge/heave/pitch statistics stay within 0.2 % / 0.4 % / 1.7 % (mean) of the deck with line 1 on a `Coupled` point | | Coupled finite-EI touchdown/contact | Pass verified | flat `WtrDpth` and equivalent constant structured bathymetry initialise and step with matching loads; friction and checkpoint restore are tested. The IEA-15 mixed example (its power cable on 248 elements, each at most half the bending length) has 149 grounded nodes and completes a 20 s aggregate trajectory at `dtM=0.025 s` with 2 m surge, 1 m heave, and 0.5 m/s host current, without fallback or stall recovery, at most 12 Newton iterations. A full-turbine run of the same model (one hour after a 200 s transient; TurbSim normal turbulence, 10.6 m/s, 17 % TI; JONSWAP Hs 8 m, Tp 12 s, aligned with the wind and the cable; AeroDyn with the rotor held at 7.55 rpm, no controller, rigid blades and tower; SeaState grid covering the lines) completes without recoveries or non-finite values. The cable's hang-off tension is 11.5 ± 1.1 kN (static 11.9 kN, maximum 17.9 kN). The 149 nodes grounded at the static state stay grounded, joined by one more once the platform has drifted (the touchdown moves 2.5 m toward the platform). The peak curvature is 0.156 1/m at the sag bend, 72 m from the hang-off, and 0.109 1/m at the touchdown. On the former 87-element mesh (10 m elements along the laid section) the peak was 0.160 1/m and the touchdown curvature 0.075 1/m, under-resolved by about 30 %. These curvatures were recorded before the `Curv` channels took the curvature recovered from nodal equilibrium: they are the geometric curvature of the centreline (the larger one-sided trace at a node), which `OutputRecovery element` reproduces. The chain-only twin of the run matches stock MoorDyn over 1200 s to 0.3 % in platform motion and fairlead tension statistics. The anchor tension of the laid cable stays at its static 1.23 kN (maximum 1.24 kN): the seabed friction of the 370 m laid section holds the tension changes at the touchdown. On the former mesh it read 1.39 kN (median) with wave-frequency stick-slip peaks up to 4.1 kN lasting under 1 s, which the resolved mesh does not show, and before the anchor-end correction of this release it locked at about 2.75 kN for the whole run. The run takes 27.1 min of wall time (18.8 min on the former mesh) | | `WaterKin` from file | Pass verified | See [WaterKin and SeaState modes](#waterkin-and-seastate-modes) | | Syrope polyester (`SYROPE:` syntax; [Falkenberg et al., 2017](https://cabledyn.readthedocs.io/en/latest/references.html#ref-falkenberg2017)) | Pass verified | MoorDyn-F/C `BA_s|BA_d` rate and force equations; analytic position/velocity tangents with finite-difference checks; projected, bracketed backward-Euler slow-state update with a strong-unloading boundary test; OWC running maximum; `SYROPE IC` `Tmax0/Tmean0` history with range/order checks; both states carried through every lifecycle stage and the coupled checkpoint. `BA_s` is kept separate from line axial damping (`BA`) and tested against double counting. Composite, hydrodynamic, finite-EI, current, and wave combinations stop with a named error | diff --git a/doc/capabilities.rst b/doc/capabilities.rst index 398383c7..df3a5864 100644 --- a/doc/capabilities.rst +++ b/doc/capabilities.rst @@ -179,8 +179,11 @@ and ``RODS`` are MoorDyn-compatible deck records that the driver translates; the alternative discretisation of the line. Supported translations include fixed/coupled/vessel attachments, free or connecting masses and clumps, ``Point3`` buoys, ``Rigid6`` bodies, and coupled rigid rods. In OpenFAST, ``Coupled``/``Vessel`` bodies and rods are platform-borne 6-DOF nodes that -return a force and a moment; the C API and Python run free bodies and rods in still water. The -coupled body/rod routes carry checkpoint state and SeaState drag, Froude–Krylov, and added mass. +return a force and a moment, ``CoupledPinned``/``VesselPinned`` rods turn about a platform-borne +node that takes the platform position only and returns a force with zero moment, and ``Pinned`` +rods turn about a fixed End A; ``CoupledPinned`` bodies are not supported. The C API and Python +run free, fixed and pinned rods and free bodies in still water. The coupled body/rod routes carry +checkpoint state and SeaState drag, Froude–Krylov, and added mass. ``Rigid6`` also carries the documented hydrostatic restoring terms. Consult :doc:`driver_format` before using an imported object because unsupported fields fail closed. diff --git a/doc/capi.rst b/doc/capi.rst index aad269a4..8cd3272a 100644 --- a/doc/capi.rst +++ b/doc/capi.rst @@ -862,9 +862,9 @@ Newton settings are taken from the deck. The deck's ``OUTPUTS`` section is parse but the C ABI writes no output files. **Finite-EI lines, bodies and rods.** A deck with finite-EI (``EI > 0``) lines or with a -``BODIES`` or ``RODS`` table (``Point3`` buoys, free ``Rigid6`` bodies, free, fixed or pinned -rods, with their lines) runs on the same coupled aggregate as the OpenFAST module, with these -differences from the point-system decks: +``BODIES`` or ``RODS`` table (``Point3`` buoys, free ``Rigid6`` bodies, or free, fixed and +``Pinned`` rods, with their lines; a ``Pinned`` rod turns about its fixed End A) runs on the same +coupled aggregate as the OpenFAST module, with these differences from the point-system decks: * the coupled DOFs are the ``x, y, z`` of the deck's ``Coupled``/``Vessel`` points only, in the order of `Coupled DOF layout`_ (anchors are not part of the vector); the bodies and @@ -893,6 +893,8 @@ The deck is validated under the standalone-deck rules: - Where it is supported * - ``Coupled``/``Vessel`` bodies or rods (6-DOF host nodes) - the OpenFAST module; the standalone driver with a ``motionFile`` + * - ``CoupledPinned``/``VesselPinned`` rods (a pin the host moves) + - the OpenFAST module * - a ``motionFile`` option - the standalone driver (prescribe motion through ``CableDyn_Step`` instead) * - a ``FAILURE`` section (line failures) diff --git a/doc/coupling.rst b/doc/coupling.rst index 585a92d7..12c84ab4 100644 --- a/doc/coupling.rst +++ b/doc/coupling.rst @@ -32,7 +32,8 @@ checkpoint-restart, quasi-static linearisation (``dYdu``), FAST.Farm farm-level ``C33``/``C44``/``C55`` hydrostatic restoring, restart state, and SeaState drag / Froude-Krylov / added-mass), coupled ``Point3`` buoys (buoyancy and SeaState drag / Froude-Krylov / added-mass), and coupled rigid rods with host-driven endpoints, correction rewind, checkpoint state, and two-point -Gauss SeaState sampling. +Gauss SeaState sampling, including MoorDyn-F's coupled pinned rods (``CoupledPinned``, force only) +and rods pinned to a fixed point. The input/output Jacobian has two deliberately different contracts. During an ordinary nonlinear OpenFAST run, CableDyn returns the partial direct-feedthrough derivative at fixed committed internal diff --git a/doc/driver_format.md b/doc/driver_format.md index 105bf385..e934d6cb 100644 --- a/doc/driver_format.md +++ b/doc/driver_format.md @@ -392,8 +392,23 @@ row. On this route: like those of `Coupled` points, are given at the undisplaced platform and moved by `PtfmInit`), and returns to the platform the force and moment about End A of its attached lines, weight, buoyancy, Morison loads, seabed contact and its own and added-mass inertia - (MoorDyn-F's coupled rod). `CoupledPinned` and `VesselPinned` rods are rejected by name, and on the OpenFAST route - `Pinned` rods fail closed as well (the coupled rod march does not turn a rod about its pin); + (MoorDyn-F's coupled rod); +- `CoupledPinned`/`VesselPinned` rods are pinned to the platform: each is a node of the OpenFAST + mesh at its End A (moved by `PtfmInit` with the rod, like a `Coupled` rod) that takes the + platform position only. The rod turns about the node with its own three rotations, the node + orientation and angular rates are ignored, and the node returns a force and no moment: the + rod's lines, weight, buoyancy, Morison loads and seabed contact less its own and added-mass + inertia (MoorDyn-F's coupled pinned rod). The angular acceleration in that inertia is solved + for the node's current acceleration, so the rotation feels the platform acceleration and a + CalcOutput at an off-step acceleration returns the rod's effective inertia about the pin. + `Pinned` rods turn about their fixed End A. With `bodyIC static` both start balanced about + their pins; a pinned rod that carries no line is not part of the static solve and starts at + rest in its deck orientation, turned by `PtfmInit` for a `CoupledPinned` rod (a dry pendulum + given at an angle starts at that angle). An end + of a `Pinned` or `CoupledPinned` rod that carries no line needs no `RodA`/`RodB` POINT + row on this route; every other rod needs a line or a POINT row at both ends. Outside a + coupled host a `CoupledPinned` rod is rejected by name ("requires a coupled host"), + zero-length ones included; - `Coupled`/`Vessel` bodies are platform-borne the same way: a mesh node at the body reference point, the body frame turning with the platform, returning the force and moment about the reference point of its `Body` lines, weight, buoyancy and restoring, Morison and @@ -579,10 +594,10 @@ rod lying on the bed along its whole length. |--------|---------| | `ID` | unique rod id ≥ 1 | | `RodType` | a `ROD TYPES` key | -| `Type` | `Free`, `Fixed`, `Pinned`, `Coupled`, `Vessel`, `Body`, or `BodyPinned` (MoorDyn aliases `Anchor`/`Fix`, `Pin`, `Point`/`Con`, `Ves`, `Cpld`, `BodyPin`). `Coupled`/`Vessel` rods are prescribed by `motionFile` rows for both `RodA` and `RodB`, which must preserve the rod length; in OpenFAST (`CompMooring = 5`) they follow the platform instead (see the OpenFAST route below). `Free` rods are integrated dynamically and may coexist with prescribed rods. A `Pinned` rod turns about its End A, which stays fixed; it may carry lines. A `Body` rod is fixed to Rigid6 body N: its end coordinates are in the body frame from the body reference point, and its mass, inertia, hydrostatic, Morison, and seabed loads and added mass are lumped into the body about that point. A `BodyPinned` rod has its end coordinates in the body frame too, but only its End A is held, on the body: the rod has its own three rotations, its loads reach the body as the pin force (no moment), and it may carry lines. | +| `Type` | `Free`, `Fixed`, `Pinned`, `Coupled`, `Vessel`, `CoupledPinned`, `VesselPinned`, `Body`, or `BodyPinned` (MoorDyn aliases `Anchor`/`Fix`, `Pin`, `Point`/`Con`, `Ves`, `Cpld`, `CpldPin`, `VesPin`, `BodyPin`). `Coupled`/`Vessel` rods are prescribed by `motionFile` rows for both `RodA` and `RodB`, which must preserve the rod length; in OpenFAST (`CompMooring = 5`) they follow the platform instead (see the OpenFAST route above). `CoupledPinned`/`VesselPinned` rods run only in OpenFAST, pinned at End A to a node that follows the platform position. `Free` rods are integrated dynamically and may coexist with prescribed rods. A `Pinned` rod turns about its End A, which stays fixed; it may carry lines. A `Body` rod is fixed to Rigid6 body N: its end coordinates are in the body frame from the body reference point, and its mass, inertia, hydrostatic, Morison, and seabed loads and added mass are lumped into the body about that point. A `BodyPinned` rod has its end coordinates in the body frame too, but only its End A is held, on the body: the rod has its own three rotations, its loads reach the body as the pin force (no moment), and it may carry lines. | | `XA,YA,ZA` | rod End A coordinates [m] | | `XB,YB,ZB` | rod End B coordinates [m]; distinct from End A (ignored for a zero-length rod) | -| `NumSegs` | ≥ 1; hydrodynamic segments of the rod (loads integrated per segment); seabed contact uses max(20, `NumSegs`) segments. `0` declares a zero-length rod (MoorDyn): a point-like connector at End A with no mass, volume or side loads and, having no axis, no end loads either. It becomes one point that both of its ends resolve to: `Free` for a free rod, `Fixed` for a fixed or pinned rod, `Coupled` for a coupled rod, `Body` for a rod on body N. A free zero-length rod therefore moves with the end-node mass of its lines, as a `Mass = 0` `Free` point, and `Rod` output channels of it are rejected by name (use `Point

` channels) | +| `NumSegs` | ≥ 1; hydrodynamic segments of the rod (loads integrated per segment); seabed contact uses max(20, `NumSegs`) segments. `0` declares a zero-length rod (MoorDyn): a point-like connector at End A with no mass, volume or side loads and, having no axis, no end loads either. It becomes one point that both of its ends resolve to: `Free` for a free rod, `Fixed` for a fixed or pinned rod, `Coupled` for a coupled rod or, in OpenFAST, a `CoupledPinned` rod, `Body` for a rod on body N. A free zero-length rod therefore moves with the end-node mass of its lines, as a `Mass = 0` `Free` point, and `Rod` output channels of it are rejected by name (use `Point

` channels) | | `Outputs` | `-` or `p`; `p` writes the end positions as a time series to `.Rod.p.out`, End A first | ### POINTS diff --git a/doc/migrating.rst b/doc/migrating.rst index e987db21..e4723966 100644 --- a/doc/migrating.rst +++ b/doc/migrating.rst @@ -104,7 +104,10 @@ Keyword map - supported subset: ``Point3``/``Rigid6`` bodies and rigid rods, lines attached through ``Body`` points and at rod ends (``RA``/``RB`` in ``LINES``, or ``RodA``/``RodB`` points) (:doc:`tutorial_bodies`); ``ROD TYPES`` - ``Cd Ca CdEnd CaEnd`` as in MoorDyn, with optional axial side ``CdAx CaAx`` columns + ``Cd Ca CdEnd CaEnd`` as in MoorDyn, with optional axial side ``CdAx CaAx`` columns. + ``CoupledPinned``/``VesselPinned`` rods run in OpenFAST as in MoorDyn-F (End A follows + the platform position, the rod turns about it, a force is returned without moment); + ``CoupledPinned`` bodies are rejected * - ``dtM``, ``TMax`` (standalone), ``WtrDpth``, ``rhoW``/``WtrDnsty``, ``g`` - same * - ``kBot``, ``cBot``, seabed friction coefficient diff --git a/doc/openfast.rst b/doc/openfast.rst index c8cfbe3b..92f0c401 100644 --- a/doc/openfast.rst +++ b/doc/openfast.rst @@ -272,13 +272,23 @@ without an auxiliary process: lines reject it. * **Rigid6 bodies, Point3 bodies, and rigid rods** are translated at the deck boundary; their supported loads and restrictions in coupled runs are listed in :doc:`capabilities`. Free - Rigid6 bodies and rods start at their static equilibrium with the platform at ``PtfmInit`` - (``bodyIC static``, the default), as in standalone runs. ``Coupled``/``Vessel`` rods are - platform-borne: each is a node of the coupling mesh at its End A that follows the platform - position and orientation and returns a force and a moment (MoorDyn-F's coupled rod, including - the rod's own and added-mass inertia). ``Coupled``/``Vessel`` bodies are platform-borne the - same way, with the node at the body reference point, and may share a deck with ``Free`` - bodies. ``CoupledPinned`` rods and bodies, and ``Pinned`` rods, are not supported on this route. + Rigid6 bodies, free rods and pinned rods start at their static equilibrium with the platform + at ``PtfmInit`` (``bodyIC static``, the default), as in standalone runs; one that carries no + line is not part of that solve and starts at rest in its deck pose. ``Coupled``/``Vessel`` + rods are platform-borne: each is a node of the coupling mesh at its End A that follows the + platform position and orientation and returns a force and a moment (MoorDyn-F's coupled rod, + including the rod's own and added-mass inertia). ``CoupledPinned``/``VesselPinned`` rods are + pinned to the platform: the node at End A follows the platform position only, the rod turns + about it with its own rotation (the node orientation and angular rates are ignored), and the + node returns a force with zero moment (MoorDyn-F's coupled pinned rod). That force is the + rod's net load less its inertia, with the angular acceleration solved for the node's current + acceleration; a CalcOutput at an off-step acceleration therefore returns the rod's effective + inertia about the pin rather than its full mass (the rotation, the angular velocity and the + held fluid stay those of the committed step). ``PtfmInit`` moves and turns such a rod with + the platform before the static solve balances it about its pin. ``Pinned`` rods turn about a + fixed End A. ``Coupled``/``Vessel`` bodies are platform-borne the same way as ``Coupled`` rods, + with the node at the body reference point, and may share a deck with ``Free`` bodies. + ``CoupledPinned`` bodies are not supported on this route. Each is a separate qualification: a successful ordinary run does not qualify restart, linearisation, control, failure, or farm behaviour for a new model. diff --git a/doc/options.rst b/doc/options.rst index 27253d99..ca95a4af 100644 --- a/doc/options.rst +++ b/doc/options.rst @@ -234,8 +234,9 @@ Clock and initial condition ``Free``/``Connect`` points step in one implicit generalised-alpha step with their ``EI = 0`` lines (a Newton iteration on the object accelerations around the line steps); no sub-stepping is needed for stability. A deck without lines keeps its explicit - central-difference march unless it names ``monolithic bodyScheme``. ``staggered``: the - staggered predictor-corrector, sub-stepped for the stiffest body-mooring mode. Decks with + central-difference march, sub-stepped for the objects' own restoring, unless it names + ``monolithic bodyScheme``. ``staggered``: the staggered predictor-corrector, sub-stepped + for the stiffest body-mooring mode and the objects' own restoring. Decks with a ``motionFile`` or a ``FAILURE`` section, and coupled runs, use ``staggered`` whatever the value. See :doc:`theory` - standalone @@ -701,10 +702,10 @@ These names exist so a migrated MoorDyn deck fails less often at the syntax boun ``frictionMu``, ``frictionMuLateral`` and ``frictionMuAxial``, with no static-to-kinetic ratio or friction damping. Remove the row. -Other MoorDyn constructs that fail by name rather than as unknown input: ``CoupledPinned`` and -``VesselPinned`` rods, and ``CoupledPinned`` bodies. Line-node output channels start at node 1 -(``N0`` is rejected), and a number with a sign inside its mantissa (such as ``1+2``) is rejected -instead of being read up to the sign. +Other MoorDyn constructs that fail by name rather than as unknown input: ``CoupledPinned`` bodies, +and ``CoupledPinned``/``VesselPinned`` rods outside a coupled host (they run in OpenFAST, see +:doc:`openfast`). Line-node output channels start at node 1 (``N0`` is rejected), and a number +with a sign inside its mantissa (such as ``1+2``) is rejected instead of being read up to the sign. Water-kinematics sources ------------------------ diff --git a/doc/outputs.rst b/doc/outputs.rst index 9f06152e..e5a02415 100644 --- a/doc/outputs.rst +++ b/doc/outputs.rst @@ -730,8 +730,9 @@ Body and rod channels ~~~~~~~~~~~~~~~~~~~~~ The MoorDyn-F names, for Rigid6 bodies and for rods (free, fixed, pinned, prescribed, fixed or -pinned to a body), on every route that carries them, the OpenFAST ``CompMooring = 5`` route -included. Loads are evaluated at the committed state of the output time. +pinned to a body, and in OpenFAST pinned to the platform), on every route that carries them, the +OpenFAST ``CompMooring = 5`` route included. Loads are evaluated at the committed state of the +output time. .. list-table:: :header-rows: 1 diff --git a/doc/theory.rst b/doc/theory.rst index 20a6de90..2a61acce 100644 --- a/doc/theory.rst +++ b/doc/theory.rst @@ -1781,9 +1781,9 @@ Deck ``POINTS``, ``BODIES``, and ``RODS`` records follow the MoorDyn object mode and :math:`\mathbf{G}_{c,k}^T(\mathbf{M}_k\mathbf{X}_k - \mathbf{F}_k) = \mathbf{0}` for each pinned rod :math:`k`: the pin passes the rod's force to the body and no moment, and the rod's rotation feels the pin acceleration. (MoorDyn adds every body-attached rod, pinned or not, to the body's - equations with its full force, moment and mass, and its pinned-rod rotation does not include - the pin acceleration, so the two formulations can differ for a pinned rod on an accelerating - body.) + equations with its full force, moment and mass; its pinned-rod rotation includes the pin + acceleration, taken from the body acceleration the rod's kinematics were last set with, so the + two formulations can differ by that lag for a pinned rod on an accelerating body.) - A **zero-length rod** (``NumSegs`` 0) is a point-like connector: it has no mass, volume or side loads, and its end terms act along an axis it does not have, so it reduces to a massless point at End A (``Free``, ``Fixed``, ``Coupled`` or on a body). @@ -1793,7 +1793,10 @@ static equilibrium, solved jointly with the ``Free``/``Connect`` points. The unk body's position and a rotation-vector increment on SO(3) (for a free rod only the two rotations normal to its axis), each pinned rod's two rotations about its pin, and each point's position. A pinned rod's residual rows are its moment about the pin; its net force acts on its parent body -at the pin (a rod pinned to a fixed point has none). A deck with pinned rods takes the +at the pin (a rod pinned to a fixed point has none, and a ``CoupledPinned`` rod in OpenFAST is +balanced about its pin at the platform's initial pose). A free or pinned rod that no line +attaches to (nor, for a rod pinned to a body, any line of its body) is not an unknown: it keeps +its deck pose and starts at rest there. A deck with pinned rods takes the central-difference Jacobian of the full residual. A finite-EI line enters with its axial stiffness and weight only. The residual is the net force and moment of the loads the dynamic step applies at rest: weight, buoyancy and hydrostatic restoring, steady-current drag, @@ -1919,14 +1922,115 @@ update is explicit. Each coupled step is therefore divided into equal sub-steps body-mooring frequency. Each attached line acts as the directional spring :math:`k_a\mathbf{t}\mathbf{t}^T + (T/L)(\mathbf{I} - \mathbf{t}\mathbf{t}^T)` (:math:`\mathbf{t}` the chord direction, :math:`L` the chord length, :math:`k_a = 1/\sum l_0/EA`, :math:`T` the end -tension), carried to the reference point and added to the hydrostatic restoring; the inertia is -the structural plus added mass. The estimate omits the line-end inertia and the coupling between +tension), carried to the reference point and added to the hydrostatic restoring and to the +seabed contact; the inertia is the structural plus added mass. The contact springs are the +penalty springs of the seabed model (:math:`k_\text{Bot}\,d\,\mathrm{d}l` at each contact station +of a rod, :math:`k_\text{Bot}` over 1 m² at a body's reference point) that can act within the +coming step. A station at arm :math:`\mathbf{s}` from the rod centre moves with +:math:`\mathbf{v} + \boldsymbol{\omega}\times\mathbf{s}`, and its acceleration is bounded by +:math:`a_s = |\mathbf{a}| + |\boldsymbol{\alpha}\times\mathbf{s}| + |\boldsymbol{\omega}|^2|\mathbf{s}| + g` +(:math:`\mathbf{a}`, :math:`\boldsymbol{\alpha}` the committed accelerations, the free fall added +so that a first step without them counts); its reach +:math:`\rho = \Delta t\,|\mathbf{v} + \boldsymbol{\omega}\times\mathbf{s}| + \tfrac{1}{2}\Delta t^2 a_s` +bounds its travel in every direction, vertical and horizontal. The station counts when its height +above the highest floor within the horizontal distance :math:`\rho` (the depth on a flat seabed; +on a bathymetry grid the highest node of the cells the surrounding box overlaps, raised by +:math:`0.05` of their range for the crease rounding) is at most :math:`\rho` plus the rod radius. +An object about to land, sliding towards a shallower bed or turning a station onto it is thus +resolved as well as one at rest on the bed. A spring :math:`k` at arm :math:`\mathbf{a}` +adds :math:`k` in heave and :math:`k a_y^2`, :math:`k a_x^2` in roll and pitch. A rod near the +free surface adds its waterplane stiffness in the same way: :math:`\rho_w g\,d\,\mathrm{d}l` at each +station whose cross-section can cross the (held or wave) surface within the step, and +:math:`\rho_w g\,\pi d^2/4` between each pair of stations whose axis can cross it, which together +bound the elliptical waterplane of any crossing; its inertia is then the structural one, since +the added mass changes as it crosses. A finite-EI cable on a body or rod of the staggered march, +whose end force the march returns explicitly, adds the directional spring above with +:math:`k_a = 1/\sum l_0/EA` and its current end tension. The normal seabed damping and the +regularised friction (a damper :math:`\mu N/\sqrt{v^2 + v_\text{reg}^2}`, :math:`\mu N/v_\text{reg}` +at rest) are applied implicitly, the friction as that secant coefficient, so they set no limit; +the monolithic scheme carries the contact and the hydrostatics in its Jacobian, and its accuracy +sub-steps (above) leave them out. A step that would need more than 256 sub-steps is warned about +once per run. The estimate omits the line-end inertia and the coupling between the diagonal terms, so it can understate the coupled frequency by about a factor 1.6; stability alone (the central-difference bound :math:`\omega\,\Delta t < 2`) would allow a limit near 1. The limit of 0.4 is set by accuracy: a rod released out of balance at :math:`\Delta t = 0.1` s follows the fairlead-tension transient of a :math:`\Delta t = 0.005` s run within 1.5 %. +The objects' own terms (hydrostatic restoring, a rod's waterplane, seabed contact, and the +swing of a pinned rod below, about its pin on every route, with its parent body's pin +acceleration and the reduced mass :math:`m m_b/(m + m_b)` for a rod pinned to a body) enter +whether or not a line is attached: a deck without lines, which marches its +objects by the same explicit scheme, and a staggered deck whose only lines are finite-EI cables +are sub-stepped for them as well. Both schemes start from the instantaneous acceleration of the initial state. +On the coupled route a ``Pinned`` or ``CoupledPinned`` rod advances only its rotation in this +way; its centre then follows the pin at :math:`t_{n+1}` (fixed, or placed by the host), so End A +drives its lines with the pin motion exactly. The end-of-step angular acceleration solves the +reduced pinned-rod equation with +:math:`\mathbf{a} = \mathbf{a}_p + \boldsymbol{\alpha}\times\mathbf{r} + \boldsymbol{\omega}\times(\boldsymbol{\omega}\times\mathbf{r})`, +so the pin acceleration :math:`\mathbf{a}_p` loads the rotation through the rod's inertia, and +the implicit drag acts on the velocity change +:math:`\tfrac{1}{2}\Delta t(\boldsymbol{\alpha}_{n+1} - \boldsymbol{\alpha}_n)\times\mathbf{r}` of the +pinned centre. The sub-step estimate takes the line springs through their arms from the pin +against the rotational inertia about the pin, and adds the rod's own swing about the pin, so a +pinned rod that carries no line is still sub-stepped as the compound pendulum it is. Its weight +and buoyancy act vertically at points :math:`\mathbf{p}_i` from the pin; the first moment +:math:`\mathbf{P} = \sum_i f_i\,\mathbf{p}_i` of these loads turns with the rod, and its length +:math:`|\mathbf{P}| = |W d_g - B d_b|` (weight :math:`W` and buoyancy :math:`B` on the axis at +:math:`d_g` and :math:`d_b` from the pin) is the swing stiffness at the bottom of the swing, +whatever the current pose. The pin acceleration adds :math:`|\mathbf{a}_p|\,|\mathbf{G}|`, with +:math:`|\mathbf{G}|` the first moment of the rod's translational inertia (structural and added) +about the pin, :math:`m d_g` for a dry rod; for the hanging dry rod this is the effective gravity +bound :math:`g + |\mathbf{a}_p| \ge |\mathbf{g} - \mathbf{a}_p|`, taken with the larger of the +step-start and end-of-step pin accelerations. The swing stiffness over the smaller rotational +inertia about the pin across the rod axis, about :math:`3g/(2L)` for a dry uniform rod of length +:math:`L`, adds to the line estimate of :math:`\omega^2`. The buoyancy is that of the wet +length at the evaluated pose; the change of a surface-piercing rod's waterline with its tilt +(an articulated column) enters through the rod's waterplane stiffness about the pin (above). +The host places a ``CoupledPinned`` pin at :math:`t_{n+1}` before the estimate, so +the swing is evaluated with the rod at both its step-start and its end-of-step pin, taking the +larger stiffness and the smaller inertia. The sub-steps move the pin along a straight line; at +the rod's orientation and with the surface held over the step, every slice's clearance to the +surface then changes monotonically and in the same sense, so the wetting, the moment +:math:`W d_g - B d_b` and the added mass are bounded by their values at the two ends, and a step +whose pin crosses the free surface (a light rod lifted out of the water, or a heavy one lowered +into it) is sub-stepped for the stiffer of its wet states. The seabed contact adds its angular +stiffness about the pin, :math:`\sum k\,|\mathbf{a}\times\mathbf{e}_z|^2` over the contact +stations within reach (at both pin poses for a ``CoupledPinned`` rod), so a rod whose far end +rests on the bed is sub-stepped for its contact mode. In a sub-cycled step the host pin's +position, +velocity and acceleration are each interpolated linearly between their step-start values (the End +A motion of the committed rod) and the end-of-step host input, as the host fairleads of the lines +and the ``Coupled`` rods are, so points on one platform keep their relative positions under a +translation within the step. This is second order: between exact end values the interpolated +position departs from the host path by at most :math:`\Delta t^2 \max|\mathbf{a}_p|/8`, the +interpolated velocity is not the derivative of the interpolated position (they differ by +:math:`O(\Delta t\,|\mathbf{a}_p|)`), and a pin moving at constant velocity is reproduced exactly. +A first step without a committed angular acceleration (the aggregate and the C API) takes its +starting one with the pin at its step-start pose; under OpenFAST the rod state mirror reloaded +at the initial output call carries the committed accelerations of the initial condition, zero +for the static start, so a start out of equilibrium (``bodyIC deck``) begins its first step +from rest acceleration, an error of order :math:`\Delta t` in that step's velocity, as for a +free rod. + +The host receives the rod's net load less its inertia at the pin, and no moment. It is the +direct feedthrough of the pin acceleration at the rod's current state: the pin position, +velocity and acceleration are those the host last set (re-derived from the rod's End A motion, +so that a checkpoint restart reproduces the force between steps bit for bit), the rotation, the +angular velocity and the held fluid are the committed ones, and the angular acceleration is +solved again for the pin's current acceleration. A CalcOutput at an off-step pin acceleration +therefore returns the rod's effective inertia about the pin. The attached lines keep their +committed interior state, accelerations included, as in every output evaluation, and their end +loads are taken at the end accelerations of the re-solved rotation: the solve moves the end-node +inertia from the end accelerations the system holds with the lines' coupled mass block +:math:`\mathbf{M}_{cc}` (structural and added mass; the step's corrector instead lets the line +interior follow, :math:`\mathbf{M}_{cc} - \mathbf{M}_{cf}\mathbf{M}_{ff}^{-1}\mathbf{M}_{fc}`). At a +held interior the end loads are linear in the end accelerations, so the force does not depend on +the end accelerations the line loads were evaluated with. MoorDyn-F's coupled pinned rod keeps +the same pin acceleration term in its rotation equation and returns the same force: its output +call evaluates the rod's state derivative at the current input first (its lumped line mass has +no interior coupling). + **Mixed topologies.** One step marches every object of a deck together: bodies with their fixed and pinned rods, free and pinned rods, the ``EI = 0`` lines with their ``Free``/``Connect`` points, and the finite-EI cables. In the monolithic scheme the points are junctions of the diff --git a/python/cabledyn/deck_file.py b/python/cabledyn/deck_file.py index f7163bf1..ff1eeb09 100644 --- a/python/cabledyn/deck_file.py +++ b/python/cabledyn/deck_file.py @@ -325,6 +325,9 @@ "con": "free", "ves": "vessel", "cpld": "coupled", + "cpldpin": "coupledpinned", + "vesselpinned": "coupledpinned", + "vespin": "coupledpinned", } _RIGID_END_CONNECTIONS = frozenset({"rigid", "infinity", "inf"}) # TorsStiffness keywords of an end free to twist (a numeric 0 is free too) @@ -1866,7 +1869,8 @@ def _resolve_rod_ends( end points of a rod fixed to a body (RODS type ``Body``) into ``Body`` points. Native ``collapse_zero_length_rods`` first merges both ends of a zero-length rod (NumSegs 0) into one connector point typed after the rod: - Free, Fixed (fixed or pinned rod), Coupled, or ``Body``. ``point_types``, + Free, Fixed (fixed or pinned rod), Coupled (coupled or CoupledPinned rod), or + ``Body``. ``point_types``, ``point_ids`` and ``point_z`` are updated in place. """ merged: dict[str, str] = {} @@ -1904,7 +1908,9 @@ def _resolve_rod_ends( resolved = kind elif kind == "pinned": resolved = "fixed" - elif kind == "vessel": + elif kind in {"vessel", "coupledpinned"}: + # a zero-length CoupledPinned rod is a Coupled point on the coupled + # route (and refused elsewhere, see the RODS checks) resolved = "coupled" elif body is not None: resolved = f"body{_native_id_suffix(body.group(1))}" @@ -3230,10 +3236,13 @@ def end_key(token: str) -> str: f"{self._at(row)}: rod references missing rod type {row.tokens[1]}" ) rod_kind = _ROD_ATTACHMENT_ALIASES.get(row.tokens[2].lower(), row.tokens[2].lower()) - if rod_kind in {"coupledpinned", "cpldpin", "vesselpinned", "vespin"}: + # native finalize_checks: the host moves the pin of a CoupledPinned rod, so only the + # coupled route (a caller-driven deck) takes one, zero-length ones included + if rod_kind == "coupledpinned" and not self.caller_driven: raise DeckFormatError( - f"{self._at(row)}: CoupledPinned/VesselPinned RODS are not supported (use " - "Coupled, Vessel, Pinned or BodyPinned)" + f"{self._at(row)}: CoupledPinned/VesselPinned ROD requires a coupled host " + "(OpenFAST CompMooring = 5); in a standalone deck use Pinned, BodyPinned, " + "or a Coupled rod with a motionFile" ) # Body (fixed to the body) or BodyPinned / BodyPin (End A pinned to it) body_kind = re.fullmatch(r"body([0-9]+)(?:pin|pinned)?", rod_kind) @@ -3242,10 +3251,10 @@ def end_key(token: str) -> str: raise DeckFormatError( f"{self._at(row)}: ROD attachment must name a Rigid6 (Free) BODY" ) - elif rod_kind not in {"free", "fixed", "coupled", "vessel", "pinned"}: + elif rod_kind not in {"free", "fixed", "coupled", "vessel", "pinned", "coupledpinned"}: raise DeckFormatError( f"{self._at(row)}: ROD type must be Free, Fixed, Pinned, Coupled, Vessel, " - "Body, or BodyPinned" + "CoupledPinned, VesselPinned, Body, or BodyPinned" ) if ( not zero_length diff --git a/python/tests/test_deck_native_parity.py b/python/tests/test_deck_native_parity.py index 70afcd07..bc1f2d4c 100644 --- a/python/tests/test_deck_native_parity.py +++ b/python/tests/test_deck_native_parity.py @@ -298,6 +298,31 @@ def test_rod_channel_quantities_follow_the_native_vocabulary(): # --------------------------------------------------------------------------- rods +@pytest.mark.parametrize("kind", ["CoupledPinned", "CpldPin", "VesselPinned", "VesPin"]) +def test_coupled_pinned_rods_need_a_coupled_host(kind): + # native finalize_checks: the host moves the pin, so the standalone driver refuses the rod + # (zero-length ones too) and the coupled route takes it + pinned = _spar((_SPAR_ROD, _SPAR_ROD.replace("Free", kind))) + _rejects(pinned, "requires a coupled host") + zero_length = _spar( + (_SPAR_ROD, _SPAR_ROD.replace("Free", kind).replace("-20.0 1", "-20.0 0")) + ) + _rejects(zero_length, "requires a coupled host") + still = ("uniform 0.5 0.0 0.0 current", "none current") + DeckFile.from_text( + _spar((_SPAR_ROD, _SPAR_ROD.replace("Free", kind)), still), caller_driven=True + ) + # a zero-length one is a Coupled point at End A that its End B point merges into + DeckFile.from_text( + _spar( + (_SPAR_ROD, _SPAR_ROD.replace("Free", kind).replace("-20.0 1", "-20.0 0")), + still, + ('"Point2px"\n"Point2pz"', '"Point3px"\n"Point3pz"'), + ), + caller_driven=True, + ) + + def test_rod_endpoints_have_an_admissible_magnitude(): text = _spar((_SPAR_ROD, _SPAR_ROD.replace("0.0 0.0 -30.0", "2.0e6 0.0 -30.0"))) _rejects(text, "ROD endpoint coordinates must be at most 1e6 m") @@ -643,8 +668,6 @@ def test_named_rejections_of_moordyn_only_rows(): _rejects(_options(_HELD, "airy 2 8 0 waves regular"), "is a positional") _rejects(_options(_HELD, "200 WaveComponents", "600 WaveDirections"), "at most 100000") DeckFile.from_text(_options(_HELD, "200 WaveComponents", "500 WaveDirections")) - coupled_pinned = _SPAR_ROD.replace("Free", "CoupledPinned") - _rejects(_spar((_SPAR_ROD, coupled_pinned)), "CoupledPinned/VesselPinned RODS") _rejects(_edit(_HELD, ("0.252 390.0", "0.252 39+1")), "is not a plain number") turbine = _edit(_HELD, ("2 Coupled 0.0", "2 Turbine1 0.0")) _rejects(turbine, "Turbine points need a TURBINES section") diff --git a/src/CableDyn_Bathymetry.f90 b/src/CableDyn_Bathymetry.f90 index 6c5db76a..a040656f 100644 --- a/src/CableDyn_Bathymetry.f90 +++ b/src/CableDyn_Bathymetry.f90 @@ -28,6 +28,7 @@ MODULE CableDyn_Bathymetry PUBLIC :: CD_Bathymetry_Floor PUBLIC :: CD_Bathymetry_Floor_Gradient PUBLIC :: CD_Bathymetry_Grid_Floor + PUBLIC :: CD_Bathymetry_Max_Floor PUBLIC :: CD_Bathymetry_Rotate_Curvature PUBLIC :: CD_Bathymetry_Seabed_Load INTEGER, PARAMETER, PUBLIC :: CD_BATHY_OK = 0, CD_BATHY_BADINPUT = 1, CD_BATHY_ALLOCFAIL = 2 @@ -187,6 +188,42 @@ SUBROUTINE CD_Bathymetry_Grid_Floor(bathy, xq, yq, z_floor, ErrStat, ErrMsg) CALL floor_eval(bathy, xq, yq, z_floor, dfdx, dfdy, ErrStat, ErrMsg, rounded=.FALSE.) END SUBROUTINE CD_Bathymetry_Grid_Floor + SUBROUTINE CD_Bathymetry_Max_Floor(bathy, x_lo, x_hi, y_lo, y_hi, z_max, ErrStat, ErrMsg) + !! An upper bound of the seabed elevation (CD_Bathymetry_Floor) over the horizontal box + !! [x_lo, x_hi] x [y_lo, y_hi]: the highest grid node of the cells the box overlaps (the + !! bilinear surface of a cell lies within its node range, and outside the grid the floor + !! is clamped to its edge cells), raised by CD_BATHY_CREASE_FRACTION times the node range, + !! which bounds the crease rounding (it moves the surface by at most |J| delta/6 per + !! direction, below a thirtieth of the node range for both directions together). + TYPE(CD_BathymetryType), INTENT(IN) :: bathy + REAL(wp), INTENT(IN) :: x_lo, x_hi, y_lo, y_hi + REAL(wp), INTENT(OUT) :: z_max + INTEGER, INTENT(OUT) :: ErrStat + CHARACTER(*), INTENT(OUT) :: ErrMsg + INTEGER :: i0, i1, j0, j1 + REAL(wp) :: t, z_min + LOGICAL :: clamped + + z_max = CD_ZERO + ErrStat = CD_BATHY_OK + ErrMsg = '' + IF (.NOT. CD_Bathymetry_Is_Initialized(bathy)) THEN + CALL fail(ErrStat, ErrMsg, 'bathymetry object is not initialized') + RETURN + END IF + IF (.NOT. (CD_All_Finite([x_lo, x_hi, y_lo, y_hi]) .AND. x_lo <= x_hi .AND. y_lo <= y_hi)) THEN + CALL fail(ErrStat, ErrMsg, 'bathymetry box bounds must be finite and ordered') + RETURN + END IF + CALL locate_axis(bathy%x, x_lo, i0, t, clamped) + CALL locate_axis(bathy%x, x_hi, i1, t, clamped) + CALL locate_axis(bathy%y, y_lo, j0, t, clamped) + CALL locate_axis(bathy%y, y_hi, j1, t, clamped) + z_max = -MINVAL(bathy%depth(i0:i1 + 1, j0:j1 + 1)) + z_min = -MAXVAL(bathy%depth(i0:i1 + 1, j0:j1 + 1)) + z_max = z_max + CD_BATHY_CREASE_FRACTION*(z_max - z_min) + END SUBROUTINE CD_Bathymetry_Max_Floor + SUBROUTINE CD_Bathymetry_Floor_Gradient(bathy, xq, yq, z_floor, dfdx, dfdy, ErrStat, ErrMsg, crease_curvature) !! Return seabed elevation and horizontal gradients dz_floor/dx, dz_floor/dy. !! crease_curvature (optional): the second derivatives (z_xx, z_xy, z_yy) of the crease diff --git a/src/CableDyn_DeckDriver.f90 b/src/CableDyn_DeckDriver.f90 index fd34c926..73328fbe 100644 --- a/src/CableDyn_DeckDriver.f90 +++ b/src/CableDyn_DeckDriver.f90 @@ -41,7 +41,8 @@ MODULE CableDyn_DeckDriver CD_STATIC_FRICTION_AS_LAID, CD_STATIC_FRICTION_NONE USE CableDyn_Bathymetry, ONLY: CD_BathymetryType, CD_Init_Bathymetry, CD_End_Bathymetry, & CD_Bathymetry_Is_Initialized, CD_Bathymetry_Floor, & - CD_Bathymetry_Floor_Gradient, CD_Bathymetry_Grid_Floor, CD_BATHY_OK + CD_Bathymetry_Floor_Gradient, CD_Bathymetry_Grid_Floor, CD_Bathymetry_Max_Floor, & + CD_BATHY_OK USE CableDyn_Line, ONLY: CD_LineType, CD_LineSection, CD_Build_Line_Mesh, & CD_Nodal_Seabed_Stiffness, CD_LINE_OK USE CableDyn_Catenary, ONLY: CD_Catenary_Seed, CD_CAT_OK, CD_CAT_NOSEED @@ -715,6 +716,18 @@ MODULE CableDyn_DeckDriver ! Pinned rod: End A held at pin, the rod turns about it (three rotational DOFs) LOGICAL :: is_pinned = .FALSE. REAL(wp) :: pin(3) = CD_ZERO + ! CoupledPinned/VesselPinned rod (coupled aggregate): a pinned rod whose pin is a host node; + ! the host prescribes pin, pin_v and pin_a (zero for a fixed pin), and the rod's rotation + ! about it stays its own degree of freedom + LOGICAL :: is_host_pinned = .FALSE. + REAL(wp) :: pin_v(3) = CD_ZERO, pin_a(3) = CD_ZERO + ! pin0, pin0_v, pin0_a (host-pinned rod): the pin kinematics at the start of the coming step, + ! i.e. the End A motion of the committed rod state (set_rod_pin_start). They are set where + ! the committed state is (Init, the end of every step, a mirror restore, a host transfer + ! that does not advance) and not by the transfer of the t + dt host kinematics before a + ! step, so the step's start-acceleration solve and its sub-steps have the step-start pin + ! without a staged copy of the rods. + REAL(wp) :: pin0(3) = CD_ZERO, pin0_v(3) = CD_ZERO, pin0_a(3) = CD_ZERO ! Rod pinned to a body (BodyPinned): the index of the parent body in the march's body ! states and the pin (End A) in the body frame; pin then follows the body INTEGER :: parent = 0 @@ -810,6 +823,9 @@ MODULE CableDyn_DeckDriver ! 2 rod end (cab_obj rod index, cab_off(1) = -1 End A, +1 End B), 0 held point INTEGER, ALLOCATABLE :: cab_kind(:), cab_obj(:), cable_points(:, :) REAL(wp), ALLOCATABLE :: cab_off(:, :), cab_force(:, :) + ! cab_kax, cab_len: a cable's static axial stiffness 1/sum(l0/EA) and unstretched length, for the + ! sub-step estimate of the staggered march (mb_cable_k6) + REAL(wp), ALLOCATABLE :: cab_kax(:), cab_len(:) ! cab_clamp: End A carries a Rigid or elastic END CONNECTION on its body or rod; its end ! tangent then follows the object orientation, the cable is re-stepped at every outer ! iteration of the monolithic step (implicit coupling, its end stiffness in the Jacobian) and @@ -5934,9 +5950,10 @@ SUBROUTINE CD_Init_Deck_Aggregate(deck_path, dt, agg, ErrStat, ErrMsg, env_gravi !! the cables are both built under the environment the host owns (host overrides deck). !! !! Scope: EI=0 lines with Fixed/Coupled/Vessel/Connect/Free points, Point3 buoys, Rigid6 - !! bodies and RODs (host-coupled or free), CONTROL, FAILURE and FAST.Farm turbines, plus - !! finite-EI cables. Fails closed with a clear message on: a motionFile (the host drives the - !! coupled boundary); deck waves (the host supplies wave kinematics); a deck current on + !! bodies and RODs (free, fixed, pinned, host-coupled or host-pinned), CONTROL, FAILURE and + !! FAST.Farm turbines, plus finite-EI cables. Fails closed with a clear message on: a + !! motionFile (the host drives the coupled boundary); deck waves (the host supplies wave + !! kinematics); a deck current on !! a deck with a finite-EI cable, a Rigid6 body or a rod, under a host fluid field, or in !! FAST.Farm mode; a deck with a finite-EI cable that also carries Free/Connect dynamic !! points. A deck current on any other deck is a steady field applied through the lines. @@ -6048,8 +6065,9 @@ SUBROUTINE CD_Init_Deck_Aggregate(deck_path, dt, agg, ErrStat, ErrMsg, env_gravi END IF IF (MAXVAL(ABS(ptfm_init)) > CD_ZERO) THEN CALL apply_ptfm_init(points, ptfm_init) - ! Coupled/Vessel RODS are platform-borne like Coupled points: their ends and their - ! RodA/B attachment points move rigidly with the initial platform displacement. + ! Coupled/Vessel and CoupledPinned RODS are platform-borne like Coupled points: their ends + ! and their RodA/B attachment points move rigidly with the initial platform + ! displacement (MoorDyn-F also turns a coupled pinned rod's axis with PtfmInit). CALL apply_ptfm_host_rods(rods, points, ptfm_init) CALL apply_ptfm_host_bodies(bodies, points, ptfm_init) host_dcm = ptfm_zyx_dcm(ptfm_init(4:6)) @@ -6264,7 +6282,8 @@ SUBROUTINE CD_Init_Deck_Aggregate(deck_path, dt, agg, ErrStat, ErrMsg, env_gravi ! below (n_rod block) and built into agg%rod. A rod deck mixed with Rigid6 bodies fails closed ! there (the aggregate marches one body/rod family per step). n_rod = SIZE(rods) - n_host_rod = COUNT(rods%rod_type == 'coupled' .OR. rods%rod_type == 'vessel') + n_host_rod = COUNT(rods%rod_type == 'coupled' .OR. rods%rod_type == 'vessel' .OR. & + rods%rod_type == 'coupledpinned') n_host_body = COUNT(bodies%host_coupled) IF (opts%has_motion_file) THEN CALL fail(ErrStat, ErrMsg, 'CD_Init_Deck_Aggregate: the coupled boundary is driven by the host, '// & @@ -6361,12 +6380,9 @@ SUBROUTINE CD_Init_Deck_Aggregate(deck_path, dt, agg, ErrStat, ErrMsg, env_gravi CALL fail(ErrStat, ErrMsg, 'CD_Init_Deck_Aggregate: a coupled ROD with a finite-EI cable in the '// & 'same deck is not supported'); RETURN END IF - ! The aggregate rod march integrates Free rods and prescribes Coupled/Vessel ones; any other - ! rod would be held at its pose, so a Pinned rod (which must turn about its pin) is refused. - IF (ANY(rods%rod_type == 'pinned')) THEN - CALL fail(ErrStat, ErrMsg, 'CD_Init_Deck_Aggregate: a Pinned ROD is not supported on the coupled '// & - 'route (the coupled rod march does not turn rods about a pin); use the standalone driver'); RETURN - END IF + ! The aggregate rod march integrates Free rods, turns Pinned and CoupledPinned rods about + ! their pins (a fixed point, or a host node that moves the pin), prescribes Coupled/Vessel + ! rods and holds Fixed ones. IF (nturb > 0) THEN CALL fail(ErrStat, ErrMsg, 'CD_Init_Deck_Aggregate: coupled RODs in a FAST.Farm deck are not '// & 'supported'); RETURN @@ -6389,11 +6405,13 @@ SUBROUTINE CD_Init_Deck_Aggregate(deck_path, dt, agg, ErrStat, ErrMsg, env_gravi CALL fail(ErrStat, ErrMsg, 'CD_Init_Deck_Aggregate: line FAILURE on a coupled ROD deck is not '// & 'supported (the failure trigger is not evaluated against the post-rod-march state)'); RETURN END IF - ! Coupled/Vessel rods become 6-DOF host nodes (End A position + platform orientation). The - ! linearization probe places translational moving points only, so it cannot carry them. + ! Coupled/Vessel rods become 6-DOF host nodes (End A position + platform orientation), + ! CoupledPinned ones translational host nodes with a rotation of their own. The + ! linearization probe places translational moving points only and holds every rod, so it + ! carries neither. IF (n_host_rod > 0 .AND. PRESENT(coupled_positions)) THEN CALL fail(ErrStat, ErrMsg, 'CD_Init_Deck_Aggregate: coupled_positions (the linearization probe) '// & - 'does not support Coupled/Vessel RODS'); RETURN + 'does not support Coupled/Vessel or CoupledPinned RODS'); RETURN END IF END IF @@ -11541,10 +11559,9 @@ SUBROUTINE append_rod(line, rods, nr, ErrStat, ErrMsg) r%rod_type = 'vessel' CASE ('cpld') r%rod_type = 'coupled' - CASE ('coupledpinned', 'cpldpin', 'vesselpinned', 'vespin') - ! rejected here, before a NumSegs 0 rod collapses to an unknown point type - CALL fail(ErrStat, ErrMsg, 'CoupledPinned/VesselPinned RODS are not supported (use Coupled, Vessel, '// & - 'Pinned or BodyPinned)'); RETURN + CASE ('cpldpin', 'vesselpinned', 'vespin') + ! MoorDyn-F treats the four spellings alike: End A pinned to a host node + r%rod_type = 'coupledpinned' CASE DEFAULT IF (starts_with(TRIM(r%rod_type), 'body') .AND. LEN_TRIM(r%rod_type) > 7) THEN IF (r%rod_type(LEN_TRIM(r%rod_type) - 2:LEN_TRIM(r%rod_type)) == 'pin' .AND. & @@ -11985,8 +12002,9 @@ SUBROUTINE collapse_zero_length_rods(rods, points, np, lines, opts) !! the rod axis, which a zero-length rod does not have (zero for lines without bending !! stiffness), so it carries no hydrodynamic load either. Each one becomes one POINT at End A !! that both of its ends (RA/RB tokens and RodA/B POINT rows) resolve to: Free for a - !! free rod, Fixed for a fixed or pinned rod, Coupled for a coupled rod and Body for a rod - !! fixed or pinned to body M. The rod leaves the rod list; opts%zl_rod/zl_point keep the map + !! free rod, Fixed for a fixed or pinned rod, Coupled for a coupled or (coupled host only) + !! CoupledPinned rod and Body for a rod fixed or pinned to body M. The rod leaves the rod + !! list; opts%zl_rod/zl_point keep the map !! so that a Rod output channel on it can be refused by name. TYPE(DeckRod), ALLOCATABLE, INTENT(INOUT) :: rods(:) TYPE(DeckPoint), ALLOCATABLE, INTENT(INOUT) :: points(:) @@ -12009,13 +12027,17 @@ SUBROUTINE collapse_zero_length_rods(rods, points, np, lines, opts) drop = .FALSE. DO i = 1, SIZE(rods) IF (rods(i)%nsegs /= 0) CYCLE + ! a CoupledPinned rod needs a coupled host; elsewhere it stays a rod and is refused by name + IF (TRIM(rods(i)%rod_type) == 'coupledpinned' .AND. .NOT. opts%host_coupled_objects) CYCLE keep(i) = .FALSE. SELECT CASE (TRIM(rods(i)%rod_type)) CASE ('free') ptype = 'free' CASE ('fixed', 'pinned') ptype = 'fixed' - CASE ('coupled', 'vessel') + CASE ('coupled', 'vessel', 'coupledpinned') + ! a point at End A has no rotation to pin: a zero-length CoupledPinned rod transmits the + ! force of its lines to the host, as a Coupled point does ptype = 'coupled' CASE DEFAULT bid = MAX(body_id_of_rod_type(rods(i)%rod_type), pinned_body_of_rod_type(rods(i)%rod_type)) @@ -14217,9 +14239,10 @@ SUBROUTINE finalize_checks(types, bodies, rod_types, rods, points, lines, sectio END IF ELSE IF (TRIM(rods(i)%rod_type) /= 'free' .AND. TRIM(rods(i)%rod_type) /= 'fixed' .AND. & TRIM(rods(i)%rod_type) /= 'coupled' .AND. TRIM(rods(i)%rod_type) /= 'vessel' .AND. & - TRIM(rods(i)%rod_type) /= 'pinned') THEN + TRIM(rods(i)%rod_type) /= 'pinned' .AND. TRIM(rods(i)%rod_type) /= 'coupledpinned') THEN CALL fail(ErrStat, ErrMsg, 'ROD type "'//TRIM(rods(i)%rod_type)// & - '" is not supported (supported: Free, Fixed, Pinned, Coupled, Vessel, Body, BodyPinned)') + '" is not supported (supported: Free, Fixed, Pinned, Coupled, Vessel, CoupledPinned, '// & + 'VesselPinned, Body, BodyPinned)') RETURN END IF IF ((TRIM(rods(i)%rod_type) == 'coupled' .OR. TRIM(rods(i)%rod_type) == 'vessel') .AND. & @@ -14227,6 +14250,14 @@ SUBROUTINE finalize_checks(types, bodies, rod_types, rods, points, lines, sectio CALL fail(ErrStat, ErrMsg, 'Coupled/Vessel ROD requires a motionFile (or a coupled host)') RETURN END IF + ! The host moves the pin of a CoupledPinned rod and takes its force; a motionFile cannot + ! stand in for it (it prescribes both rod ends), so the rod needs the coupled aggregate. + IF (TRIM(rods(i)%rod_type) == 'coupledpinned' .AND. .NOT. opts%host_coupled_objects) THEN + CALL fail(ErrStat, ErrMsg, 'CoupledPinned/VesselPinned ROD requires a coupled host (OpenFAST '// & + 'CompMooring = 5); in a standalone deck use Pinned, BodyPinned, or a Coupled rod with a '// & + 'motionFile') + RETURN + END IF IF (.NOT. valid_rod_output_flags(rods(i)%outputs)) THEN CALL fail(ErrStat, ErrMsg, 'ROD Outputs "'//TRIM(rods(i)%outputs)// & '": supported rod-output flag is p') @@ -16358,7 +16389,8 @@ SUBROUTINE init_rod_states(rod_types, rods, points, rod_state, ErrStat, ErrMsg, rod_state(i)%rod_id = rods(i)%id rod_state(i)%is_free = TRIM(rods(i)%rod_type) == 'free' rod_state(i)%is_prescribed = TRIM(rods(i)%rod_type) == 'coupled' .OR. TRIM(rods(i)%rod_type) == 'vessel' - rod_state(i)%is_pinned = TRIM(rods(i)%rod_type) == 'pinned' + rod_state(i)%is_host_pinned = TRIM(rods(i)%rod_type) == 'coupledpinned' + rod_state(i)%is_pinned = TRIM(rods(i)%rod_type) == 'pinned' .OR. rod_state(i)%is_host_pinned rod_state(i)%pin = rods(i)%end_a rod_state(i)%point_a_index = rod_point_index(points, rods(i)%id, 1) rod_state(i)%point_b_index = rod_point_index(points, rods(i)%id, 2) @@ -16387,9 +16419,31 @@ SUBROUTINE init_rod_states(rod_types, rods, points, rod_state, ErrStat, ErrMsg, rod_state(i)%inertia(1) = 0.5_wp*rod_state(i)%mass*radius*radius rod_state(i)%inertia(2) = rod_state(i)%mass*(3.0_wp*radius*radius + rod_state(i)%length**2)/12.0_wp rod_state(i)%inertia(3) = rod_state(i)%inertia(2) + ! a host-pinned rod starts its first step from its pin at rest in the deck pose + IF (rod_state(i)%is_host_pinned) CALL set_rod_pin_start(rod_state(i)) END DO END SUBROUTINE init_rod_states + SUBROUTINE rod_end_a_motion(rod, p, v, a) + !! Position, velocity and acceleration of a rod's End A from its rigid motion (centre, frame, + !! angular rates). + TYPE(RodState), INTENT(IN) :: rod + REAL(wp), INTENT(OUT) :: p(3), v(3), a(3) + REAL(wp) :: arm(3) + arm = MATMUL(rod%rot_mat, [-rod%half_length, CD_ZERO, CD_ZERO]) + p = rod%r + arm + v = rod%v + cross3(rod%omega, arm) + a = rod%a + cross3(rod%alpha, arm) + cross3(rod%omega, cross3(rod%omega, arm)) + END SUBROUTINE rod_end_a_motion + + SUBROUTINE set_rod_pin_start(rod) + !! Record the committed End A motion of a host-pinned rod as the pin kinematics its next step + !! starts from (RodState%pin0). Derived from the rod state, which the checkpoint mirror + !! carries, so a restored run takes the same values bit for bit. + TYPE(RodState), INTENT(INOUT) :: rod + CALL rod_end_a_motion(rod, rod%pin0, rod%pin0_v, rod%pin0_a) + END SUBROUTINE set_rod_pin_start + SUBROUTINE ensure_rod_step_workspace(work, ncoupled, nrod, npoint) TYPE(RodStepWorkspace), INTENT(INOUT) :: work INTEGER, INTENT(IN) :: ncoupled, nrod, npoint @@ -16461,7 +16515,7 @@ END SUBROUTINE ensure_square_workspace SUBROUTINE rigid_coupled_acceleration(dload_da, dt, a_points, bases, arms, mass_eff, added6, inertia_body, & rot_mat, omega, f_global, m_global, dv0, dfo_dv, acc, alpha, & - ErrStat, ErrMsg, pin_arm, m6_out, rhs_out) + ErrStat, ErrMsg, pin_arm, m6_out, rhs_out, pin_acc, pin_load) !! End-of-step rigid-body (rod or Rigid6) accelerations x = (acc, alpha) of the staggered !! central-difference corrector of step_rigid6_system / step_rod_system. The loads were !! evaluated at the predictor, whose position is the final position (Newmark beta = 0) and @@ -16500,13 +16554,18 @@ SUBROUTINE rigid_coupled_acceleration(dload_da, dt, a_points, bases, arms, mass_ REAL(wp), INTENT(OUT) :: acc(3), alpha(3) INTEGER, INTENT(OUT) :: ErrStat CHARACTER(*), INTENT(OUT) :: ErrMsg - ! pin_arm: the reference point turns about a fixed pin at -pin_arm from it (a pinned rod): - ! with x = T y + b, T = [-[r]x; I], b = [w x (w x r); 0], the rotational acceleration y solves - ! T^T m6 T y = T^T (rhs - m6 b) - REAL(wp), INTENT(IN), OPTIONAL :: pin_arm(3) + ! pin_arm: the reference point turns about a pin at -pin_arm from it (a pinned rod): with + ! x = T y + b, T = [-[r]x; I], b = [a_p + w x (w x r); 0], the rotational acceleration y + ! solves T^T m6 T y = T^T (rhs - m6 b). a_p is pin_acc, the pin acceleration (zero when + ! absent: a fixed pin); a moving pin (a CoupledPinned rod) thus loads the rotation with the + ! inertia of its acceleration. + REAL(wp), INTENT(IN), OPTIONAL :: pin_arm(3), pin_acc(3) ! m6_out/rhs_out: return the assembled system m6 x = rhs instead of solving it (the pinned- ! child group solve of mb_group_solve); acc and alpha are then zero REAL(wp), INTENT(OUT), OPTIONAL :: m6_out(6, 6), rhs_out(6) + ! pin_load (with pin_arm): the force the body exerts on its pin, rhs(1:3) - m6(1:3, :) x, i.e. + ! its net load less its inertia (line-end inertia at the solved attachment accelerations) + REAL(wp), INTENT(OUT), OPTIONAL :: pin_load(3) INTEGER :: i, j, k, bi, bj REAL(wp) :: m6(6, 6), rhs(6), inertia_g(3, 3), s_i(3, 3), s_j(3, 3), d_ij(3, 3), g(3), c_j(3) @@ -16573,6 +16632,7 @@ SUBROUTINE rigid_coupled_acceleration(dload_da, dt, a_points, bases, arms, mass_ END DO b6 = CD_ZERO b6(1:3) = cross3(omega, cross3(omega, pin_arm)) + IF (PRESENT(pin_acc)) b6(1:3) = pin_acc + b6(1:3) CALL solve_sym3(MATMUL(TRANSPOSE(t63), MATMUL(m6, t63)), MATMUL(TRANSPOSE(t63), rhs - MATMUL(m6, b6)), y, ok) IF (.NOT. ok) THEN ErrStat = CD_DECKDRV_SOLVEFAIL @@ -16581,6 +16641,7 @@ SUBROUTINE rigid_coupled_acceleration(dload_da, dt, a_points, bases, arms, mass_ END IF alpha = y acc = MATMUL(t63(1:3, :), y) + b6(1:3) + IF (PRESENT(pin_load)) pin_load = rhs(1:3) - MATMUL(m6(1:3, 1:3), acc) - MATMUL(m6(1:3, 4:6), alpha) RETURN END IF CALL solve_rigid6x6(m6, rhs, ErrStat, ErrMsg) @@ -17215,7 +17276,8 @@ SUBROUTINE write_objects_dynamic_out(out_root, channels, bodies, rod_types, rods ErrStat, ErrMsg, bathymetry) !! March the bodies (with the rods fixed to them) and the free and pinned rods of a deck !! without lines: each object is advanced by the staggered central-difference scheme of the - !! line-coupled routes (Newmark gamma = 1/2, beta = 0, drag implicit), with no line loads. With + !! line-coupled routes (Newmark gamma = 1/2, beta = 0, drag implicit), with no line loads, + !! sub-cycled for the objects' own restoring (objects_substep_count). With !! bodyIC static a floating body starts at its hydrostatic equilibrium (float_body_equilibrium). CHARACTER(*), INTENT(IN) :: out_root CHARACTER(NAMELEN), INTENT(IN) :: channels(:) @@ -17232,8 +17294,8 @@ SUBROUTINE write_objects_dynamic_out(out_root, channels, bodies, rod_types, rods TYPE(RigidBodyState), ALLOCATABLE :: rigid(:), old_rigid(:) TYPE(RodState), ALLOCATABLE :: rst(:), old_rst(:) TYPE(DeckRod), ALLOCATABLE :: own(:) - INTEGER :: unit, ios, step, nstep, k, es - REAL(wp) :: t, acc(3), alpha(3), dv0(6) + INTEGER :: unit, ios, step, nstep, k, es, nsub, isub + REAL(wp) :: t, acc(3), alpha(3), dv0(6), dts, ts CHARACTER(160) :: em TYPE(DriverProgress) :: progress @@ -17288,53 +17350,62 @@ SUBROUTINE write_objects_dynamic_out(out_root, channels, bodies, rod_types, rods DO step = 1, nstep CALL CD_Profile_Enter(CD_PROF_SOLVE) t = REAL(step, wp)*opts%dtM - old_rigid = rigid - old_rst = rst - DO k = 1, SIZE(rigid) - CALL CD_Rigid_Advance_Newmark(rigid(k)%r, rigid(k)%v, rigid(k)%rot_mat, rigid(k)%omega, rigid(k)%a, & - rigid(k)%alpha, rigid(k)%a, rigid(k)%alpha, opts%dtM, CD_RIGID_NEWMARK_GAMMA, & - CD_RIGID_NEWMARK_BETA, es, em) - IF (es /= CD_RIGID_OK) CALL fail_solve(ErrStat, ErrMsg, 'body finite-rotation update failed: '//TRIM(em)) - IF (ErrStat /= CD_DECKDRV_OK) EXIT - dv0(1:3) = -CD_RIGID_NEWMARK_GAMMA*opts%dtM*old_rigid(k)%a - dv0(4:6) = -CD_RIGID_NEWMARK_GAMMA*opts%dtM*old_rigid(k)%alpha - CALL objects_acceleration(opts, t, opts%dtM, dv0, acc, alpha, ErrStat, ErrMsg, body=rigid(k), & - bathymetry=bathymetry) - IF (ErrStat /= CD_DECKDRV_OK) EXIT - rigid(k) = old_rigid(k) - CALL CD_Rigid_Advance_Newmark(rigid(k)%r, rigid(k)%v, rigid(k)%rot_mat, rigid(k)%omega, old_rigid(k)%a, & - old_rigid(k)%alpha, acc, alpha, opts%dtM, CD_RIGID_NEWMARK_GAMMA, & - CD_RIGID_NEWMARK_BETA, es, em) - IF (es /= CD_RIGID_OK) CALL fail_solve(ErrStat, ErrMsg, 'body finite-rotation update failed: '//TRIM(em)) - IF (ErrStat /= CD_DECKDRV_OK) EXIT - rigid(k)%a = acc - rigid(k)%alpha = alpha - END DO - IF (ErrStat == CD_DECKDRV_OK) THEN - DO k = 1, SIZE(rst) - IF (.NOT. (rst(k)%is_free .OR. rst(k)%is_pinned)) CYCLE - CALL CD_Rigid_Advance_Newmark(rst(k)%r, rst(k)%v, rst(k)%rot_mat, rst(k)%omega, rst(k)%a, rst(k)%alpha, & - rst(k)%a, rst(k)%alpha, opts%dtM, CD_RIGID_NEWMARK_GAMMA, & + ! sub-steps that resolve the objects' own restoring (objects_substep_count) + CALL objects_substep_count(rigid, rst, opts, t - opts%dtM, opts%dtM, nsub, ErrStat, ErrMsg, bathymetry) + IF (ErrStat /= CD_DECKDRV_OK) nsub = 0 + dts = opts%dtM/REAL(MAX(1, nsub), wp) + DO isub = 1, nsub + ts = t - opts%dtM + REAL(isub, wp)*dts + IF (isub == nsub) ts = t + old_rigid = rigid + old_rst = rst + DO k = 1, SIZE(rigid) + CALL CD_Rigid_Advance_Newmark(rigid(k)%r, rigid(k)%v, rigid(k)%rot_mat, rigid(k)%omega, rigid(k)%a, & + rigid(k)%alpha, rigid(k)%a, rigid(k)%alpha, dts, CD_RIGID_NEWMARK_GAMMA, & CD_RIGID_NEWMARK_BETA, es, em) - IF (es /= CD_RIGID_OK) CALL fail_solve(ErrStat, ErrMsg, 'rod finite-rotation update failed: '//TRIM(em)) + IF (es /= CD_RIGID_OK) CALL fail_solve(ErrStat, ErrMsg, 'body finite-rotation update failed: '//TRIM(em)) IF (ErrStat /= CD_DECKDRV_OK) EXIT - CALL pin_rod(rst(k)) - dv0(1:3) = -CD_RIGID_NEWMARK_GAMMA*opts%dtM*old_rst(k)%a - dv0(4:6) = -CD_RIGID_NEWMARK_GAMMA*opts%dtM*old_rst(k)%alpha - CALL objects_acceleration(opts, t, opts%dtM, dv0, acc, alpha, ErrStat, ErrMsg, rod=rst(k), & + dv0(1:3) = -CD_RIGID_NEWMARK_GAMMA*dts*old_rigid(k)%a + dv0(4:6) = -CD_RIGID_NEWMARK_GAMMA*dts*old_rigid(k)%alpha + CALL objects_acceleration(opts, ts, dts, dv0, acc, alpha, ErrStat, ErrMsg, body=rigid(k), & bathymetry=bathymetry) IF (ErrStat /= CD_DECKDRV_OK) EXIT - rst(k) = old_rst(k) - CALL CD_Rigid_Advance_Newmark(rst(k)%r, rst(k)%v, rst(k)%rot_mat, rst(k)%omega, old_rst(k)%a, & - old_rst(k)%alpha, acc, alpha, opts%dtM, CD_RIGID_NEWMARK_GAMMA, & + rigid(k) = old_rigid(k) + CALL CD_Rigid_Advance_Newmark(rigid(k)%r, rigid(k)%v, rigid(k)%rot_mat, rigid(k)%omega, old_rigid(k)%a, & + old_rigid(k)%alpha, acc, alpha, dts, CD_RIGID_NEWMARK_GAMMA, & CD_RIGID_NEWMARK_BETA, es, em) - IF (es /= CD_RIGID_OK) CALL fail_solve(ErrStat, ErrMsg, 'rod finite-rotation update failed: '//TRIM(em)) + IF (es /= CD_RIGID_OK) CALL fail_solve(ErrStat, ErrMsg, 'body finite-rotation update failed: '//TRIM(em)) IF (ErrStat /= CD_DECKDRV_OK) EXIT - rst(k)%a = acc - rst(k)%alpha = alpha - CALL pin_rod(rst(k)) + rigid(k)%a = acc + rigid(k)%alpha = alpha END DO - END IF + IF (ErrStat == CD_DECKDRV_OK) THEN + DO k = 1, SIZE(rst) + IF (.NOT. (rst(k)%is_free .OR. rst(k)%is_pinned)) CYCLE + CALL CD_Rigid_Advance_Newmark(rst(k)%r, rst(k)%v, rst(k)%rot_mat, rst(k)%omega, rst(k)%a, rst(k)%alpha, & + rst(k)%a, rst(k)%alpha, dts, CD_RIGID_NEWMARK_GAMMA, & + CD_RIGID_NEWMARK_BETA, es, em) + IF (es /= CD_RIGID_OK) CALL fail_solve(ErrStat, ErrMsg, 'rod finite-rotation update failed: '//TRIM(em)) + IF (ErrStat /= CD_DECKDRV_OK) EXIT + CALL pin_rod(rst(k)) + dv0(1:3) = -CD_RIGID_NEWMARK_GAMMA*dts*old_rst(k)%a + dv0(4:6) = -CD_RIGID_NEWMARK_GAMMA*dts*old_rst(k)%alpha + CALL objects_acceleration(opts, ts, dts, dv0, acc, alpha, ErrStat, ErrMsg, rod=rst(k), & + bathymetry=bathymetry) + IF (ErrStat /= CD_DECKDRV_OK) EXIT + rst(k) = old_rst(k) + CALL CD_Rigid_Advance_Newmark(rst(k)%r, rst(k)%v, rst(k)%rot_mat, rst(k)%omega, old_rst(k)%a, & + old_rst(k)%alpha, acc, alpha, dts, CD_RIGID_NEWMARK_GAMMA, & + CD_RIGID_NEWMARK_BETA, es, em) + IF (es /= CD_RIGID_OK) CALL fail_solve(ErrStat, ErrMsg, 'rod finite-rotation update failed: '//TRIM(em)) + IF (ErrStat /= CD_DECKDRV_OK) EXIT + rst(k)%a = acc + rst(k)%alpha = alpha + CALL pin_rod(rst(k)) + END DO + END IF + IF (ErrStat /= CD_DECKDRV_OK) EXIT + END DO IF (ErrStat == CD_DECKDRV_OK) THEN CALL CD_Profile_Step() CALL CD_Profile_Enter(CD_PROF_OUTPUT) @@ -17378,6 +17449,54 @@ SUBROUTINE write_row(time) END SUBROUTINE write_row END SUBROUTINE write_objects_dynamic_out + SUBROUTINE objects_substep_count(rigid, rst, opts, time, dt, nsub, ErrStat, ErrMsg, bathymetry) + !! Sub-steps of a step of length dt of the march of a deck without lines + !! (write_objects_dynamic_out), from the estimate of the line-coupled routes without its line + !! springs (rigid_substep_count): a body's hydrostatic restoring and seabed contact, with the + !! contact and waterplane of the rods fixed to it (rigid6_contact_stiffness), over its + !! structural mass and inertia plus the submerged translational added mass, as in + !! step_rigid6_system; a free or pinned rod's own terms (rod_estimate_terms), as in + !! step_rod_system. + TYPE(RigidBodyState), INTENT(IN) :: rigid(:) + TYPE(RodState), INTENT(IN) :: rst(:) + TYPE(DeckOptions), INTENT(IN) :: opts + REAL(wp), INTENT(IN) :: time, dt + INTEGER, INTENT(OUT) :: nsub + INTEGER, INTENT(OUT) :: ErrStat + CHARACTER(*), INTENT(OUT) :: ErrMsg + TYPE(CD_BathymetryType), INTENT(IN), OPTIONAL :: bathymetry + INTEGER :: k, j + REAL(wp) :: omega2, om2, mass6(6), k6(6), w2, shift(3) + + nsub = 1 + ErrStat = CD_DECKDRV_OK + ErrMsg = '' + omega2 = CD_ZERO + DO k = 1, SIZE(rigid) + IF (rigid(k)%is_prescribed) CYCLE + mass6(1:3) = rigid(k)%mass + IF (rigid(k)%r(3) < CD_ZERO) mass6(1:3) = mass6(1:3) + opts%rhoW*rigid(k)%vol*MAX(CD_ZERO, rigid(k)%ca) + mass6(4:6) = global_inertia_diag(rigid(k)%rot_mat, rigid(k)%inertia) + k6 = [CD_ZERO, CD_ZERO, rigid(k)%c33, rigid(k)%c44, rigid(k)%c55, CD_ZERO] + CALL rigid6_contact_stiffness(rigid(k), opts, time, dt, k6, ErrStat, ErrMsg, bathymetry) + IF (ErrStat /= CD_DECKDRV_OK) RETURN + DO j = 1, 6 + IF (mass6(j) > CD_ZERO) omega2 = MAX(omega2, k6(j)/mass6(j)) + END DO + END DO + DO k = 1, SIZE(rst) + IF (.NOT. (rst(k)%is_free .OR. rst(k)%is_pinned)) CYCLE + CALL rod_estimate_terms(rst(k), opts, time, dt, mass6, k6, w2, shift, ErrStat, ErrMsg, bathymetry) + IF (ErrStat /= CD_DECKDRV_OK) RETURN + om2 = CD_ZERO + DO j = 1, 6 + IF (mass6(j) > CD_ZERO) om2 = MAX(om2, k6(j)/mass6(j)) + END DO + omega2 = MAX(omega2, om2 + w2) + END DO + nsub = rigid_substep_count(omega2, dt) + END SUBROUTINE objects_substep_count + ! --------------------------------------------------------------------------- ! ! multibody march: Rigid6 bodies (with fixed and pinned rods), free, pinned ! ! and fixed rods, Free/Connect points, EI=0 lines and finite-EI cables ! @@ -17625,7 +17744,8 @@ SUBROUTINE write_multibody_dynamic_out(deck_path, out_root, channels, types, bod ALLOCATE (mb%cables(SIZE(cab_lines)), mb%cab_kind(SIZE(cab_lines)), mb%cab_obj(SIZE(cab_lines)), & mb%cab_off(3, SIZE(cab_lines)), mb%cab_force(3, SIZE(cab_lines)), & mb%cab_clamp(SIZE(cab_lines)), mb%cab_moment(3, SIZE(cab_lines)), mb%cab_fend(3, SIZE(cab_lines)), & - mb%cab_mend(3, SIZE(cab_lines)), mb%cab_f0(3, SIZE(cab_lines)), mb%cab_m0(3, SIZE(cab_lines))) + mb%cab_mend(3, SIZE(cab_lines)), mb%cab_f0(3, SIZE(cab_lines)), mb%cab_m0(3, SIZE(cab_lines)), & + mb%cab_kax(SIZE(cab_lines)), mb%cab_len(SIZE(cab_lines))) mb%cab_age = HUGE(1) mb%cab_kind = 0 mb%cab_obj = 0 @@ -17637,6 +17757,25 @@ SUBROUTINE write_multibody_dynamic_out(deck_path, out_root, channels, types, bod mb%cab_mend = CD_ZERO mb%cab_f0 = CD_ZERO mb%cab_m0 = CD_ZERO + ! static axial stiffness and length of each cable (its sections, the dynamic modulus when it + ! has one), for the sub-step estimate of the staggered march + DO c = 1, SIZE(cab_lines) + BLOCK + REAL(wp) :: compl, clen, ea_s + INTEGER :: js + compl = CD_ZERO + clen = CD_ZERO + DO js = 1, SIZE(sections) + IF (sections(js)%line_id /= cab_lines(c)%id .OR. sections(js)%ltype < 1) CYCLE + clen = clen + sections(js)%length + ea_s = MAX(types(sections(js)%ltype)%ea, types(sections(js)%ltype)%ea_d) + IF (ea_s > CD_ZERO) compl = compl + sections(js)%length/ea_s + END DO + mb%cab_len(c) = clen + mb%cab_kax(c) = CD_ZERO + IF (compl > CD_ZERO) mb%cab_kax(c) = CD_ONE/compl + END BLOCK + END DO DO c = 1, SIZE(cab_lines) pc = points pa = find_point(points, cab_lines(c)%nodeA) @@ -17944,14 +18083,17 @@ SUBROUTINE CD_Multibody_Probe_Get(rec) END SUBROUTINE CD_Multibody_Probe_Get SUBROUTINE mb_snap_pinned(rod, rigid) - !! A pinned rod keeps End A on its pin: a fixed point, or the pin point of its parent body. + !! A pinned rod keeps End A on its pin: a fixed point, a host node (a CoupledPinned rod on + !! the coupled aggregate, whose pin, pin_v and pin_a the host sets) or the pin point of its + !! parent body. !! Its centre, velocity and acceleration follow the pin motion and the rod's own rotation. TYPE(RodState), INTENT(INOUT) :: rod TYPE(RigidBodyState), INTENT(IN) :: rigid(:) REAL(wp) :: p(3), v_pin(3), a_pin(3), arm(3) IF (.NOT. rod%is_pinned) RETURN - v_pin = CD_ZERO - a_pin = CD_ZERO + ! zero for a fixed pin + v_pin = rod%pin_v + a_pin = rod%pin_a IF (rod%parent > 0) THEN ASSOCIATE (b => rigid(rod%parent)) p = MATMUL(b%rot_mat, rod%pin_body) @@ -18076,6 +18218,44 @@ SUBROUTINE mb_cable_arm(mb, c, arm) END SELECT END SUBROUTINE mb_cable_arm + SUBROUTINE mb_cable_k6(mb, kind, obj, shift, k6) + !! Add to k6 the diagonal stiffness of the finite-EI cables attached to object obj (cab_kind + !! kind) at their arms (mb_cable_arm, plus shift: from a pinned rod's centre to its pin): the + !! directional spring k_ax t t^T + (T/L)(I - t t^T) of line_attachment_stiffness, t along the + !! cable's current end force, T its magnitude, L its unstretched length and k_ax = 1/sum(l0/EA). + !! The staggered march returns the cable end force explicitly, so this spring bounds its step. + TYPE(MultibodyMarch), INTENT(IN) :: mb + INTEGER, INTENT(IN) :: kind, obj + REAL(wp), INTENT(IN) :: shift(3) + REAL(wp), INTENT(INOUT) :: k6(6) + INTEGER :: c, k + REAL(wp) :: arm(3), t(3), ten, katt(3, 3), s(3, 3), krot(3, 3), eye(3, 3) + IF (.NOT. ALLOCATED(mb%cables)) RETURN + eye = CD_ZERO + DO k = 1, 3 + eye(k, k) = CD_ONE + END DO + DO c = 1, SIZE(mb%cables) + IF (mb%cab_kind(c) /= kind .OR. mb%cab_obj(c) /= obj) CYCLE + CALL mb_cable_arm(mb, c, arm) + arm = arm + shift + ten = NORM2(mb%cab_force(:, c)) + IF (ten > CD_ZERO .AND. mb%cab_len(c) > CD_ZERO) THEN + t = mb%cab_force(:, c)/ten + katt = mb%cab_kax(c)*SPREAD(t, 2, 3)*SPREAD(t, 1, 3) + & + ten/mb%cab_len(c)*(eye - SPREAD(t, 2, 3)*SPREAD(t, 1, 3)) + ELSE + katt = mb%cab_kax(c)*eye + END IF + s = skew3(arm) + krot = -MATMUL(s, MATMUL(katt, s)) + DO k = 1, 3 + k6(k) = k6(k) + katt(k, k) + k6(3 + k) = k6(3 + k) + krot(k, k) + END DO + END DO + END SUBROUTINE mb_cable_k6 + SUBROUTINE mb_rod_bases(mb, points, rod, bases, arms) !! System coupled-DOF bases (-1: no EI=0 line) and arms of a rod's End A and End B points. TYPE(MultibodyMarch), INTENT(IN) :: mb @@ -18508,7 +18688,8 @@ END SUBROUTINE mb_line_loads SUBROUTINE mb_step(mb, points, opts, time, dt, converged, stalled, n_iter, ErrStat, ErrMsg, bathymetry) !! Advance the multibody march from time - dt to time, sub-cycled so that the explicit object - !! positions resolve the stiffest object-mooring mode of the EI=0 lines (rigid_substep_count). + !! positions resolve the stiffest object-mooring mode of the EI=0 lines and the objects' own + !! restoring, with or without lines (rigid_substep_count). TYPE(MultibodyMarch), INTENT(INOUT) :: mb TYPE(DeckPoint), INTENT(IN) :: points(:) TYPE(DeckOptions), INTENT(IN) :: opts @@ -18519,7 +18700,7 @@ SUBROUTINE mb_step(mb, points, opts, time, dt, converged, stalled, n_iter, ErrSt TYPE(CD_BathymetryType), INTENT(IN), OPTIONAL :: bathymetry INTEGER :: ib, ir, ip, nsub, isub, it, k, bases(2) LOGICAL :: conv_s, stall_s - REAL(wp) :: omega2, mass6(6), arms(3, 2), f_d(3), m_d(3), added6(6, 6), drag6(6, 6) + REAL(wp) :: omega2, mass6(6), arms(3, 2), f_d(3), m_d(3), added6(6, 6), drag6(6, 6), k6c(6), w2_pin, shift(3) converged = .TRUE. stalled = .FALSE. @@ -18552,45 +18733,73 @@ SUBROUTINE mb_step(mb, points, opts, time, dt, converged, stalled, n_iter, ErrSt END IF END IF omega2 = CD_ZERO - ! a body-only monolithic deck still resolves its hydrostatic restoring - IF (mb%has_sys .OR. mb%implicit) THEN - DO ib = 1, SIZE(mb%rigid) - BLOCK - INTEGER :: att_base(SIZE(mb%rigid(ib)%point_indices)) - REAL(wp) :: att_arm(3, SIZE(mb%rigid(ib)%point_indices)) - DO ip = 1, SIZE(mb%rigid(ib)%point_indices) - att_base(ip) = -1 - IF (mb%has_sys) att_base(ip) = system_point_base(mb%system, & - points(mb%rigid(ib)%point_indices(ip))%id) - att_arm(:, ip) = MATMUL(mb%rigid(ib)%rot_mat, points(mb%rigid(ib)%point_indices(ip))%body_offset) + ! the bodies' own restoring enters with or without lines (a body-only deck still resolves it) + DO ib = 1, SIZE(mb%rigid) + BLOCK + INTEGER :: att_base(SIZE(mb%rigid(ib)%point_indices)) + REAL(wp) :: att_arm(3, SIZE(mb%rigid(ib)%point_indices)) + DO ip = 1, SIZE(mb%rigid(ib)%point_indices) + att_base(ip) = -1 + IF (mb%has_sys) att_base(ip) = system_point_base(mb%system, & + points(mb%rigid(ib)%point_indices(ip))%id) + att_arm(:, ip) = MATMUL(mb%rigid(ib)%rot_mat, points(mb%rigid(ib)%point_indices(ip))%body_offset) + END DO + mass6(1:3) = mb%rigid(ib)%mass + IF (mb%rigid(ib)%r(3) < CD_ZERO) mass6(1:3) = mass6(1:3) + opts%rhoW*mb%rigid(ib)%vol* & + MAX(CD_ZERO, mb%rigid(ib)%ca) + mass6(4:6) = global_inertia_diag(mb%rigid(ib)%rot_mat, mb%rigid(ib)%inertia) + IF (ALLOCATED(mb%rigid(ib)%att_rods)) THEN + DO k = 1, SIZE(mb%rigid(ib)%att_rods) + mass6(1:3) = mass6(1:3) + mb%rigid(ib)%att_rods(k)%mass END DO - mass6(1:3) = mb%rigid(ib)%mass - IF (mb%rigid(ib)%r(3) < CD_ZERO) mass6(1:3) = mass6(1:3) + opts%rhoW*mb%rigid(ib)%vol* & - MAX(CD_ZERO, mb%rigid(ib)%ca) - mass6(4:6) = global_inertia_diag(mb%rigid(ib)%rot_mat, mb%rigid(ib)%inertia) - IF (ALLOCATED(mb%rigid(ib)%att_rods)) THEN - DO k = 1, SIZE(mb%rigid(ib)%att_rods) - mass6(1:3) = mass6(1:3) + mb%rigid(ib)%att_rods(k)%mass - END DO - END IF - omega2 = MAX(omega2, rigid_omega2_estimate(mb%system, att_base, att_arm, mass6, & - [CD_ZERO, CD_ZERO, mb%rigid(ib)%c33, mb%rigid(ib)%c44, & - mb%rigid(ib)%c55, CD_ZERO])) - END BLOCK - END DO - END IF - IF (mb%has_sys) THEN + END IF + ! hydrostatic restoring; the staggered scheme's explicit positions also meet the seabed + ! contact that acts within the step (the monolithic scheme carries it in its Jacobian) + k6c = [CD_ZERO, CD_ZERO, mb%rigid(ib)%c33, mb%rigid(ib)%c44, mb%rigid(ib)%c55, CD_ZERO] + IF (.NOT. mb%implicit) THEN + CALL rigid6_contact_stiffness(mb%rigid(ib), opts, time - dt, dt, k6c, ErrStat, ErrMsg, bathymetry) + IF (ErrStat /= CD_DECKDRV_OK) RETURN + CALL mb_cable_k6(mb, 1, ib, [CD_ZERO, CD_ZERO, CD_ZERO], k6c) + END IF + omega2 = MAX(omega2, rigid_omega2_estimate(mb%system, att_base, att_arm, mass6, k6c)) + END BLOCK + END DO + ! the rods' own terms enter the staggered scheme with or without lines + IF (mb%has_sys .OR. .NOT. mb%implicit) THEN DO ir = 1, SIZE(mb%rods) IF (.NOT. (mb%rods(ir)%is_free .OR. mb%rods(ir)%is_pinned)) CYCLE CALL mb_rod_bases(mb, points, mb%rods(ir), bases, arms) - CALL rod_environment_force(mb%rods(ir), opts, time - dt, f_d, m_d, added6, drag6, ErrStat, ErrMsg) + IF (mb%implicit) THEN + ! monolithic accuracy sub-steps: the line springs over the structural plus added mass + CALL rod_environment_force(mb%rods(ir), opts, time - dt, f_d, m_d, added6, drag6, ErrStat, ErrMsg) + IF (ErrStat /= CD_DECKDRV_OK) RETURN + mass6(1:3) = mb%rods(ir)%mass + mass6(4:6) = global_inertia_diag(mb%rods(ir)%rot_mat, mb%rods(ir)%inertia) + DO k = 1, 6 + mass6(k) = mass6(k) + MAX(CD_ZERO, added6(k, k)) + END DO + omega2 = MAX(omega2, rigid_omega2_estimate(mb%system, bases, arms, mass6)) + CYCLE + END IF + ! the staggered scheme's explicit positions also meet the rod's own terms + ! (rod_estimate_terms, as in step_rod_system: a pinned rod about its pin, with the pin + ! acceleration of its parent body) and its finite-EI cables (mb_cable_k6), whose end + ! forces it applies explicitly; the monolithic scheme carries the contact and the + ! hydrostatics in its Jacobian + IF (mb%rods(ir)%is_pinned .AND. mb%rods(ir)%parent > 0) THEN + CALL rod_estimate_terms(mb%rods(ir), opts, time - dt, dt, mass6, k6c, w2_pin, shift, ErrStat, ErrMsg, & + bathymetry, parent=mb%rigid(mb%rods(ir)%parent)) + ELSE + CALL rod_estimate_terms(mb%rods(ir), opts, time - dt, dt, mass6, k6c, w2_pin, shift, ErrStat, ErrMsg, & + bathymetry) + END IF IF (ErrStat /= CD_DECKDRV_OK) RETURN - mass6(1:3) = mb%rods(ir)%mass - mass6(4:6) = global_inertia_diag(mb%rods(ir)%rot_mat, mb%rods(ir)%inertia) - DO k = 1, 6 - mass6(k) = mass6(k) + MAX(CD_ZERO, added6(k, k)) - END DO - omega2 = MAX(omega2, rigid_omega2_estimate(mb%system, bases, arms, mass6)) + IF (mb%rods(ir)%is_pinned) THEN + arms(:, 1) = arms(:, 1) + shift + arms(:, 2) = arms(:, 2) + shift + END IF + CALL mb_cable_k6(mb, 2, ir, shift, k6c) + omega2 = MAX(omega2, rigid_omega2_estimate(mb%system, bases, arms, mass6, k6c) + w2_pin) END DO END IF IF (mb%implicit) THEN @@ -19922,7 +20131,7 @@ FUNCTION line_attachment_stiffness(system, dof) RESULT(katt) END DO END FUNCTION line_attachment_stiffness - PURE INTEGER FUNCTION rigid_substep_count(omega2, dt, omega_dt_max) RESULT(nsub) + INTEGER FUNCTION rigid_substep_count(omega2, dt, omega_dt_max) RESULT(nsub) !! Sub-steps per coupled step so that omega*dt_sub stays at or below RIGID_OMEGA_DT_MAX, !! capped at RIGID_MAX_SUBSTEPS. The explicit central-difference stability limit is !! omega*dt < 2, and omega from rigid_omega2_estimate (directional line stiffness, added @@ -19930,11 +20139,14 @@ PURE INTEGER FUNCTION rigid_substep_count(omega2, dt, omega_dt_max) RESULT(nsub) !! on short lines goes unstable at an estimated omega*dt of 1.27). The limit 0.4 is set by !! accuracy, not stability: a rod released out of equilibrium at dt 0.1 s keeps its !! fairlead-tension transient within 1.5% of a dt 0.005 s run. omega_dt_max replaces the - !! limit (bodySubstep accuracy of the monolithic scheme). + !! limit (bodySubstep accuracy of the monolithic scheme). A step that needs more than the + !! cap is warned about once per run (process): its sub-steps then exceed the limit, and + !! beyond omega*dt_sub = 2 the explicit step is unstable, so dtM must come down. REAL(wp), INTENT(IN) :: omega2, dt REAL(wp), INTENT(IN), OPTIONAL :: omega_dt_max REAL(wp), PARAMETER :: RIGID_OMEGA_DT_MAX = 0.4_wp INTEGER, PARAMETER :: RIGID_MAX_SUBSTEPS = 256 + LOGICAL, SAVE :: warned = .FALSE. REAL(wp) :: ratio, lim nsub = 1 IF (.NOT. (omega2 > CD_ZERO .AND. dt > CD_ZERO)) RETURN @@ -19943,6 +20155,14 @@ PURE INTEGER FUNCTION rigid_substep_count(omega2, dt, omega_dt_max) RESULT(nsub) ratio = SQRT(omega2)*dt/lim IF (.NOT. (ratio < REAL(RIGID_MAX_SUBSTEPS, wp))) THEN nsub = RIGID_MAX_SUBSTEPS + !$OMP CRITICAL (cd_substep_cap_warning) + IF (.NOT. warned) THEN + warned = .TRUE. + WRITE (output_unit, '(A,I0,A,ES10.3,A)') ' Warning: an object step needs more than ', RIGID_MAX_SUBSTEPS, & + ' sub-steps (estimated omega dt_sub at the cap ', SQRT(omega2)*dt/REAL(RIGID_MAX_SUBSTEPS, wp), & + '; the explicit step is unstable above 2): reduce dtM.' + END IF + !$OMP END CRITICAL (cd_substep_cap_warning) ELSE IF (ratio > CD_ONE) THEN nsub = CEILING(ratio) END IF @@ -19951,8 +20171,9 @@ END FUNCTION rigid_substep_count SUBROUTINE step_rod_system(system, points, opts, rod_state, time, dt, converged, stalled, n_iter, ErrStat, ErrMsg, & work, bathymetry, host_mask, host_q, host_v, host_a, host_start) !! Advance rods and lines from time - dt to time: step_rod_once, sub-cycled so that the - !! explicit central-difference rod position resolves the stiffest rod-mooring mode - !! (rigid_substep_count). converged is the AND and stalled the OR over the sub-steps. + !! explicit central-difference rod position resolves the stiffest rod-mooring mode and the + !! swing of a pinned rod about its pin (rigid_substep_count). converged is the AND and + !! stalled the OR over the sub-steps. TYPE(CD_SystemType), INTENT(INOUT) :: system TYPE(DeckPoint), INTENT(IN) :: points(:) TYPE(DeckOptions), INTENT(IN) :: opts @@ -19969,12 +20190,14 @@ SUBROUTINE step_rod_system(system, points, opts, rod_state, time, dt, converged, LOGICAL, INTENT(IN), OPTIONAL :: host_mask(:) REAL(wp), INTENT(IN), OPTIONAL :: host_q(:), host_v(:), host_a(:) - INTEGER :: ir, nsub, isub, it, base_a, base_b, k - ! host_start: step-start state of the host-driven rods (see step_rigid6_system) + INTEGER :: ir, nsub, isub, it, base_a, base_b + ! host_start: step-start state of the Coupled/Vessel rods (see step_rigid6_system); a + ! host-pinned rod carries its step-start pin itself (RodState%pin0) TYPE(RodState), INTENT(IN), OPTIONAL :: host_start(:) REAL(wp), ALLOCATABLE :: hk_end(:, :) - LOGICAL :: conv_s, stall_s - REAL(wp) :: omega2, arms(3, 2), mass6(6), added6(6, 6), drag6(6, 6), f_dummy(3), m_dummy(3) + LOGICAL :: conv_s, stall_s, host_pins + REAL(wp) :: omega2, arms(3, 2), mass6(6), k6c(6), w2_pin, shift(3) + TYPE(RodState) :: rod0 REAL(wp), ALLOCATABLE :: q0h(:), v0h(:), a0h(:) converged = .TRUE. @@ -19982,28 +20205,57 @@ SUBROUTINE step_rod_system(system, points, opts, rod_state, time, dt, converged, n_iter = 0 omega2 = CD_ZERO DO ir = 1, SIZE(rod_state) - IF (.NOT. rod_state(ir)%is_free) CYCLE + IF (.NOT. (rod_state(ir)%is_free .OR. rod_state(ir)%is_pinned)) CYCLE arms(:, 1) = MATMUL(rod_state(ir)%rot_mat, [-rod_state(ir)%half_length, CD_ZERO, CD_ZERO]) arms(:, 2) = -arms(:, 1) - base_a = system_point_base(system, points(rod_state(ir)%point_a_index)%id) - base_b = system_point_base(system, points(rod_state(ir)%point_b_index)%id) - ! structural inertia plus the rod's wet added mass (its 6x6 added-mass diagonal) - CALL rod_environment_force(rod_state(ir), opts, time - dt, f_dummy, m_dummy, added6, drag6, ErrStat, ErrMsg) + base_a = rod_end_base(system, points, rod_state(ir)%point_a_index) + base_b = rod_end_base(system, points, rod_state(ir)%point_b_index) + ! the rod's own terms (rod_estimate_terms): a free rod's structural plus added mass with its + ! seabed contact and waterplane stiffness; a pinned rod only turns about its pin, so its line + ! ends act through their arms from the pin on its rotational inertia about the pin (the + ! translational entries stay zero, so rigid_omega2_estimate skips them), and its weight, + ! buoyancy, pin acceleration, seabed contact and waterplane make it a compound pendulum even + ! without a line, whose squared frequency w2_pin adds to that of the lines + IF (rod_state(ir)%is_host_pinned) THEN + ! the host has already placed the pin at t + dt: the rod at its step-start pin (pin0) is + ! bounded with it, so that a step whose pin crosses the free surface keeps the restoring + ! of the wetting it starts from (and of its seabed contact) + rod0 = rod_state(ir) + rod0%r = rod0%r + (rod0%pin0 - rod0%pin) + rod0%pin = rod0%pin0 + CALL rod_estimate_terms(rod_state(ir), opts, time - dt, dt, mass6, k6c, w2_pin, shift, ErrStat, ErrMsg, & + bathymetry, rod_start=rod0) + ELSE + CALL rod_estimate_terms(rod_state(ir), opts, time - dt, dt, mass6, k6c, w2_pin, shift, ErrStat, ErrMsg, & + bathymetry) + END IF IF (ErrStat /= CD_DECKDRV_OK) RETURN - mass6(1:3) = rod_state(ir)%mass - mass6(4:6) = global_inertia_diag(rod_state(ir)%rot_mat, rod_state(ir)%inertia) - DO k = 1, 6 - mass6(k) = mass6(k) + MAX(CD_ZERO, added6(k, k)) - END DO - omega2 = MAX(omega2, rigid_omega2_estimate(system, [base_a, base_b], arms, mass6)) + IF (rod_state(ir)%is_pinned) THEN + arms(:, 1) = arms(:, 1) + shift + arms(:, 2) = arms(:, 2) + shift + END IF + omega2 = MAX(omega2, rigid_omega2_estimate(system, [base_a, base_b], arms, mass6, k6c) + w2_pin) END DO nsub = rigid_substep_count(omega2, dt) CALL host_substep_start(system, nsub, q0h, v0h, a0h, ErrStat, ErrMsg, host_mask) IF (ErrStat /= CD_DECKDRV_OK) RETURN + ! A host-pinned rod without a committed acceleration (the first step) takes its starting + ! acceleration with its pin at the step start: the host has already placed the pin at + ! t + dt, so the rods go back to their step-start pin (pin0, which the rod state carries; + ! no staged copy is needed) for it and return to t + dt after it. + host_pins = ANY(rod_state%is_host_pinned) + IF (ANY(rod_state%is_host_pinned .AND. .NOT. rod_state%accel_valid)) THEN + CALL save_host_end_rod(rod_state, hk_end) + CALL interp_host_pins(rod_state, hk_end, CD_ZERO) + CALL rod_start_accelerations(system, points, opts, rod_state, time - dt, work, ErrStat, ErrMsg, bathymetry) + IF (ErrStat /= CD_DECKDRV_OK) RETURN + CALL interp_host_pins(rod_state, hk_end, CD_ONE) + END IF DO isub = 1, nsub - IF (nsub > 1 .AND. PRESENT(host_start)) THEN + IF (nsub > 1 .AND. (PRESENT(host_start) .OR. host_pins)) THEN IF (isub == 1) CALL save_host_end_rod(rod_state, hk_end) - CALL interp_host_rod(rod_state, host_start, hk_end, REAL(isub, wp)/REAL(nsub, wp)) + IF (PRESENT(host_start)) CALL interp_host_rod(rod_state, host_start, hk_end, REAL(isub, wp)/REAL(nsub, wp)) + IF (host_pins) CALL interp_host_pins(rod_state, hk_end, REAL(isub, wp)/REAL(nsub, wp)) END IF IF (.NOT. PRESENT(host_mask)) THEN CALL step_rod_once(system, points, opts, rod_state, time - dt + REAL(isub, wp)*dt/REAL(nsub, wp), & @@ -20024,6 +20276,10 @@ SUBROUTINE step_rod_system(system, points, opts, rod_state, time, dt, converged, n_iter = n_iter + it IF (ErrStat /= CD_DECKDRV_OK) RETURN END DO + ! the committed pin of a host-pinned rod starts its next step + DO ir = 1, SIZE(rod_state) + IF (rod_state(ir)%is_host_pinned) CALL set_rod_pin_start(rod_state(ir)) + END DO END SUBROUTINE step_rod_system SUBROUTINE save_host_end_rigid(rigid, hk) @@ -20073,20 +20329,22 @@ SUBROUTINE interp_host_rigid(rigid, start, hk, s) END SUBROUTINE interp_host_rigid SUBROUTINE save_host_end_rod(rods, hk) - !! Rod twin of save_host_end_rigid. + !! Rod twin of save_host_end_rigid; rows 25 to 33 hold the pin, pin velocity and pin + !! acceleration (the host kinematics of a host-pinned rod). TYPE(RodState), INTENT(IN) :: rods(:) REAL(wp), ALLOCATABLE, INTENT(INOUT) :: hk(:, :) INTEGER :: ir IF (ALLOCATED(hk)) DEALLOCATE (hk) - ALLOCATE (hk(24, SIZE(rods))) + ALLOCATE (hk(33, SIZE(rods))) DO ir = 1, SIZE(rods) hk(:, ir) = [rods(ir)%r, rods(ir)%v, rods(ir)%a, rods(ir)%omega, rods(ir)%alpha, & - RESHAPE(rods(ir)%rot_mat, [9])] + RESHAPE(rods(ir)%rot_mat, [9]), rods(ir)%pin, rods(ir)%pin_v, rods(ir)%pin_a] END DO END SUBROUTINE save_host_end_rod SUBROUTINE interp_host_rod(rods, start, hk, s) - !! Rod twin of interp_host_rigid (the rod centre and frame of each host-driven rod). + !! Rod twin of interp_host_rigid (the rod centre and frame of each Coupled/Vessel rod; a + !! host-pinned rod moves its pin in interp_host_pins). TYPE(RodState), INTENT(INOUT) :: rods(:) TYPE(RodState), INTENT(IN) :: start(:) REAL(wp), INTENT(IN) :: hk(:, :), s @@ -20114,10 +20372,43 @@ SUBROUTINE interp_host_rod(rods, start, hk, s) END DO END SUBROUTINE interp_host_rod + SUBROUTINE interp_host_pins(rods, hk, s) + !! Place the pin of every host-pinned rod at fraction s of its step and move the rod with it + !! (mb_snap_pinned); the rod keeps its own rotation. Position, velocity and acceleration are + !! each linear between the step-start pin (pin0, the End A motion of the committed rod state, + !! as the line ends see it) and the t + dt host values in hk (rows 25 to 33); s = 1 restores + !! the t + dt pin. This is the interpolation the sub-steps give every other host node (the + !! host fairleads of the lines and the Coupled rods), so points on one platform keep their + !! relative positions under a translation inside the step. It is second order: between exact + !! end values a linear position deviates from the host path by at most dt^2 max|a|/8, the + !! velocity by dt^2 max|da/dt|/8 and the acceleration by dt^2 max|d2a/dt2|/8, and the + !! interpolated velocity is not the derivative of the interpolated position (the two differ + !! by O(dt max|a|)). A constant-velocity pin is reproduced exactly. + TYPE(RodState), INTENT(INOUT) :: rods(:) + REAL(wp), INTENT(IN) :: hk(:, :), s + INTEGER :: ir + TYPE(RigidBodyState) :: no_parent(0) + DO ir = 1, SIZE(rods) + IF (.NOT. rods(ir)%is_host_pinned) CYCLE + IF (s >= CD_ONE) THEN + rods(ir)%pin = hk(25:27, ir) + rods(ir)%pin_v = hk(28:30, ir) + rods(ir)%pin_a = hk(31:33, ir) + ELSE + rods(ir)%pin = rods(ir)%pin0 + s*(hk(25:27, ir) - rods(ir)%pin0) + rods(ir)%pin_v = rods(ir)%pin0_v + s*(hk(28:30, ir) - rods(ir)%pin0_v) + rods(ir)%pin_a = rods(ir)%pin0_a + s*(hk(31:33, ir) - rods(ir)%pin0_a) + END IF + CALL mb_snap_pinned(rods(ir), no_parent) + END DO + END SUBROUTINE interp_host_pins + SUBROUTINE step_rod_once(system, points, opts, rod_state, time, dt, converged, stalled, n_iter, ErrStat, ErrMsg, & work, bathymetry, host_mask, host_q, host_v, host_a) - !! One staggered central-difference step of the free rods and their lines (the scheme of - !! step_rigid6_once; the rod adds its 6x6 added-mass matrix and distributed drag). + !! One staggered central-difference step of the free and pinned rods and their lines (the + !! scheme of step_rigid6_once; the rod adds its 6x6 added-mass matrix and distributed drag). + !! A pinned rod (fixed pin, or a host-pinned rod whose pin the host has placed at t + dt) + !! integrates its rotation about the pin only. TYPE(CD_SystemType), INTENT(INOUT) :: system TYPE(DeckPoint), INTENT(IN) :: points(:) TYPE(DeckOptions), INTENT(IN) :: opts @@ -20136,8 +20427,9 @@ SUBROUTINE step_rod_once(system, points, opts, rod_state, time, dt, converged, s REAL(wp), INTENT(IN), OPTIONAL :: host_q(:), host_v(:), host_a(:) INTEGER :: ir, es - REAL(wp) :: dv0(6), acc(3), alpha(3) + REAL(wp) :: dv0(6), acc(3), alpha(3), arm(3) CHARACTER(160) :: em + TYPE(RigidBodyState) :: no_parent(0) converged = .FALSE. stalled = .FALSE. @@ -20145,24 +20437,10 @@ SUBROUTINE step_rod_once(system, points, opts, rod_state, time, dt, converged, s ErrStat = CD_DECKDRV_OK ErrMsg = '' CALL ensure_rod_step_workspace(work, system%n_system_coupled_dof, SIZE(rod_state), SIZE(system%points)) - ! 0. a free rod without a committed acceleration (the first step) gets the instantaneous - ! one from the current line loads, so the predictor starts from the actual a_0 - IF (.NOT. ALL(rod_state%accel_valid .OR. .NOT. rod_state%is_free)) THEN - CALL rigid_start_loads(system, work%q(1:system%n_system_coupled_dof), work%v(1:system%n_system_coupled_dof), & - work%a(1:system%n_system_coupled_dof), work%loads(1:system%n_system_coupled_dof), & - work%dload_da, ErrStat, ErrMsg) - IF (ErrStat /= CD_DECKDRV_OK) RETURN - DO ir = 1, SIZE(rod_state) - IF (rod_state(ir)%accel_valid .OR. .NOT. rod_state(ir)%is_free) CYCLE - CALL rod_body_acceleration(system, points, opts, rod_state(ir), time - dt, CD_ZERO, & - [CD_ZERO, CD_ZERO, CD_ZERO, CD_ZERO, CD_ZERO, CD_ZERO], work, acc, alpha, & - ErrStat, ErrMsg, bathymetry) - IF (ErrStat /= CD_DECKDRV_OK) RETURN - rod_state(ir)%a = acc - rod_state(ir)%alpha = alpha - rod_state(ir)%accel_valid = .TRUE. - END DO - END IF + ! 0. a free or pinned rod without a committed acceleration (the first step) gets the + ! instantaneous one from the current line loads, so the predictor starts from the actual a_0 + CALL rod_start_accelerations(system, points, opts, rod_state, time - dt, work, ErrStat, ErrMsg, bathymetry) + IF (ErrStat /= CD_DECKDRV_OK) RETURN work%old_rods = rod_state work%old_points = system%points CALL CD_Get_System_CoupledMotion(system, work%q(1:system%n_system_coupled_dof), & @@ -20175,10 +20453,12 @@ SUBROUTINE step_rod_once(system, points, opts, rod_state, time, dt, converged, s END IF CALL overlay_host_motion(work%q(1:system%n_system_coupled_dof), work%v(1:system%n_system_coupled_dof), & work%a(1:system%n_system_coupled_dof), host_mask, host_q, host_v, host_a) - ! 1. predictor for the free rods (central difference; see step_rigid6_once for the - ! staggered predictor-corrector) and the line step to t + dt + ! 1. predictor for the free and pinned rods (central difference; see step_rigid6_once for + ! the staggered predictor-corrector) and the line step to t + dt. A pinned rod advances its + ! rotation only: its centre then follows the pin at t + dt (mb_snap_pinned), so End A + ! drives its lines with the pin motion exactly. DO ir = 1, SIZE(rod_state) - IF (.NOT. rod_state(ir)%is_free) THEN + IF (.NOT. (rod_state(ir)%is_free .OR. rod_state(ir)%is_pinned)) THEN IF (.NOT. rod_state(ir)%is_prescribed) THEN rod_state(ir)%v = CD_ZERO rod_state(ir)%a = CD_ZERO @@ -20196,6 +20476,7 @@ SUBROUTINE step_rod_once(system, points, opts, rod_state, time, dt, converged, s ErrMsg = 'CableDyn_DeckDriver: rod finite-rotation update failed: '//TRIM(em) RETURN END IF + CALL mb_snap_pinned(rod_state(ir), no_parent) END DO CALL scatter_rod_point_motion(system, points, rod_state, work%q(1:system%n_system_coupled_dof), & work%v(1:system%n_system_coupled_dof), & @@ -20220,7 +20501,7 @@ SUBROUTINE step_rod_once(system, points, opts, rod_state, time, dt, converged, s ErrMsg = 'CableDyn_DeckDriver: rod line-system step failed: '//TRIM(em) RETURN END IF - IF (.NOT. ANY(rod_state%is_free)) RETURN + IF (.NOT. ANY(rod_state%is_free .OR. rod_state%is_pinned)) RETURN ! 2. corrector from the end-of-step line loads at the predictor CALL CD_Calc_System_CoupledLoads(system, work%loads(1:system%n_system_coupled_dof), es, em) IF (es /= CD_SYSTEM_OK) THEN @@ -20240,9 +20521,18 @@ SUBROUTINE step_rod_once(system, points, opts, rod_state, time, dt, converged, s END IF DO ir = 1, SIZE(rod_state) - IF (.NOT. rod_state(ir)%is_free) CYCLE - dv0(1:3) = -CD_RIGID_NEWMARK_GAMMA*dt*work%old_rods(ir)%a + IF (.NOT. (rod_state(ir)%is_free .OR. rod_state(ir)%is_pinned)) CYCLE dv0(4:6) = -CD_RIGID_NEWMARK_GAMMA*dt*work%old_rods(ir)%alpha + IF (rod_state(ir)%is_pinned) THEN + ! The predictor centre velocity is the pin's plus w x r, so the final one differs from it + ! by gamma dt (alpha_{n+1} - alpha_n) x r only: with x = T y + b (rigid_coupled_acceleration) + ! that is dv0 + gamma dt x for dv0 = -gamma dt (alpha_n x r + b), b = a_p + w x (w x r). + arm = rod_state(ir)%r - rod_state(ir)%pin + dv0(1:3) = -CD_RIGID_NEWMARK_GAMMA*dt*(cross3(work%old_rods(ir)%alpha, arm) + rod_state(ir)%pin_a + & + cross3(rod_state(ir)%omega, cross3(rod_state(ir)%omega, arm))) + ELSE + dv0(1:3) = -CD_RIGID_NEWMARK_GAMMA*dt*work%old_rods(ir)%a + END IF CALL rod_body_acceleration(system, points, opts, rod_state(ir), time, dt, dv0, work, acc, alpha, & ErrStat, ErrMsg, bathymetry) IF (ErrStat /= CD_DECKDRV_OK) THEN @@ -20264,6 +20554,7 @@ SUBROUTINE step_rod_once(system, points, opts, rod_state, time, dt, converged, s END IF rod_state(ir)%a = acc rod_state(ir)%alpha = alpha + CALL mb_snap_pinned(rod_state(ir), no_parent) END DO ! the RodA/B point records follow the corrected rods CALL scatter_rod_point_motion(system, points, rod_state, work%q(1:system%n_system_coupled_dof), & @@ -20282,12 +20573,13 @@ SUBROUTINE step_rod_once(system, points, opts, rod_state, time, dt, converged, s END SUBROUTINE step_rod_once SUBROUTINE rod_body_acceleration(system, points, opts, rod, time, dt, dv0, work, acc, alpha, ErrStat, ErrMsg, & - bathymetry) - !! The acceleration of a free rod at its current state and time from its weight, the - !! distributed Morison / buoyancy loads (rod_environment_force), the seabed contact and the - !! line loads in work%loads (evaluated with the attachment accelerations work%a, end-node + bathymetry, pin_load) + !! The acceleration of a free or pinned rod at its current state and time from its weight, + !! the distributed Morison / buoyancy loads (rod_environment_force), the seabed contact and + !! the line loads in work%loads (evaluated with the attachment accelerations work%a, end-node !! inertia derivative work%dload_da): rigid_coupled_acceleration with the step dt and - !! velocity offset dv0 (dt = 0, dv0 = 0: the instantaneous acceleration). + !! velocity offset dv0 (dt = 0, dv0 = 0: the instantaneous acceleration). A pinned rod turns + !! about its pin, which moves with rod%pin_a (zero for a fixed pin). TYPE(CD_SystemType), INTENT(IN) :: system TYPE(DeckPoint), INTENT(IN) :: points(:) TYPE(DeckOptions), INTENT(IN) :: opts @@ -20298,6 +20590,8 @@ SUBROUTINE rod_body_acceleration(system, points, opts, rod, time, dt, dv0, work, INTEGER, INTENT(OUT) :: ErrStat CHARACTER(*), INTENT(OUT) :: ErrMsg TYPE(CD_BathymetryType), INTENT(IN), OPTIONAL :: bathymetry + ! pin_load (a pinned rod): the force the rod exerts on its pin (rigid_coupled_acceleration) + REAL(wp), INTENT(OUT), OPTIONAL :: pin_load(3) INTEGER :: base_a, base_b REAL(wp) :: f_body(3), f_env(3), f_seabed(3), m_env(3), m_seabed(3), m_global(3) @@ -20307,8 +20601,8 @@ SUBROUTINE rod_body_acceleration(system, points, opts, rod, time, dt, dv0, work, alpha = CD_ZERO att_arm(:, 1) = MATMUL(rod%rot_mat, [-rod%half_length, CD_ZERO, CD_ZERO]) att_arm(:, 2) = -att_arm(:, 1) - base_a = system_point_base(system, points(rod%point_a_index)%id) - base_b = system_point_base(system, points(rod%point_b_index)%id) + base_a = rod_end_base(system, points, rod%point_a_index) + base_b = rod_end_base(system, points, rod%point_b_index) f_a = CD_ZERO f_b = CD_ZERO IF (base_a >= 0) f_a = work%loads(base_a + 1:base_a + 3) @@ -20323,11 +20617,158 @@ SUBROUTINE rod_body_acceleration(system, points, opts, rod, time, dt, dv0, work, IF (ErrStat /= CD_DECKDRV_OK) RETURN f_body = f_body + f_env + f_seabed m_global = m_global + m_env + m_seabed - CALL rigid_coupled_acceleration(work%dload_da, dt, work%a(1:system%n_system_coupled_dof), [base_a, base_b], & - att_arm, rod%mass, added6, rod%inertia, rod%rot_mat, rod%omega, f_body, & - m_global, dv0, drag6 + contact_dv, acc, alpha, ErrStat, ErrMsg) + IF (rod%is_pinned) THEN + CALL rigid_coupled_acceleration(work%dload_da, dt, work%a(1:system%n_system_coupled_dof), [base_a, base_b], & + att_arm, rod%mass, added6, rod%inertia, rod%rot_mat, rod%omega, f_body, & + m_global, dv0, drag6 + contact_dv, acc, alpha, ErrStat, ErrMsg, & + pin_arm=rod%r - rod%pin, pin_acc=rod%pin_a, pin_load=pin_load) + ELSE + CALL rigid_coupled_acceleration(work%dload_da, dt, work%a(1:system%n_system_coupled_dof), [base_a, base_b], & + att_arm, rod%mass, added6, rod%inertia, rod%rot_mat, rod%omega, f_body, & + m_global, dv0, drag6 + contact_dv, acc, alpha, ErrStat, ErrMsg) + END IF END SUBROUTINE rod_body_acceleration + SUBROUTINE rod_start_accelerations(system, points, opts, rod_state, time, work, ErrStat, ErrMsg, bathymetry) + !! The instantaneous acceleration of every free or pinned rod without a committed one (the + !! first step) from the current line loads at time, so the predictor starts from the + !! actual a_0 (rod_body_acceleration at dt = 0). + TYPE(CD_SystemType), INTENT(INOUT) :: system + TYPE(DeckPoint), INTENT(IN) :: points(:) + TYPE(DeckOptions), INTENT(IN) :: opts + TYPE(RodState), INTENT(INOUT) :: rod_state(:) + REAL(wp), INTENT(IN) :: time + TYPE(RodStepWorkspace), INTENT(INOUT) :: work + INTEGER, INTENT(OUT) :: ErrStat + CHARACTER(*), INTENT(OUT) :: ErrMsg + TYPE(CD_BathymetryType), INTENT(IN), OPTIONAL :: bathymetry + INTEGER :: ir + REAL(wp) :: acc(3), alpha(3) + TYPE(RigidBodyState) :: no_parent(0) + + ErrStat = CD_DECKDRV_OK + ErrMsg = '' + IF (ALL(rod_state%accel_valid .OR. .NOT. (rod_state%is_free .OR. rod_state%is_pinned))) RETURN + CALL ensure_rod_step_workspace(work, system%n_system_coupled_dof, SIZE(rod_state), SIZE(system%points)) + CALL rigid_start_loads(system, work%q(1:system%n_system_coupled_dof), work%v(1:system%n_system_coupled_dof), & + work%a(1:system%n_system_coupled_dof), work%loads(1:system%n_system_coupled_dof), & + work%dload_da, ErrStat, ErrMsg) + IF (ErrStat /= CD_DECKDRV_OK) RETURN + DO ir = 1, SIZE(rod_state) + IF (rod_state(ir)%accel_valid .OR. .NOT. (rod_state(ir)%is_free .OR. rod_state(ir)%is_pinned)) CYCLE + CALL rod_body_acceleration(system, points, opts, rod_state(ir), time, CD_ZERO, & + [CD_ZERO, CD_ZERO, CD_ZERO, CD_ZERO, CD_ZERO, CD_ZERO], work, acc, alpha, & + ErrStat, ErrMsg, bathymetry) + IF (ErrStat /= CD_DECKDRV_OK) RETURN + rod_state(ir)%a = acc + rod_state(ir)%alpha = alpha + rod_state(ir)%accel_valid = .TRUE. + CALL mb_snap_pinned(rod_state(ir), no_parent) + END DO + END SUBROUTINE rod_start_accelerations + + FUNCTION pinned_rotational_inertia(rod, added6) RESULT(mp) + !! The 3x3 rotational inertia of a pinned rod about its pin (global axes): the structural + !! and added mass about the centre, T^T M T with T = [-[r]x; I] and r from the pin to the + !! centre (the reduction of rigid_coupled_acceleration). + TYPE(RodState), INTENT(IN) :: rod + REAL(wp), INTENT(IN) :: added6(6, 6) + REAL(wp) :: mp(3, 3) + REAL(wp) :: m6(6, 6), t63(6, 3), ig(3, 3) + INTEGER :: k + ig = CD_ZERO + DO k = 1, 3 + ig(k, k) = rod%inertia(k) + END DO + m6 = added6 + DO k = 1, 3 + m6(k, k) = m6(k, k) + rod%mass + END DO + m6(4:6, 4:6) = m6(4:6, 4:6) + MATMUL(rod%rot_mat, MATMUL(ig, TRANSPOSE(rod%rot_mat))) + t63 = CD_ZERO + t63(1:3, :) = -skew3(rod%r - rod%pin) + DO k = 1, 3 + t63(3 + k, k) = CD_ONE + END DO + mp = MATMUL(TRANSPOSE(t63), MATMUL(m6, t63)) + END FUNCTION pinned_rotational_inertia + + FUNCTION pinned_swing_omega2(rod, opts, mp, added6, buoyancy, mp_start, added_start, buoy_start, k_extra) & + RESULT(omega2) + !! Squared frequency of a pinned rod swinging about its pin under its weight, its buoyancy + !! and the pin acceleration, for the sub-step estimate of step_rod_system (added there to + !! the line estimate). Vertical loads f_i at p_i from the pin turn with the rod; the moment + !! of the loads about the pin has the rotational stiffness -[e_z]x [P]x with P = sum f_i p_i, + !! whose length |P| does not depend on the pose for a fixed load distribution and is the + !! swing stiffness at the bottom of the compound pendulum: |W d_g - B d_b| for a weight W and + !! a buoyancy B on the axis at d_g and d_b from the pin (omega^2 about 3 g/(2 L) for a dry + !! uniform rod). The buoyancy is the wet distribution of the evaluated pose + !! (rod_environment_force); the change of a surface-piercing rod's wet length with its tilt + !! enters through k_extra (rod_hydrostatic_stiffness). The pin acceleration a_p loads the + !! rod with -M_t a_p, whose + !! stiffness is |a_p| |G|, G = [r]x M_tt + M_rt the first moment of the translational inertia + !! (structural and added) about the pin: c [q]x for a rod (c = m d_g when dry), so + !! |G| = ||G||_F/sqrt(2), and the hanging dry rod sees the effective gravity bound + !! g + |a_p| >= |g - a_p|. |a_p| is the larger of the step-start and end-of-step host pin + !! accelerations (zero for a fixed pin). The inertia is the smaller principal rotational + !! inertia about the pin across the rod axis (mp: structural and added mass). + !! + !! mp_start, added_start and buoy_start (a host-pinned rod) are the inertia, added mass and + !! buoyancy of the same rod at its step-start pin: the stiffness is then the larger and the + !! inertia the smaller of the two poses. The sub-steps move the pin along a straight line, so + !! at the rod's orientation, with the surface held over the step, every slice's clearance to + !! the surface changes monotonically and in the same sense: each slice's wet area, and with + !! it the net first moment W d_g - B d_b about the pin and the added mass, change + !! monotonically, and the two ends bound the path, a step whose pin crosses the free surface + !! included. k_extra adds a further angular stiffness about the pin (the seabed contact of + !! rod_contact_stiffness). + TYPE(RodState), INTENT(IN) :: rod + TYPE(DeckOptions), INTENT(IN) :: opts + REAL(wp), INTENT(IN) :: mp(3, 3), added6(6, 6), buoyancy(4) + REAL(wp), INTENT(IN), OPTIONAL :: mp_start(3, 3), added_start(6, 6), buoy_start(4), k_extra + REAL(wp) :: omega2 + REAL(wp) :: arm(3), a_pin, k_swing, i_min + + omega2 = CD_ZERO + arm = rod%r - rod%pin + a_pin = MAX(NORM2(rod%pin_a), NORM2(rod%pin0_a)) + k_swing = swing_stiffness(added6, buoyancy) + i_min = cross_inertia(mp) + IF (PRESENT(mp_start) .AND. PRESENT(added_start) .AND. PRESENT(buoy_start)) THEN + k_swing = MAX(k_swing, swing_stiffness(added_start, buoy_start)) + i_min = MIN(i_min, cross_inertia(mp_start)) + END IF + IF (PRESENT(k_extra)) k_swing = k_swing + k_extra + IF (i_min > CD_ZERO) omega2 = k_swing/i_min + + CONTAINS + + REAL(wp) FUNCTION swing_stiffness(added, buoy) RESULT(k) + !! |P| plus the pin-acceleration term for one pose's added mass and buoyancy. + REAL(wp), INTENT(IN) :: added(6, 6), buoy(4) + REAL(wp) :: p(3), g3(3, 3) + ! weight at the centre, buoyancy at its first moment about the centre + p = (buoy(1) - rod%mass*opts%g)*arm + buoy(2:4) + k = NORM2(p) + IF (a_pin > CD_ZERO) THEN + g3 = rod%mass*skew3(arm) + MATMUL(skew3(arm), added(1:3, 1:3)) + added(4:6, 1:3) + k = k + a_pin*NORM2(g3)/SQRT(2.0_wp) + END IF + END FUNCTION swing_stiffness + + REAL(wp) FUNCTION cross_inertia(m3) RESULT(i) + !! The smaller principal value of m3 in the plane across the rod axis. + REAL(wp), INTENT(IN) :: m3(3, 3) + REAL(wp) :: e1(3), e2(3), m11, m22, m12 + e1 = rod%rot_mat(:, 2) + e2 = rod%rot_mat(:, 3) + m11 = DOT_PRODUCT(e1, MATMUL(m3, e1)) + m22 = DOT_PRODUCT(e2, MATMUL(m3, e2)) + m12 = DOT_PRODUCT(e1, MATMUL(m3, e2)) + i = 0.5_wp*(m11 + m22) - SQRT(0.25_wp*(m11 - m22)**2 + m12**2) + END FUNCTION cross_inertia + END FUNCTION pinned_swing_omega2 + SUBROUTINE step_prescribed_rod_system(system, points, opts, motion, rod_state, time_index, time, dt, & converged, stalled, n_iter, ErrStat, ErrMsg, work, hydro_work, bathymetry) !! Impose the motionFile rows on prescribed rods, then march the free rods and lines. The @@ -20495,8 +20936,9 @@ SUBROUTINE rod_seabed_contact(rod, opts, force, moment, load_dv, ErrStat, ErrMsg !! force and a moment about the rod centre, so a rod lying on the bed is supported along !! its whole length with the distributed rotational stiffness. load_dv returns the 6x6 !! derivative of (force, moment) w.r.t. the rod (velocity, angular velocity) from the - !! active normal dampers, which the rigid-body step applies implicitly; the springs and the - !! regularized friction act at the evaluated position and velocity. + !! active normal dampers and the regularised friction (as a damper of its secant coefficient + !! mu N/sqrt(v^2 + vreg^2)), which the + !! rigid-body step applies implicitly; the springs act at the evaluated position. TYPE(RodState), INTENT(IN) :: rod TYPE(DeckOptions), INTENT(IN) :: opts REAL(wp), INTENT(OUT) :: force(3), moment(3), load_dv(6, 6) @@ -20541,6 +20983,14 @@ SUBROUTINE rod_seabed_contact(rod, opts, force, moment, load_dv, ErrStat, ErrMsg denom = SQRT(v_eval(1)**2 + v_eval(2)**2 + vreg**2) f_i(1) = -opts%friction_mu*normal*v_eval(1)/denom f_i(2) = -opts%friction_mu*normal*v_eval(2)/denom + ! the regularised friction is a damper c = mu N/sqrt(v^2 + vreg^2), mu N/vreg at rest, far + ! stiffer than the step allows explicitly: it enters the implicit velocity derivative as + ! that secant coefficient, f = -c v at the end-of-step velocity (exact at the evaluated + ! velocity; the tangent would vanish where the trapezoidal acceleration rings) + blk = CD_ZERO + blk(1, 1) = -opts%friction_mu*normal/denom + blk(2, 2) = blk(1, 1) + CALL add_arm_block6(load_dv, blk, arm) END IF f_i(3) = normal force = force + f_i @@ -20548,6 +20998,304 @@ SUBROUTINE rod_seabed_contact(rod, opts, force, moment, load_dv, ErrStat, ErrMsg END DO END SUBROUTINE rod_seabed_contact + SUBROUTINE rod_contact_stiffness(rod, opts, ref, dt, k6, ErrStat, ErrMsg, bathymetry) + !! Add to k6 the diagonal stiffness, about the point ref in global axes, of the seabed contact + !! springs of rod_seabed_contact (kBot d dl at each of its stations) that can act within the + !! coming step of length dt (contact_within_reach, with the station's rigid-body velocity + !! v + w x s, the bound |a| + |alpha x s| + |w|^2 |s| + g of its acceleration and the rod + !! radius), so a rod about to land, sliding towards a shallower bed or turning a station + !! onto it is covered as well as one already on the bed. A vertical spring k at arm a from + !! ref adds k to the heave entry and k a_y^2, k a_x^2 to the roll and pitch entries (the bound + !! k |a x e_z|^2 of its rotational stiffness about any axis is their sum). The normal damper + !! and the friction are left out: the step applies the damper implicitly, and the + !! regularised friction is bounded by mu times the normal load. + TYPE(RodState), INTENT(IN) :: rod + TYPE(DeckOptions), INTENT(IN) :: opts + REAL(wp), INTENT(IN) :: ref(3), dt + REAL(wp), INTENT(INOUT) :: k6(6) + INTEGER, INTENT(OUT) :: ErrStat + CHARACTER(*), INTENT(OUT) :: ErrMsg + TYPE(CD_BathymetryType), INTENT(IN), OPTIONAL :: bathymetry + INTEGER :: i, ncontact + REAL(wp) :: s, dl, arm(3), r_eval(3), k, a_ref(3), a_rigid + LOGICAL :: within + + ErrStat = CD_DECKDRV_OK + ErrMsg = '' + IF (.NOT. (opts%kbot > CD_ZERO .AND. rod%diam > CD_ZERO)) RETURN + ncontact = MAX(20, rod%nsegs) + DO i = 0, ncontact + s = -rod%half_length + rod%length*REAL(i, wp)/REAL(ncontact, wp) + dl = rod%length/REAL(ncontact, wp) + IF (i == 0 .OR. i == ncontact) dl = 0.5_wp*dl + arm = MATMUL(rod%rot_mat, [s, CD_ZERO, CD_ZERO]) + r_eval = rod%r + arm + a_rigid = NORM2(rod%a) + NORM2(cross3(rod%alpha, arm)) + SUM(rod%omega**2)*ABS(s) + CALL contact_within_reach(r_eval, rod%v + cross3(rod%omega, arm), a_rigid, 0.5_wp*rod%diam, dt, opts, & + within, ErrStat, ErrMsg, bathymetry) + IF (ErrStat /= CD_DECKDRV_OK) RETURN + IF (.NOT. within) CYCLE + k = opts%kbot*rod%diam*dl + a_ref = r_eval - ref + k6(3) = k6(3) + k + k6(4) = k6(4) + k*a_ref(2)**2 + k6(5) = k6(5) + k*a_ref(1)**2 + END DO + END SUBROUTINE rod_contact_stiffness + + SUBROUTINE contact_within_reach(x, v, a_rigid, radius, dt, opts, within, ErrStat, ErrMsg, bathymetry) + !! Whether a contact point at x (velocity v, acceleration bounded by a_rigid, the free fall + !! g added) of a body of the given radius about it can meet the seabed within a step dt: its + !! reach dt |v| + dt^2 (a_rigid + g)/2 bounds its travel in every direction, and it counts when + !! its height above the highest floor within that horizontal distance (the depth on a flat + !! seabed, CD_Bathymetry_Max_Floor over the box around the disk on a bathymetry grid) is at + !! most the reach plus the radius. + REAL(wp), INTENT(IN) :: x(3), v(3), a_rigid, radius, dt + TYPE(DeckOptions), INTENT(IN) :: opts + LOGICAL, INTENT(OUT) :: within + INTEGER, INTENT(OUT) :: ErrStat + CHARACTER(*), INTENT(OUT) :: ErrMsg + TYPE(CD_BathymetryType), INTENT(IN), OPTIONAL :: bathymetry + INTEGER :: es + REAL(wp) :: reach, z_max + LOGICAL :: bathy_ready + CHARACTER(160) :: em + + within = .FALSE. + ErrStat = CD_DECKDRV_OK + ErrMsg = '' + reach = dt*NORM2(v) + 0.5_wp*dt*dt*(a_rigid + opts%g) + ! see deck_seabed_floor_at: no short-circuit on the absent OPTIONAL bathymetry + bathy_ready = .FALSE. + IF (PRESENT(bathymetry)) bathy_ready = CD_Bathymetry_Is_Initialized(bathymetry) + IF (bathy_ready) THEN + CALL CD_Bathymetry_Max_Floor(bathymetry, x(1) - reach, x(1) + reach, x(2) - reach, x(2) + reach, z_max, es, em) + IF (es /= CD_BATHY_OK) THEN + CALL fail_solve(ErrStat, ErrMsg, 'deck bathymetry floor bound failed: '//TRIM(em)) + RETURN + END IF + ELSE IF (opts%has_wtrdpth) THEN + z_max = -opts%wtrdpth + ELSE + RETURN + END IF + within = x(3) - z_max <= reach + radius + END SUBROUTINE contact_within_reach + + SUBROUTINE rod_hydrostatic_stiffness(rod, opts, time, ref, dt, k6, near, ErrStat, ErrMsg) + !! Add to k6 a bound of the waterplane (hydrostatic) stiffness of a rod near the free surface + !! within the coming step, about ref in global axes, as rod_contact_stiffness adds its contact: + !! rhoW g D dl at each station (those of rod_contact_stiffness) whose cross-section can cross + !! the surface within the step (its height above the surface within r sin(phi) plus its reach, + !! phi the axis angle from the vertical), and rhoW g pi D^2/4 at each pair of neighbouring + !! stations between which the axis can cross it; together they bound the elliptical + !! waterplane pi r^2/cos(phi) of any crossing. The surface is the host-held or deck wave + !! elevation at the station, still water otherwise. near returns whether any term was added + !! (the rod's added mass then changes within the step and the estimate takes its dry inertia). + TYPE(RodState), INTENT(IN) :: rod + TYPE(DeckOptions), INTENT(IN) :: opts + REAL(wp), INTENT(IN) :: time, ref(3), dt + REAL(wp), INTENT(INOUT) :: k6(6) + LOGICAL, INTENT(OUT) :: near + INTEGER, INTENT(OUT) :: ErrStat + CHARACTER(*), INTENT(OUT) :: ErrMsg + INTEGER :: i, ncontact, es, ih + REAL(wp) :: reach(0:MAX(20, rod%nsegs)), h(0:MAX(20, rod%nsegs)), xs(3, 0:MAX(20, rod%nsegs)) + REAL(wp) :: s, dl, arm(3), x(3), eta, u(3), du(3), tq, lseg, sphi, k, kpair, rmax + CHARACTER(160) :: em + + near = .FALSE. + ErrStat = CD_DECKDRV_OK + ErrMsg = '' + IF (.NOT. (rod%diam > CD_ZERO .AND. opts%rhoW > CD_ZERO)) RETURN + ncontact = MAX(20, rod%nsegs) + lseg = rod%length/REAL(MAX(1, rod%nsegs), wp) + sphi = SQRT(MAX(CD_ZERO, CD_ONE - rod%rot_mat(3, 1)**2)) + DO i = 0, ncontact + s = -rod%half_length + rod%length*REAL(i, wp)/REAL(ncontact, wp) + arm = MATMUL(rod%rot_mat, [s, CD_ZERO, CD_ZERO]) + x = rod%r + arm + eta = CD_ZERO + IF (rod%has_held) THEN + tq = (s + rod%half_length)/lseg + ih = MIN(MAX(1, rod%nsegs) - 1, MAX(0, INT(tq))) + tq = MIN(CD_ONE, MAX(CD_ZERO, tq - REAL(ih, wp))) + eta = (CD_ONE - tq)*rod%held_eta(ih) + tq*rod%held_eta(ih + 1) + ELSE IF (opts%has_wave) THEN + CALL deck_wave_kinematics(opts, x(1), x(2), x(3), time, eta, u, du, es, em) + IF (es /= CD_HYDRO_OK) THEN + CALL fail_solve(ErrStat, ErrMsg, 'rod waterplane estimate: wave kinematics failed: '//TRIM(em)) + RETURN + END IF + END IF + xs(:, i) = x + h(i) = x(3) - eta + reach(i) = dt*NORM2(rod%v + cross3(rod%omega, arm)) + 0.5_wp*dt*dt* & + (NORM2(rod%a) + NORM2(cross3(rod%alpha, arm)) + SUM(rod%omega**2)*ABS(s) + opts%g) + END DO + k = opts%rhoW*opts%g*rod%diam + kpair = opts%rhoW*opts%g*QUARTER_PI*rod%diam**2 + DO i = 0, ncontact + dl = rod%length/REAL(ncontact, wp) + IF (i == 0 .OR. i == ncontact) dl = 0.5_wp*dl + IF (ABS(h(i)) <= 0.5_wp*rod%diam*sphi + reach(i)) CALL add_spring(k*dl, xs(:, i)) + IF (i < ncontact) THEN + rmax = MAX(reach(i), reach(i + 1)) + IF (MIN(h(i), h(i + 1)) - rmax <= CD_ZERO .AND. MAX(h(i), h(i + 1)) + rmax >= CD_ZERO) & + CALL add_spring(kpair, 0.5_wp*(xs(:, i) + xs(:, i + 1))) + END IF + END DO + + CONTAINS + + SUBROUTINE add_spring(kv, xp) + REAL(wp), INTENT(IN) :: kv, xp(3) + REAL(wp) :: a(3) + a = xp - ref + k6(3) = k6(3) + kv + k6(4) = k6(4) + kv*a(2)**2 + k6(5) = k6(5) + kv*a(1)**2 + near = .TRUE. + END SUBROUTINE add_spring + END SUBROUTINE rod_hydrostatic_stiffness + + SUBROUTINE rod_estimate_terms(rod, opts, time, dt, mass6, k6, w2, shift, ErrStat, ErrMsg, bathymetry, & + rod_start, parent) + !! A free or pinned rod's own terms of the sub-step estimate, shared by step_rod_system, the + !! staggered multibody march and the deck without lines. A free rod: its seabed contact + !! (rod_contact_stiffness) and waterplane stiffness (rod_hydrostatic_stiffness) about its + !! centre in k6, over its structural plus added mass in mass6 (structural only near the + !! surface, whose crossing changes the added mass within the step). A pinned rod: its swing + !! about the pin (pinned_swing_omega2, with its contact and waterplane stiffness about the + !! pin) in w2, its rotational inertia about the pin in mass6(4:6) with mass6(1:3) = 0, and + !! shift = r - pin, which carries the arms of its line springs from its centre to its pin. + !! rod_start (a host-pinned rod) is the rod at its step-start pin, bounded together with it. + !! parent (a rod pinned to a body) gives the pin acceleration and, through the reduced mass + !! m m_b/(m + m_b) with the translational added mass left out, a lower bound of the inertia + !! about the pin when the body moves with the swing. + TYPE(RodState), INTENT(IN) :: rod + TYPE(DeckOptions), INTENT(IN) :: opts + REAL(wp), INTENT(IN) :: time, dt + REAL(wp), INTENT(OUT) :: mass6(6), k6(6), w2, shift(3) + INTEGER, INTENT(OUT) :: ErrStat + CHARACTER(*), INTENT(OUT) :: ErrMsg + TYPE(CD_BathymetryType), INTENT(IN), OPTIONAL :: bathymetry + TYPE(RodState), INTENT(IN), OPTIONAL :: rod_start + TYPE(RigidBodyState), INTENT(IN), OPTIONAL :: parent + REAL(wp) :: f(3), m(3), added6(6, 6), drag6(6, 6), buoy(4), mp(3, 3), kh(6), kc, a6(6, 6) + REAL(wp) :: added0(6, 6), buoy0(4), a60(6, 6), p(3) + LOGICAL :: near, near0 + INTEGER :: k + TYPE(RodState) :: rc + + mass6 = CD_ZERO + k6 = CD_ZERO + w2 = CD_ZERO + shift = CD_ZERO + CALL rod_environment_force(rod, opts, time, f, m, added6, drag6, ErrStat, ErrMsg, buoyancy=buoy) + IF (ErrStat /= CD_DECKDRV_OK) RETURN + IF (rod%is_pinned) THEN + rc = rod + a6 = added6 + IF (PRESENT(parent)) THEN + p = rod%pin - parent%r + rc%pin_a = parent%a + cross3(parent%alpha, p) + cross3(parent%omega, cross3(parent%omega, p)) + rc%pin0_a = rc%pin_a + IF (parent%mass > CD_ZERO) rc%mass = rod%mass*parent%mass/(rod%mass + parent%mass) + a6(1:3, :) = CD_ZERO + a6(:, 1:3) = CD_ZERO + END IF + kh = CD_ZERO + CALL rod_contact_stiffness(rod, opts, rod%pin, dt, kh, ErrStat, ErrMsg, bathymetry) + IF (ErrStat /= CD_DECKDRV_OK) RETURN + CALL rod_hydrostatic_stiffness(rod, opts, time, rod%pin, dt, kh, near, ErrStat, ErrMsg) + IF (ErrStat /= CD_DECKDRV_OK) RETURN + kc = kh(4) + kh(5) + IF (PRESENT(rod_start)) THEN + CALL rod_environment_force(rod_start, opts, time, f, m, added0, drag6, ErrStat, ErrMsg, buoyancy=buoy0) + IF (ErrStat /= CD_DECKDRV_OK) RETURN + kh = CD_ZERO + CALL rod_contact_stiffness(rod_start, opts, rod_start%pin, dt, kh, ErrStat, ErrMsg, bathymetry) + IF (ErrStat /= CD_DECKDRV_OK) RETURN + CALL rod_hydrostatic_stiffness(rod_start, opts, time, rod_start%pin, dt, kh, near0, ErrStat, ErrMsg) + IF (ErrStat /= CD_DECKDRV_OK) RETURN + kc = MAX(kc, kh(4) + kh(5)) + near = near .OR. near0 + a60 = added0 + IF (near) THEN + a6 = CD_ZERO + a60 = CD_ZERO + END IF + mp = pinned_rotational_inertia(rc, a6) + w2 = pinned_swing_omega2(rc, opts, mp, added6, buoy, pinned_rotational_inertia(rod_start, a60), added0, & + buoy0, k_extra=kc) + ELSE + IF (near) a6 = CD_ZERO + mp = pinned_rotational_inertia(rc, a6) + w2 = pinned_swing_omega2(rc, opts, mp, added6, buoy, k_extra=kc) + END IF + DO k = 1, 3 + mass6(3 + k) = mp(k, k) + END DO + shift = rod%r - rod%pin + ELSE + CALL rod_contact_stiffness(rod, opts, rod%r, dt, k6, ErrStat, ErrMsg, bathymetry) + IF (ErrStat /= CD_DECKDRV_OK) RETURN + CALL rod_hydrostatic_stiffness(rod, opts, time, rod%r, dt, k6, near, ErrStat, ErrMsg) + IF (ErrStat /= CD_DECKDRV_OK) RETURN + mass6(1:3) = rod%mass + mass6(4:6) = global_inertia_diag(rod%rot_mat, rod%inertia) + IF (.NOT. near) THEN + DO k = 1, 6 + mass6(k) = mass6(k) + MAX(CD_ZERO, added6(k, k)) + END DO + END IF + END IF + END SUBROUTINE rod_estimate_terms + + SUBROUTINE rigid6_contact_stiffness(body, opts, time, dt, k6, ErrStat, ErrMsg, bathymetry) + !! Add to k6 the diagonal seabed contact stiffness of a Rigid6 body about its reference point + !! that can act within the coming step (contact_within_reach): the reference-point penalty of + !! rigid6_seabed_contact (kBot over 1 m^2, heave only) and the stations of the rods fixed to + !! the body, posed as rigid6_rod_loads poses them, with the body's rigid-body motion; and the + !! waterplane stiffness of those rods near the surface (rod_hydrostatic_stiffness). + TYPE(RigidBodyState), INTENT(IN) :: body + TYPE(DeckOptions), INTENT(IN) :: opts + REAL(wp), INTENT(IN) :: time, dt + REAL(wp), INTENT(INOUT) :: k6(6) + INTEGER, INTENT(OUT) :: ErrStat + CHARACTER(*), INTENT(OUT) :: ErrMsg + TYPE(CD_BathymetryType), INTENT(IN), OPTIONAL :: bathymetry + INTEGER :: k + REAL(wp) :: r(3) + LOGICAL :: within, near + TYPE(RodState) :: rs + + ErrStat = CD_DECKDRV_OK + ErrMsg = '' + IF (opts%kbot > CD_ZERO) THEN + CALL contact_within_reach(body%r, body%v, NORM2(body%a), CD_ZERO, dt, opts, within, ErrStat, ErrMsg, bathymetry) + IF (ErrStat /= CD_DECKDRV_OK) RETURN + IF (within) k6(3) = k6(3) + opts%kbot + END IF + IF (.NOT. ALLOCATED(body%att_rods)) RETURN + DO k = 1, SIZE(body%att_rods) + rs = body%att_rods(k) + r = MATMUL(body%rot_mat, body%att_c(:, k)) + rs%r = body%r + r + rs%rot_mat = MATMUL(body%rot_mat, body%att_rot(:, :, k)) + rs%v = body%v + cross3(body%omega, r) + rs%omega = body%omega + rs%a = body%a + cross3(body%alpha, r) + cross3(body%omega, cross3(body%omega, r)) + rs%alpha = body%alpha + rs%has_held = .FALSE. + CALL rod_contact_stiffness(rs, opts, body%r, dt, k6, ErrStat, ErrMsg, bathymetry) + IF (ErrStat /= CD_DECKDRV_OK) RETURN + CALL rod_hydrostatic_stiffness(rs, opts, time, body%r, dt, k6, near, ErrStat, ErrMsg) + IF (ErrStat /= CD_DECKDRV_OK) RETURN + END DO + END SUBROUTINE rigid6_contact_stiffness + PURE SUBROUTINE add_arm_block6(mat, blk, arm) !! Add T^T blk T to a 6x6 rigid-body matrix about the reference point, T = [I, -[arm]x] !! mapping (translation, rotation) of the reference point to the point at arm: the 3x3 @@ -20564,7 +21312,7 @@ PURE SUBROUTINE add_arm_block6(mat, blk, arm) mat(4:6, 4:6) = mat(4:6, 4:6) - MATMUL(s, b_s) END SUBROUTINE add_arm_block6 - SUBROUTINE rod_environment_force(rod, opts, time, force, moment, added_mass, drag_dv, ErrStat, ErrMsg) + SUBROUTINE rod_environment_force(rod, opts, time, force, moment, added_mass, drag_dv, ErrStat, ErrMsg, buoyancy) !! Distributed hydrostatic and Morison loads of a rigid rod about its centre, the rod's 6x6 !! hydrodynamic added-mass matrix about the same point (global frame) and the 6x6 derivative !! drag_dv of the drag force/moment w.r.t. the rod (velocity, angular velocity), which the @@ -20599,12 +21347,15 @@ SUBROUTINE rod_environment_force(rod, opts, time, force, moment, added_mass, dra !! and no host dynamic pressure the side keeps 1 + CaAx. Host-held fluid is sampled at the NumSegs + 1 !! segment stations and interpolated linearly along the rod; when the host also supplies the !! dynamic pressure the end caps carry it as with deck waves (side axial term CaAx only). + !! buoyancy (optional) returns the slice buoyancy alone: its upward total and its first + !! moment about the rod centre, the sum of rhoW g V_i (s_i q + c_i p) over the stations. TYPE(RodState), INTENT(IN) :: rod TYPE(DeckOptions), INTENT(IN) :: opts REAL(wp), INTENT(IN) :: time REAL(wp), INTENT(OUT) :: force(3), moment(3), added_mass(6, 6), drag_dv(6, 6) INTEGER, INTENT(OUT) :: ErrStat CHARACTER(*), INTENT(OUT) :: ErrMsg + REAL(wp), INTENT(OUT), OPTIONAL :: buoyancy(4) REAL(wp), PARAMETER :: gp2(2) = [-0.57735026918962576451_wp, 0.57735026918962576451_wp] REAL(wp), PARAMETER :: gx10(10) = [-0.97390652851717174343_wp, -0.86506336668898453635_wp, & @@ -20624,6 +21375,7 @@ SUBROUTINE rod_environment_force(rod, opts, time, force, moment, added_mass, dra REAL(wp) :: r0, area, lseg, sphi, rs, eta_mean, ax_fk, s_a, h_a, h_b, dh, tlo, thi, tmp, th1, th2, th REAL(wp) :: f_end(2), eta_end(2), h_st(0:MAX(1, rod%nsegs)) REAL(wp) :: vol_end, kq, vq, u(3), du(3), eta, pd, x(3), v_end(3), arm(3), n_e(3), eta_star, f_c(3) + REAL(wp) :: buoy(4) ErrStat = CD_DECKDRV_OK ErrMsg = '' @@ -20631,6 +21383,8 @@ SUBROUTINE rod_environment_force(rod, opts, time, force, moment, added_mass, dra moment = CD_ZERO added_mass = CD_ZERO drag_dv = CD_ZERO + buoy = CD_ZERO + IF (PRESENT(buoyancy)) buoyancy = CD_ZERO nseg = MAX(1, rod%nsegs) axis = rod%rot_mat(:, 1) r0 = 0.5_wp*rod%diam @@ -20719,6 +21473,7 @@ SUBROUTINE rod_environment_force(rod, opts, time, force, moment, added_mass, dra END IF IF (ErrStat /= CD_DECKDRV_OK) RETURN END DO + IF (PRESENT(buoyancy)) buoyancy = buoy ! rodHydro moordyn: MoorDyn's waterplane moment (pi d^4/16) rho g sin(phi) cos(phi) with its ! end-cap moment, whose net exceeds the exact displaced-volume moment by (pi d^4/32) rho g @@ -20815,6 +21570,8 @@ SUBROUTINE station(s, w, f, c) fb = [CD_ZERO, CD_ZERO, opts%rhoW*vol*opts%g] force = force + fb moment = moment + cross3(arm_s + c*pvec, fb) + buoy(1) = buoy(1) + fb(3) + buoy(2:4) = buoy(2:4) + fb(3)*(arm_s + c*pvec) rel = us - vs acc_axial = DOT_PRODUCT(dus, axis)*axis rel_axial = DOT_PRODUCT(rel, axis)*axis @@ -21208,12 +21965,14 @@ SUBROUTINE solve_body_equilibrium_core(types, bodies, rod_types, rods, points, l okind(nobj) = OBJ_ROD idx(nobj) = i END DO - ! pinned rods (to a fixed pin or to a body) with a line, or on a moving body: two - ! rotations about the pin; the pin force acts on the parent body + ! pinned rods (to a fixed pin, to a body, or to a host node held at its initial pose: a + ! CoupledPinned rod) with a line, or on a moving body: two rotations about the pin; the + ! pin force acts on the parent body IF (.NOT. opts%has_motion_file) THEN DO i = 1, SIZE(rods) ibp = pinned_body_of_rod_type(rods(i)%rod_type) - IF (TRIM(rods(i)%rod_type) /= 'pinned' .AND. ibp < 1) CYCLE + IF (TRIM(rods(i)%rod_type) /= 'pinned' .AND. TRIM(rods(i)%rod_type) /= 'coupledpinned' .AND. & + ibp < 1) CYCLE k = rod_point_index(points, rods(i)%id, 1) j = rod_point_index(points, rods(i)%id, 2) ok = point_has_line(k) @@ -23136,10 +23895,11 @@ END SUBROUTINE CD_Rigid6_End SUBROUTINE CD_Init_Deck_Aggregate_Rod(rod_types, rods, points, opts, rt, ErrStat, ErrMsg, host_dcm) !! Populate the opaque rod runtime for the coupled aggregate: build the rod states and retain !! the deck options + points the per-step marcher needs (the aggregate keeps neither). The rod - !! twin of CD_Init_Deck_Aggregate_Rigid6. Coupled/Vessel rods become host nodes (one per rod, - !! in deck ROD order) at their End A; host_dcm is the host orientation at Init (the ZYX - !! global-to-platform DCM of PtfmInit, identity when absent), so the rod frame in platform - !! axes is host_dcm R0 and follows the host orientation afterwards. + !! twin of CD_Init_Deck_Aggregate_Rigid6. Coupled/Vessel and CoupledPinned/VesselPinned rods + !! become host nodes (one per rod, in deck ROD order) at their End A; host_dcm is the host + !! orientation at Init (the ZYX global-to-platform DCM of PtfmInit, identity when absent), so + !! the frame of a Coupled rod in platform axes is host_dcm R0 and follows the host orientation + !! afterwards. A CoupledPinned rod takes only the position of its node: it turns about it. TYPE(DeckRodType), INTENT(IN) :: rod_types(:) TYPE(DeckRod), INTENT(IN) :: rods(:) TYPE(DeckPoint), INTENT(IN) :: points(:) @@ -23150,8 +23910,21 @@ SUBROUTINE CD_Init_Deck_Aggregate_Rod(rod_types, rods, points, opts, rt, ErrStat REAL(wp), INTENT(IN), OPTIONAL :: host_dcm(3, 3) INTEGER :: ir, k, nh - CALL init_rod_states(rod_types, rods, points, rt%rods, ErrStat, ErrMsg) + ! An end of a Pinned or CoupledPinned rod that no line attaches to needs no RodA/B point + ! (a CoupledPinned rod often carries its line at End B only, and a pendulum none): its + ! pin holds the rod. Every other rod keeps the rule that both ends have a point. + CALL init_rod_states(rod_types, rods, points, rt%rods, ErrStat, ErrMsg, no_points=.TRUE.) IF (ErrStat /= CD_DECKDRV_OK) RETURN + DO ir = 1, SIZE(rt%rods) + IF (rt%rods(ir)%is_pinned) CYCLE + IF (rt%rods(ir)%point_a_index == 0 .OR. rt%rods(ir)%point_b_index == 0) THEN + CALL fail(ErrStat, ErrMsg, 'Rod state initialization requires RodA and RodB points: ROD '// & + TRIM(int_to_str(rt%rods(ir)%rod_id))//' ('//TRIM(rods(ir)%rod_type)//') has no line or Rod'// & + TRIM(int_to_str(rt%rods(ir)%rod_id))//MERGE('A', 'B', rt%rods(ir)%point_a_index == 0)// & + ' POINT at that end; on the coupled route only a Pinned or CoupledPinned rod may leave an end free') + RETURN + END IF + END DO rt%opts = opts rt%points = points rt%host_o0 = CD_ZERO @@ -23159,43 +23932,54 @@ SUBROUTINE CD_Init_Deck_Aggregate_Rod(rod_types, rods, points, opts, rt, ErrStat rt%host_o0(2, 2) = CD_ONE rt%host_o0(3, 3) = CD_ONE IF (PRESENT(host_dcm)) rt%host_o0 = host_dcm - nh = COUNT(rt%rods%is_prescribed) + nh = COUNT(rt%rods%is_prescribed .OR. rt%rods%is_host_pinned) ALLOCATE (rt%host_rod(nh), rt%host_rrel(3, 3, nh)) k = 0 DO ir = 1, SIZE(rt%rods) - IF (.NOT. rt%rods(ir)%is_prescribed) CYCLE + IF (.NOT. (rt%rods(ir)%is_prescribed .OR. rt%rods(ir)%is_host_pinned)) CYCLE k = k + 1 rt%host_rod(k) = ir rt%host_rrel(:, :, k) = MATMUL(rt%host_o0, rt%rods(ir)%rot_mat) - ! a host-driven rod starts at rest in the host's Init pose; its a/alpha are the host's - rt%rods(ir)%accel_valid = .TRUE. + ! a host-driven rod starts at rest in the host's Init pose; its a/alpha are the host's (a + ! host-pinned rod solves its own at the first step, like a free rod) + IF (rt%rods(ir)%is_prescribed) rt%rods(ir)%accel_valid = .TRUE. END DO rt%snap_rods = rt%rods rt%stage_rods = rt%rods END SUBROUTINE CD_Init_Deck_Aggregate_Rod PURE INTEGER FUNCTION CD_Rod_NHost(rt) RESULT(n) - !! Number of host-driven (Coupled/Vessel) rods, i.e. the rod host nodes (0 if unpopulated). + !! Number of host-driven (Coupled/Vessel and CoupledPinned/VesselPinned) rods, i.e. the rod + !! host nodes (0 if unpopulated). TYPE(CD_RodRuntimeType), INTENT(IN) :: rt n = 0 IF (ALLOCATED(rt%host_rod)) n = SIZE(rt%host_rod) END FUNCTION CD_Rod_NHost SUBROUTINE CD_Rod_SetHostKinematics(rt, position, velocity, acceleration, ErrStat, ErrMsg, orientation, & - angular_velocity, angular_acceleration) + angular_velocity, angular_acceleration, step_start) !! Impose the host node kinematics (End A position/velocity/acceleration, the host !! orientation and angular rates, all global; arrays shaped (3[,3], NHost)) on every !! Coupled/Vessel rod: R = O^T (O0 R0), centre = End A + (L/2) R e1 with the rigid !! velocity/acceleration transfer. Without an orientation the Init orientation is held; - !! without angular rates they are zero. Atomic: validates everything before any change. + !! without angular rates they are zero. A CoupledPinned rod takes the node translation as + !! its pin kinematics and ignores the orientation and angular rates: it keeps its own + !! rotation and follows the pin (mb_snap_pinned, with its committed angular acceleration). + !! Atomic: validates everything before any change. + !! + !! step_start: the kinematics are those of the committed time (a transfer that does not + !! advance, CD_AGG_UpdateStates_Moving), not the t + dt input of a coming step; the next step + !! of a CoupledPinned rod then starts from this pin (RodState%pin0). Default .FALSE. TYPE(CD_RodRuntimeType), INTENT(INOUT) :: rt REAL(wp), INTENT(IN) :: position(:, :), velocity(:, :), acceleration(:, :) INTEGER, INTENT(OUT) :: ErrStat CHARACTER(*), INTENT(OUT) :: ErrMsg REAL(wp), INTENT(IN), OPTIONAL :: orientation(:, :, :) REAL(wp), INTENT(IN), OPTIONAL :: angular_velocity(:, :), angular_acceleration(:, :) + LOGICAL, INTENT(IN), OPTIONAL :: step_start INTEGER :: k, ir, nh REAL(wp) :: o(3, 3), rot(3, 3), arm(3), w(3), al(3) + TYPE(RigidBodyState) :: no_parent(0) ErrStat = CD_DECKDRV_OK ErrMsg = '' @@ -23221,6 +24005,16 @@ SUBROUTINE CD_Rod_SetHostKinematics(rt, position, velocity, acceleration, ErrSta END IF DO k = 1, nh ir = rt%host_rod(k) + IF (rt%rods(ir)%is_host_pinned) THEN + rt%rods(ir)%pin = position(:, k) + rt%rods(ir)%pin_v = velocity(:, k) + rt%rods(ir)%pin_a = acceleration(:, k) + CALL mb_snap_pinned(rt%rods(ir), no_parent) + IF (PRESENT(step_start)) THEN + IF (step_start) CALL set_rod_pin_start(rt%rods(ir)) + END IF + CYCLE + END IF o = rt%host_o0 IF (PRESENT(orientation)) o = orientation(:, :, k) w = CD_ZERO @@ -23245,6 +24039,8 @@ SUBROUTINE CD_Rod_GetHostKinematics(rt, k, position, velocity, acceleration, ori angular_acceleration) !! The committed kinematics of host node k (End A of the k-th Coupled/Vessel rod) and the !! host orientation O = (O0 R0) R^T it implies -- the inverse of CD_Rod_SetHostKinematics. + !! A CoupledPinned rod implies no host orientation or angular rates: its node reports the + !! Init orientation and zero rates, which CD_Rod_SetHostKinematics ignores for it. TYPE(CD_RodRuntimeType), INTENT(IN) :: rt INTEGER, INTENT(IN) :: k REAL(wp), INTENT(OUT) :: position(3), velocity(3), acceleration(3), orientation(3, 3) @@ -23270,15 +24066,19 @@ SUBROUTINE CD_Rod_GetHostKinematics(rt, k, position, velocity, acceleration, ori velocity = rt%rods(ir)%v - cross3(rt%rods(ir)%omega, arm) acceleration = rt%rods(ir)%a - cross3(rt%rods(ir)%alpha, arm) - & cross3(rt%rods(ir)%omega, cross3(rt%rods(ir)%omega, arm)) + IF (rt%rods(ir)%is_host_pinned) THEN + orientation = rt%host_o0 + RETURN + END IF orientation = MATMUL(rt%host_rrel(:, :, k), TRANSPOSE(rt%rods(ir)%rot_mat)) angular_velocity = rt%rods(ir)%omega angular_acceleration = rt%rods(ir)%alpha END SUBROUTINE CD_Rod_GetHostKinematics SUBROUTINE CD_Rod_ScatterHostPoints(system, rt, q, v, a) - !! Write the RodA/B attachment-point kinematics of every Coupled/Vessel rod into the - !! full coupled-block arrays (3, n_system_coupled_dof/3) of the EI=0 system; every other - !! block is left untouched. + !! Write the RodA/B attachment-point kinematics of every host-driven rod (Coupled/Vessel + !! and CoupledPinned) into the full coupled-block arrays (3, n_system_coupled_dof/3) of the + !! EI=0 system; every other block is left untouched. TYPE(CD_SystemType), INTENT(IN) :: system TYPE(CD_RodRuntimeType), INTENT(IN) :: rt REAL(wp), INTENT(INOUT) :: q(:, :), v(:, :), a(:, :) @@ -23295,7 +24095,7 @@ SUBROUTINE CD_Rod_ScatterHostPoints(system, rt, q, v, a) pidx = rt%rods(ir)%point_b_index arm = rt%rods(ir)%half_length*rt%rods(ir)%rot_mat(:, 1) END IF - base = system_point_base(system, rt%points(pidx)%id) + base = rod_end_base(system, rt%points, pidx) IF (base < 0 .OR. base/3 + 1 > SIZE(q, 2)) CYCLE q(:, base/3 + 1) = rt%rods(ir)%r + arm v(:, base/3 + 1) = rt%rods(ir)%v + cross3(rt%rods(ir)%omega, arm) @@ -23313,16 +24113,41 @@ SUBROUTINE CD_Rod_HostWrench(system, rt, loads, k, force, moment, ErrStat, ErrMs !! rod_environment_force (held host fluid when set), seabed contact, and the rigid-body and !! added-mass inertia -M a of the rod at its host-prescribed acceleration, including the !! gyroscopic term w x (I w). - TYPE(CD_SystemType), INTENT(IN) :: system - TYPE(CD_RodRuntimeType), INTENT(IN) :: rt + !! + !! A CoupledPinned rod returns a force and no moment (MoorDyn-F's coupled pinned rod): the + !! load it exerts on its pin, its net load less its inertia -M a. This is the direct + !! feedthrough of the pin acceleration, evaluated at the rod's current state: + !! * the pin position, velocity and acceleration are the End A motion of the rod state, + !! which CD_Rod_SetHostKinematics has moved with the host node (an output probe's + !! off-step kinematics included). They are re-derived from the rod state here (equal to + !! the host's values to round-off) so that the force depends on the checkpointed rod + !! state only: a restored run evaluates it bit for bit, also between steps; + !! * the rotation and the angular velocity are the rod's committed states (a probe moves + !! the pin, not the rotation), and the fluid is the step's held host fluid, as for every + !! other object a CalcOutput evaluates; + !! * the angular acceleration is solved again for the current pin acceleration + !! (rod_body_acceleration at dt = 0); the committed one is not used, so a probe sees the + !! rod's effective inertia about the pin; + !! * the attached lines keep their committed interior state, accelerations included (as + !! every output evaluation does), and their end loads are taken at the end accelerations + !! of the re-solved rotation: the loads come with the end accelerations the system holds + !! (the probe overlay places the RodA/B ends with the probe pin and the committed + !! angular acceleration), and the solve moves their end-node inertia to the re-solved + !! ones with the lines' coupled mass block, D = -M_cc (frozen_interior; the step's + !! corrector instead lets the interior follow). The coupled loads are linear in the end + !! accelerations at a held interior, so this is exact: the force does not depend on + !! which end accelerations the line loads were evaluated with. + TYPE(CD_SystemType), INTENT(INOUT) :: system + TYPE(CD_RodRuntimeType), INTENT(INOUT) :: rt REAL(wp), INTENT(IN) :: loads(:, :) INTEGER, INTENT(IN) :: k REAL(wp), INTENT(OUT) :: force(3), moment(3) INTEGER, INTENT(OUT) :: ErrStat CHARACTER(*), INTENT(OUT) :: ErrMsg - INTEGER :: ir, base, j + INTEGER :: ir, base, j, n, es REAL(wp) :: arm(3), f_end(3, 2), f_env(3), m_env(3), f_sb(3), m_sb(3), added6(6, 6), drag6(6, 6) - REAL(wp) :: dv(6, 6), acc6(6), ig(3, 3), mc(3) + REAL(wp) :: dv(6, 6), acc6(6), ig(3, 3), mc(3), acc(3), alpha(3), pin_host(9) + CHARACTER(160) :: em force = CD_ZERO moment = CD_ZERO @@ -23332,13 +24157,41 @@ SUBROUTINE CD_Rod_HostWrench(system, rt, loads, k, force, moment, ErrStat, ErrMs CALL fail(ErrStat, ErrMsg, 'CD_Rod_HostWrench: host node index out of range'); RETURN END IF ir = rt%host_rod(k) + IF (rt%rods(ir)%is_host_pinned) THEN + n = system%n_system_coupled_dof + IF (3*SIZE(loads, 2) /= n .OR. SIZE(loads, 1) /= 3) THEN + CALL fail(ErrStat, ErrMsg, 'CD_Rod_HostWrench: load array does not cover the coupled points'); RETURN + END IF + ! the step workspace serves as scratch between steps (a step refills it before use) + CALL ensure_rod_step_workspace(rt%work, n, SIZE(rt%rods), SIZE(system%points)) + rt%work%loads(1:n) = RESHAPE(loads, [n]) + CALL CD_Get_System_CoupledMotion(system, rt%work%q(1:n), rt%work%v(1:n), rt%work%a(1:n), es, em) + ! the end-node inertia moves with the line interior held (an output evaluation keeps the + ! committed interior state, accelerations included) + IF (es == CD_SYSTEM_OK) CALL CD_Calc_System_CoupledAccelDerivative(system, rt%work%dload_da, es, em, & + frozen_interior=.TRUE.) + IF (es /= CD_SYSTEM_OK) THEN + CALL fail_solve(ErrStat, ErrMsg, 'CD_Rod_HostWrench: pinned-rod line query failed: '//TRIM(em)); RETURN + END IF + ! evaluate with the pin re-derived from the rod state, then put the host's values back + ! (state-const) + pin_host = [rt%rods(ir)%pin, rt%rods(ir)%pin_v, rt%rods(ir)%pin_a] + CALL rod_end_a_motion(rt%rods(ir), rt%rods(ir)%pin, rt%rods(ir)%pin_v, rt%rods(ir)%pin_a) + CALL rod_body_acceleration(system, rt%points, rt%opts, rt%rods(ir), CD_ZERO, CD_ZERO, & + [CD_ZERO, CD_ZERO, CD_ZERO, CD_ZERO, CD_ZERO, CD_ZERO], rt%work, acc, alpha, & + ErrStat, ErrMsg, pin_load=force) + rt%rods(ir)%pin = pin_host(1:3) + rt%rods(ir)%pin_v = pin_host(4:6) + rt%rods(ir)%pin_a = pin_host(7:9) + RETURN + END IF arm = rt%rods(ir)%half_length*rt%rods(ir)%rot_mat(:, 1) f_end = CD_ZERO DO j = 1, 2 IF (j == 1) THEN - base = system_point_base(system, rt%points(rt%rods(ir)%point_a_index)%id) + base = rod_end_base(system, rt%points, rt%rods(ir)%point_a_index) ELSE - base = system_point_base(system, rt%points(rt%rods(ir)%point_b_index)%id) + base = rod_end_base(system, rt%points, rt%rods(ir)%point_b_index) END IF IF (base < 0) CYCLE IF (base/3 + 1 > SIZE(loads, 2)) THEN @@ -23760,6 +24613,15 @@ SUBROUTINE CD_Rod_Set_States(rt, states, ErrStat, ErrMsg) rt%rods(ir)%alpha = states(k + 13:k + 15) rt%rods(ir)%rot_mat = RESHAPE(states(k + 16:k + 24), [3, 3]) rt%rods(ir)%accel_valid = .TRUE. + ! A CoupledPinned rod's pin is its End A: its kinematics follow from the restored state + ! (the End A motion the line ends carry), so the mirror needs no pin entries. The + ! continuing run derives its step-start pin from the same committed state with the same + ! arithmetic (set_rod_pin_start), so the restored pin0 is bit-identical to it; pin, pin_v + ! and pin_a are replaced by the host transfer before the next step or output evaluation. + IF (rt%rods(ir)%is_host_pinned) THEN + CALL rod_end_a_motion(rt%rods(ir), rt%rods(ir)%pin, rt%rods(ir)%pin_v, rt%rods(ir)%pin_a) + CALL set_rod_pin_start(rt%rods(ir)) + END IF END DO END SUBROUTINE CD_Rod_Set_States @@ -23873,7 +24735,7 @@ SUBROUTINE step_rigid6_system(system, points, opts, rigid, time, dt, converged, INTEGER :: ib, ip, nsub, isub, it REAL(wp), ALLOCATABLE :: hk_end(:, :) LOGICAL :: conv_s, stall_s - REAL(wp) :: omega2, mass6(6) + REAL(wp) :: omega2, mass6(6), k6c(6) converged = .TRUE. stalled = .FALSE. @@ -23892,9 +24754,11 @@ SUBROUTINE step_rigid6_system(system, points, opts, rigid, time, dt, converged, mass6(1:3) = rigid(ib)%mass IF (rigid(ib)%r(3) < CD_ZERO) mass6(1:3) = mass6(1:3) + opts%rhoW*rigid(ib)%vol*MAX(CD_ZERO, rigid(ib)%ca) mass6(4:6) = global_inertia_diag(rigid(ib)%rot_mat, rigid(ib)%inertia) - omega2 = MAX(omega2, rigid_omega2_estimate(system, att_base, att_arm, mass6, & - [CD_ZERO, CD_ZERO, rigid(ib)%c33, rigid(ib)%c44, & - rigid(ib)%c55, CD_ZERO])) + ! hydrostatic restoring plus the seabed contact that acts within the step + k6c = [CD_ZERO, CD_ZERO, rigid(ib)%c33, rigid(ib)%c44, rigid(ib)%c55, CD_ZERO] + CALL rigid6_contact_stiffness(rigid(ib), opts, time - dt, dt, k6c, ErrStat, ErrMsg, bathymetry) + IF (ErrStat /= CD_DECKDRV_OK) RETURN + omega2 = MAX(omega2, rigid_omega2_estimate(system, att_base, att_arm, mass6, k6c)) END BLOCK END DO nsub = rigid_substep_count(omega2, dt) @@ -24612,9 +25476,9 @@ SUBROUTINE rigid6_seabed_contact(body, opts, force, moment, load_dv, ErrStat, Er !! kBot/cBot (N/m^3, N.s/m^3) act over a fixed reference contact area !! RIGID6_CONTACT_AREA = 1 m^2: k = kBot*1 m^2 [N/m], c = cBot*1 m^2 [N.s/m]. This is a !! penalty that keeps the reference point out of the bed, not a footprint model. - !! load_dv returns the 6x6 derivative of the normal damping force w.r.t. the body - !! (velocity, angular velocity), which the rigid-body step applies implicitly; the spring - !! and the regularized friction act at the evaluated position and velocity. + !! load_dv returns the 6x6 derivative of the normal damping force and the friction damper (its + !! secant coefficient, see rod_seabed_contact) w.r.t. the body velocity, which the rigid-body + !! step applies implicitly; the spring acts at the evaluated position. TYPE(RigidBodyState), INTENT(IN) :: body TYPE(DeckOptions), INTENT(IN) :: opts REAL(wp), INTENT(OUT) :: force(3), moment(3), load_dv(6, 6) @@ -24645,6 +25509,9 @@ SUBROUTINE rigid6_seabed_contact(body, opts, force, moment, load_dv, ErrStat, Er denom = SQRT(body%v(1)**2 + body%v(2)**2 + vreg**2) force(1) = -opts%friction_mu*normal*body%v(1)/denom force(2) = -opts%friction_mu*normal*body%v(2)/denom + ! the friction damper as its secant coefficient, applied implicitly (rod_seabed_contact) + load_dv(1, 1) = -opts%friction_mu*normal/denom + load_dv(2, 2) = load_dv(1, 1) END IF force(3) = normal END SUBROUTINE rigid6_seabed_contact @@ -32124,8 +32991,8 @@ SUBROUTINE apply_ptfm_host_bodies(bodies, points, ptfm_init) END SUBROUTINE apply_ptfm_host_bodies SUBROUTINE apply_ptfm_host_rods(rods, points, ptfm_init) - !! Rigid-transform every Coupled/Vessel ROD (its End A/B and its RodA/B attachment - !! points) by the initial platform displacement, p' = r + M^T p (apply_ptfm_init). + !! Rigid-transform every Coupled/Vessel and CoupledPinned ROD (its End A/B and its RodA/B + !! attachment points) by the initial platform displacement, p' = r + M^T p (apply_ptfm_init). TYPE(DeckRod), INTENT(INOUT) :: rods(:) TYPE(DeckPoint), INTENT(INOUT) :: points(:) REAL(wp), INTENT(IN) :: ptfm_init(6) @@ -32133,7 +33000,8 @@ SUBROUTINE apply_ptfm_host_rods(rods, points, ptfm_init) INTEGER :: i, j, k dcm = ptfm_zyx_dcm(ptfm_init(4:6)) DO i = 1, SIZE(rods) - IF (TRIM(rods(i)%rod_type) /= 'coupled' .AND. TRIM(rods(i)%rod_type) /= 'vessel') CYCLE + IF (TRIM(rods(i)%rod_type) /= 'coupled' .AND. TRIM(rods(i)%rod_type) /= 'vessel' .AND. & + TRIM(rods(i)%rod_type) /= 'coupledpinned') CYCLE rods(i)%end_a = ptfm_init(1:3) + MATMUL(TRANSPOSE(dcm), rods(i)%end_a) rods(i)%end_b = ptfm_init(1:3) + MATMUL(TRANSPOSE(dcm), rods(i)%end_b) DO j = 1, 2 @@ -32649,7 +33517,7 @@ SUBROUTINE scatter_rod_point_motion(system, points, rod_state, q, v, a) REAL(wp) :: arm(3) DO ir = 1, SIZE(rod_state) - base = system_point_base(system, points(rod_state(ir)%point_a_index)%id) + base = rod_end_base(system, points, rod_state(ir)%point_a_index) IF (base >= 0) THEN arm = MATMUL(rod_state(ir)%rot_mat, [-rod_state(ir)%half_length, CD_ZERO, CD_ZERO]) q(base + 1:base + 3) = rod_state(ir)%r + arm @@ -32657,7 +33525,7 @@ SUBROUTINE scatter_rod_point_motion(system, points, rod_state, q, v, a) a(base + 1:base + 3) = rod_state(ir)%a + cross3(rod_state(ir)%alpha, arm) + & cross3(rod_state(ir)%omega, cross3(rod_state(ir)%omega, arm)) END IF - base = system_point_base(system, points(rod_state(ir)%point_b_index)%id) + base = rod_end_base(system, points, rod_state(ir)%point_b_index) IF (base >= 0) THEN arm = MATMUL(rod_state(ir)%rot_mat, [rod_state(ir)%half_length, CD_ZERO, CD_ZERO]) q(base + 1:base + 3) = rod_state(ir)%r + arm @@ -32792,6 +33660,16 @@ INTEGER FUNCTION system_point_base(system, point_id) RESULT(base) END DO END FUNCTION system_point_base + INTEGER FUNCTION rod_end_base(system, points, pidx) RESULT(base) + !! system_point_base of a rod end point; -1 for a rod end without a point (pidx = 0: no line + !! attaches there, a coupled-aggregate rod). + TYPE(CD_SystemType), INTENT(IN) :: system + TYPE(DeckPoint), INTENT(IN) :: points(:) + INTEGER, INTENT(IN) :: pidx + base = -1 + IF (pidx > 0) base = system_point_base(system, points(pidx)%id) + END FUNCTION rod_end_base + PURE FUNCTION cross3(a, b) RESULT(c) REAL(wp), INTENT(IN) :: a(3), b(3) REAL(wp) :: c(3) diff --git a/src/CableDyn_Model.f90 b/src/CableDyn_Model.f90 index ffa0736a..9e3971ad 100644 --- a/src/CableDyn_Model.f90 +++ b/src/CableDyn_Model.f90 @@ -96,6 +96,7 @@ MODULE CableDyn_Model PUBLIC :: CD_Calc_Model_CoupledLoads PUBLIC :: CD_Calc_Model_CoupledKinematicDerivatives PUBLIC :: CD_Calc_Model_CoupledAccelDerivative, CD_Update_Model_CoupledAccelDerivative + PUBLIC :: CD_Calc_Model_CoupledEndMass PUBLIC :: CD_Update_Model_Hydro_Fields PUBLIC :: CD_Update_Model_External_Loads PUBLIC :: CD_Update_Model_CoupledMotion @@ -3492,6 +3493,51 @@ SUBROUTINE CD_Calc_Model_CoupledAccelDerivative(model, dload_da, ErrStat, ErrMsg IF (ErrStat == CD_MODEL_OK) dload_da = model%dynamic_workspace%ad_result END SUBROUTINE CD_Calc_Model_CoupledAccelDerivative + SUBROUTINE CD_Calc_Model_CoupledEndMass(model, m_cc, ErrStat, ErrMsg) + !! The coupled-coupled block M_cc of the line mass (the consistent structural mass plus the + !! added mass at the current positions, exactly as CD_Update_Model_CoupledAccelDerivative + !! assembles it), n_coupled_dof square in the compact coupled ordering. -M_cc is the + !! derivative of CD_Calc_Model_CoupledLoads with respect to the prescribed coupled + !! accelerations at fixed free-DOF accelerations: the response of the coupled loads when + !! only the coupled motion changes and the line interior keeps its state (an output probe), + !! whereas CD_Calc_Model_CoupledAccelDerivative lets the free accelerations follow. + TYPE(CD_ModelType), INTENT(INOUT) :: model + REAL(wp), INTENT(OUT) :: m_cc(:, :) + INTEGER, INTENT(OUT) :: ErrStat + CHARACTER(*), INTENT(OUT) :: ErrMsg + INTEGER :: nc, bwf, e, i, j, r, c + + ErrStat = CD_MODEL_OK + ErrMsg = '' + m_cc = CD_ZERO + IF (.NOT. model%initialized) THEN + ErrStat = CD_MODEL_NOT_INITIALIZED + ErrMsg = 'CableDyn_Model: model is not initialized' + RETURN + END IF + nc = SIZE(model%fixed_dofs) + IF (SIZE(m_cc, 1) /= nc .OR. SIZE(m_cc, 2) /= nc) THEN + CALL fail(ErrStat, ErrMsg, 'm_cc output must have shape (n_coupled_dof, n_coupled_dof)') + RETURN + END IF + IF (nc == 0) RETURN + ! brings the banded full mass ad_full up to date (or confirms its cache) + CALL CD_Update_Model_CoupledAccelDerivative(model, ErrStat, ErrMsg) + IF (ErrStat /= CD_MODEL_OK) RETURN + ! the half-bandwidth ad_full was stored with (CD_Update_Model_CoupledAccelDerivative) + bwf = 2 + DO e = 1, model%n_elem + bwf = MAX(bwf, 3*ABS(model%elem_conn(1, e) - model%elem_conn(2, e)) + 2) + END DO + DO j = 1, nc + c = model%fixed_dofs(j) + DO i = 1, nc + r = model%fixed_dofs(i) + IF (ABS(r - c) <= bwf) m_cc(i, j) = model%dynamic_workspace%ad_full(bwf + 1 + r - c, c) + END DO + END DO + END SUBROUTINE CD_Calc_Model_CoupledEndMass + SUBROUTINE CD_Update_Model_SegmentLength(model, elem, l0_new, l0_dot, ErrStat, ErrMsg) !! Active line control (the MoorDyn CtrlChan mechanism): set one element's !! unstretched length and its rate. The elastic tension and the per-step mass diff --git a/src/CableDyn_OpenFAST_Aggregate.f90 b/src/CableDyn_OpenFAST_Aggregate.f90 index 3eb67ebc..991c352e 100644 --- a/src/CableDyn_OpenFAST_Aggregate.f90 +++ b/src/CableDyn_OpenFAST_Aggregate.f90 @@ -16,7 +16,9 @@ MODULE CableDyn_OpenFAST_Aggregate !! i in ncp_sys+1 .. ncp_sys+ncable -> cable (i - ncp_sys)'s single coupled fairlead, !! next nhost_rod columns -> the k-th Coupled/Vessel ROD's End A (a 6-DOF host !! node: orientation and angular rates in, force and - !! moment about End A out), + !! moment about End A out) or CoupledPinned ROD's pin + !! (translation in, force out, zero moment; the rod + !! turns about it on its own), !! last nhost_body columns -> the k-th Coupled/Vessel BODY's reference point !! (6-DOF host node, force and moment about it), !! with ncp_total = ncp_sys + ncable + nhost_rod + nhost_body. All facade arrays are shaped @@ -204,8 +206,9 @@ MODULE CableDyn_OpenFAST_Aggregate ! channels, keyed by deck line id. The references are fixed at the converged initial ! state (a checkpoint rebuild re-derives the same state), so they carry no step state. TYPE(CD_RangeSet) :: ranges - ! Coupled/Vessel rods: the trailing host nodes of the moving surface, and the full EI=0 - ! coupled-block scratch (3, n_system_coupled_dof/3) their RodA/B points are overlaid on. + ! Coupled/Vessel and CoupledPinned rods: the trailing host nodes of the moving surface, and + ! the full EI=0 coupled-block scratch (3, n_system_coupled_dof/3) their RodA/B points are + ! overlaid on. INTEGER :: nhost_rod = 0 INTEGER :: nhost_body = 0 ! Coupled/Vessel bodies: the trailing host nodes after the rods ! Body/rod marches: the host fairleads' t + dt motion as a flat coupled-DOF overlay @@ -649,7 +652,8 @@ SUBROUTINE CD_AGG_GetMovingPointMesh(self, position, velocity, acceleration, loa END IF END DO ! Host rod nodes: End A kinematics of each Coupled/Vessel rod and the wrench about End A - ! from the system's current coupled-point loads (the CD_AGG_CalcOutput evaluation). + ! from the system's current coupled-point loads (the CD_AGG_CalcOutput evaluation); the pin + ! of a CoupledPinned rod and its force, with zero moment. IF (self%nhost_rod > 0) THEN CALL CD_FMF_GetPointMesh(self%sys, self%hb_pos, self%hb_vel, self%hb_acc, self%hb_load, es, em) IF (es /= CD_FMF_OK) THEN @@ -813,12 +817,14 @@ SUBROUTINE CD_AGG_UpdateStates_Moving(self, position, velocity, acceleration, Er END IF END IF IF (self%nhost_rod + self%nhost_body > 0) THEN + ! a transfer without advancing: the host kinematics of the committed time, from which the + ! next step of a CoupledPinned rod starts (an output probe is restored by its caller) IF (PRESENT(orientation)) THEN CALL set_host_objects(self, position, velocity, acceleration, ErrStat, ErrMsg, orientation=orientation, & - angular_velocity=self%mv_omega, angular_acceleration=self%mv_alpha) + angular_velocity=self%mv_omega, angular_acceleration=self%mv_alpha, step_start=.TRUE.) ELSE CALL set_host_objects(self, position, velocity, acceleration, ErrStat, ErrMsg, & - angular_velocity=self%mv_omega, angular_acceleration=self%mv_alpha) + angular_velocity=self%mv_omega, angular_acceleration=self%mv_alpha, step_start=.TRUE.) END IF IF (ErrStat /= CD_AGG_OK) RETURN CALL overlay_host_objects(self, is_output_probe, ErrStat, ErrMsg) @@ -2224,18 +2230,24 @@ SUBROUTINE overlay_host_objects(self, output_probe, ErrStat, ErrMsg) END SUBROUTINE overlay_host_objects SUBROUTINE set_host_objects(self, position, velocity, acceleration, ErrStat, ErrMsg, orientation, & - angular_velocity, angular_acceleration) + angular_velocity, angular_acceleration, step_start) !! Impose the host-rod columns (the trailing nhost_rod moving columns) on the rod runtime. + !! step_start: a transfer that does not advance (CD_AGG_UpdateStates_Moving), whose host + !! kinematics the next step of a CoupledPinned rod starts from (CD_Rod_SetHostKinematics). TYPE(CD_AGG_ModuleType), INTENT(INOUT) :: self REAL(wp), INTENT(IN) :: position(:, :), velocity(:, :), acceleration(:, :) INTEGER, INTENT(OUT) :: ErrStat CHARACTER(*), INTENT(OUT) :: ErrMsg REAL(wp), INTENT(IN), OPTIONAL :: orientation(:, :, :) REAL(wp), INTENT(IN), OPTIONAL :: angular_velocity(:, :), angular_acceleration(:, :) + LOGICAL, INTENT(IN), OPTIONAL :: step_start INTEGER :: c0, c1, es + LOGICAL :: at_start CHARACTER(512) :: em ErrStat = CD_AGG_OK ErrMsg = '' + at_start = .FALSE. + IF (PRESENT(step_start)) at_start = step_start IF (self%nhost_body > 0) THEN c0 = self%ncp_sys + self%ncable + self%nhost_rod + 1 c1 = ncp_all(self) @@ -2261,19 +2273,19 @@ SUBROUTINE set_host_objects(self, position, velocity, acceleration, ErrStat, Err IF (PRESENT(angular_velocity)) THEN CALL CD_Rod_SetHostKinematics(self%rod, position(:, c0:c1), velocity(:, c0:c1), acceleration(:, c0:c1), & es, em, orientation(:, :, c0:c1), angular_velocity(:, c0:c1), & - angular_acceleration(:, c0:c1)) + angular_acceleration(:, c0:c1), step_start=at_start) ELSE CALL CD_Rod_SetHostKinematics(self%rod, position(:, c0:c1), velocity(:, c0:c1), acceleration(:, c0:c1), & - es, em, orientation(:, :, c0:c1)) + es, em, orientation(:, :, c0:c1), step_start=at_start) END IF ELSE IF (PRESENT(angular_velocity)) THEN CALL CD_Rod_SetHostKinematics(self%rod, position(:, c0:c1), velocity(:, c0:c1), acceleration(:, c0:c1), & es, em, angular_velocity=angular_velocity(:, c0:c1), & - angular_acceleration=angular_acceleration(:, c0:c1)) + angular_acceleration=angular_acceleration(:, c0:c1), step_start=at_start) ELSE CALL CD_Rod_SetHostKinematics(self%rod, position(:, c0:c1), velocity(:, c0:c1), acceleration(:, c0:c1), & - es, em) + es, em, step_start=at_start) END IF END IF IF (es /= CD_DECKDRV_OK) CALL map_deck_status(es, em, ErrStat, ErrMsg) diff --git a/src/CableDyn_System.f90 b/src/CableDyn_System.f90 index aceed8f4..64ef1782 100644 --- a/src/CableDyn_System.f90 +++ b/src/CableDyn_System.f90 @@ -24,6 +24,7 @@ MODULE CableDyn_System CD_Calc_Model_CoupledLoads, CD_Recompute_Model_Acceleration, & CD_Calc_Model_CoupledKinematicDerivatives, & CD_Calc_Model_CoupledAccelDerivative, CD_Update_Model_CoupledAccelDerivative, & + CD_Calc_Model_CoupledEndMass, & CD_Update_Model_External_Loads, CD_Update_Model_Hydro_Fields, & CD_MODEL_OK, CD_MODEL_BADINPUT, & CD_MODEL_SOLVEFAIL, CD_MODEL_NOT_INITIALIZED, CD_MODEL_ALLOCFAIL, CD_Copy_Model @@ -2183,20 +2184,28 @@ SUBROUTINE CD_Calc_System_CoupledKinematicDerivatives(system, dload_dq, dload_dv END DO END SUBROUTINE CD_Calc_System_CoupledKinematicDerivatives - SUBROUTINE CD_Calc_System_CoupledAccelDerivative(system, dload_da, ErrStat, ErrMsg) + SUBROUTINE CD_Calc_System_CoupledAccelDerivative(system, dload_da, ErrStat, ErrMsg, frozen_interior) !! Return the aggregate analytic coupled-load derivative with respect to - !! compact prescribed coupled accelerations. + !! compact prescribed coupled accelerations. By default the line interiors' + !! accelerations follow the coupled ones (the condensed derivative of a step); + !! frozen_interior = .TRUE. holds them (-M_cc of every line, + !! CD_Calc_Model_CoupledEndMass): the response of CD_Calc_System_CoupledLoads when + !! only the coupled motion changes, as in an output probe. TYPE(CD_SystemType), INTENT(INOUT) :: system REAL(wp), INTENT(OUT) :: dload_da(:, :) INTEGER, INTENT(OUT) :: ErrStat CHARACTER(*), INTENT(OUT) :: ErrMsg + LOGICAL, INTENT(IN), OPTIONAL :: frozen_interior INTEGER :: i, j, k, lo, hi, nc, es, row, col + LOGICAL :: frozen CHARACTER(160) :: em ErrStat = CD_SYSTEM_OK ErrMsg = '' dload_da = CD_ZERO + frozen = .FALSE. + IF (PRESENT(frozen_interior)) frozen = frozen_interior IF (.NOT. system%initialized) THEN ErrStat = CD_SYSTEM_NOT_INITIALIZED ErrMsg = 'CableDyn_System: system is not initialized' @@ -2216,8 +2225,25 @@ SUBROUTINE CD_Calc_System_CoupledAccelDerivative(system, dload_da, ErrStat, ErrM RETURN END IF hi = lo + nc - 1 - ! the line's derivative stays in its own workspace (ad_result) and is summed from there - IF (nc > 0) THEN + IF (nc > 0 .AND. frozen) THEN + BLOCK + REAL(wp) :: m_cc(nc, nc) + CALL CD_Calc_Model_CoupledEndMass(system%lines(i), m_cc, es, em) + IF (es /= CD_MODEL_OK) THEN + ErrStat = CD_SYSTEM_SOLVEFAIL + ErrMsg = 'CableDyn_System: line coupled end mass failed: '//TRIM(em) + RETURN + END IF + DO j = 1, nc + row = system%coupled_dof_map(lo + j - 1) + DO k = 1, nc + col = system%coupled_dof_map(lo + k - 1) + dload_da(row, col) = dload_da(row, col) - m_cc(j, k) + END DO + END DO + END BLOCK + ELSE IF (nc > 0) THEN + ! the line's derivative stays in its own workspace (ad_result) and is summed from there CALL CD_Update_Model_CoupledAccelDerivative(system%lines(i), es, em) IF (es /= CD_MODEL_OK) THEN ErrStat = CD_SYSTEM_SOLVEFAIL diff --git a/src/openfast/CableDyn_OF.f90 b/src/openfast/CableDyn_OF.f90 index 432f98f9..854f534c 100644 --- a/src/openfast/CableDyn_OF.f90 +++ b/src/openfast/CableDyn_OF.f90 @@ -40,8 +40,9 @@ MODULE CableDyn !! construct is routed into the corresponding CableDyn feature (bodies and rods, !! viscoelastic and Syrope ropes, line failures, active tension through the CONTROL !! section, SeaState water kinematics), or, where CableDyn has no counterpart (for - !! example a CoupledPinned body or a Pinned rod on a line deck), fails closed with a - !! named error. + !! example a CoupledPinned body), fails closed with a named error. A CoupledPinned rod + !! is a coupling-mesh node like a Coupled rod but takes only the translation of its + !! node and returns force with zero moment: it turns about the node on its own. !! !! Supported coupled surface (each verified against stock MoorDyn or a named gate): !! Fixed/Coupled(Vessel) points, EI=0 mooring lines (BA damping + the Morison set), diff --git a/tests/test_bodies_rods.f90 b/tests/test_bodies_rods.f90 index a4a9548f..2063f9fc 100644 --- a/tests/test_bodies_rods.f90 +++ b/tests/test_bodies_rods.f90 @@ -10,7 +10,11 @@ PROGRAM test_bodies_rods !! rhoW A draft = m_total and heaves with 2 pi sqrt(m_total/(rhoW g A)) (CaEnd = 0); !! 3. the same spar on a light vertical tether: the tether carries the net buoyancy, and the !! Body/Rod channels report the body and rod on the line-coupled route; - !! 4. a LINES row written with R1A/R1B equals the same deck with Rod1A/Rod1B POINT rows. + !! 4. a LINES row written with R1A/R1B equals the same deck with Rod1A/Rod1B POINT rows; + !! 5. a short pinned rod at a step beyond its explicit swing limit sub-cycles it on a deck + !! without lines and on the staggered multibody march without an EI=0 line; + !! 6. a pinned rod held by a stiff finite-EI cable on the staggered march sub-cycles the cable + !! spring, whose end force the march applies explicitly. USE CableDyn_Precision, ONLY: wp USE CableDyn_DeckDriver, ONLY: CD_Run_Deck_Driver, CD_DECKDRV_OK USE, INTRINSIC :: IEEE_ARITHMETIC, ONLY: IEEE_IS_FINITE @@ -31,6 +35,8 @@ PROGRAM test_bodies_rods CALL check_pinned_rod_with_line() CALL check_zero_length_rod() CALL check_mixed_rest() + CALL check_lineless_substep() + CALL check_cable_rod_substep() IF (nfail > 0) THEN WRITE (*, '(A,I0,A)') 'FAIL: ', nfail, ' body/rod topology check(s) failed' ERROR STOP 1 @@ -440,9 +446,10 @@ END SUBROUTINE write_rod_deck SUBROUTINE check_rod_end_tokens() REAL(wp), ALLOCATABLE :: a(:, :), b(:, :) LOGICAL :: ok1, ok2 - ! MoorDyn CoupledPinned/VesselPinned rods fail closed by name + ! MoorDyn CoupledPinned/VesselPinned rods need a coupled host: the standalone driver refuses + ! them by name CALL write_rod_deck('bodrod_cpldpin.dat', .TRUE., 'CoupledPinned') - CALL expect_reject('bodrod_cpldpin.dat', 'CoupledPinned/VesselPinned RODS are not supported', & + CALL expect_reject('bodrod_cpldpin.dat', 'CoupledPinned/VesselPinned ROD requires a coupled host', & 'a CoupledPinned rod') CALL write_rod_deck('bodrod_tokens.dat', .TRUE.) CALL write_rod_deck('bodrod_points.dat', .FALSE.) @@ -702,4 +709,158 @@ SUBROUTINE check_mixed_rest() 'cable anchor Point

F equals AnchTen') CALL require(ABS(dat(14, 1) - dat(15, 1)) <= 1.0e-9_wp*dat(15, 1), 'Rod2TenB is the tether''s FairTen') END SUBROUTINE check_mixed_rest + + SUBROUTINE write_short_pendulum(path, dt, with_cable) + !! A dry 1 m rod (50 kg/m) pinned at End A at (0, 0, 20) and released at 30 degrees, on a deck + !! without lines, or (with_cable) on the staggered multibody march beside an independent + !! finite-EI cable hung from a Fixed rod to an anchor (no EI=0 line, so no line spring reaches + !! the pinned rod). + CHARACTER(*), INTENT(IN) :: path + REAL(wp), INTENT(IN) :: dt + LOGICAL, INTENT(IN) :: with_cable + INTEGER :: u + OPEN (NEWUNIT=u, FILE=path, STATUS='REPLACE', ACTION='WRITE') + WRITE (u, '(A)') 'Short dry rod pendulum pinned at End A' + IF (with_cable) THEN + 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)') 'cable 0.15 30 5.0e8 -0.8 1.0e4 1.2 0.01 1.0 0' + END IF + WRITE (u, '(A)') '--- ROD TYPES ---' + WRITE (u, '(A)') 'Name Diam Mass Cd Ca CdEnd CaEnd' + WRITE (u, '(A)') '(-) (m) (kg/m) (-) (-) (-) (-)' + WRITE (u, '(A)') 'pend 0.2 50 0 0 0 0' + WRITE (u, '(A)') '--- RODS ---' + WRITE (u, '(A)') 'ID RodType Attachment XA YA ZA XB YB ZB NumSegs Outputs' + WRITE (u, '(A)') '(-) (-) (-) (m) (m) (m) (m) (m) (m) (-) (-)' + WRITE (u, '(A,ES22.14,A,ES22.14,A)') '1 pend Pinned 0 0 20 ', 0.5_wp, ' 0 ', 20.0_wp - SQRT(0.75_wp), ' 4 -' + IF (with_cable) WRITE (u, '(A)') '2 pend Fixed 10 0 -55 10 0 -57 2 -' + IF (with_cable) THEN + WRITE (u, '(A)') '--- POINTS ---' + WRITE (u, '(A)') 'ID Type X Y Z Mass Vol CdA Ca' + WRITE (u, '(A)') '(-) (-) (m) (m) (m) (kg) (m3) (m2) (-)' + WRITE (u, '(A)') '1 Fixed 40 0 -60 0 0 0 0' + WRITE (u, '(A)') '--- LINES ---' + WRITE (u, '(A)') 'ID LineType AttachA AttachB UnstrLen NumSegs Outputs' + WRITE (u, '(A)') '(-) (-) (-) (-) (m) (-) (-)' + WRITE (u, '(A)') '1 cable R2B 1 35 10 -' + END IF + WRITE (u, '(A)') '--- OPTIONS ---' + WRITE (u, '(A)') '70 WtrDpth' + WRITE (u, '(A)') 'deck bodyIC' + IF (with_cable) WRITE (u, '(A)') 'staggered bodyScheme' + WRITE (u, '(ES22.14,A)') dt, ' dtM' + WRITE (u, '(A)') '18 TMax' + WRITE (u, '(A)') '--- OUTPUTS ---' + WRITE (u, '(A)') 'Rod1N4Px Rod1N4Pz' + WRITE (u, '(A)') '--- end ---' + CLOSE (u) + END SUBROUTINE write_short_pendulum + + SUBROUTINE check_lineless_substep() + !! A 1 m dry pinned rod swings with omega0^2 = m g (L/2)/I_A, about 14.6 rad^2/s^2, so a 0.6 s + !! step (omega0 dt = 2.29) is beyond the explicit limit of 2 for any line-free march: the deck + !! without lines, and the staggered multibody march whose only line is a finite-EI cable, + !! must take 6 sub-steps (omega0 dt/0.4 = 5.73) from the rod's own swing. Each run must + !! reproduce a run at the sub-step size at every 0.6 s output row (to the printed digits), + !! stay within its release angle and keep the elliptic-integral period to the accuracy of + !! omega0 dt_sub of about 0.38 (near (omega dt)^2/24 = 0.6 %). + REAL(wp), PARAMETER :: TH0 = 30.0_wp + REAL(wp), ALLOCATABLE :: dc(:, :), df(:, :) + REAL(wp) :: ia, t_ref, got, err, amp + INTEGER :: kase, i, nc + LOGICAL :: ok + CHARACTER(16) :: tag + + ia = 50.0_wp*(1.0_wp/3.0_wp + 0.2_wp**2/16.0_wp) + t_ref = 4.0_wp*SQRT(ia/(50.0_wp*GRAV*0.5_wp))*ellip_k(SIN(0.5_wp*TH0*PI/180.0_wp)) + DO kase = 1, 2 + tag = MERGE('no lines ', 'staggered, cable', kase == 1) + CALL write_short_pendulum('bodrod_short_c.dat', 0.6_wp, kase == 2) + CALL run('bodrod_short_c.dat', 'bodrod_short_c', 3, dc, ok) + IF (.NOT. ok) RETURN + CALL write_short_pendulum('bodrod_short_f.dat', 0.1_wp, kase == 2) + CALL run('bodrod_short_f.dat', 'bodrod_short_f', 3, df, ok) + IF (.NOT. ok) RETURN + nc = SIZE(dc, 2) + err = 0.0_wp + DO i = 1, nc + err = MAX(err, nan_max_abs(dc(2:3, i) - df(2:3, 6*(i - 1) + 1))) + END DO + amp = MAX(nan_max_abs(dc(2, :)), nan_max_abs(df(2, :))) + got = crossing_period(df(1, :), df(2, :)) + WRITE (*, '(A,A,A,ES10.3,A,F8.5,A,2F10.6)') 'short pinned rod at a 0.6 s step (', TRIM(tag), & + '): vs 0.1 s run ', err, ' m; max End B x/release ', amp/0.5_wp, '; period got/analytic [s] ', got, t_ref + CALL require(nc == 31 .AND. SIZE(df, 2) == 181, 'short pendulum: output rows ('//TRIM(tag)//')') + CALL require(err <= 1.0e-6_wp, 'short pendulum: 0.6 s step equals its 0.1 s sub-step run ('//TRIM(tag)//')') + CALL require(amp <= 1.02_wp*0.5_wp, 'short pendulum: the swing stays within its release ('//TRIM(tag)//')') + CALL require(ABS(got - t_ref) <= 1.5e-2_wp*t_ref, 'short pendulum: period ('//TRIM(tag)//')') + END DO + END SUBROUTINE check_lineless_substep + + SUBROUTINE write_cable_rod(path, dt) + !! A heavy 1 m rod (D = 0.3 m, 500 kg/m) hanging from a pin at (0, 0, -20), its End B held by + !! a 20 m neutrally buoyant finite-EI cable (EA 1e7 N, EI 10 N m^2) to an anchor along x at + !! 100 N of pretension, on the staggered multibody march (no EI=0 line). + CHARACTER(*), INTENT(IN) :: path + REAL(wp), INTENT(IN) :: dt + INTEGER :: u + OPEN (NEWUNIT=u, FILE=path, STATUS='REPLACE', ACTION='WRITE') + WRITE (u, '(A)') 'Pinned rod held by a stiff finite-EI cable' + 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,ES24.16,A)') 'tcable 0.05 ', RHO_W*0.25_wp*PI*0.05_wp**2, ' 1.0e7 -0.8 10.0 1.2 0.01 1.0 0' + WRITE (u, '(A)') '--- ROD TYPES ---' + WRITE (u, '(A)') 'Name Diam Mass Cd Ca CdEnd CaEnd' + WRITE (u, '(A)') '(-) (m) (kg/m) (-) (-) (-) (-)' + WRITE (u, '(A)') 'heavy 0.3 500 0 0 0 0' + WRITE (u, '(A)') '--- RODS ---' + WRITE (u, '(A)') 'ID RodType Attachment XA YA ZA XB YB ZB NumSegs Outputs' + WRITE (u, '(A)') '(-) (-) (-) (m) (m) (m) (m) (m) (m) (-) (-)' + WRITE (u, '(A)') '1 heavy Pinned 0 0 -20 0 0 -21 4 -' + WRITE (u, '(A)') '--- POINTS ---' + WRITE (u, '(A)') 'ID Type X Y Z Mass Vol CdA Ca' + WRITE (u, '(A)') '(-) (-) (m) (m) (m) (kg) (m3) (m2) (-)' + WRITE (u, '(A)') '1 Fixed 20 0 -21 0 0 0 0' + WRITE (u, '(A)') '--- LINES ---' + WRITE (u, '(A)') 'ID LineType AttachA AttachB UnstrLen NumSegs Outputs' + WRITE (u, '(A)') '(-) (-) (-) (-) (m) (-) (-)' + WRITE (u, '(A,ES24.16,A)') '1 tcable R1B 1 ', 20.0_wp*(1.0_wp - 1.0e-5_wp), ' 10 -' + WRITE (u, '(A)') '--- OPTIONS ---' + WRITE (u, '(A)') '70 WtrDpth' + WRITE (u, '(A)') 'deck bodyIC' + WRITE (u, '(A)') 'staggered bodyScheme' + WRITE (u, '(ES22.14,A)') dt, ' dtM' + WRITE (u, '(A)') '2 TMax' + WRITE (u, '(A)') '--- OUTPUTS ---' + WRITE (u, '(A)') 'Rod1N4Px Rod1N4Pz' + WRITE (u, '(A)') '--- end ---' + CLOSE (u) + END SUBROUTINE write_cable_rod + + SUBROUTINE check_cable_rod_substep() + !! The cable's axial stiffness EA/L = 5e5 N/m acts at the 1 m arm against the rod's inertia + !! about its pin (about 170 kg m^2): omega^2 about 3e3 rad^2/s^2, against about 14 from the + !! rod's net weight, so a 0.05 s step (omega dt = 2.7) needs sub-steps that only the cable + !! spring of the estimate asks for (the staggered march returns the cable end force + !! explicitly). The rod must stay near its pose (End B within 0.1 m) and end within 1 cm of + !! a run at dtM = 0.005 s. + REAL(wp), ALLOCATABLE :: dc(:, :), df(:, :) + REAL(wp) :: dev, err + LOGICAL :: ok + CALL write_cable_rod('bodrod_cable_c.dat', 0.05_wp) + CALL run('bodrod_cable_c.dat', 'bodrod_cable_c', 3, dc, ok) + IF (.NOT. ok) RETURN + CALL write_cable_rod('bodrod_cable_f.dat', 0.005_wp) + CALL run('bodrod_cable_f.dat', 'bodrod_cable_f', 3, df, ok) + IF (.NOT. ok) RETURN + dev = nan_max_abs(dc(2, :)) + err = nan_max_abs(dc(2:3, SIZE(dc, 2)) - df(2:3, SIZE(df, 2))) + WRITE (*, '(A,ES10.3,A,ES10.3)') 'pinned rod on a stiff cable at a 0.05 s step: max |End B x| ', dev, & + ' m; end vs dtM/10 ', err + CALL require(dev <= 0.1_wp, 'cable rod: End B stays near its pose (cable spring sub-steps)') + CALL require(err <= 1.0e-2_wp, 'cable rod: ends as the dtM/10 run') + END SUBROUTINE check_cable_rod_substep END PROGRAM test_bodies_rods diff --git a/tests/test_body_rod_physics.f90 b/tests/test_body_rod_physics.f90 index 2e039c0b..95525e5e 100644 --- a/tests/test_body_rod_physics.f90 +++ b/tests/test_body_rod_physics.f90 @@ -25,6 +25,10 @@ PROGRAM test_body_rod_physics !! buoy on an overstretched line, bodies and rods displaced and turned) reach the same !! stable equilibrium, never an unstable one. The rigs of 1-4 !! release a body from its deck pose (bodyIC deck). + !! 7. a rod carried horizontally (drifting, or turning about its pin) onto a bathymetry step + !! up is sub-stepped for the contact it reaches within a step. + !! 8. a floating rod is sub-stepped for its waterplane stiffness, and a rod held by seabed + !! friction holds still at a coarse step (the friction damper is implicit). USE CableDyn_Precision, ONLY: wp USE CableDyn_DeckDriver, ONLY: CD_Run_Deck_Driver, CD_Deck_Equilibrium_Jacobian_Check, CD_DECKDRV_OK USE, INTRINSIC :: IEEE_ARITHMETIC, ONLY: IEEE_IS_FINITE @@ -49,6 +53,9 @@ PROGRAM test_body_rod_physics CALL check_equilibrium_jacobian() CALL check_equilibrium_seed_robustness() CALL check_static_body_start() + CALL check_bathymetry_reach_substep() + CALL check_floating_rod_substep() + CALL check_rod_friction_hold() IF (nfail > 0) THEN WRITE (*, '(A,I0,A)') 'FAIL: ', nfail, ' body/rod physics check(s) failed' ERROR STOP 1 @@ -1442,4 +1449,221 @@ SUBROUTINE write_connect_deck(path) CLOSE (u) END SUBROUTINE write_connect_deck + ! ------------------------------------------------------------------------------------------ + ! 7. Contact reach over a bathymetry step + ! ------------------------------------------------------------------------------------------ + + REAL(wp) FUNCTION step_floor(x) RESULT(z) + !! The seabed of write_step_bathy: z = -10 m up to x = X0, a linear ramp to -9.2 m at + !! x = X0 + 0.8 (a 45 degree slope), and -9.2 m beyond. + REAL(wp), INTENT(IN) :: x + REAL(wp), PARAMETER :: X0 = 0.3_wp + z = -10.0_wp + 0.8_wp*MIN(1.0_wp, MAX(0.0_wp, (x - X0)/0.8_wp)) + END FUNCTION step_floor + + SUBROUTINE write_step_bathy(path) + CHARACTER(*), INTENT(IN) :: path + INTEGER :: u + OPEN (NEWUNIT=u, FILE=path, STATUS='REPLACE', ACTION='WRITE') + WRITE (u, '(A)') '-20.0 -20.0 10.0' + WRITE (u, '(A)') '0.3 -20.0 10.0' + WRITE (u, '(A)') '1.1 -20.0 9.2' + WRITE (u, '(A)') '20.0 -20.0 9.2' + WRITE (u, '(A)') '-20.0 20.0 10.0' + WRITE (u, '(A)') '0.3 20.0 10.0' + WRITE (u, '(A)') '1.1 20.0 9.2' + WRITE (u, '(A)') '20.0 20.0 9.2' + CLOSE (u) + END SUBROUTINE write_step_bathy + + SUBROUTINE write_reach_deck(path, rod_type, x_a, dt) + !! A neutrally buoyant 2 m rod (D = 0.2 m, Cd = 1.2, Ca = 1) along y with its axis 0.5 m above + !! the 10 m bed of write_step_bathy, on a deck without lines, carried towards the 0.8 m step + !! up by a 2 m/s current along x: a Free rod at x = x_a drifts over it; a Pinned rod + !! (End A at the origin) weathervanes about its pin and sweeps its stations into it. + CHARACTER(*), INTENT(IN) :: path, rod_type + REAL(wp), INTENT(IN) :: x_a, dt + INTEGER :: u + OPEN (NEWUNIT=u, FILE=path, STATUS='REPLACE', ACTION='WRITE') + WRITE (u, '(A)') 'Rod carried over a bathymetry step by a current' + WRITE (u, '(A)') '--- ROD TYPES ---' + WRITE (u, '(A)') 'Name Diam Mass Cd Ca CdEnd CaEnd' + WRITE (u, '(A)') '(-) (m) (kg/m) (-) (-) (-) (-)' + WRITE (u, '(A,ES24.16,A)') 'float 0.2 ', RHO_W*0.25_wp*PI*0.2_wp**2, ' 1.2 1.0 0 0' + WRITE (u, '(A)') '--- RODS ---' + WRITE (u, '(A)') 'ID RodType Attachment XA YA ZA XB YB ZB NumSegs Outputs' + WRITE (u, '(A)') '(-) (-) (-) (m) (m) (m) (m) (m) (m) (-) (-)' + WRITE (u, '(A,A,A,ES24.16,A,ES24.16,A)') '1 float ', rod_type, ' ', x_a, ' 0 -9.5 ', x_a, ' 2 -9.5 4 -' + WRITE (u, '(A)') '--- OPTIONS ---' + WRITE (u, '(A)') '9.80665 g' + WRITE (u, '(A)') '1025.0 rhoW' + WRITE (u, '(A)') 'reach_step.xyz bathymetryFile' + WRITE (u, '(A)') '1.0e7 kBot' + WRITE (u, '(A)') 'uniform 2.0 0 0 current' + WRITE (u, '(A)') 'deck bodyIC' + WRITE (u, '(ES22.14,A)') dt, ' dtM' + WRITE (u, '(A)') '4.0 TMax' + WRITE (u, '(A)') '--- OUTPUTS ---' + WRITE (u, '(A)') 'Rod1N0Px Rod1N0Pz Rod1N2Px Rod1N2Pz Rod1N4Px Rod1N4Pz' + WRITE (u, '(A)') '--- end ---' + CLOSE (u) + END SUBROUTINE write_reach_deck + + SUBROUTINE check_bathymetry_reach_substep() + !! The contact reach must look along the station's whole path over the step. A neutrally + !! buoyant rod 0.5 m above a 10 m bed, carried by a 2 m/s current towards an 0.8 m step up (a + !! 45 degree ramp), meets the higher bed only by moving horizontally: (1) a Free rod drifting + !! over the step, (2) a Pinned rod turning about its pin (its stations move horizontally, + !! with no vertical velocity and an acceleration towards the pin). At dtM = 0.2 s the bed + !! below each station is out of vertical reach (0.5 m against g dt^2/2 = 0.2 m plus the + !! radius), so only the horizontal reach dt |v + w x s| + dt^2 (|a| + |alpha x s| + + !! |w|^2 |s| + g)/2 and the highest floor within it bring the contact springs (kBot 1e7) + !! into the sub-step estimate before a station is driven into the ramp. The run must stay + !! finite, keep every output node out of the bed (at most 8 cm below the floor under it, the + !! penalty set against the drag that presses the rod onto the slope) + !! and below z = -8 m, and end within 0.2 m of a run at dtM = 0.05 s (the rod meets a 45 + !! degree slope at about 2 m/s). With the vertical reach and the floor under each station + !! alone, the Free rod ends 3 m from the dtM = 0.05 s run and the Pinned rod sinks 14 cm into + !! the slope and is thrown up to z = -7.7 m. + REAL(wp), ALLOCATABLE :: dc(:, :), df(:, :) + REAL(wp) :: worst, zmax, err + INTEGER :: kase, i, j + LOGICAL :: ok + CHARACTER(8) :: kind + + CALL write_step_bathy('reach_step.xyz') + DO kase = 1, 2 + IF (kase == 1) THEN + kind = 'Free' + CALL write_reach_deck('reach_c.dat', 'Free', -3.0_wp, 0.2_wp) + CALL write_reach_deck('reach_f.dat', 'Free', -3.0_wp, 0.05_wp) + ELSE + kind = 'Pinned' + CALL write_reach_deck('reach_c.dat', 'Pinned', 0.0_wp, 0.2_wp) + CALL write_reach_deck('reach_f.dat', 'Pinned', 0.0_wp, 0.05_wp) + END IF + CALL run_deck('reach_c.dat', 'reach_c', ok) + IF (.NOT. ok) CYCLE + CALL read_out('reach_c.out', 7, dc, ok) + IF (.NOT. ok) CYCLE + CALL run_deck('reach_f.dat', 'reach_f', ok) + IF (.NOT. ok) CYCLE + CALL read_out('reach_f.out', 7, df, ok) + IF (.NOT. ok) CYCLE + worst = HUGE(1.0_wp) + zmax = -HUGE(1.0_wp) + DO i = 1, SIZE(dc, 2) + DO j = 2, 6, 2 + worst = MIN(worst, dc(j + 1, i) - step_floor(dc(j, i))) + zmax = MAX(zmax, dc(j + 1, i)) + END DO + END DO + err = nan_max_abs(dc(2:7, SIZE(dc, 2)) - df(2:7, SIZE(df, 2))) + WRITE (*, '(A,A,A,F8.4,A,F8.4,A,F8.4,A,ES10.3)') 'rod over a bathymetry step (', TRIM(kind), & + '): end x ', dc(6, SIZE(dc, 2)), ' m; least clearance ', worst, ' m; highest node ', zmax, & + ' m; end vs dtM/4 ', err + CALL require(ALL(IEEE_IS_FINITE(dc)), 'reach: '//TRIM(kind)//' run finite') + CALL require(dc(6, SIZE(dc, 2)) > 0.6_wp, 'reach: '//TRIM(kind)//' rod carried over the step') + CALL require(worst >= -0.08_wp .AND. zmax <= -8.0_wp, 'reach: '//TRIM(kind)//' rod kept out of the bed') + CALL require(err <= 0.2_wp, 'reach: '//TRIM(kind)//' ends as the dtM/4 run') + END DO + END SUBROUTINE check_bathymetry_reach_substep + + ! ------------------------------------------------------------------------------------------ + ! 8. A floating rod and a rod held by seabed friction at a coarse step + ! ------------------------------------------------------------------------------------------ + + SUBROUTINE check_floating_rod_substep() + !! A horizontal 1 m rod (D = 0.05 m, no drag or added mass) floating half submerged on a deck + !! without lines, released 5 mm below its waterline: its waterplane rhoW g D L against its + !! mass rhoW pi D^2 L/8 gives omega^2 = 8 g/(pi D), about 500 rad^2/s^2, so a 0.1 s step + !! (omega dt = 2.2) is beyond the explicit limit. The waterplane stiffness of the sub-step + !! estimate must keep the undamped heave within its release amplitude over 3 s. + REAL(wp), ALLOCATABLE :: dat(:, :) + REAL(wp) :: amp + INTEGER :: u + LOGICAL :: ok + OPEN (NEWUNIT=u, FILE='float_rod.dat', STATUS='REPLACE', ACTION='WRITE') + WRITE (u, '(A)') 'Floating horizontal rod released below its waterline' + WRITE (u, '(A)') '--- ROD TYPES ---' + WRITE (u, '(A)') 'Name Diam Mass Cd Ca CdEnd CaEnd' + WRITE (u, '(A)') '(-) (m) (kg/m) (-) (-) (-) (-)' + WRITE (u, '(A,ES24.16,A)') 'stick 0.05 ', RHO_W*PI*0.05_wp**2/8.0_wp, ' 0 0 0 0' + WRITE (u, '(A)') '--- RODS ---' + WRITE (u, '(A)') 'ID RodType Attachment XA YA ZA XB YB ZB NumSegs Outputs' + WRITE (u, '(A)') '(-) (-) (-) (m) (m) (m) (m) (m) (m) (-) (-)' + WRITE (u, '(A)') '1 stick Free 0 0 -0.005 1 0 -0.005 4 -' + WRITE (u, '(A)') '--- OPTIONS ---' + WRITE (u, '(A)') '9.80665 g' + WRITE (u, '(A)') '1025.0 rhoW' + WRITE (u, '(A)') '50 WtrDpth' + WRITE (u, '(A)') 'deck bodyIC' + WRITE (u, '(A)') '0.1 dtM' + WRITE (u, '(A)') '3.0 TMax' + WRITE (u, '(A)') '--- OUTPUTS ---' + WRITE (u, '(A)') 'Rod1N2Pz' + WRITE (u, '(A)') '--- end ---' + CLOSE (u) + CALL run_deck('float_rod.dat', 'float_rod', ok) + IF (.NOT. ok) RETURN + CALL read_out('float_rod.out', 2, dat, ok) + IF (.NOT. ok) RETURN + amp = nan_max_abs(dat(2, :)) + WRITE (*, '(A,ES10.3,A)') 'floating rod at a 0.1 s step: max |heave| ', amp, ' m (released at 5.0e-3 m)' + CALL require(amp <= 5.5e-3_wp, 'floating rod: the heave stays within its release (waterplane sub-steps)') + END SUBROUTINE check_floating_rod_substep + + SUBROUTINE check_rod_friction_hold() + !! A heavy rod (D = 0.2 m, 50 kg/m) lying on a frictional bed (mu = 0.5, kBot 1e5) in a + !! 0.3 m/s cross current, on a deck without lines at dtM = 0.1 s: the drag (about 11 N/m) + !! is far below mu N (about 87 N/m), so the rod holds. The regularised friction is a damper + !! mu N/vreg (vreg = 1e-3 m/s); applied explicitly it would flip the friction by mu N each + !! step. Implicit, the rod must hold still after the first second (|End A velocity| below + !! 5e-3 m/s) and its net cross load (drag less friction, Rod1Fy) stay below 5 % of mu N L. + REAL(wp), ALLOCATABLE :: dat(:, :) + REAL(wp) :: vmax, fmax, mun + INTEGER :: u, i + LOGICAL :: ok + OPEN (NEWUNIT=u, FILE='fric_rod.dat', STATUS='REPLACE', ACTION='WRITE') + WRITE (u, '(A)') 'Heavy rod held by seabed friction in a cross current' + WRITE (u, '(A)') '--- ROD TYPES ---' + WRITE (u, '(A)') 'Name Diam Mass Cd Ca CdEnd CaEnd' + WRITE (u, '(A)') '(-) (m) (kg/m) (-) (-) (-) (-)' + WRITE (u, '(A)') 'bar 0.2 50 1.2 1.0 0 0' + WRITE (u, '(A)') '--- RODS ---' + WRITE (u, '(A)') 'ID RodType Attachment XA YA ZA XB YB ZB NumSegs Outputs' + WRITE (u, '(A)') '(-) (-) (-) (m) (m) (m) (m) (m) (m) (-) (-)' + WRITE (u, '(A)') '1 bar Free 0 0 -20 1 0 -20 4 -' + WRITE (u, '(A)') '--- OPTIONS ---' + WRITE (u, '(A)') '9.80665 g' + WRITE (u, '(A)') '1025.0 rhoW' + WRITE (u, '(A)') '20 WtrDpth' + WRITE (u, '(A)') '1.0e5 kBot' + WRITE (u, '(A)') '0.5 frictionMu' + WRITE (u, '(A)') 'uniform 0 0.3 0 current' + WRITE (u, '(A)') 'deck bodyIC' + WRITE (u, '(A)') '0.1 dtM' + WRITE (u, '(A)') '4.0 TMax' + WRITE (u, '(A)') '--- OUTPUTS ---' + WRITE (u, '(A)') 'Rod1Vy Rod1Fy' + WRITE (u, '(A)') '--- end ---' + CLOSE (u) + CALL run_deck('fric_rod.dat', 'fric_rod', ok) + IF (.NOT. ok) RETURN + CALL read_out('fric_rod.out', 3, dat, ok) + IF (.NOT. ok) RETURN + mun = 0.5_wp*(50.0_wp - RHO_W*0.25_wp*PI*0.2_wp**2)*GRAV + vmax = 0.0_wp + fmax = 0.0_wp + DO i = 1, SIZE(dat, 2) + IF (dat(1, i) < 1.0_wp) CYCLE + vmax = MAX(vmax, ABS(dat(2, i))) + fmax = MAX(fmax, ABS(dat(3, i))) + END DO + WRITE (*, '(A,ES10.3,A,ES10.3,A,ES10.3,A)') 'rod held by friction at a 0.1 s step: max |v| ', vmax, & + ' m/s; max |net cross load| ', fmax, ' N against mu N L ', mun, ' N' + CALL require(vmax <= 5.0e-3_wp, 'friction: the rod holds still (implicit friction damper)') + CALL require(fmax <= 0.05_wp*mun, 'friction: the net cross load stays balanced') + END SUBROUTINE check_rod_friction_hold + END PROGRAM test_body_rod_physics diff --git a/tests/test_c_api.f90 b/tests/test_c_api.f90 index ea8aa269..92e78e42 100644 --- a/tests/test_c_api.f90 +++ b/tests/test_c_api.f90 @@ -538,14 +538,16 @@ SUBROUTINE case_stale_double_close_copied_handle() END SUBROUTINE case_stale_double_close_copied_handle SUBROUTINE case_deck_bodies_rods() - !! A deck with a free rod (and one with a free Rigid6 body) initializes through the aggregate: - !! the coupled DOFs are its Coupled points, the step is the deck dtM, and 20 driven steps - !! reproduce CD_AGG driven directly bit-for-bit (loads and coupled motion), also across a - !! SaveState / three trial steps / RestoreState rewind half way. A mismatched dt, - !! load derivatives and point fluid fields fail closed by name; a Coupled rod (a 6-DOF host - !! node) is rejected by the standalone deck rules. + !! A deck with a free rod (and one with a free Rigid6 body, and one with a Pinned rod) + !! initializes through the aggregate: the coupled DOFs are its Coupled points, the step is the + !! deck dtM, and 20 driven steps reproduce CD_AGG driven directly bit-for-bit (loads and + !! coupled motion), also across a SaveState / three trial steps / RestoreState rewind half + !! way. A mismatched dt, load derivatives and point fluid fields fail closed by name; a + !! Coupled rod (a 6-DOF host node) and a CoupledPinned rod (a host-driven pin) are rejected + !! by the standalone deck rules. CHARACTER(*), PARAMETER :: ROD_DECK = 'capi_rod_deck.dat', BODY_DECK = 'capi_body_deck.dat', & - HOST_DECK = 'capi_hostrod_deck.dat' + HOST_DECK = 'capi_hostrod_deck.dat', PIN_DECK = 'capi_pinrod_deck.dat', & + HOST_PIN_DECK = 'capi_hostpin_deck.dat' CHARACTER(KIND=C_CHAR), TARGET :: c_path(64) CHARACTER(KIND=C_CHAR), TARGET :: msg(300) TYPE(C_PTR) :: handle @@ -562,12 +564,17 @@ SUBROUTINE case_deck_bodies_rods() CALL write_capi_object_deck(ROD_DECK, 1) CALL write_capi_object_deck(BODY_DECK, 2) CALL write_capi_object_deck(HOST_DECK, 3) - DO ideck = 1, 2 - IF (ideck == 1) THEN + CALL write_capi_object_deck(PIN_DECK, 4) + CALL write_capi_object_deck(HOST_PIN_DECK, 5) + DO ideck = 1, 3 + SELECT CASE (ideck) + CASE (1) path = ROD_DECK - ELSE + CASE (2) path = BODY_DECK - END IF + CASE DEFAULT + path = PIN_DECK + END SELECT c_path = C_NULL_CHAR DO i = 1, LEN_TRIM(path) c_path(i) = path(i:i) @@ -651,11 +658,24 @@ SUBROUTINE case_deck_bodies_rods() CALL CableDyn_GetLastError(handle, C_LOC(msg), INT(SIZE(msg), C_INT)) CALL require(es == 3_C_INT .AND. INDEX(c_text(msg), 'Coupled/Vessel ROD') > 0, 'c-api-objects:host-rod-rejected') CALL CableDyn_Close(handle, es) + ! so is a CoupledPinned rod, whose pin a coupled host moves + path = HOST_PIN_DECK + c_path = C_NULL_CHAR + DO i = 1, LEN_TRIM(path) + c_path(i) = path(i:i) + END DO + CALL CableDyn_Create(handle, es) + CALL CableDyn_InitDeck(handle, C_LOC(c_path), INT(LEN_TRIM(path), C_INT), es) + CALL CableDyn_GetLastError(handle, C_LOC(msg), INT(SIZE(msg), C_INT)) + CALL require(es == 3_C_INT .AND. INDEX(c_text(msg), 'requires a coupled host') > 0, & + 'c-api-objects:host-pinned-rod-rejected') + CALL CableDyn_Close(handle, es) END SUBROUTINE case_deck_bodies_rods SUBROUTINE write_capi_object_deck(path, kind) !! kind 1: a submerged free rod between a Fixed anchor and a Coupled fairlead; kind 2: the same - !! with a free Rigid6 body; kind 3: a Coupled rod (a 6-DOF host node). + !! with a free Rigid6 body; kind 3: a Coupled rod (a 6-DOF host node); kind 4: a Pinned rod + !! (End A on a fixed pin); kind 5: a CoupledPinned rod (its pin a host node). CHARACTER(*), INTENT(IN) :: path INTEGER, INTENT(IN) :: kind INTEGER :: u @@ -679,11 +699,16 @@ SUBROUTINE write_capi_object_deck(path, kind) 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) (-) (-)' - IF (kind == 1) THEN + SELECT CASE (kind) + CASE (1) WRITE (u, '(A)') '1 rodmat Free 0.0 0.0 -4.0 0.0 0.0 -2.0 2 -' - ELSE + CASE (3) WRITE (u, '(A)') '1 rodmat Coupled 0.0 0.0 -4.0 0.0 0.0 -2.0 2 -' - END IF + CASE (4) + WRITE (u, '(A)') '1 rodmat Pinned 0.0 0.0 -4.0 0.0 0.0 -2.0 2 -' + CASE DEFAULT + WRITE (u, '(A)') '1 rodmat CoupledPinned 0.0 0.0 -4.0 0.0 0.0 -2.0 2 -' + END SELECT END IF WRITE (u, '(A)') '--- POINTS ---' WRITE (u, '(A)') 'ID Type X Y Z Mass Vol CdA Ca' @@ -723,6 +748,8 @@ SUBROUTINE write_capi_object_deck(path, kind) WRITE (u, '(A)') '1.0e5 kBot' WRITE (u, '(A)') '0.005 dtM' WRITE (u, '(A)') '1.0 TMax' + ! the rod pinned at its lower end has no stable static balance: start from the deck pose + IF (kind == 4) WRITE (u, '(A)') 'deck bodyIC' WRITE (u, '(A)') '--- end ---' CLOSE (u) END SUBROUTINE write_capi_object_deck diff --git a/tests/test_openfast_aggregate.f90 b/tests/test_openfast_aggregate.f90 index 56f52f54..c2a04914 100644 --- a/tests/test_openfast_aggregate.f90 +++ b/tests/test_openfast_aggregate.f90 @@ -1821,13 +1821,14 @@ SUBROUTINE case_coupled_rigid6_mirror() DEALLOCATE (s1, s2, s3, sbad) END SUBROUTINE case_coupled_rigid6_mirror - SUBROUTINE write_coupled_rod_deck(path, add_current, rod_type) + SUBROUTINE write_coupled_rod_deck(path, add_current, rod_type, extra_option) !! A submerged Free rod tethered between a Fixed anchor and a Coupled fairlead by two chain !! lines (still water). add_current appends a deck current OPTION to exercise the still-water scope. - !! rod_type replaces the rod's Free type (the other rod routes). + !! rod_type replaces the rod's Free type (the other rod routes); extra_option is one more + !! OPTIONS row. CHARACTER(*), INTENT(IN) :: path LOGICAL, INTENT(IN) :: add_current - CHARACTER(*), INTENT(IN), OPTIONAL :: rod_type + CHARACTER(*), INTENT(IN), OPTIONAL :: rod_type, extra_option INTEGER :: u, ios CHARACTER(16) :: rt rt = 'Free' @@ -1872,6 +1873,7 @@ SUBROUTINE write_coupled_rod_deck(path, add_current, rod_type) WRITE (u, '(A)') '10.0 WtrDpth' WRITE (u, '(A)') '1.0e5 kBot' IF (add_current) WRITE (u, '(A)') 'profile -2.0 0.0 0.0 0.0 0.0 2.0 0.0 0.0 current' + IF (PRESENT(extra_option)) WRITE (u, '(A)') extra_option WRITE (u, '(A)') '--- OUTPUTS ---' WRITE (u, '(A)') 'FairTen2' WRITE (u, '(A)') '--- end ---' @@ -2037,10 +2039,35 @@ SUBROUTINE case_coupled_rod_fluid() CALL require(x_flow - x_still > 1.0e-4_wp, 'rod-fluid:host-current-drives-rod-downstream') CALL CD_AGG_End(flow, es, em) CALL CD_AGG_End(still, es, em) - ! the coupled rod march turns no rod about a pin: a Pinned rod is refused by name + ! the coupled rod march turns a Pinned rod about its fixed End A. Pinned at its lower end the + ! rod (heavier than water, its slack upper line pulling End B down) has no stable balance, so + ! the static start refuses it by name; from the deck pose a sideways fairlead drift turns it. CALL write_coupled_rod_deck('agg_rod_pinned.dat', .FALSE., 'Pinned') CALL CD_AGG_Init_From_Deck(still, 'agg_rod_pinned.dat', DT, es, em) - CALL require(es /= CD_AGG_OK .AND. INDEX(em, 'Pinned ROD') > 0, 'rod:pinned-fails-closed-by-name: '//TRIM(em)) + CALL require(es /= CD_AGG_OK .AND. INDEX(em, 'unstable') > 0, 'rod:pinned-unstable-static-start: '//TRIM(em)) + CALL write_coupled_rod_deck('agg_rod_pinned.dat', .FALSE., 'Pinned', 'deck bodyIC') + CALL CD_AGG_Init_From_Deck(still, 'agg_rod_pinned.dat', DT, es, em) + CALL require(es == CD_AGG_OK, 'rod:pinned-accepted: '//TRIM(em)) + IF (es /= CD_AGG_OK) RETURN + CALL CD_AGG_GetMovingPointMesh(still, r0, v0, a0, load, es, em) + v0 = 0.0_wp + a0 = 0.0_wp + v0(1, 1) = 0.2_wp + x_still = 0.0_wp + DO s = 1, 40 + r0(1, 1) = r0(1, 1) + 0.2_wp*DT + CALL CD_AGG_Step_Moving(still, DT, r0, v0, a0, cv, st, ia, es, em, t_committed=REAL(s, wp)*DT) + CALL require(es == CD_AGG_OK .AND. cv, 'rod:pinned-step: '//TRIM(em)) + IF (es /= CD_AGG_OK) EXIT + CALL CD_AGG_Get_Rod_States(still, ss, es, em) + ! End A = centre - (L/2) e1 stays on the pin at (0, 0, -4) + x_still = MAX(x_still, nan_max_abs(ss(1:3) - ss(16:18) - [0.0_wp, 0.0_wp, -4.0_wp])) + END DO + WRITE (*, '(A,ES10.3,A,ES10.3)') 'coupled Pinned rod: max |End A - pin| = ', x_still, & + ' m; |omega| after 40 steps = ', nan_max_abs(ss(10:12)) + CALL require(x_still <= 1.0e-12_wp, 'rod:pinned-end-A-stays-at-pin') + CALL require(nan_max_abs(ss(10:12)) > 0.0_wp, 'rod:pinned-turns-about-pin') + CALL CD_AGG_End(still, es, em) END SUBROUTINE case_coupled_rod_fluid SUBROUTINE case_rejected_static_branch_status() diff --git a/tests/test_openfast_pinned_rod.f90 b/tests/test_openfast_pinned_rod.f90 new file mode 100644 index 00000000..530d4ae5 --- /dev/null +++ b/tests/test_openfast_pinned_rod.f90 @@ -0,0 +1,1471 @@ +! File: tests/test_openfast_pinned_rod.f90 +! SPDX-License-Identifier: Apache-2.0 +! Copyright (c) 2026 Jae Hoon Seo, SMI Lab, Inha University +PROGRAM test_openfast_pinned_rod + !! Pinned and CoupledPinned rods on the OpenFAST CompMooring = 5 aggregate (the coupled rod + !! march turning a rod about a fixed pin or about a pin the host moves). Gates: + !! 1) a dry Pinned rod released at 30 degrees swings with the compound-pendulum period of + !! the complete elliptic integral (1e-3 at dt = T/100) and End A stays at the pin; + !! 2) a CoupledPinned rod whose host node is held reproduces the Pinned rod (1e-12), returns + !! zero moment, and its host force is the analytic pin reaction of the swinging rod; + !! 3) under a constant host acceleration a the rod swings about the mean angle atan(a/g) + !! with the period of the effective gravity sqrt(g^2 + a^2); + !! 4) a harmonic pin motion reproduces the linear base-excitation solution, converging at + !! second order in dt; + !! 5) a rod held by stiff tethers sub-cycles a coarse coupling step it could not take + !! explicitly and matches a run at the sub-step size; the host orientation and angular + !! rates are ignored; + !! 6) snapshot / step / restore / step is bit-identical; + !! 7) an output probe returns -M_eff a_p for a pin acceleration a_p (the re-solved rotation), + !! does not depend on the end acceleration the attached lines' loads were evaluated with, + !! and leaves the state bit-identical once restored; + !! 8) a fresh instance overlaid with the checkpoint state (host kinematics, line interiors, + !! rod states, committed line-end motion) returns the same loads before the next step and + !! continues bit-identically; + !! 9) PtfmInit moves the pin with the platform and the static initial condition balances the + !! rod about it; + !! 10) a CoupledPinned rod outside a coupled host is refused by name; + !! 11) the rod march needs no staged copy of the step-start rods (the rod carries its + !! step-start pin): a step without one is bit-identical; + !! 12) only a Pinned or CoupledPinned rod may leave an end without a line or POINT row; + !! 13) a short Pinned rod without a line (dry and hanging, or buoyant and upright) sub-cycles + !! a coupling step beyond the explicit limit of its own swing and keeps its period; + !! 14) a CoupledPinned rod whose pin crosses the free surface within one coupling step + !! (submerged to dry, or dry to submerged) sub-cycles it for the stiffer of its wet states; + !! 15) a Pinned rod whose far end rests on a stiff seabed, and a Free rod lying on it, sub-cycle + !! the contact mode of a large coupling step and stay at rest on the bed. + USE CableDyn_Precision, ONLY: wp + USE CableDyn_DeckDriver, ONLY: CD_Run_Deck_Driver, CD_DECKDRV_OK, CD_Rod_SetHostKinematics, CD_Step_Aggregate_Rod + USE CableDyn_OpenFAST_Aggregate, ONLY: CD_AGG_ModuleType, CD_AGG_Init_From_Deck, CD_AGG_NMovingPoints, & + CD_AGG_GetMovingPointMesh, CD_AGG_UpdateStates_Moving, & + CD_AGG_Step_Moving, CD_AGG_CalcOutput, CD_AGG_Snapshot, CD_AGG_Restore, & + CD_AGG_End, CD_AGG_OK, CD_AGG_EvalChannel, CD_AGG_NumChannels, & + CD_AGG_Rod_MirrorSize, CD_AGG_Get_Rod_States, CD_AGG_Set_Rod_States, & + CD_AGG_HasRod + USE CableDyn_System, ONLY: CD_System_NLines, CD_System_Line_NDOF, CD_Get_System_Line_State, & + CD_Update_System_Line_Interior_State, CD_SYSTEM_OK, CD_System_NSystemCoupledDOF, & + CD_Get_System_CoupledMotion, CD_Update_System_CoupledMotion, CD_Calc_System_CoupledLoads + USE, INTRINSIC :: IEEE_ARITHMETIC, ONLY: IEEE_IS_FINITE + IMPLICIT NONE + REAL(wp), PARAMETER :: PI = 3.141592653589793_wp, G = 9.80665_wp + ! the dry pendulum: L = 10 m, D = 0.2 m, 50 kg/m, pinned at z = 20 m (above the water) + REAL(wp), PARAMETER :: LP = 10.0_wp, DP = 0.2_wp, MP = 500.0_wp, ZPIN = 20.0_wp + INTEGER :: nfail + + nfail = 0 + CALL case_pendulum_and_held_host() + CALL case_constant_acceleration() + CALL case_harmonic_base_excitation() + CALL case_substep_and_state() + CALL case_probe() + CALL case_ptfm_static() + CALL case_standalone_refusal() + CALL case_unstaged_step() + CALL case_bare_rod_ends() + CALL case_lineless_swing_substep() + CALL case_surface_crossing_pin() + CALL case_seabed_contact_substep() + IF (nfail > 0) THEN + WRITE (*, '(A,I0,A)') 'FAIL: ', nfail, ' assertion(s) failed' + ERROR STOP 1 + END IF + WRITE (*, '(A)') 'PASS: Pinned and CoupledPinned rods on the coupled aggregate' + +CONTAINS + + INCLUDE 'nan_max_abs.inc' + + SUBROUTINE require(cond, msg) + LOGICAL, INTENT(IN) :: cond + CHARACTER(*), INTENT(IN) :: msg + IF (.NOT. cond) THEN + WRITE (*, '(A)') 'MISMATCH: '//msg + nfail = nfail + 1 + END IF + END SUBROUTINE require + + ! --------------------------------------------------------------------------------------------- ! + ! decks ! + ! --------------------------------------------------------------------------------------------- ! + + SUBROUTINE write_pendulum_deck(path, rod_type, theta_deg, standalone, nsegs) + !! A dry rod (no drag, no added mass) pinned at End A at (0, 0, 20), above the water, released + !! at theta_deg from the vertical in the x-z plane, deck pose (bodyIC deck); no line touches + !! it. An independent Coupled fairlead with its own line keeps a mooring system in the deck. + !! standalone adds the dtM/TMax clock of a standalone run; nsegs replaces NumSegs 4. + CHARACTER(*), INTENT(IN) :: path, rod_type + REAL(wp), INTENT(IN) :: theta_deg + LOGICAL, INTENT(IN), OPTIONAL :: standalone + INTEGER, INTENT(IN), OPTIONAL :: nsegs + REAL(wp) :: th, xb, zb + INTEGER :: u, ns + ns = 4 + IF (PRESENT(nsegs)) ns = nsegs + th = theta_deg*PI/180.0_wp + xb = LP*SIN(th) + zb = ZPIN - LP*COS(th) + OPEN (NEWUNIT=u, FILE=path, STATUS='REPLACE', ACTION='WRITE') + WRITE (u, '(A)') 'pinned rod pendulum on the coupled aggregate' + WRITE (u, '(A)') '--- LINE TYPES ---' + WRITE (u, '(A)') 'Name Diam Mass EA BA EI Cdn Cdt Can Cat' + WRITE (u, '(A)') '(-) (m) (kg/m) (N) (-) (Nm2) (-) (-) (-) (-)' + WRITE (u, '(A)') 'line 0.10 80.0 1.0e6 0.0 0.0 1.0 0.0 1.0 0.0' + WRITE (u, '(A)') '--- ROD TYPES ---' + WRITE (u, '(A)') 'Name Diam Mass Cd Ca CdEnd CaEnd' + WRITE (u, '(A)') '(-) (m) (kg/m) (-) (-) (-) (-)' + WRITE (u, '(A)') 'pend 0.2 50 0 0 0 0' + WRITE (u, '(A)') '--- RODS ---' + WRITE (u, '(A)') 'ID RodType Type XA YA ZA XB YB ZB NumSegs Outputs' + WRITE (u, '(A)') '(-) (-) (-) (m) (m) (m) (m) (m) (m) (-) (-)' + WRITE (u, '(A,A,A,ES24.16,A,ES24.16,A,I0,A)') '1 pend ', rod_type, ' 0 0 20 ', xb, ' 0 ', zb, ' ', ns, ' -' + WRITE (u, '(A)') '--- POINTS ---' + WRITE (u, '(A)') 'ID Type X Y Z Mass Vol CdA Ca' + WRITE (u, '(A)') '(-) (-) (m) (m) (m) (kg) (m3) (m2) (-)' + WRITE (u, '(A)') '1 Coupled 0.0 30.0 -1.0 0 0 0 0' + WRITE (u, '(A)') '2 Fixed 6.0 30.0 -8.0 0 0 0 0' + WRITE (u, '(A)') '--- LINES ---' + WRITE (u, '(A)') 'ID NodeA NodeB Outputs' + WRITE (u, '(A)') '(-) (-) (-) (-)' + WRITE (u, '(A)') '1 1 2 -' + WRITE (u, '(A)') '--- SECTIONS ---' + WRITE (u, '(A)') 'LineID LineType Length NumSegs' + WRITE (u, '(A)') '(-) (-) (m) (-)' + WRITE (u, '(A)') '1 line 9.5 6' + WRITE (u, '(A)') '--- OPTIONS ---' + WRITE (u, '(A)') '9.80665 g' + WRITE (u, '(A)') '1025.0 rhoW' + WRITE (u, '(A)') '10.0 WtrDpth' + WRITE (u, '(A)') '1.0e5 kBot' + WRITE (u, '(A)') 'deck bodyIC' + IF (PRESENT(standalone)) THEN + IF (standalone) THEN + WRITE (u, '(A)') '0.01 dtM' + WRITE (u, '(A)') '0.1 TMax' + END IF + END IF + WRITE (u, '(A)') '--- end ---' + CLOSE (u) + END SUBROUTINE write_pendulum_deck + + SUBROUTINE write_short_pendulum_deck(path, mass_pm, zpin, upright, theta_deg, rod_type) + !! A 1 m Pinned rod (rod_type replaces Pinned; D = 0.2 m, mass_pm kg/m, no drag or added + !! mass) pinned at End A at (0, 0, zpin) and released at theta_deg in the x-z plane from the + !! downward vertical (from the upward one with upright), deck pose; no line touches it. The + !! fairlead line of write_pendulum_deck keeps a mooring system in the deck. + CHARACTER(*), INTENT(IN) :: path + REAL(wp), INTENT(IN) :: mass_pm, zpin, theta_deg + LOGICAL, INTENT(IN) :: upright + CHARACTER(*), INTENT(IN), OPTIONAL :: rod_type + CHARACTER(16) :: rt + REAL(wp) :: th, xb, zb + INTEGER :: u + rt = 'Pinned' + IF (PRESENT(rod_type)) rt = rod_type + th = theta_deg*PI/180.0_wp + xb = SIN(th) + zb = zpin - COS(th) + IF (upright) zb = zpin + COS(th) + OPEN (NEWUNIT=u, FILE=path, STATUS='REPLACE', ACTION='WRITE') + WRITE (u, '(A)') 'short pinned rod pendulum on the coupled aggregate' + WRITE (u, '(A)') '--- LINE TYPES ---' + WRITE (u, '(A)') 'Name Diam Mass EA BA EI Cdn Cdt Can Cat' + WRITE (u, '(A)') '(-) (m) (kg/m) (N) (-) (Nm2) (-) (-) (-) (-)' + WRITE (u, '(A)') 'line 0.10 80.0 1.0e6 0.0 0.0 1.0 0.0 1.0 0.0' + WRITE (u, '(A)') '--- ROD TYPES ---' + WRITE (u, '(A)') 'Name Diam Mass Cd Ca CdEnd CaEnd' + WRITE (u, '(A)') '(-) (m) (kg/m) (-) (-) (-) (-)' + WRITE (u, '(A,ES24.16,A)') 'pend 0.2 ', mass_pm, ' 0 0 0 0' + WRITE (u, '(A)') '--- RODS ---' + WRITE (u, '(A)') 'ID RodType Type XA YA ZA XB YB ZB NumSegs Outputs' + WRITE (u, '(A)') '(-) (-) (-) (m) (m) (m) (m) (m) (m) (-) (-)' + WRITE (u, '(A,ES24.16,A,ES24.16,A,ES24.16,A)') '1 pend '//TRIM(rt)//' 0 0 ', zpin, ' ', xb, ' 0 ', zb, ' 4 -' + WRITE (u, '(A)') '--- POINTS ---' + WRITE (u, '(A)') 'ID Type X Y Z Mass Vol CdA Ca' + WRITE (u, '(A)') '(-) (-) (m) (m) (m) (kg) (m3) (m2) (-)' + WRITE (u, '(A)') '1 Coupled 0.0 30.0 -1.0 0 0 0 0' + WRITE (u, '(A)') '2 Fixed 6.0 30.0 -8.0 0 0 0 0' + WRITE (u, '(A)') '--- LINES ---' + WRITE (u, '(A)') 'ID NodeA NodeB Outputs' + WRITE (u, '(A)') '(-) (-) (-) (-)' + WRITE (u, '(A)') '1 1 2 -' + WRITE (u, '(A)') '--- SECTIONS ---' + WRITE (u, '(A)') 'LineID LineType Length NumSegs' + WRITE (u, '(A)') '(-) (-) (m) (-)' + WRITE (u, '(A)') '1 line 9.5 6' + WRITE (u, '(A)') '--- OPTIONS ---' + WRITE (u, '(A)') '9.80665 g' + WRITE (u, '(A)') '1025.0 rhoW' + WRITE (u, '(A)') '30.0 WtrDpth' + WRITE (u, '(A)') '1.0e5 kBot' + WRITE (u, '(A)') 'deck bodyIC' + WRITE (u, '(A)') '--- end ---' + CLOSE (u) + END SUBROUTINE write_short_pendulum_deck + + SUBROUTINE write_tethered_deck(path, rod_type, body_ic) + !! A submerged rod (2 m, 0.2 m diameter, Cd = Ca = 1) hanging from End A at (0, 0, -10), held + !! at End B by two horizontal tethers to anchors at x = +/-10 m (EA 2e5 N, 0.5 % pretension): + !! the rotation about y meets their axial stiffness, a stiff mode of about 27 rad/s. End A + !! carries no line and has no Rod1A POINT row, which the coupled route does not need. An + !! independent Coupled fairlead with its own line comes first in the moving surface. The + !! deck asks for the rod's net load about End A (Rod1F/Rod1M). + CHARACTER(*), INTENT(IN) :: path, rod_type, body_ic + INTEGER :: u + OPEN (NEWUNIT=u, FILE=path, STATUS='REPLACE', ACTION='WRITE') + WRITE (u, '(A)') 'tethered pinned rod on the coupled aggregate' + WRITE (u, '(A)') '--- LINE TYPES ---' + WRITE (u, '(A)') 'Name Diam Mass EA BA EI Cdn Cdt Can Cat' + WRITE (u, '(A)') '(-) (m) (kg/m) (N) (-) (Nm2) (-) (-) (-) (-)' + WRITE (u, '(A)') 'line 0.10 80.0 1.0e6 0.0 0.0 1.0 0.0 1.0 0.0' + WRITE (u, '(A)') 'tether 0.05 4.0 2.0e5 0.0 0.0 1.0 0.0 1.0 0.0' + WRITE (u, '(A)') '--- ROD TYPES ---' + WRITE (u, '(A)') 'Name Diam Mass Cd Ca CdEnd CaEnd' + WRITE (u, '(A)') '(-) (m) (kg/m) (-) (-) (-) (-)' + WRITE (u, '(A)') 'arm 0.2 50 1.0 1.0 0.0 0.0' + WRITE (u, '(A)') '--- RODS ---' + WRITE (u, '(A)') 'ID RodType Type XA YA ZA XB YB ZB NumSegs Outputs' + WRITE (u, '(A)') '(-) (-) (-) (m) (m) (m) (m) (m) (m) (-) (-)' + WRITE (u, '(A)') '1 arm '//rod_type//' 0 0 -10 0 0 -12 4 -' + WRITE (u, '(A)') '--- POINTS ---' + WRITE (u, '(A)') 'ID Type X Y Z Mass Vol CdA Ca' + WRITE (u, '(A)') '(-) (-) (m) (m) (m) (kg) (m3) (m2) (-)' + WRITE (u, '(A)') '1 Coupled 0.0 30.0 -1.0 0 0 0 0' + WRITE (u, '(A)') '2 Fixed 6.0 30.0 -8.0 0 0 0 0' + WRITE (u, '(A)') '3 Fixed 10.0 0 -12 0 0 0 0' + WRITE (u, '(A)') '4 Fixed -10.0 0 -12 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 R1B 3 -' + WRITE (u, '(A)') '3 R1B 4 -' + WRITE (u, '(A)') '--- SECTIONS ---' + WRITE (u, '(A)') 'LineID LineType Length NumSegs' + WRITE (u, '(A)') '(-) (-) (m) (-)' + WRITE (u, '(A)') '1 line 9.5 6' + WRITE (u, '(A)') '2 tether 9.95 10' + WRITE (u, '(A)') '3 tether 9.95 10' + WRITE (u, '(A)') '--- OPTIONS ---' + WRITE (u, '(A)') '9.80665 g' + WRITE (u, '(A)') '1025.0 rhoW' + WRITE (u, '(A)') '20.0 WtrDpth' + WRITE (u, '(A)') '1.0e5 kBot' + WRITE (u, '(A)') body_ic//' bodyIC' + WRITE (u, '(A)') '--- OUTPUTS ---' + WRITE (u, '(A)') 'Rod1Fx' + WRITE (u, '(A)') 'Rod1Fy' + WRITE (u, '(A)') 'Rod1Fz' + WRITE (u, '(A)') 'Rod1Mx' + WRITE (u, '(A)') 'Rod1My' + WRITE (u, '(A)') 'Rod1Mz' + WRITE (u, '(A)') '--- end ---' + CLOSE (u) + END SUBROUTINE write_tethered_deck + + ! --------------------------------------------------------------------------------------------- ! + ! helpers ! + ! --------------------------------------------------------------------------------------------- ! + + REAL(wp) FUNCTION rod_angle(s) RESULT(th) + !! Angle of the rod axis (End A -> End B) from the downward vertical, positive towards +x. + REAL(wp), INTENT(IN) :: s(:) + th = ATAN2(s(16), -s(18)) + END FUNCTION rod_angle + + REAL(wp) FUNCTION ellip_k(k) RESULT(kk) + !! Complete elliptic integral of the first kind by the arithmetic-geometric mean. + REAL(wp), INTENT(IN) :: k + REAL(wp) :: a, b, c + INTEGER :: i + a = 1.0_wp + b = SQRT(1.0_wp - k*k) + DO i = 1, 30 + c = 0.5_wp*(a + b) + b = SQRT(a*b) + a = c + END DO + kk = PI/(2.0_wp*a) + END FUNCTION ellip_k + + SUBROUTINE crossings(t, x, xm, period, mean) + !! Mean period between the up-crossings of x through xm and the mean of x over those whole + !! periods (trapezoidal); period = -1 with fewer than three crossings. + REAL(wp), INTENT(IN) :: t(:), x(:), xm + REAL(wp), INTENT(OUT) :: period, mean + REAL(wp) :: tc, t0, t1, area + INTEGER :: i, n, i0, i1 + n = 0 + t0 = 0.0_wp + t1 = 0.0_wp + i0 = 0 + i1 = 0 + DO i = 1, SIZE(x) - 1 + IF (x(i) - xm < 0.0_wp .AND. x(i + 1) - xm >= 0.0_wp) THEN + tc = t(i) + (xm - x(i))*(t(i + 1) - t(i))/(x(i + 1) - x(i)) + IF (n == 0) THEN + t0 = tc + i0 = i + END IF + t1 = tc + i1 = i + n = n + 1 + END IF + END DO + period = -1.0_wp + mean = 0.0_wp + IF (n < 3) RETURN + period = (t1 - t0)/REAL(n - 1, wp) + ! the crossing value xm closes both ends of the window + area = 0.5_wp*(xm + x(i0 + 1))*(t(i0 + 1) - t0) + 0.5_wp*(x(i1) + xm)*(t1 - t(i1)) + DO i = i0 + 1, i1 - 1 + area = area + 0.5_wp*(x(i) + x(i + 1))*(t(i + 1) - t(i)) + END DO + mean = area/(t1 - t0) + END SUBROUTINE crossings + + FUNCTION pin_inertia(s) RESULT(ip) + !! Inertia tensor of the dry pendulum rod about its pin (End A), global axes. + REAL(wp), INTENT(IN) :: s(:) + REAL(wp) :: ip(3, 3), rot(3, 3), ib(3, 3), arm(3) + INTEGER :: k + rot = RESHAPE(s(16:24), [3, 3]) + ib = 0.0_wp + ib(1, 1) = 0.5_wp*MP*(0.5_wp*DP)**2 + ib(2, 2) = MP*(3.0_wp*(0.5_wp*DP)**2 + LP*LP)/12.0_wp + ib(3, 3) = ib(2, 2) + arm = 0.5_wp*LP*rot(:, 1) + ip = MATMUL(rot, MATMUL(ib, TRANSPOSE(rot))) + DO k = 1, 3 + ip(k, k) = ip(k, k) + MP*DOT_PRODUCT(arm, arm) + END DO + ip = ip - MP*SPREAD(arm, 2, 3)*SPREAD(arm, 1, 3) + END FUNCTION pin_inertia + + FUNCTION solve3(a, b) RESULT(x) + !! x = a^-1 b by Cramer's rule (a 3x3, well conditioned here). + REAL(wp), INTENT(IN) :: a(3, 3), b(3) + REAL(wp) :: x(3), d, c(3, 3) + INTEGER :: k + d = det3(a) + DO k = 1, 3 + c = a + c(:, k) = b + x(k) = det3(c)/d + END DO + END FUNCTION solve3 + + PURE REAL(wp) FUNCTION det3(m) RESULT(d) + REAL(wp), INTENT(IN) :: m(3, 3) + d = m(1, 1)*(m(2, 2)*m(3, 3) - m(2, 3)*m(3, 2)) - m(1, 2)*(m(2, 1)*m(3, 3) - m(2, 3)*m(3, 1)) + & + m(1, 3)*(m(2, 1)*m(3, 2) - m(2, 2)*m(3, 1)) + END FUNCTION det3 + + PURE FUNCTION cross(x, y) RESULT(z) + REAL(wp), INTENT(IN) :: x(3), y(3) + REAL(wp) :: z(3) + z = [x(2)*y(3) - x(3)*y(2), x(3)*y(1) - x(1)*y(3), x(1)*y(2) - x(2)*y(1)] + END FUNCTION cross + + FUNCTION pin_reaction(s, a_pin) RESULT(f) + !! The force a dry rod exerts on its pin at state s (rod mirror) for a pin acceleration + !! a_pin: Euler's equation about the pin, I_p alpha + w x (I_p w) = r x m (g - a_pin), then + !! f = m g - m (a_pin + alpha x r + w x (w x r)), g = (0, 0, -9.80665). + REAL(wp), INTENT(IN) :: s(:), a_pin(3) + REAL(wp) :: f(3), ip(3, 3), arm(3), w(3), alpha(3), gv(3) + ip = pin_inertia(s) + arm = 0.5_wp*LP*s(16:18) + w = s(10:12) + gv = [0.0_wp, 0.0_wp, -G] + alpha = solve3(ip, cross(arm, MP*(gv - a_pin)) - cross(w, MATMUL(ip, w))) + f = MP*gv - MP*(a_pin + cross(alpha, arm) + cross(w, cross(w, arm))) + END FUNCTION pin_reaction + + SUBROUTINE march(agg, dt, nstep, host, ang, t, ok, s_end, force) + !! March nstep coupling steps, the last moving column (the rod's pin when present) driven by + !! host(t) = [position, velocity, acceleration] and every other column held at its initial + !! position; ang(0:nstep) the rod angle, t the times. Before the first step the host + !! kinematics at t = 0 are transferred (the start of the run, as the coupled shell does). + TYPE(CD_AGG_ModuleType), INTENT(INOUT) :: agg + REAL(wp), INTENT(IN) :: dt + INTEGER, INTENT(IN) :: nstep + INTERFACE + FUNCTION host(time) RESULT(k) + IMPORT :: wp + REAL(wp), INTENT(IN) :: time + REAL(wp) :: k(9) + END FUNCTION host + END INTERFACE + REAL(wp), INTENT(OUT) :: ang(0:nstep), t(0:nstep) + LOGICAL, INTENT(OUT) :: ok + REAL(wp), INTENT(OUT), OPTIONAL :: s_end(24), force(3, 0:nstep) + REAL(wp), ALLOCATABLE :: p(:, :), v(:, :), a(:, :), f(:, :), p0(:, :), s(:) + REAL(wp) :: k(9) + INTEGER :: n, es, it, step + LOGICAL :: cv, st + CHARACTER(512) :: em + + ok = .FALSE. + n = CD_AGG_NMovingPoints(agg, es, em) + ALLOCATE (p(3, n), v(3, n), a(3, n), f(3, n), p0(3, n), s(CD_AGG_Rod_MirrorSize(agg))) + CALL CD_AGG_GetMovingPointMesh(agg, p0, v, a, f, es, em) + v = 0.0_wp + a = 0.0_wp + p = p0 + k = host(0.0_wp) + p(:, n) = p0(:, n) + k(1:3) + v(:, n) = k(4:6) + a(:, n) = k(7:9) + CALL CD_AGG_UpdateStates_Moving(agg, p, v, a, es, em) + CALL require(es == CD_AGG_OK, 'march:start-transfer: '//TRIM(em)) + IF (es /= CD_AGG_OK) RETURN + CALL CD_AGG_Get_Rod_States(agg, s, es, em) + ang(0) = rod_angle(s) + t(0) = 0.0_wp + IF (PRESENT(force)) THEN + CALL CD_AGG_CalcOutput(agg, es, em) + CALL CD_AGG_GetMovingPointMesh(agg, p, v, a, f, es, em) + force(:, 0) = f(:, n) + END IF + DO step = 1, nstep + t(step) = REAL(step, wp)*dt + k = host(t(step)) + p = p0 + v = 0.0_wp + a = 0.0_wp + p(:, n) = p0(:, n) + k(1:3) + v(:, n) = k(4:6) + a(:, n) = k(7:9) + CALL CD_AGG_Step_Moving(agg, dt, p, v, a, cv, st, it, es, em, t_committed=t(step)) + CALL require(es == CD_AGG_OK .AND. cv, 'march:step: '//TRIM(em)) + IF (es /= CD_AGG_OK) RETURN + CALL CD_AGG_Get_Rod_States(agg, s, es, em) + ang(step) = rod_angle(s) + IF (PRESENT(force)) THEN + CALL CD_AGG_CalcOutput(agg, es, em) + CALL CD_AGG_GetMovingPointMesh(agg, p, v, a, f, es, em) + force(:, step) = f(:, n) + END IF + END DO + IF (PRESENT(s_end)) s_end = s + ok = ALL(IEEE_IS_FINITE(ang)) + END SUBROUTINE march + + ! --------------------------------------------------------------------------------------------- ! + ! 1-2: the fixed-pin pendulum and the held host ! + ! --------------------------------------------------------------------------------------------- ! + + SUBROUTINE case_pendulum_and_held_host() + TYPE(CD_AGG_ModuleType) :: pinned, held + REAL(wp), PARAMETER :: TH0 = 30.0_wp + REAL(wp), ALLOCATABLE :: p(:, :), v(:, :), a(:, :), f(:, :), mo(:, :), p0(:, :) + REAL(wp), ALLOCATABLE :: ang(:), t(:) + REAL(wp) :: s1(24), s2(24), ia, t_ref, dt, period, mean, err_state, err_pin, err_force, fref(3), pin(3) + INTEGER :: es, n, nstep, step, it + LOGICAL :: cv, st + CHARACTER(512) :: em + + ia = MP*(LP*LP/3.0_wp + DP*DP/16.0_wp) + t_ref = 4.0_wp*SQRT(ia/(MP*G*0.5_wp*LP))*ellip_k(SIN(0.5_wp*TH0*PI/180.0_wp)) + dt = t_ref/100.0_wp + nstep = 500 + CALL write_pendulum_deck('pinrod_pendulum.dat', 'Pinned', TH0) + CALL write_pendulum_deck('pinrod_pendulum_held.dat', 'CoupledPinned', TH0) + CALL CD_AGG_Init_From_Deck(pinned, 'pinrod_pendulum.dat', dt, es, em) + CALL require(es == CD_AGG_OK, 'pendulum:init: '//TRIM(em)) + IF (es /= CD_AGG_OK) RETURN + CALL CD_AGG_Init_From_Deck(held, 'pinrod_pendulum_held.dat', dt, es, em) + CALL require(es == CD_AGG_OK, 'held:init: '//TRIM(em)) + IF (es /= CD_AGG_OK) RETURN + CALL require(CD_AGG_HasRod(pinned) .AND. CD_AGG_NMovingPoints(pinned, es, em) == 1, & + 'pendulum:a Pinned rod adds no host node') + n = CD_AGG_NMovingPoints(held, es, em) + CALL require(n == 2, 'held:one host node for the CoupledPinned rod after the fairlead') + IF (n /= 2) RETURN + ALLOCATE (p(3, 2), v(3, 2), a(3, 2), f(3, 2), mo(3, 2), p0(3, 2), ang(0:nstep), t(0:nstep)) + CALL CD_AGG_GetMovingPointMesh(held, p0, v, a, f, es, em) + CALL require(nan_max_abs(p0(:, 2) - [0.0_wp, 0.0_wp, ZPIN]) <= 1.0e-13_wp, 'held:host node at End A') + p = p0 + v = 0.0_wp + a = 0.0_wp + CALL CD_AGG_Get_Rod_States(pinned, s1, es, em) + ang(0) = rod_angle(s1) + t(0) = 0.0_wp + err_state = 0.0_wp + err_pin = 0.0_wp + err_force = 0.0_wp + pin = [0.0_wp, 0.0_wp, ZPIN] + DO step = 0, nstep + IF (step > 0) THEN + CALL CD_AGG_Step_Moving(pinned, dt, p(:, 1:1), v(:, 1:1), a(:, 1:1), cv, st, it, es, em, & + t_committed=REAL(step, wp)*dt) + CALL require(es == CD_AGG_OK .AND. cv, 'pendulum:step: '//TRIM(em)) + IF (es /= CD_AGG_OK) RETURN + CALL CD_AGG_Step_Moving(held, dt, p, v, a, cv, st, it, es, em, t_committed=REAL(step, wp)*dt) + CALL require(es == CD_AGG_OK .AND. cv, 'held:step: '//TRIM(em)) + IF (es /= CD_AGG_OK) RETURN + END IF + CALL CD_AGG_Get_Rod_States(pinned, s1, es, em) + CALL CD_AGG_Get_Rod_States(held, s2, es, em) + t(step) = REAL(step, wp)*dt + ang(step) = rod_angle(s1) + err_pin = MAX(err_pin, nan_max_abs(s1(1:3) - 0.5_wp*LP*s1(16:18) - pin)) + err_state = MAX(err_state, nan_max_abs(s2 - s1)/MAX(1.0_wp, nan_max_abs(s1))) + CALL CD_AGG_CalcOutput(held, es, em) + CALL CD_AGG_GetMovingPointMesh(held, p, v, a, f, es, em, moment=mo) + CALL require(es == CD_AGG_OK, 'held:mesh: '//TRIM(em)) + CALL require(nan_max_abs(mo(:, 2)) <= 0.0_wp, 'held:host moment is zero') + fref = pin_reaction(s2, [0.0_wp, 0.0_wp, 0.0_wp]) + err_force = MAX(err_force, nan_max_abs(f(:, 2) - fref)/(MP*G)) + p = p0 + v = 0.0_wp + a = 0.0_wp + END DO + CALL crossings(t, ang, 0.0_wp, period, mean) + WRITE (*, '(A,2F12.6,A,ES10.3)') 'coupled Pinned pendulum period got/analytic [s]: ', period, t_ref, & + '; rel. error ', ABS(period - t_ref)/t_ref + WRITE (*, '(A,ES10.3,A,ES10.3,A,ES10.3)') 'max |End A - pin| [m] ', err_pin, & + '; held CoupledPinned vs Pinned state ', err_state, '; host force vs pin reaction / mg ', err_force + CALL require(ABS(period - t_ref) <= 1.0e-3_wp*t_ref, 'pendulum:period (elliptic integral)') + CALL require(err_pin <= 1.0e-12_wp, 'pendulum:End A stays at the pin') + CALL require(err_state <= 1.0e-12_wp, 'held:CoupledPinned with the host held equals Pinned') + CALL require(err_force <= 1.0e-10_wp, 'held:host force is the analytic pin reaction') + CALL CD_AGG_End(pinned, es, em) + CALL CD_AGG_End(held, es, em) + END SUBROUTINE case_pendulum_and_held_host + + ! --------------------------------------------------------------------------------------------- ! + ! 3: constant host acceleration ! + ! --------------------------------------------------------------------------------------------- ! + + FUNCTION host_const(time) RESULT(k) + !! The pin accelerating uniformly along +x from rest: a = 2 m/s^2. + REAL(wp), INTENT(IN) :: time + REAL(wp) :: k(9) + REAL(wp), PARAMETER :: AX = 2.0_wp + k = 0.0_wp + k(1) = 0.5_wp*AX*time*time + k(4) = AX*time + k(7) = AX + END FUNCTION host_const + + SUBROUTINE case_constant_acceleration() + !! In the frame of a pin accelerating at a along x the rod is a pendulum in the effective + !! gravity (-a, 0, -g): it swings about theta_eq = -atan(a/g) (trailing) with the period + !! 4 sqrt(I_p/(m h g_eff)) K(sin(delta/2)), g_eff = sqrt(g^2 + a^2), for an amplitude delta. + TYPE(CD_AGG_ModuleType) :: agg + REAL(wp), PARAMETER :: AX = 2.0_wp, DELTA = 5.0_wp + REAL(wp), ALLOCATABLE :: ang(:), t(:) + REAL(wp) :: ia, th_eq, geff, t_ref, dt, period, mean + INTEGER :: es, nstep + LOGICAL :: ok + CHARACTER(512) :: em + + th_eq = -ATAN(AX/G) + geff = SQRT(G*G + AX*AX) + ia = MP*(LP*LP/3.0_wp + DP*DP/16.0_wp) + t_ref = 4.0_wp*SQRT(ia/(MP*geff*0.5_wp*LP))*ellip_k(SIN(0.5_wp*DELTA*PI/180.0_wp)) + dt = t_ref/100.0_wp + nstep = 500 + CALL write_pendulum_deck('pinrod_accel.dat', 'CoupledPinned', th_eq*180.0_wp/PI + DELTA) + CALL CD_AGG_Init_From_Deck(agg, 'pinrod_accel.dat', dt, es, em) + CALL require(es == CD_AGG_OK, 'accel:init: '//TRIM(em)) + IF (es /= CD_AGG_OK) RETURN + ALLOCATE (ang(0:nstep), t(0:nstep)) + CALL march(agg, dt, nstep, host_const, ang, t, ok) + CALL require(ok, 'accel:march finite') + IF (.NOT. ok) RETURN + CALL crossings(t, ang, th_eq, period, mean) + WRITE (*, '(A,2F12.6,A,2F10.6)') 'constant pin acceleration: period got/analytic [s] ', period, t_ref, & + '; mean angle got/atan(a/g) [rad] ', mean, th_eq + CALL require(ABS(period - t_ref) <= 1.0e-3_wp*t_ref, 'accel:period with g_eff') + CALL require(ABS(mean - th_eq) <= 1.0e-4_wp, 'accel:mean angle -atan(a/g)') + CALL CD_AGG_End(agg, es, em) + END SUBROUTINE case_constant_acceleration + + ! --------------------------------------------------------------------------------------------- ! + ! 4: harmonic base excitation ! + ! --------------------------------------------------------------------------------------------- ! + + FUNCTION host_harm(time) RESULT(k) + !! x_p = X (1 - cos W t): the pin starts at rest, X = 0.05 m, W = 0.6 w0. + REAL(wp), INTENT(IN) :: time + REAL(wp) :: k(9), w + REAL(wp), PARAMETER :: X = 0.05_wp + w = 0.6_wp*omega0() + k = 0.0_wp + k(1) = X*(1.0_wp - COS(w*time)) + k(4) = X*w*SIN(w*time) + k(7) = X*w*w*COS(w*time) + END FUNCTION host_harm + + REAL(wp) FUNCTION omega0() RESULT(w0) + !! Small-amplitude natural frequency of the dry pendulum about its pin. + w0 = SQRT(MP*G*0.5_wp*LP/(MP*(LP*LP/3.0_wp + DP*DP/16.0_wp))) + END FUNCTION omega0 + + SUBROUTINE case_harmonic_base_excitation() + !! Linear base excitation of the pendulum from rest, theta'' + w0^2 theta = -(m h/I_p) a_p(t): + !! theta = -(m h/I_p) X W^2 (cos W t - cos w0 t)/(w0^2 - W^2). The amplitude is about 0.01 + !! rad, so the neglected sin/cos terms stay near 1e-4 of it; three natural periods at + !! dt = T0/100 and T0/200 must converge at second order to below 2e-3 of the amplitude. + TYPE(CD_AGG_ModuleType) :: agg + REAL(wp), ALLOCATABLE :: ang(:), t(:), ref(:) + REAL(wp) :: w0, w, kap, dt, err(2), amp + INTEGER :: es, nstep, ires, i + LOGICAL :: ok + CHARACTER(512) :: em + + w0 = omega0() + w = 0.6_wp*w0 + kap = MP*0.5_wp*LP/(MP*(LP*LP/3.0_wp + DP*DP/16.0_wp)) + CALL write_pendulum_deck('pinrod_harm.dat', 'CoupledPinned', 0.0_wp) + DO ires = 1, 2 + nstep = 300*ires + dt = 2.0_wp*PI/w0/REAL(100*ires, wp) + CALL CD_AGG_Init_From_Deck(agg, 'pinrod_harm.dat', dt, es, em) + CALL require(es == CD_AGG_OK, 'harm:init: '//TRIM(em)) + IF (es /= CD_AGG_OK) RETURN + ALLOCATE (ang(0:nstep), t(0:nstep), ref(0:nstep)) + CALL march(agg, dt, nstep, host_harm, ang, t, ok) + CALL require(ok, 'harm:march finite') + IF (.NOT. ok) RETURN + DO i = 0, nstep + ref(i) = -kap*0.05_wp*w*w*(COS(w*t(i)) - COS(w0*t(i)))/(w0*w0 - w*w) + END DO + amp = nan_max_abs(ref) + err(ires) = nan_max_abs(ang - ref)/amp + DEALLOCATE (ang, t, ref) + CALL CD_AGG_End(agg, es, em) + END DO + WRITE (*, '(A,ES10.3,A,2ES10.3,A,F6.2)') 'harmonic pin motion: amplitude ', amp, & + ' rad; rel. error dt = T0/100, T0/200: ', err, '; ratio ', err(1)/err(2) + CALL require(err(2) <= 2.0e-3_wp, 'harm:linear base-excitation solution') + CALL require(err(1)/err(2) > 3.0_wp, 'harm:second-order convergence') + END SUBROUTINE case_harmonic_base_excitation + + ! --------------------------------------------------------------------------------------------- ! + ! 5-6, 8: sub-stepping, snapshot / restore, restart overlay ! + ! --------------------------------------------------------------------------------------------- ! + + FUNCTION host_surge(time) RESULT(k) + !! x_p = X (1 - cos W t), X = 0.2 m, a 5 s period. + REAL(wp), INTENT(IN) :: time + REAL(wp) :: k(9), w + REAL(wp), PARAMETER :: X = 0.2_wp + w = 2.0_wp*PI/5.0_wp + k = 0.0_wp + k(1) = X*(1.0_wp - COS(w*time)) + k(4) = X*w*SIN(w*time) + k(7) = X*w*w*COS(w*time) + END FUNCTION host_surge + + FUNCTION host_drift(time) RESULT(k) + !! The pin drifting along +x at a constant 0.05 m/s from t = 0. + REAL(wp), INTENT(IN) :: time + REAL(wp) :: k(9) + k = 0.0_wp + k(1) = 0.05_wp*time + k(4) = 0.05_wp + END FUNCTION host_drift + + SUBROUTINE case_substep_and_state() + !! The tethered rod's stiff mode (about 27 rad/s) makes omega dt about 2.7 at a 0.1 s + !! coupling step, beyond the explicit limit of 2: the march must sub-cycle it (7 sub-steps). + !! Against a run at the sub-step size: a pin drifting at constant velocity, which the linear + !! interpolation of the host motion inside a step represents exactly, gives the same rod + !! motion and pin force; a harmonic surge gives the same rod motion within 1 % (the + !! interpolated pin path deviates by a dt^2 a/8 that the stiff tethers turn into a few N). + !! On the coarse run: host orientation and angular rates are ignored for the pin node; + !! snapshot/step/restore/step and the restart overlay are bit-identical. + TYPE(CD_AGG_ModuleType) :: coarse, fine, turned, agg_b + REAL(wp), PARAMETER :: DTC = 0.1_wp + INTEGER, PARAMETER :: NSUB = 7, NC = 60 + REAL(wp), ALLOCATABLE :: angc(:), tc(:), angf(:), tf(:), fc(:, :), ff(:, :) + REAL(wp), ALLOCATABLE :: p(:, :), v(:, :), a(:, :), f(:, :), fb(:, :), mo(:, :), mb(:, :), p0(:, :) + REAL(wp), ALLOCATABLE :: orr(:, :, :), w(:, :), al(:, :), lq(:), lv(:), la(:), rs(:), rs2(:) + REAL(wp), ALLOCATABLE :: cq(:), cvv(:), ca(:) + REAL(wp) :: err_ang, err_f, amp, famp, k(9), th, err + INTEGER :: es, i, n, step, it, nl, il, ndof, kind, ncd + LOGICAL :: ok, cv, st + CHARACTER(512) :: em + + CALL write_tethered_deck('pinrod_tether.dat', 'CoupledPinned', 'deck') + ALLOCATE (angc(0:NC), tc(0:NC), angf(0:NC*NSUB), tf(0:NC*NSUB), fc(3, 0:NC), ff(3, 0:NC*NSUB)) + DO kind = 1, 2 + CALL CD_AGG_Init_From_Deck(coarse, 'pinrod_tether.dat', DTC, es, em) + CALL require(es == CD_AGG_OK, 'substep:coarse-init: '//TRIM(em)) + IF (es /= CD_AGG_OK) RETURN + CALL CD_AGG_Init_From_Deck(fine, 'pinrod_tether.dat', DTC/REAL(NSUB, wp), es, em) + CALL require(es == CD_AGG_OK, 'substep:fine-init: '//TRIM(em)) + IF (es /= CD_AGG_OK) RETURN + IF (kind == 1) THEN + CALL march(coarse, DTC, NC, host_drift, angc, tc, ok, force=fc) + CALL require(ok, 'substep:coarse march finite (the stiff mode is sub-cycled)') + CALL march(fine, DTC/REAL(NSUB, wp), NC*NSUB, host_drift, angf, tf, ok, force=ff) + ELSE + CALL march(coarse, DTC, NC, host_surge, angc, tc, ok, force=fc) + CALL require(ok, 'substep:coarse march finite (the stiff mode is sub-cycled)') + CALL march(fine, DTC/REAL(NSUB, wp), NC*NSUB, host_surge, angf, tf, ok, force=ff) + END IF + CALL require(ok, 'substep:fine march finite') + IF (.NOT. ok) RETURN + err_ang = 0.0_wp + err_f = 0.0_wp + DO i = 0, NC + err_ang = MAX(err_ang, ABS(angc(i) - angf(NSUB*i))) + err_f = MAX(err_f, nan_max_abs(fc(:, i) - ff(:, NSUB*i))) + END DO + amp = nan_max_abs(angf) + famp = nan_max_abs(ff) + WRITE (*, '(A,I0,A,ES10.3,A,ES10.3,A,ES10.3,A,ES10.3)') 'sub-cycled coarse step vs sub-step run (', kind, & + '): angle ', err_ang, ' of ', amp, ' rad; pin force ', err_f, ' of ', famp + CALL require(amp > 0.05_wp, 'substep:the pin motion turns the rod') + IF (kind == 1) THEN + CALL require(err_ang <= 1.0e-8_wp*amp .AND. err_f <= 1.0e-8_wp*famp, & + 'substep:drifting pin: coarse equals fine') + CALL CD_AGG_End(coarse, es, em) + ELSE + CALL require(err_ang <= 1.0e-2_wp*amp, 'substep:surge: coarse equals fine (angle)') + END IF + CALL CD_AGG_End(fine, es, em) + END DO + + ! the host orientation and angular rates do not reach a CoupledPinned rod + n = CD_AGG_NMovingPoints(coarse, es, em) + ALLOCATE (p(3, n), v(3, n), a(3, n), f(3, n), fb(3, n), mo(3, n), mb(3, n), p0(3, n)) + ALLOCATE (orr(3, 3, n), w(3, n), al(3, n), rs(CD_AGG_Rod_MirrorSize(coarse)), rs2(CD_AGG_Rod_MirrorSize(coarse))) + CALL CD_AGG_Init_From_Deck(turned, 'pinrod_tether.dat', DTC, es, em) + CALL CD_AGG_GetMovingPointMesh(turned, p0, v, a, f, es, em) + CALL CD_AGG_Init_From_Deck(fine, 'pinrod_tether.dat', DTC, es, em) + err = 0.0_wp + DO step = 0, 20 + k = host_surge(REAL(step, wp)*DTC) + p = p0 + v = 0.0_wp + a = 0.0_wp + p(:, n) = p0(:, n) + k(1:3) + v(:, n) = k(4:6) + a(:, n) = k(7:9) + th = 0.3_wp*SIN(REAL(step, wp)) + orr = 0.0_wp + DO i = 1, n + orr(1, 1, i) = 1.0_wp + orr(2, 2, i) = 1.0_wp + orr(3, 3, i) = 1.0_wp + END DO + orr(1, 1, n) = COS(th) + orr(1, 3, n) = -SIN(th) + orr(3, 1, n) = SIN(th) + orr(3, 3, n) = COS(th) + w = 0.0_wp + al = 0.0_wp + w(2, n) = 0.3_wp*COS(REAL(step, wp)) + al(2, n) = -0.3_wp*SIN(REAL(step, wp)) + IF (step == 0) THEN + CALL CD_AGG_UpdateStates_Moving(turned, p, v, a, es, em, orientation=orr, angular_velocity=w, & + angular_acceleration=al) + CALL CD_AGG_UpdateStates_Moving(fine, p, v, a, es, em) + ELSE + CALL CD_AGG_Step_Moving(turned, DTC, p, v, a, cv, st, it, es, em, t_committed=REAL(step, wp)*DTC, & + orientation=orr, angular_velocity=w, angular_acceleration=al) + CALL require(es == CD_AGG_OK, 'orient:turned step: '//TRIM(em)) + CALL CD_AGG_Step_Moving(fine, DTC, p, v, a, cv, st, it, es, em, t_committed=REAL(step, wp)*DTC) + END IF + CALL CD_AGG_Get_Rod_States(turned, rs, es, em) + CALL CD_AGG_Get_Rod_States(fine, rs2, es, em) + err = MAX(err, nan_max_abs(rs - rs2)) + END DO + CALL require(err <= 0.0_wp, 'orient:host orientation and rates ignored by the pinned rod') + CALL CD_AGG_End(turned, es, em) + CALL CD_AGG_End(fine, es, em) + + ! snapshot -> step A -> restore -> step B reproduces step A + k = host_surge(REAL(NC + 1, wp)*DTC) + p = p0 + v = 0.0_wp + a = 0.0_wp + p(:, n) = p0(:, n) + k(1:3) + v(:, n) = k(4:6) + a(:, n) = k(7:9) + CALL CD_AGG_Snapshot(coarse, es, em) + CALL CD_AGG_Step_Moving(coarse, DTC, p, v, a, cv, st, it, es, em, t_committed=REAL(NC + 1, wp)*DTC) + CALL CD_AGG_CalcOutput(coarse, es, em) + CALL CD_AGG_GetMovingPointMesh(coarse, p, v, a, fb, es, em, moment=mb) + CALL CD_AGG_Get_Rod_States(coarse, rs, es, em) + CALL CD_AGG_Restore(coarse, es, em) + p = p0 + v = 0.0_wp + a = 0.0_wp + p(:, n) = p0(:, n) + k(1:3) + v(:, n) = k(4:6) + a(:, n) = k(7:9) + CALL CD_AGG_Step_Moving(coarse, DTC, p, v, a, cv, st, it, es, em, t_committed=REAL(NC + 1, wp)*DTC) + CALL CD_AGG_CalcOutput(coarse, es, em) + CALL CD_AGG_GetMovingPointMesh(coarse, p, v, a, f, es, em, moment=mo) + CALL CD_AGG_Get_Rod_States(coarse, rs2, es, em) + CALL require(nan_max_abs(f - fb) <= 0.0_wp .AND. nan_max_abs(mo - mb) <= 0.0_wp .AND. & + nan_max_abs(rs - rs2) <= 0.0_wp, 'state:snapshot-step-restore-step bit-identical') + CALL require(nan_max_abs(mo(:, n)) <= 0.0_wp .AND. nan_max_abs(f(:, n)) > 0.0_wp, 'state:force only at the pin node') + + ! restart: a fresh instance takes the host kinematics, the line interiors and the rod states + CALL CD_AGG_Init_From_Deck(agg_b, 'pinrod_tether.dat', DTC, es, em) + CALL require(es == CD_AGG_OK, 'restart:init: '//TRIM(em)) + IF (es /= CD_AGG_OK) RETURN + CALL CD_AGG_UpdateStates_Moving(agg_b, p, v, a, es, em) + CALL require(es == CD_AGG_OK, 'restart:host: '//TRIM(em)) + nl = CD_System_NLines(coarse%sys%fast%system, es, em) + DO il = 1, nl + ndof = CD_System_Line_NDOF(coarse%sys%fast%system, il, es, em) + ALLOCATE (lq(ndof), lv(ndof), la(ndof)) + CALL CD_Get_System_Line_State(coarse%sys%fast%system, il, lq, lv, la, es, em) + CALL CD_Update_System_Line_Interior_State(agg_b%sys%fast%system, il, lq(4:ndof - 3), lv(4:ndof - 3), es, em, & + a_interior=la(4:ndof - 3)) + CALL require(es == CD_SYSTEM_OK, 'restart:interior: '//TRIM(em)) + DEALLOCATE (lq, lv, la) + END DO + CALL CD_AGG_Get_Rod_States(coarse, rs, es, em) + CALL CD_AGG_Set_Rod_States(agg_b, rs, es, em) + CALL require(es == CD_AGG_OK, 'restart:rod states: '//TRIM(em)) + ! the committed line-end motion closes the mirror (the shell restores it last) + ncd = CD_System_NSystemCoupledDOF(coarse%sys%fast%system) + ALLOCATE (cq(ncd), cvv(ncd), ca(ncd)) + CALL CD_Get_System_CoupledMotion(coarse%sys%fast%system, cq, cvv, ca, es, em) + CALL CD_Update_System_CoupledMotion(agg_b%sys%fast%system, cq, cvv, ca, es, em) + CALL require(es == CD_SYSTEM_OK, 'restart:coupled motion: '//TRIM(em)) + ! between steps (a supercycled host evaluates the restored state before the next step) the + ! pin force depends on the mirrored rod state only, not on the host pin it was stepped with + CALL CD_AGG_CalcOutput(coarse, es, em) + CALL CD_AGG_GetMovingPointMesh(coarse, p, v, a, f, es, em, moment=mo) + CALL CD_AGG_CalcOutput(agg_b, es, em) + CALL CD_AGG_GetMovingPointMesh(agg_b, p, v, a, fb, es, em, moment=mb) + WRITE (*, '(A,ES10.3)') 'CoupledPinned restart overlay: |pin force difference| before the next step = ', & + nan_max_abs(f - fb) + CALL require(nan_max_abs(f - fb) <= 0.0_wp .AND. nan_max_abs(mo - mb) <= 0.0_wp, & + 'restart:bit-identical loads of the restored state before the next step') + err = 0.0_wp + DO step = NC + 2, NC + 30 + k = host_surge(REAL(step, wp)*DTC) + p = p0 + v = 0.0_wp + a = 0.0_wp + p(:, n) = p0(:, n) + k(1:3) + v(:, n) = k(4:6) + a(:, n) = k(7:9) + CALL CD_AGG_Step_Moving(coarse, DTC, p, v, a, cv, st, it, es, em, t_committed=REAL(step, wp)*DTC) + CALL CD_AGG_Step_Moving(agg_b, DTC, p, v, a, cv, st, it, es, em, t_committed=REAL(step, wp)*DTC) + CALL require(es == CD_AGG_OK, 'restart:march: '//TRIM(em)) + CALL CD_AGG_CalcOutput(coarse, es, em) + CALL CD_AGG_GetMovingPointMesh(coarse, p, v, a, f, es, em, moment=mo) + CALL CD_AGG_CalcOutput(agg_b, es, em) + CALL CD_AGG_GetMovingPointMesh(agg_b, p, v, a, fb, es, em, moment=mb) + err = MAX(err, nan_max_abs(f - fb), nan_max_abs(mo - mb)) + END DO + CALL CD_AGG_Get_Rod_States(coarse, rs, es, em) + CALL CD_AGG_Get_Rod_States(agg_b, rs2, es, em) + WRITE (*, '(A,ES10.3)') 'CoupledPinned restart overlay: max |load difference| over 29 steps = ', err + CALL require(err <= 0.0_wp .AND. nan_max_abs(rs - rs2) <= 0.0_wp, 'restart:bit-identical continuation') + CALL CD_AGG_End(agg_b, es, em) + CALL CD_AGG_End(coarse, es, em) + END SUBROUTINE case_substep_and_state + + ! --------------------------------------------------------------------------------------------- ! + ! 7: the output probe ! + ! --------------------------------------------------------------------------------------------- ! + + SUBROUTINE case_probe() + !! On the hanging dry pendulum at rest, a probe pin acceleration a_p along x returns the + !! rest force plus -M_eff a_p with M_eff = m I_c/I_p (the rotation re-solved at a_p; the + !! committed angular acceleration would give -m a_p). On the tethered rod mid-swing, a + !! probe (pin moved, accelerated) restored as the coupled shell restores it (saved host + !! kinematics, line interiors, rod states, committed line-end motion) leaves the + !! continuation bit-identical to a twin that was never probed. + TYPE(CD_AGG_ModuleType) :: agg, twin + REAL(wp), ALLOCATABLE :: p(:, :), v(:, :), a(:, :), f(:, :), f0(:, :), mo(:, :), p0(:, :) + REAL(wp), ALLOCATABLE :: sp(:, :), sv(:, :), sa(:, :), so(:, :, :), sw(:, :), sal(:, :) + REAL(wp), ALLOCATABLE :: lq(:, :), lv(:, :), la(:, :), rs(:), rs2(:), fb(:, :), mb(:, :) + REAL(wp), ALLOCATABLE :: cq(:), cvv(:), ca(:), q2(:), v2(:), a2(:), l1(:), l2(:) + REAL(wp) :: ic, ip, ap, k(9), err, endb(3) + INTEGER :: es, n, step, it, nl, il, ndof, maxdof, ncd, ib + LOGICAL :: cv, st + CHARACTER(512) :: em + + CALL write_pendulum_deck('pinrod_probe.dat', 'CoupledPinned', 0.0_wp) + CALL CD_AGG_Init_From_Deck(agg, 'pinrod_probe.dat', 0.01_wp, es, em) + CALL require(es == CD_AGG_OK, 'probe:init: '//TRIM(em)) + IF (es /= CD_AGG_OK) RETURN + n = CD_AGG_NMovingPoints(agg, es, em) + ALLOCATE (p(3, n), v(3, n), a(3, n), f(3, n), f0(3, n), mo(3, n), p0(3, n)) + CALL CD_AGG_CalcOutput(agg, es, em) + CALL CD_AGG_GetMovingPointMesh(agg, p0, v, a, f0, es, em) + ap = 1.5_wp + p = p0 + v = 0.0_wp + a = 0.0_wp + a(1, n) = ap + CALL CD_AGG_UpdateStates_Moving(agg, p, v, a, es, em, output_probe=.TRUE.) + CALL CD_AGG_CalcOutput(agg, es, em) + CALL CD_AGG_GetMovingPointMesh(agg, p, v, a, f, es, em, moment=mo) + ic = MP*(3.0_wp*(0.5_wp*DP)**2 + LP*LP)/12.0_wp + ip = ic + MP*(0.5_wp*LP)**2 + WRITE (*, '(A,F10.4,A,F10.4,A,F10.4)') 'probe pin acceleration: dF_x got ', f(1, n) - f0(1, n), & + ' N; -m (I_c/I_p) a_p ', -MP*ic/ip*ap, ' N; -m a_p ', -MP*ap + CALL require(ABS(f(1, n) - f0(1, n) + MP*ic/ip*ap) <= 1.0e-10_wp*MP*G, 'probe:-M_eff a_p (re-solved rotation)') + CALL require(nan_max_abs(f(2:3, n) - f0(2:3, n)) <= 1.0e-10_wp*MP*G .AND. nan_max_abs(mo(:, n)) <= 0.0_wp, & + 'probe:no other force change, zero moment') + CALL CD_AGG_End(agg, es, em) + + ! state-const probe on the tethered rod + CALL write_tethered_deck('pinrod_probe_tether.dat', 'CoupledPinned', 'deck') + CALL CD_AGG_Init_From_Deck(agg, 'pinrod_probe_tether.dat', 0.02_wp, es, em) + CALL CD_AGG_Init_From_Deck(twin, 'pinrod_probe_tether.dat', 0.02_wp, es, em) + CALL require(es == CD_AGG_OK, 'probe:tether init: '//TRIM(em)) + IF (es /= CD_AGG_OK) RETURN + DEALLOCATE (p, v, a, f, mo, p0) + n = CD_AGG_NMovingPoints(agg, es, em) + ALLOCATE (p(3, n), v(3, n), a(3, n), f(3, n), mo(3, n), p0(3, n), fb(3, n), mb(3, n)) + ALLOCATE (sp(3, n), sv(3, n), sa(3, n), so(3, 3, n), sw(3, n), sal(3, n)) + ALLOCATE (rs(CD_AGG_Rod_MirrorSize(agg)), rs2(CD_AGG_Rod_MirrorSize(agg))) + CALL CD_AGG_GetMovingPointMesh(agg, p0, v, a, f, es, em) + err = 0.0_wp + DO step = 1, 40 + k = host_surge(REAL(step, wp)*0.02_wp) + p = p0 + v = 0.0_wp + a = 0.0_wp + p(:, n) = p0(:, n) + k(1:3) + v(:, n) = k(4:6) + a(:, n) = k(7:9) + CALL CD_AGG_Step_Moving(agg, 0.02_wp, p, v, a, cv, st, it, es, em, t_committed=REAL(step, wp)*0.02_wp) + CALL CD_AGG_Step_Moving(twin, 0.02_wp, p, v, a, cv, st, it, es, em, t_committed=REAL(step, wp)*0.02_wp) + CALL require(es == CD_AGG_OK, 'probe:march: '//TRIM(em)) + IF (step /= 20) CYCLE + ! the shell's probe: save the committed host kinematics and the state mirror, overlay, evaluate + CALL CD_AGG_GetMovingPointMesh(agg, sp, sv, sa, f, es, em, orientation=so, angular_velocity=sw, & + angular_acceleration=sal) + CALL CD_AGG_Get_Rod_States(agg, rs, es, em) + nl = CD_System_NLines(agg%sys%fast%system, es, em) + maxdof = 0 + DO il = 1, nl + maxdof = MAX(maxdof, CD_System_Line_NDOF(agg%sys%fast%system, il, es, em)) + END DO + ALLOCATE (lq(maxdof, nl), lv(maxdof, nl), la(maxdof, nl)) + DO il = 1, nl + ndof = CD_System_Line_NDOF(agg%sys%fast%system, il, es, em) + CALL CD_Get_System_Line_State(agg%sys%fast%system, il, lq(1:ndof, il), lv(1:ndof, il), la(1:ndof, il), es, em) + END DO + ncd = CD_System_NSystemCoupledDOF(agg%sys%fast%system) + ALLOCATE (cq(ncd), cvv(ncd), ca(ncd)) + CALL CD_Get_System_CoupledMotion(agg%sys%fast%system, cq, cvv, ca, es, em) + p(1, n) = p(1, n) + 0.3_wp + a(1, n) = a(1, n) + 4.0_wp + v(1, n) = v(1, n) - 0.5_wp + CALL CD_AGG_UpdateStates_Moving(agg, p, v, a, es, em, output_probe=.TRUE.) + CALL require(es == CD_AGG_OK, 'probe:overlay: '//TRIM(em)) + CALL CD_AGG_CalcOutput(agg, es, em) + CALL CD_AGG_GetMovingPointMesh(agg, p, v, a, f, es, em, moment=mo) + CALL require(ALL(IEEE_IS_FINITE(f)) .AND. nan_max_abs(mo(:, n)) <= 0.0_wp, 'probe:finite force, zero moment') + ! The tethers load End B with their end-node inertia at the end acceleration the system + ! holds (the probe pin with the committed rotation). Give that end another acceleration: + ! its line load changes, the pin force does not (the inertia is moved to the re-solved + ! rotation exactly). + CALL CD_AGG_Get_Rod_States(agg, rs2, es, em) + endb = rs2(1:3) + rs2(16:18) + ALLOCATE (q2(ncd), v2(ncd), a2(ncd), l1(ncd), l2(ncd)) + CALL CD_Get_System_CoupledMotion(agg%sys%fast%system, q2, v2, a2, es, em) + ib = 0 + DO il = 1, ncd/3 + IF (nan_max_abs(q2(3*il - 2:3*il) - endb) <= 1.0e-9_wp) ib = il + END DO + CALL require(ib > 0, 'probe:End B is a coupled point of the line system') + IF (ib > 0) THEN + CALL CD_Calc_System_CoupledLoads(agg%sys%fast%system, l1, es, em) + a2(3*ib - 2:3*ib) = a2(3*ib - 2:3*ib) + [3.0_wp, -2.0_wp, 1.0_wp] + CALL CD_Update_System_CoupledMotion(agg%sys%fast%system, q2, v2, a2, es, em) + CALL require(es == CD_SYSTEM_OK, 'probe:end acceleration: '//TRIM(em)) + CALL CD_Calc_System_CoupledLoads(agg%sys%fast%system, l2, es, em) + CALL CD_AGG_CalcOutput(agg, es, em) + CALL CD_AGG_GetMovingPointMesh(agg, p, v, a, fb, es, em, moment=mb) + WRITE (*, '(A,ES10.3,A,ES10.3,A)') 'probe with another End B acceleration: line load change ', & + nan_max_abs(l2(3*ib - 2:3*ib) - l1(3*ib - 2:3*ib)), ' N, pin force change ', & + nan_max_abs(fb(:, n) - f(:, n)), ' N' + CALL require(nan_max_abs(l2(3*ib - 2:3*ib) - l1(3*ib - 2:3*ib)) > 1.0_wp, & + 'probe:the End B line load carries the end acceleration') + CALL require(nan_max_abs(fb(:, n) - f(:, n)) <= 1.0e-9_wp*nan_max_abs(f(:, n)) .AND. & + nan_max_abs(mb(:, n)) <= 0.0_wp, 'probe:pin force independent of the held end acceleration') + END IF + DEALLOCATE (q2, v2, a2, l1, l2) + CALL CD_AGG_UpdateStates_Moving(agg, sp, sv, sa, es, em, output_probe=.TRUE., orientation=so, & + angular_velocity=sw, angular_acceleration=sal) + DO il = 1, nl + ndof = CD_System_Line_NDOF(agg%sys%fast%system, il, es, em) + CALL CD_Update_System_Line_Interior_State(agg%sys%fast%system, il, lq(4:ndof - 3, il), lv(4:ndof - 3, il), & + es, em, a_interior=la(4:ndof - 3, il)) + END DO + CALL CD_AGG_Set_Rod_States(agg, rs, es, em) + CALL require(es == CD_AGG_OK, 'probe:restore: '//TRIM(em)) + CALL CD_Update_System_CoupledMotion(agg%sys%fast%system, cq, cvv, ca, es, em) + CALL require(es == CD_SYSTEM_OK, 'probe:coupled motion: '//TRIM(em)) + CALL CD_AGG_Get_Rod_States(agg, rs2, es, em) + CALL require(nan_max_abs(rs2 - rs) <= 0.0_wp, 'probe:rod state restored bit-identically') + END DO + ! continuation after the probe: compare the steps 21-40 (already marched) at the end state + CALL CD_AGG_CalcOutput(agg, es, em) + CALL CD_AGG_GetMovingPointMesh(agg, p, v, a, f, es, em, moment=mo) + CALL CD_AGG_CalcOutput(twin, es, em) + CALL CD_AGG_GetMovingPointMesh(twin, p, v, a, fb, es, em, moment=mb) + CALL CD_AGG_Get_Rod_States(agg, rs, es, em) + CALL CD_AGG_Get_Rod_States(twin, rs2, es, em) + CALL require(nan_max_abs(f - fb) <= 0.0_wp .AND. nan_max_abs(mo - mb) <= 0.0_wp .AND. & + nan_max_abs(rs - rs2) <= 0.0_wp, 'probe:state-const (probed run equals the twin bit for bit)') + CALL CD_AGG_End(agg, es, em) + CALL CD_AGG_End(twin, es, em) + END SUBROUTINE case_probe + + ! --------------------------------------------------------------------------------------------- ! + ! 9: PtfmInit and the static initial condition ! + ! --------------------------------------------------------------------------------------------- ! + + SUBROUTINE case_ptfm_static() + !! PtfmInit (surge 1 m, sway 0.5 m, yaw 10 deg) moves the pin and the rod rigidly with the + !! platform before the static solve, which then turns the rod about its pin against the + !! now unequal tethers: the pin is the displaced End A, the rod's net moment about it + !! vanishes, the host node carries the rod's net force and no moment, and the rod starts + !! at rest. + TYPE(CD_AGG_ModuleType) :: agg + REAL(wp), ALLOCATABLE :: p(:, :), v(:, :), a(:, :), f(:, :), mo(:, :) + REAL(wp) :: ptfm(6), dcm(3, 3), pin(3), s(24), ch(6), cz, sz, tilt, fsc + INTEGER :: es, n, i + CHARACTER(512) :: em + + CALL write_tethered_deck('pinrod_ptfm.dat', 'CoupledPinned', 'static') + ptfm = [1.0_wp, 0.5_wp, 0.0_wp, 0.0_wp, 0.0_wp, 10.0_wp*PI/180.0_wp] + CALL CD_AGG_Init_From_Deck(agg, 'pinrod_ptfm.dat', 0.02_wp, es, em, ptfm_init=ptfm) + CALL require(es == CD_AGG_OK, 'ptfm:init: '//TRIM(em)) + IF (es /= CD_AGG_OK) RETURN + n = CD_AGG_NMovingPoints(agg, es, em) + ALLOCATE (p(3, n), v(3, n), a(3, n), f(3, n), mo(3, n)) + cz = COS(ptfm(6)) + sz = SIN(ptfm(6)) + dcm = 0.0_wp + dcm(1, 1) = cz + dcm(1, 2) = sz + dcm(2, 1) = -sz + dcm(2, 2) = cz + dcm(3, 3) = 1.0_wp + pin = ptfm(1:3) + MATMUL(TRANSPOSE(dcm), [0.0_wp, 0.0_wp, -10.0_wp]) + CALL CD_AGG_CalcOutput(agg, es, em) + CALL CD_AGG_GetMovingPointMesh(agg, p, v, a, f, es, em, moment=mo) + CALL CD_AGG_Get_Rod_States(agg, s, es, em) + DO i = 1, 6 + CALL CD_AGG_EvalChannel(agg, i, ch(i), es, em) + END DO + tilt = ACOS(MIN(1.0_wp, -s(18))) + fsc = nan_max_abs(ch(1:3)) + WRITE (*, '(A,ES10.3,A,F8.4,A,ES10.3,A,ES10.3)') 'PtfmInit + static IC: |pin - displaced End A| ', & + nan_max_abs(p(:, n) - pin), '; rod tilt ', tilt, ' rad; |Rod1M| ', nan_max_abs(ch(4:6)), & + ' N m; |host force - Rod1F| ', nan_max_abs(f(:, n) - ch(1:3)) + CALL require(nan_max_abs(p(:, n) - pin) <= 1.0e-12_wp, 'ptfm:pin at the displaced End A') + CALL require(nan_max_abs(s(1:3) - 1.0_wp*s(16:18) - pin) <= 1.0e-12_wp, 'ptfm:rod End A on the pin') + CALL require(tilt > 1.0e-3_wp, 'ptfm:the static solve turned the rod') + CALL require(nan_max_abs(ch(4:6)) <= 1.0e-6_wp*fsc*2.0_wp, 'ptfm:net moment about the pin vanishes') + CALL require(nan_max_abs(f(:, n) - ch(1:3)) <= 1.0e-8_wp*fsc .AND. nan_max_abs(mo(:, n)) <= 0.0_wp, & + 'ptfm:host force is the net rod load, no moment') + CALL CD_AGG_End(agg, es, em) + END SUBROUTINE case_ptfm_static + + ! --------------------------------------------------------------------------------------------- ! + ! 11-12: a step without the staged rods, and rod ends without a point ! + ! --------------------------------------------------------------------------------------------- ! + + SUBROUTINE case_unstaged_step() + !! The rod march of a CoupledPinned rod needs no staged copy of the step-start rods: the rod + !! state carries its step-start pin. One instance marches through CD_AGG_Step_Moving (which + !! stages the rods and passes them on); its twin takes the t + dt pin through + !! CD_Rod_SetHostKinematics and steps with CD_Step_Aggregate_Rod alone (no staged rods, no + !! host overlay: the independent fairlead stays where the start transfer put it). Over the + !! first step (the start-acceleration solve with the pin at its step-start pose) and the + !! sub-cycled steps after it (the pin interpolated from its step start), the two are + !! bit-identical under a harmonic pin surge, whose acceleration differs between step start + !! and end. + TYPE(CD_AGG_ModuleType) :: staged, bare + REAL(wp), PARAMETER :: DTC = 0.1_wp + REAL(wp), ALLOCATABLE :: p(:, :), v(:, :), a(:, :), f(:, :), p0(:, :), rs(:), rs2(:) + REAL(wp), ALLOCATABLE :: cq(:), cvv(:), ca(:), cq2(:), cvv2(:), ca2(:) + REAL(wp) :: k(9), err, t + INTEGER :: es, n, step, it, ncd + LOGICAL :: cv, st + CHARACTER(512) :: em + + CALL write_tethered_deck('pinrod_unstaged.dat', 'CoupledPinned', 'deck') + CALL CD_AGG_Init_From_Deck(staged, 'pinrod_unstaged.dat', DTC, es, em) + CALL require(es == CD_AGG_OK, 'unstaged:init: '//TRIM(em)) + IF (es /= CD_AGG_OK) RETURN + CALL CD_AGG_Init_From_Deck(bare, 'pinrod_unstaged.dat', DTC, es, em) + n = CD_AGG_NMovingPoints(staged, es, em) + ALLOCATE (p(3, n), v(3, n), a(3, n), f(3, n), p0(3, n)) + ALLOCATE (rs(CD_AGG_Rod_MirrorSize(staged)), rs2(CD_AGG_Rod_MirrorSize(staged))) + ncd = CD_System_NSystemCoupledDOF(staged%sys%fast%system) + ALLOCATE (cq(ncd), cvv(ncd), ca(ncd), cq2(ncd), cvv2(ncd), ca2(ncd)) + CALL CD_AGG_GetMovingPointMesh(staged, p0, v, a, f, es, em) + err = 0.0_wp + DO step = 0, 20 + t = REAL(step, wp)*DTC + k = host_surge(t) + p = p0 + v = 0.0_wp + a = 0.0_wp + p(:, n) = p0(:, n) + k(1:3) + v(:, n) = k(4:6) + a(:, n) = k(7:9) + IF (step == 0) THEN + CALL CD_AGG_UpdateStates_Moving(staged, p, v, a, es, em) + CALL CD_AGG_UpdateStates_Moving(bare, p, v, a, es, em) + CALL require(es == CD_AGG_OK, 'unstaged:start transfer: '//TRIM(em)) + CYCLE + END IF + CALL CD_AGG_Step_Moving(staged, DTC, p, v, a, cv, st, it, es, em, t_committed=t) + CALL require(es == CD_AGG_OK, 'unstaged:staged step: '//TRIM(em)) + CALL CD_Rod_SetHostKinematics(bare%rod, p(:, n:n), v(:, n:n), a(:, n:n), es, em) + CALL require(es == CD_DECKDRV_OK, 'unstaged:pin transfer: '//TRIM(em)) + CALL CD_Step_Aggregate_Rod(bare%sys%fast%system, bare%rod, t - DTC, DTC, cv, st, it, es, em) + CALL require(es == CD_DECKDRV_OK, 'unstaged:bare step: '//TRIM(em)) + IF (es /= CD_DECKDRV_OK) EXIT + CALL CD_AGG_Get_Rod_States(staged, rs, es, em) + CALL CD_AGG_Get_Rod_States(bare, rs2, es, em) + CALL CD_Get_System_CoupledMotion(staged%sys%fast%system, cq, cvv, ca, es, em) + CALL CD_Get_System_CoupledMotion(bare%sys%fast%system, cq2, cvv2, ca2, es, em) + err = MAX(err, nan_max_abs(rs - rs2), nan_max_abs(cq - cq2), nan_max_abs(cvv - cvv2), nan_max_abs(ca - ca2)) + END DO + WRITE (*, '(A,ES10.3,A,ES10.3,A)') 'CoupledPinned step without staged rods: max |state difference| = ', err, & + ' (rod turned ', ABS(rod_angle(rs)), ' rad)' + CALL require(err <= 0.0_wp, 'unstaged:the step-start pin needs no staged rods (bit-identical)') + CALL require(ABS(rod_angle(rs)) > 1.0e-3_wp, 'unstaged:the pin motion turns the rod') + CALL CD_AGG_End(staged, es, em) + CALL CD_AGG_End(bare, es, em) + END SUBROUTINE case_unstaged_step + + ! --------------------------------------------------------------------------------------------- ! + ! 13: a pinned rod without a line sub-cycles its own swing ! + ! --------------------------------------------------------------------------------------------- ! + + FUNCTION host_rest(time) RESULT(k) + !! A host node held at its initial position. + REAL(wp), INTENT(IN) :: time + REAL(wp) :: k(9) + k = 0.0_wp*time + END FUNCTION host_rest + + SUBROUTINE case_lineless_swing_substep() + !! A 1 m Pinned rod that carries no line, released at 30 degrees: (1) dry, hanging from a pin + !! above the water, omega0^2 = m g (L/2)/I_p, about 14.6 rad^2/s^2; (2) submerged and buoyant + !! (10 kg/m against 32.2 kg/m of displaced water), standing up from a pin at z = -15 m (out of + !! the surface's reach), + !! omega0^2 = (B - W)(L/2)/I_p, about 32.4 rad^2/s^2. At a 0.6 s coupling step omega0 dt is + !! 2.29 and 3.42, beyond the explicit limit of 2, and the sub-step estimate (the swing + !! stiffness |W d_g - B d_b| over the inertia about the pin) asks for 6 and 9 sub-steps + !! (omega0 dt/0.4 = 5.73 and 8.54). The coarse run must equal a run at that sub-step size at + !! every coupling step (so it took those sub-steps; taking each step whole, it departs by + !! radians and turns over), stay within its release angle, and swing + !! with the elliptic-integral period of the compound pendulum to the accuracy of + !! omega0 dt_sub, about 0.38 (a central-difference period error near (omega dt)^2/24 = 0.6 %). + TYPE(CD_AGG_ModuleType) :: coarse, fine + REAL(wp), PARAMETER :: DTC = 0.6_wp, TH0 = 30.0_wp, ZW = -15.0_wp + INTEGER, PARAMETER :: NC = 30, NSUBS(2) = [6, 9] + REAL(wp), ALLOCATABLE :: angc(:), tc(:), angf(:), tf(:) + REAL(wp) :: mpm, ip, kswing, t_ref, period, mean, err_ang, amp, rel + INTEGER :: es, i, kase, nsub + LOGICAL :: ok + CHARACTER(512) :: em + + DO kase = 1, 2 + nsub = NSUBS(kase) + IF (kase == 1) THEN + mpm = 50.0_wp + CALL write_short_pendulum_deck('pinrod_short.dat', mpm, ZPIN, .FALSE., TH0) + kswing = mpm*G*0.5_wp + ELSE + mpm = 10.0_wp + CALL write_short_pendulum_deck('pinrod_short.dat', mpm, ZW, .TRUE., TH0) + kswing = (1025.0_wp*0.25_wp*PI*DP*DP - mpm)*G*0.5_wp + END IF + ip = mpm*(1.0_wp/3.0_wp + DP*DP/16.0_wp) + t_ref = 4.0_wp*SQRT(ip/kswing)*ellip_k(SIN(0.5_wp*TH0*PI/180.0_wp)) + CALL CD_AGG_Init_From_Deck(coarse, 'pinrod_short.dat', DTC, es, em) + CALL require(es == CD_AGG_OK, 'lineless:coarse-init: '//TRIM(em)) + IF (es /= CD_AGG_OK) RETURN + CALL CD_AGG_Init_From_Deck(fine, 'pinrod_short.dat', DTC/REAL(nsub, wp), es, em) + CALL require(es == CD_AGG_OK, 'lineless:fine-init: '//TRIM(em)) + IF (es /= CD_AGG_OK) RETURN + ALLOCATE (angc(0:NC), tc(0:NC), angf(0:NC*nsub), tf(0:NC*nsub)) + CALL march(coarse, DTC, NC, host_rest, angc, tc, ok) + CALL require(ok, 'lineless:coarse march finite (the swing is sub-cycled)') + CALL march(fine, DTC/REAL(nsub, wp), NC*nsub, host_rest, angf, tf, ok) + CALL require(ok, 'lineless:fine march finite') + IF (.NOT. ok) RETURN + ! rod_angle is measured from the downward vertical: the upright rod's angle from the + ! upward one is pi - rod_angle, wrapped to (-pi, pi] + IF (kase == 2) THEN + angc = MODULO(2.0_wp*PI - angc, 2.0_wp*PI) - PI + angf = MODULO(2.0_wp*PI - angf, 2.0_wp*PI) - PI + END IF + err_ang = 0.0_wp + DO i = 0, NC + err_ang = MAX(err_ang, ABS(angc(i) - angf(nsub*i))) + END DO + amp = MAX(nan_max_abs(angc), nan_max_abs(angf)) + CALL crossings(tf, angf, 0.0_wp, period, mean) + rel = ABS(period - t_ref)/t_ref + WRITE (*, '(A,I0,A,ES10.3,A,F8.5,A,2F10.6,A,ES10.3)') 'lineless pinned swing (', kase, & + '): coarse vs sub-step run ', err_ang, ' rad; max angle/release ', amp/(TH0*PI/180.0_wp), & + '; period got/analytic [s] ', period, t_ref, '; rel. error ', rel + CALL require(err_ang <= 1.0e-8_wp*amp, 'lineless:coarse step equals its sub-step run') + CALL require(amp <= 1.02_wp*TH0*PI/180.0_wp, 'lineless:the swing stays within its release angle') + CALL require(rel <= 1.5e-2_wp, 'lineless:period (elliptic integral)') + DEALLOCATE (angc, tc, angf, tf) + CALL CD_AGG_End(coarse, es, em) + CALL CD_AGG_End(fine, es, em) + END DO + END SUBROUTINE case_lineless_swing_substep + + ! --------------------------------------------------------------------------------------------- ! + ! 14: a host pin crossing the free surface within one coupling step ! + ! --------------------------------------------------------------------------------------------- ! + + FUNCTION host_rise(time) RESULT(k) + !! The pin rising at a constant 12 m/s from t = 0. + REAL(wp), INTENT(IN) :: time + REAL(wp) :: k(9) + k = 0.0_wp + k(3) = 12.0_wp*time + k(6) = 12.0_wp + END FUNCTION host_rise + + FUNCTION host_sink(time) RESULT(k) + !! The pin sinking at a constant 2 m/s from t = 0. + REAL(wp), INTENT(IN) :: time + REAL(wp) :: k(9) + k = 0.0_wp + k(3) = -2.0_wp*time + k(6) = -2.0_wp + END FUNCTION host_sink + + SUBROUTINE case_surface_crossing_pin() + !! A 1 m CoupledPinned rod without a line whose host pin crosses the free surface in one + !! coupling step at constant velocity, which the linear interpolation of the pin inside the + !! step represents exactly. The march sizes its sub-steps after the host has placed the pin at + !! the end of the step, so the swing estimate must also take the step-start wetting: + !! (1) a light rod (1 kg/m against 32.2 kg/m of displaced water) standing up from a pin at + !! z = -1.1 m that rises at 12 m/s, fully submerged at the start of a 0.1 s step and dry + !! at its end: omega^2 = (B - W)(L/2)/I_p = 456 rad^2/s^2 at the start (omega dt = 2.13, + !! beyond the explicit limit of 2) but 14.6 at the end, which alone asks for one + !! sub-step; the start wetting asks for 6 (omega dt/0.4 = 5.34); + !! (2) a rod just heavier than water (33 kg/m) hanging from a pin at z = 1 m that sinks at + !! 2 m/s, dry at the start of a 0.6 s step and submerged at its end: 14.6 rad^2/s^2 at the + !! start (omega dt = 2.29) against 0.354 at the end; the start asks for 6 (5.73). + !! The crossing step must stay within 5e-3 rad and 1 % of the rod state of a run at a sixtieth + !! of the step (the wetting along the step is bounded by its two ends; near the surface the + !! waterplane term of the estimate adds sub-steps beyond these). + TYPE(CD_AGG_ModuleType) :: coarse, fine + INTEGER, PARAMETER :: NSUB = 60 + REAL(wp) :: angc(0:1), tc(0:1), angf(0:NSUB), tf(0:NSUB), sc(24), sf(24), dtc, err_ang, err_s + INTEGER :: es, kase + LOGICAL :: ok + CHARACTER(512) :: em + + DO kase = 1, 2 + IF (kase == 1) THEN + dtc = 0.1_wp + CALL write_short_pendulum_deck('pinrod_cross.dat', 1.0_wp, -1.1_wp, .TRUE., 10.0_wp, 'CoupledPinned') + ELSE + dtc = 0.6_wp + CALL write_short_pendulum_deck('pinrod_cross.dat', 33.0_wp, 1.0_wp, .FALSE., 30.0_wp, 'CoupledPinned') + END IF + CALL CD_AGG_Init_From_Deck(coarse, 'pinrod_cross.dat', dtc, es, em) + CALL require(es == CD_AGG_OK, 'cross:coarse-init: '//TRIM(em)) + IF (es /= CD_AGG_OK) RETURN + CALL CD_AGG_Init_From_Deck(fine, 'pinrod_cross.dat', dtc/REAL(NSUB, wp), es, em) + CALL require(es == CD_AGG_OK, 'cross:fine-init: '//TRIM(em)) + IF (es /= CD_AGG_OK) RETURN + IF (kase == 1) THEN + CALL march(coarse, dtc, 1, host_rise, angc, tc, ok, s_end=sc) + CALL require(ok, 'cross:coarse march finite') + CALL march(fine, dtc/REAL(NSUB, wp), NSUB, host_rise, angf, tf, ok, s_end=sf) + ELSE + CALL march(coarse, dtc, 1, host_sink, angc, tc, ok, s_end=sc) + CALL require(ok, 'cross:coarse march finite') + CALL march(fine, dtc/REAL(NSUB, wp), NSUB, host_sink, angf, tf, ok, s_end=sf) + END IF + CALL require(ok, 'cross:fine march finite') + IF (.NOT. ok) RETURN + err_ang = ABS(angc(1) - angf(NSUB)) + err_s = nan_max_abs(sc - sf)/MAX(1.0_wp, nan_max_abs(sf)) + WRITE (*, '(A,I0,A,ES10.3,A,F9.5,A,ES10.3)') 'surface-crossing pin (', kase, & + '): crossing step vs dt/60 run: angle ', err_ang, ' of ', angf(NSUB), ' rad; rod state ', err_s + CALL require(err_ang <= 5.0e-3_wp .AND. err_s <= 1.0e-2_wp, 'cross:crossing step follows the fine run') + CALL CD_AGG_End(coarse, es, em) + CALL CD_AGG_End(fine, es, em) + END DO + END SUBROUTINE case_surface_crossing_pin + + ! --------------------------------------------------------------------------------------------- ! + ! 15: seabed contact at a large coupling step ! + ! --------------------------------------------------------------------------------------------- ! + + SUBROUTINE write_seabed_rod_deck(path, rod_type) + !! A rod (D = 0.2 m, 50 kg/m, no drag or added mass) on a stiff seabed at z = -10 m (kBot + !! 1e7 N/m^3): a 1 m Pinned rod from a pin at (0, 0, -9.5) whose End B rests on the bed at + !! 30 degrees below the horizontal, or a 2 m Free rod lying on the bed from x = 0 to 2, held + !! by two lightly taut tethers to anchors 1 m above the bed. The fairlead line of + !! write_pendulum_deck keeps a mooring system in the deck. + CHARACTER(*), INTENT(IN) :: path, rod_type + INTEGER :: u + OPEN (NEWUNIT=u, FILE=path, STATUS='REPLACE', ACTION='WRITE') + WRITE (u, '(A)') 'rod on a stiff seabed on the coupled aggregate' + WRITE (u, '(A)') '--- LINE TYPES ---' + WRITE (u, '(A)') 'Name Diam Mass EA BA EI Cdn Cdt Can Cat' + WRITE (u, '(A)') '(-) (m) (kg/m) (N) (-) (Nm2) (-) (-) (-) (-)' + WRITE (u, '(A)') 'line 0.10 80.0 1.0e6 0.0 0.0 1.0 0.0 1.0 0.0' + WRITE (u, '(A)') 'tether 0.05 4.0 2.0e5 0.0 0.0 1.0 0.0 1.0 0.0' + WRITE (u, '(A)') '--- ROD TYPES ---' + WRITE (u, '(A)') 'Name Diam Mass Cd Ca CdEnd CaEnd' + WRITE (u, '(A)') '(-) (m) (kg/m) (-) (-) (-) (-)' + WRITE (u, '(A)') 'bar 0.2 50 0 0 0 0' + WRITE (u, '(A)') '--- RODS ---' + WRITE (u, '(A)') 'ID RodType Type XA YA ZA XB YB ZB NumSegs Outputs' + WRITE (u, '(A)') '(-) (-) (-) (m) (m) (m) (m) (m) (m) (-) (-)' + IF (rod_type == 'Free') THEN + WRITE (u, '(A)') '1 bar Free 0 0 -10 2 0 -10 4 -' + ELSE + WRITE (u, '(A,ES24.16,A)') '1 bar Pinned 0 0 -9.5 ', SQRT(0.75_wp), ' 0 -10 4 -' + END IF + WRITE (u, '(A)') '--- POINTS ---' + WRITE (u, '(A)') 'ID Type X Y Z Mass Vol CdA Ca' + WRITE (u, '(A)') '(-) (-) (m) (m) (m) (kg) (m3) (m2) (-)' + WRITE (u, '(A)') '1 Coupled 0.0 30.0 -1.0 0 0 0 0' + WRITE (u, '(A)') '2 Fixed 6.0 30.0 -8.0 0 0 0 0' + IF (rod_type == 'Free') THEN + WRITE (u, '(A)') '3 Fixed -5.0 0 -9 0 0 0 0' + WRITE (u, '(A)') '4 Fixed 7.0 0 -9 0 0 0 0' + END IF + WRITE (u, '(A)') '--- LINES ---' + WRITE (u, '(A)') 'ID NodeA NodeB Outputs' + WRITE (u, '(A)') '(-) (-) (-) (-)' + WRITE (u, '(A)') '1 1 2 -' + IF (rod_type == 'Free') THEN + WRITE (u, '(A)') '2 R1A 3 -' + WRITE (u, '(A)') '3 R1B 4 -' + END IF + WRITE (u, '(A)') '--- SECTIONS ---' + WRITE (u, '(A)') 'LineID LineType Length NumSegs' + WRITE (u, '(A)') '(-) (-) (m) (-)' + WRITE (u, '(A)') '1 line 9.5 6' + IF (rod_type == 'Free') THEN + WRITE (u, '(A)') '2 tether 5.09 10' + WRITE (u, '(A)') '3 tether 5.09 10' + END IF + WRITE (u, '(A)') '--- OPTIONS ---' + WRITE (u, '(A)') '9.80665 g' + WRITE (u, '(A)') '1025.0 rhoW' + WRITE (u, '(A)') '10.0 WtrDpth' + WRITE (u, '(A)') '1.0e7 kBot' + WRITE (u, '(A)') 'deck bodyIC' + WRITE (u, '(A)') '--- end ---' + CLOSE (u) + END SUBROUTINE write_seabed_rod_deck + + SUBROUTINE case_seabed_contact_substep() + !! The contact springs kBot d dl of the rod stations on the bed are far stiffer than the rod's + !! other restoring: (1) the Pinned rod's End B station alone, 5e4 N/m at 0.87 m horizontally + !! from the pin, gives omega^2 about 2e3 rad^2/s^2 about the pin (omega dt about 4.7 at a + !! 0.1 s step; the stations within reach of the bed over the step ask for 34 to 36 + !! sub-steps) against 5 from its submerged weight; (2) the Free rod's 21 stations, 4e6 N/m in + !! all on 100 kg, give omega^2 about 4e4 in heave (omega dt about 10 at a 0.05 s step, 26 + !! sub-steps) against about 800 from its tethers (4 sub-steps). The march must sub-cycle the + !! contact mode: over 5 s each rod stays at rest on the bed (its static settlement is below + !! 2 mm) and ends where a run at a tenth of the step ends; with the sub-steps of its other + !! restoring alone it is thrown off the bed. + TYPE(CD_AGG_ModuleType) :: coarse, fine + REAL(wp), ALLOCATABLE :: angc(:), tc(:), angf(:), tf(:) + REAL(wp) :: sc(24), sf(24), dtc, dev, err_end + INTEGER :: es, kase, nc + LOGICAL :: ok + CHARACTER(512) :: em + CHARACTER(8) :: kind + + DO kase = 1, 2 + IF (kase == 1) THEN + kind = 'Pinned' + dtc = 0.1_wp + ELSE + kind = 'Free' + dtc = 0.05_wp + END IF + nc = NINT(5.0_wp/dtc) + CALL write_seabed_rod_deck('pinrod_seabed.dat', TRIM(kind)) + CALL CD_AGG_Init_From_Deck(coarse, 'pinrod_seabed.dat', dtc, es, em) + CALL require(es == CD_AGG_OK, 'seabed:coarse-init: '//TRIM(em)) + IF (es /= CD_AGG_OK) RETURN + CALL CD_AGG_Init_From_Deck(fine, 'pinrod_seabed.dat', 0.1_wp*dtc, es, em) + CALL require(es == CD_AGG_OK, 'seabed:fine-init: '//TRIM(em)) + IF (es /= CD_AGG_OK) RETURN + ALLOCATE (angc(0:nc), tc(0:nc), angf(0:10*nc), tf(0:10*nc)) + CALL march(coarse, dtc, nc, host_rest, angc, tc, ok, s_end=sc) + CALL require(ok, 'seabed:'//TRIM(kind)//' coarse march finite (the contact mode is sub-cycled)') + IF (.NOT. ok) RETURN + CALL march(fine, 0.1_wp*dtc, 10*nc, host_rest, angf, tf, ok, s_end=sf) + CALL require(ok, 'seabed:'//TRIM(kind)//' fine march finite') + IF (.NOT. ok) RETURN + dev = nan_max_abs(angc - angc(0)) + err_end = MAX(ABS(angc(nc) - angf(10*nc)), nan_max_abs(sc(1:3) - sf(1:3))) + WRITE (*, '(A,A,A,ES10.3,A,ES10.3,A,ES10.3)') 'rod on a stiff seabed (', TRIM(kind), & + '): max angle change ', dev, ' rad; centre depth ', sc(3), '; end state vs dt/10 ', err_end + CALL require(dev <= 1.0e-2_wp .AND. ABS(sc(3) - MERGE(-9.75_wp, -10.0_wp, kase == 1)) <= 1.0e-2_wp, & + 'seabed:'//TRIM(kind)//' rod stays at rest on the bed') + CALL require(err_end <= 1.0e-4_wp, 'seabed:'//TRIM(kind)//' ends as the dt/10 run') + DEALLOCATE (angc, tc, angf, tf) + CALL CD_AGG_End(coarse, es, em) + CALL CD_AGG_End(fine, es, em) + END DO + END SUBROUTINE case_seabed_contact_substep + + SUBROUTINE case_bare_rod_ends() + !! On the coupled route only a Pinned or CoupledPinned rod may leave an end without a line or + !! RodA/B POINT row (its pin holds it): the tethered deck, whose rod carries no line at End + !! A, initialises with a Pinned or CoupledPinned rod and is refused with a Free or Coupled + !! one, as before this release. + TYPE(CD_AGG_ModuleType) :: agg + CHARACTER(16), PARAMETER :: KINDS(4) = [CHARACTER(16) :: 'Pinned', 'CoupledPinned', 'Free', 'Coupled'] + INTEGER :: es, i + CHARACTER(512) :: em + DO i = 1, 4 + CALL write_tethered_deck('pinrod_bare.dat', TRIM(KINDS(i)), 'deck') + CALL CD_AGG_Init_From_Deck(agg, 'pinrod_bare.dat', 0.02_wp, es, em) + IF (i <= 2) THEN + CALL require(es == CD_AGG_OK, 'bare-end:'//TRIM(KINDS(i))//' rod accepted: '//TRIM(em)) + ELSE + CALL require(es /= CD_AGG_OK .AND. INDEX(em, 'requires RodA and RodB points') > 0 .AND. & + INDEX(em, 'Rod1A') > 0, 'bare-end:'//TRIM(KINDS(i))//' rod refused: '//TRIM(em)) + END IF + CALL CD_AGG_End(agg, es, em) + END DO + END SUBROUTINE case_bare_rod_ends + + ! --------------------------------------------------------------------------------------------- ! + ! 10: no coupled host ! + ! --------------------------------------------------------------------------------------------- ! + + SUBROUTINE case_standalone_refusal() + !! The standalone driver has no host to move the pin: a CoupledPinned (or VesselPinned) rod + !! is refused by name, including a zero-length one. + LOGICAL :: conv + INTEGER :: es, ns + CHARACTER(512) :: em + DO ns = 0, 4, 4 + CALL write_pendulum_deck('pinrod_standalone.dat', 'VesselPinned', 10.0_wp, standalone=.TRUE., nsegs=ns) + CALL CD_Run_Deck_Driver('pinrod_standalone.dat', 'pinrod_standalone', conv, es, em) + CALL require(es /= CD_DECKDRV_OK .AND. INDEX(em, 'requires a coupled host') > 0, & + 'standalone:CoupledPinned refused by name: '//TRIM(em)) + END DO + END SUBROUTINE case_standalone_refusal + +END PROGRAM test_openfast_pinned_rod From 10a7b14a7d7bf5ef1fe28ddb175be7506051f68d Mon Sep 17 00:00:00 2001 From: Jae Hoon Seo Date: Sat, 17 Oct 2026 20:37:25 +0900 Subject: [PATCH 17/31] fix(outputs): node channels report the deck node on refined lines (#23) On a finite-EI line whose mesh was refined automatically, the node-indexed OUTPUT channels (Ten/Curv/BendMomN, LNp/v/a, Dec, Azi, Torq, Twist) read node J of the refined mesh instead of deck node J, silently: on a lazy wave refined from 71 to 1136 elements, Ten4N34 (the touchdown, 220 m) read 5488 N from 41 m against a true 1544 N, and BendMom4N54 (on the seabed) 1214 N m against 0. Refinement bisects elements, so every deck node is a node of the final mesh. The cable builder now maps each deck node to its final-mesh node by unstretched arc length from End A (also for non-uniform refinement; a deck node not on the mesh fails closed), and node channels name deck nodes on every route: standalone static and dynamic, mixed aggregate, multibody, OpenFAST/FAST.Farm and the C API EvalChannel. Whole-mesh outputs keep the refined mesh and say where the deck nodes are: a DeckNode column in .static.out and a # DeckNode line in .Line.p.out (only on refined lines), the C API GetLineValues quantity CD_C_LINE_DECK_NODE, and Python Line.deck_nodes; the Python placement helpers use the map and raise rather than guess without one. Unrefined lines and EI = 0 lines are unchanged; every example output is byte-identical. validation/PAPER_REPRODUCTION.md is brought up to date with a re-run of the article's table: paper mode (now also element OutputRecovery) reproduces v0.1.0 in every printed digit except the two-point axial-rule row, moved by the seabed anchor-end weight moment fix; the defaults columns carry the force-blended EI = 0 step. Tests: node_channels_refined_line (deck nodes against the static profile and .elements.out, dynamic positions against .p.out, the mixed route, the C API, Python placement), Python unit tests, and seabed_friction_aniso's gate moved to the deck nodes it meant. Signed-off-by: Jae Hoon Seo --- CHANGELOG.md | 23 ++ CMakeLists.txt | 24 ++ doc/capi.rst | 22 +- doc/options.rst | 3 +- doc/outputs.rst | 46 ++- doc/python_postprocessing.rst | 4 +- python/cabledyn/model.py | 4 +- python/cabledyn/objects.py | 36 +- python/cabledyn/profiles.py | 161 +++++++- python/cabledyn/ranges.py | 21 +- python/cabledyn/results.py | 109 +++++- python/tests/test_profiles.py | 72 +++- python/tests/test_results.py | 31 ++ src/CableDyn_CAPI.f90 | 44 ++- src/CableDyn_CAPI.h | 12 +- src/CableDyn_DeckDriver.f90 | 128 ++++++- src/CableDyn_OpenFAST_Aggregate.f90 | 37 +- src/CableDyn_OpenFAST_HermiteFMF.f90 | 6 + tests/test_anchor_uplift.py | 10 +- tests/test_c_api_shared.c | 3 + tests/test_node_channels_refined.py | 358 ++++++++++++++++++ tests/test_seabed_friction_aniso.f90 | 6 +- validation/PAPER_REPRODUCTION.md | 78 +++- .../orcaflex_discrete_modules_reference.py | 21 +- 24 files changed, 1157 insertions(+), 102 deletions(-) create mode 100644 tests/test_node_channels_refined.py diff --git a/CHANGELOG.md b/CHANGELOG.md index 7bc9d957..99f92999 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -321,6 +321,29 @@ All notable changes to CableDyn are recorded in this file. The format follows `vreg F/(mu N)`) where it slid back and forth at a few mm/s. This changes the results of decks with rods or bodies on a frictional seabed; none of the shipped examples or existing tests has one. +- Node output channels of a finite-EI line whose mesh the static solve refined read the wrong + node, silently. `TenN`, `CurvN`, `BendMomN`, `LNp/v/a{x,y,z}`, + `LNDec`/`Azi`, `TorqN` and `TwistN` name a deck node (1 + the total + `NumSegs` of the line's sections) and are checked against that count, but after an automatic + refinement (adaptive, stability or curvature refinement) they reported node `J` of the refined + mesh. On the lazy-wave cable of `tests/data/lazy_wave_touchdown_planar_coarse.dat` with its top + section cut from 20 to 4 elements (refined from 71 to 1136 elements), `Ten4N34`, the deck node + at the 220 m touchdown, reported 5488 N, the tension at 41 m from End A, against 1544 N, and + `BendMom4N54`, on the seabed at 420 m, 1214 N·m against 0. Each refined line now maps its deck + nodes onto the final mesh by their unstretched arc length from End A (an exact match, which + does not assume a uniform refinement; a deck node not on the mesh fails closed), and the node + channels read deck nodes on every route: standalone static and dynamic cubic-Hermite, mixed + `EI = 0` + finite-EI, multibody, OpenFAST and the C API `CableDyn_EvalChannel`. `.static.out`, + the range graphs, the per-line files and `CableDyn_GetLineValues` still list every node of the + refined mesh; `.static.out` then carries a `DeckNode` column naming the deck node of each row + (0 for a node the refinement added), `.Line.p.out` a `# DeckNode` comment line (also on the + multibody march, which writes no `.static.out`), and the new C API quantity + `CD_C_LINE_DECK_NODE` (10) of `CableDyn_GetLineValues`, Python `Line.deck_nodes`, gives the + same numbering in process. The Python `StaticProfile.deck_node_arc_lengths`, + `LineNodeHistory.deck_nodes`, `node_range_graph`, `profile_at`/`profiles_at` and + `line_range_graph` place main-output node channels at their deck node, from a static profile, + a per-line position file or `LinePositions` read from one. `EI = 0` lines are never refined, and every output of a deck whose meshes are + not refined is unchanged. See the manual's output reference (Node channels on a refined line). - Tension spikes of tension-only (`EI = 0`) lines that go slack. The generalised-α step evaluated the axial force and the dynamic loads at the blended configuration diff --git a/CMakeLists.txt b/CMakeLists.txt index fd3bdce1..b57cb64e 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -1503,6 +1503,30 @@ if(Python3_Interpreter_FOUND) message(STATUS "anchor_uplift_channels: skipped (numpy not importable in ${Python3_EXECUTABLE})") endif() + # Node channels on a refined finite-EI line name deck nodes: the static profile's DeckNode + # column, the standalone static and dynamic cubic-Hermite routes, the mixed route (the OpenFAST + # aggregate evaluator) and the C API on the coarse lazy-wave deck the static solve refines + # (needs numpy). + if(_range_tdp_numpy_rc EQUAL 0) + if(WIN32 AND CABLEDYN_RUNTIME_DLLS) + set(_node_channels_library "${CMAKE_BINARY_DIR}/runtime/$") + else() + set(_node_channels_library "$") + endif() + add_test(NAME node_channels_refined_line + COMMAND ${Python3_EXECUTABLE} ${CMAKE_CURRENT_SOURCE_DIR}/tests/test_node_channels_refined.py + --exe $ + --deck ${CMAKE_CURRENT_SOURCE_DIR}/tests/data/lazy_wave_touchdown_planar_coarse.dat + --output ${CMAKE_BINARY_DIR}/node_channels_refined_line + --library ${_node_channels_library}) + set_tests_properties(node_channels_refined_line PROPERTIES + LABELS "python;integration;static;dynamic;capi" + TIMEOUT 600 + ENVIRONMENT "${_cabledyn_python_test_environment}") + else() + message(STATUS "node_channels_refined_line: skipped (numpy not importable in ${Python3_EXECUTABLE})") + endif() + # The arbiter imports numpy + scipy at load time; only register the test when they are # importable, so an image with python3 but without those packages does not fail the # validation suite with ModuleNotFoundError before any CableDyn gate runs. diff --git a/doc/capi.rst b/doc/capi.rst index 8cd3272a..19c90a50 100644 --- a/doc/capi.rst +++ b/doc/capi.rst @@ -1760,16 +1760,21 @@ handle numbers its lines 1..n). * - ``CableDyn_NObjects`` - number of objects of ``kind`` * - ``CableDyn_GetObjectInfo`` - - ``id``; ``n_nodes`` (lines: node count; rods: ``NumSegs + 1``; points and bodies: 1); + - ``id``; ``n_nodes`` (lines: node count of the final mesh; rods: ``NumSegs + 1``; points and + bodies: 1); ``subtype`` (lines: 1 finite-EI, 0 EI = 0; points: 1 Fixed, 2 Coupled, 3 Free, 4 Connect) * - ``CableDyn_GetLineValues`` - - one quantity along the line, End A first: ``CD_C_LINE_POSITION`` (1), + - one quantity at every node of the line's final mesh, End A first: + ``CD_C_LINE_POSITION`` (1), ``_VELOCITY`` (2), ``_ACCELERATION`` (4), 3 values per node, xyz interleaved; ``_TENSION`` (3, the ``TenN`` node tension), ``_CURVATURE`` (5), ``_BEND_MOMENT`` (6, zero on an EI = 0 line), ``_DECLINATION`` (7), ``_AZIMUTH`` (8), - one value per node; ``_SEGMENT_TENSION`` (9), one value per segment. ``n_out`` must - equal the value count. + one value per node; ``_SEGMENT_TENSION`` (9), one value per segment; + ``_DECK_NODE`` (10), one value per node: the deck node ``J`` of the node (the ```` + of the node channels), 0 for a node a mesh refinement added, ``1 … n_nodes`` on a line + meshed as the deck. ``n_out`` must equal the value count. A library without code 10 + rejects it with ``CD_C_BAD_INPUT``. * - ``CableDyn_GetPointState`` - position, velocity and the resultant force of the attached lines (``Point

F``), 3 doubles each @@ -1782,7 +1787,14 @@ handle numbers its lines 1..n). of End A with the axis roll and pitch from vertical; velocity and wrench about End A * - ``CableDyn_EvalChannel`` - the value of one ``OUTPUTS`` token (:doc:`outputs`), for example ``FairTen1``, - ``L2N5px``, ``Curv1N3``, ``Point4Fz``, ``Body1Pz`` or ``Rod2TenA`` + ``L2N5px``, ``Curv1N3``, ``Point4Fz``, ``Body1Pz`` or ``Rod2TenA``; a line-node token + names a deck node + +On a finite-EI line whose mesh the static solve refined, ``n_nodes`` and the +``CableDyn_GetLineValues`` arrays cover every node of the refined mesh, while a node token of +``CableDyn_EvalChannel`` (``Ten1N5``, ``L1N5px``) names deck node 5 at its node of that mesh +(:ref:`outputs-refined-nodes`); ``CD_C_LINE_DECK_NODE`` locates it: the array row whose value is +5. A ``NULL`` output pointer skips that output, except for the ``out`` array of ``CableDyn_GetLineValues`` and the ``value`` of ``CableDyn_EvalChannel``; the latter is not diff --git a/doc/options.rst b/doc/options.rst index ca95a4af..d573b6e4 100644 --- a/doc/options.rst +++ b/doc/options.rst @@ -376,7 +376,8 @@ Finite-EI cable controls keeps the declared ``NumSegs`` authoritative but does not disable the folded-element safety check, nor the automatic refinement of a deck mesh that cannot resolve the curvature of the equilibrium (reported). When ``True``, reaching the refinement cap while - the mesh remains fragile is reported + the mesh remains fragile is reported. Node output channels keep naming the deck nodes + on a refined mesh (:ref:`outputs-refined-nodes`) - both (finite-EI lines) - ``True adaptive_mesh`` * - ``alpha_force_blend`` / ``alphaforceblend`` diff --git a/doc/outputs.rst b/doc/outputs.rst index e5a02415..eedcd047 100644 --- a/doc/outputs.rst +++ b/doc/outputs.rst @@ -183,7 +183,9 @@ Example (static route):: ---------------------------------------------- The along-arc static configuration, one row per node of every line (a *range graph* of the static -state). It is independent of the ``OUTPUTS`` selection. On a dynamic cubic-Hermite or mixed +state): every node of the line's final mesh, so a finite-EI line whose mesh the static solve +refined has more rows than deck nodes (see :ref:`outputs-refined-nodes`). It is independent of +the ``OUTPUTS`` selection. On a dynamic cubic-Hermite or mixed run it records the converged initial state that the march starts from. Layout: title line, header row, **units row**, then data. The title reads @@ -191,7 +193,8 @@ Layout: title line, header row, **units row**, then data. The title reads (static route), ``CableDyn standalone static configuration (deformed arc; public node order End A -> End B)`` (cubic-Hermite route) or ``CableDyn coupled static configuration (deformed arc; public node order End A -> End B)`` (mixed route and OpenFAST). The columns are identical -on every route: +on every route; the ``DeckNode`` column follows only when the static solve refined the mesh of a +finite-EI line of the run: .. list-table:: :header-rows: 1 @@ -231,6 +234,12 @@ on every route: * - ``Azimuth`` - ``(deg)`` - axial-tangent azimuth from +X toward +Y, in [0, 360) + * - ``DeckNode`` + - ``(-)`` + - the deck node of the row, the ```` of the node channels (1 = End A … 1 + the total + ``NumSegs`` of the line's sections = End B); 0 for a node the refinement added. An + ``EI = 0`` line, never refined, numbers its rows as the deck. Written only when a line's + mesh was refined Plot ``Curvature`` or ``Tension`` against ``ArcLength`` for a fatigue or strength check. @@ -335,9 +344,13 @@ channels instead) and accept ``r``. moment, declination and seabed clearance (and torque and twist on a line with torsion), one row per node (see below) -```` is the deck line id. Each file starts with a ``#`` comment line (e.g. +```` is the deck line id. The files list every node and segment of the line's final mesh, +also on a finite-EI line whose mesh the static solve refined (:ref:`outputs-refined-nodes`). +Each file starts with a ``#`` comment line (e.g. ``# CableDyn static line node positions; public node order EndA -> EndB``) and a header row; -there is no units row — units are in the column names. +there is no units row — units are in the column names. On a refined line the ``.p.out`` file +has a second comment line, ``# DeckNode`` followed by one tab-separated integer per node: the +deck node of that node, 0 for a node the refinement added. .. list-table:: :header-rows: 1 @@ -381,7 +394,8 @@ End A -> End B)``. - Meaning * - ``Node`` - ``(-)`` - - node number, 1 = End A … N = End B + - node number of the line's final mesh, 1 = End A … N = End B (the ``Node`` of + ``.static.out``) * - ``ArcLength`` - ``(m)`` - cumulative deformed chord length from End A at the first sample (``t = 0``, the static @@ -463,6 +477,28 @@ numeric id written with leading zeros (``Ten1N02`` = ``Ten1N2``), or an alias sp ``LINES`` and ``POINTS`` ids (not array positions); ```` is a node number on line ````, 1 = End A to ``N`` = End B, where ``N`` = 1 + the total ``NumSegs`` of the line's sections. +.. _outputs-refined-nodes: + +Node channels on a refined line +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + +```` is always a node of the **deck** mesh. The static solve of a finite-EI line can refine +its mesh (``OPTIONS adaptive_mesh``, or the automatic refinement after a failed stability test +or an unresolved curvature, which a note of the initialization report names). A refinement splits +deck elements, so each deck node is a node of the refined mesh at the same unstretched arc length +from End A, and ``TenN``, ``CurvN``, ``BendMomN``, ``LN…``, +``TorqN`` and ``TwistN`` report deck node ``J`` there, on every route (standalone, +mixed, multibody, OpenFAST and the C API ``CableDyn_EvalChannel``). ``.static.out``, the range +graphs, the per-line files and the C API ``CableDyn_GetLineValues`` list every node of the +refined mesh instead, and ``.elements.out`` every element. To find deck node ``J`` among them, +take the ``.static.out`` row whose ``DeckNode`` is ``J``: its ``Node`` is the node number in the +range graph and the per-line files (and the array row + 1 of ``CableDyn_GetLineValues``), its +``ArcLength`` the node's deformed arc length. The ``# DeckNode`` line of ``.Line.p.out`` gives +the same numbering on routes that write no ``.static.out`` (the multibody march), and the C API +quantity ``CD_C_LINE_DECK_NODE`` (Python ``Line.deck_nodes``) in process. The deck node also lies +where the ``ReferenceArcStart`` of ``.elements.out`` equals its unstretched arc length from End A +(``ReferenceArcEnd`` of the last element for End B). ``EI = 0`` lines are never refined. + Line-end channels ~~~~~~~~~~~~~~~~~ diff --git a/doc/python_postprocessing.rst b/doc/python_postprocessing.rst index 5f041ba0..b756e574 100644 --- a/doc/python_postprocessing.rst +++ b/doc/python_postprocessing.rst @@ -329,7 +329,9 @@ moment along a line, with ``plot()`` and ``export()``: functions below rebuild envelopes from other files. * :func:`cabledyn.node_range_graph` builds it from the ``TenN``, ``CurvN``, or ``BendMomN`` channels of a main output over a time window. Node positions come from a - static profile of the run, a ``{node: arc}`` mapping, or the node numbers. + static profile of the run, a ``{node: arc}`` mapping, or the node numbers. The channels name + deck nodes; on a line whose mesh the static solve refined, the profile's ``DeckNode`` column + places them (:ref:`outputs-refined-nodes`). * :func:`cabledyn.static_range_graph` builds it from a ``.static.out`` profile. * :func:`cabledyn.element_range_graph` builds it from a cubic-Hermite ``.elements.out`` table: the peak curvature or bend moment of each element, where it occurs between the nodes, or the diff --git a/python/cabledyn/model.py b/python/cabledyn/model.py index e05e8b24..8cf17336 100644 --- a/python/cabledyn/model.py +++ b/python/cabledyn/model.py @@ -394,7 +394,9 @@ def channel(self, token: str) -> float: ``token`` uses the deck OUTPUTS vocabulary (``FairTen1``, ``L2N5px``, ``Curv1N3``, ``Point4Fz``, ``Body1Pz``, ``Rod2TenA``, ...) and returns the - value the standalone driver writes for that channel at the same state. + value the standalone driver writes for that channel at the same state. A + node channel names a deck node, also on a finite-EI line whose mesh the + static solve refined. """ with self._lock: self._object_views() diff --git a/python/cabledyn/objects.py b/python/cabledyn/objects.py index d93bb601..c8078548 100644 --- a/python/cabledyn/objects.py +++ b/python/cabledyn/objects.py @@ -67,6 +67,9 @@ "segment_tension": (9, 1), } +#: C ABI code of the deck node of each mesh node (``CD_C_LINE_DECK_NODE``). +_LINE_DECK_NODE = 10 + PointKind = Literal["fixed", "coupled", "free", "connect"] _POINT_KINDS: dict[int, PointKind] = {1: "fixed", 2: "coupled", 3: "free", 4: "connect"} @@ -147,9 +150,12 @@ def _check(self, call: str, status: int) -> None: class Line(_View): """One line (mooring line or cable) of an in-process model. - Nodes run from End A (index 0) to End B, the order of the ``LN`` output - channels (node ``k`` is array row ``k - 1``) and of the ``.Line.p.out`` - files. Segments run in the same order. + Nodes run from End A (index 0) to End B, the order of the ``.Line.p.out`` + files; segments run in the same order. The arrays hold every node of the + line's final mesh. The output channels (:meth:`~cabledyn.CableDyn.channel`, + ``TenN``, ``LNpx``, ...) name deck nodes: on the deck mesh deck + node ``J`` is array row ``J - 1``; on a finite-EI line whose mesh the static + solve refined, :attr:`deck_nodes` locates them among the mesh nodes. """ _kind = OBJ_LINE @@ -165,6 +171,30 @@ def n_segments(self) -> int: """Segment (element) count, ``n_nodes - 1``.""" return self._info.n_nodes - 1 + @property + def deck_nodes(self) -> npt.NDArray[np.int64]: + """Deck node of each node of the final mesh ``(n_nodes,)``. + + Entry ``k`` is the deck node ``J`` (the ```` of the node output + channels) at array row ``k``, or 0 for a node a mesh refinement added. + On the deck mesh it is ``1 .. n_nodes``. Rows of the line arrays at deck + node ``J`` are ``numpy.flatnonzero(line.deck_nodes == J)``. + + Raises + ------ + CableDynError + If the library predates this query (``CD_C_LINE_DECK_NODE``). + """ + buf = _buffer(None, (self.n_nodes,)) + with self._model._lock: + handle = self._handle() + status = c_int() + self._model._lib.CableDyn_GetLineValues( + handle, self.index, _LINE_DECK_NODE, _dbl(buf), buf.size, byref(status) + ) + self._check("CableDyn_GetLineValues", status.value) + return np.rint(buf).astype(np.int64) + @property def finite_ei(self) -> bool: """Whether the line carries bending stiffness (the cubic-Hermite element).""" diff --git a/python/cabledyn/profiles.py b/python/cabledyn/profiles.py index 39578e75..0455f930 100644 --- a/python/cabledyn/profiles.py +++ b/python/cabledyn/profiles.py @@ -30,6 +30,19 @@ Arc length is the deformed arc length from End A: the ``ArcLength`` column of a static profile, otherwise the cumulative straight node-to-node distance at the requested time. + +The node channels of a main output number deck nodes (1 at End A to 1 + the +total ``NumSegs`` of the line's sections at End B); a static profile and the +per-line files list every node of the line's final mesh. The two differ on a +finite-EI line whose mesh the static solve refined: a static profile then +places main-output node channels at the rows its ``DeckNode`` column names, +and a per-line position file ``.Line.p.out`` (also as the ``source`` +of :class:`~cabledyn.LinePositions`) at the nodes its ``# DeckNode`` line names. Plain +position arrays carry no such map: they are taken as numbered by deck node, so +pass the in-process mesh positions of a refined line +(:meth:`cabledyn.objects.Line.values`) together with +:attr:`cabledyn.objects.Line.deck_nodes`, for example as a ``{node: arc}`` +mapping. """ from __future__ import annotations @@ -54,6 +67,8 @@ OutputTable, StaticProfile, TimeHistory, + _deck_node_comment, + read_output, ) __all__ = [ @@ -202,6 +217,9 @@ class LinePositions: CableDyn, ``0`` for End A of a MoorDyn line). source : pathlib.Path | None Result file the positions were read from, if any. + line_id : int | None + Line of a multi-line ``source`` (a static profile) the positions were + taken from, if any; it selects that line's deck-node map. Raises ------ @@ -214,6 +232,7 @@ class LinePositions: positions: npt.NDArray[Any] node_ids: npt.NDArray[Any] source: Path | None = None + line_id: int | None = None def __post_init__(self) -> None: positions = _readonly(self.positions) @@ -308,7 +327,9 @@ def period(self, start: float | None = None, stop: float | None = None) -> LineP if self.time is None or (start is None and stop is None): return self mask = _window(self.time, start, stop) - return LinePositions(self.time[mask], self.positions[mask], self.node_ids, self.source) + return LinePositions( + self.time[mask], self.positions[mask], self.node_ids, self.source, self.line_id + ) def _at( @@ -352,6 +373,12 @@ class LineField: ``(n_samples, n_locations)`` values. source : pathlib.Path | None Result file the field was read from, if any. + deck_nodes : bool + True when :attr:`ids` are deck node numbers, as the node channels of a + main output name them (1 at End A to 1 + the total ``NumSegs`` of the + line's sections at End B); false when they number the nodes of the + source's own mesh, as a static profile and the per-line files do. The + two differ on a finite-EI line whose mesh the static solve refined. Raises ------ @@ -367,6 +394,7 @@ class LineField: time: npt.NDArray[Any] | None values: npt.NDArray[Any] source: Path | None = None + deck_nodes: bool = False def __post_init__(self) -> None: if self.location_kind not in {"Node", "Segment"}: @@ -437,6 +465,7 @@ def period(self, start: float | None = None, stop: float | None = None) -> LineF self.time[mask], self.values[mask], self.source, + self.deck_nodes, ) @@ -649,7 +678,12 @@ def _unit(table: OutputTable, channel: str, default: str | None) -> str | None: def _history_field( - history: TimeHistory, quantity: str, kind: str, channels: Mapping[int, str], default: str | None + history: TimeHistory, + quantity: str, + kind: str, + channels: Mapping[int, str], + default: str | None, + deck_nodes: bool = False, ) -> LineField: names = list(channels.values()) return LineField( @@ -660,6 +694,7 @@ def _history_field( time=history.time, values=np.column_stack([history.column(name) for name in names]), source=history.path, + deck_nodes=deck_nodes, ) @@ -691,7 +726,7 @@ def build(axis: int = axis, name: str = name) -> LineField: elif isinstance(source, StaticProfile): line = _static_line(source, identifier) for column in line.channels: - if column in {"LineID", "Node", "ArcLength"}: + if column in {"LineID", "Node", "ArcLength", "DeckNode"}: continue def static_build(column: str = column) -> LineField: @@ -730,7 +765,8 @@ def moordyn_build(name: str = name, kind: str = kind, ids: Any = ids) -> LineFie def main_build( name: str = name, channels: Any = channels, unit: str = default ) -> LineField: - return _history_field(source, name, "Node", channels, unit) + # main-output node channels number deck nodes + return _history_field(source, name, "Node", channels, unit, deck_nodes=True) catalog[name] = main_build elif isinstance(source, OutputTable) and _is_static_node_table(source): @@ -879,7 +915,9 @@ def line_positions( if isinstance(source, StaticProfile): line = _static_line(source, identifier) xyz = np.column_stack([line.column(axis) for axis in "XYZ"]) - return LinePositions(None, xyz[None], line.column("Node").astype(np.int64), line.path) + return LinePositions( + None, xyz[None], line.column("Node").astype(np.int64), line.path, line.line_ids[0] + ) data: npt.NDArray[Any] if isinstance(source, LineNodeHistory): _no_line_id(identifier, source) @@ -941,10 +979,20 @@ def _node_arc( time: float | None, interpolation: Interpolation, line_id: int | None, + deck_nodes: bool = False, ) -> tuple[npt.NDArray[Any], npt.NDArray[Any]]: - """Return node ids and their arc lengths from End A at ``time``.""" + """Return node ids and their arc lengths from End A at ``time``. + + ``deck_nodes`` asks for deck node numbers (main-output node channels): a + static profile then gives the rows its ``DeckNode`` column names on a line + whose mesh the static solve refined. + """ if isinstance(locate, StaticProfile): line = _static_line(locate, line_id) + if deck_nodes: + lookup = line.deck_node_arc_lengths(line.line_ids[0]) + ids = np.asarray(sorted(lookup), dtype=np.int64) + return ids, np.asarray([lookup[int(node)] for node in ids], dtype=np.float64) return line.column("Node").astype(np.int64), np.asarray(line.column("ArcLength")) if isinstance(locate, Mapping): ids = np.asarray(sorted(int(node) for node in locate), dtype=np.int64) @@ -955,9 +1003,94 @@ def _node_arc( line_id=line_id if isinstance(locate, TimeHistory) and not _per_line(locate) else None, ) xyz = positions.at(None if positions.static else time, interpolation=interpolation) + if deck_nodes: + return _deck_node_positions(locate, positions.node_ids, _cumulative_arc(xyz)) return positions.node_ids, _cumulative_arc(xyz) +def _deck_node_positions( + locate: LocationSource, node_ids: npt.NDArray[Any], arc: npt.NDArray[Any] +) -> tuple[npt.NDArray[Any], npt.NDArray[Any]]: + """Deck node ids and arc lengths of the nodes of a position source. + + A per-line file ``.Line.p.out`` and a static profile list every + node of the line's final mesh. On a line whose mesh the static solve + refined, the file's ``# DeckNode`` line (or the ``DeckNode`` column of the + static profile ``.static.out`` beside it) names the deck nodes among + them; without either the file's nodes are the deck nodes. Position arrays + carry no such map and are taken as numbered by deck node. + """ + mesh_node = _deck_node_rows(locate) + if mesh_node is None: + return node_ids, arc + position = dict(zip(node_ids.tolist(), arc.tolist(), strict=True)) + deck = [j for j in sorted(mesh_node) if mesh_node[j] in position] + return ( + np.asarray(deck, dtype=np.int64), + np.asarray([position[mesh_node[j]] for j in deck], dtype=np.float64), + ) + + +def _deck_node_rows(locate: LocationSource) -> dict[int, int] | None: + """Deck node -> node id of a position source's file; ``None`` when they coincide.""" + path: Path | None + deck: npt.NDArray[Any] | None = None + if isinstance(locate, LineNodeHistory): + path, deck = locate.path, locate.deck_nodes + elif isinstance(locate, OutputTable) and _is_static_node_table(locate): + path, deck = locate.path, _deck_node_comment(locate.title, locate.path) + elif isinstance(locate, LinePositions) and locate.source is not None: + path = locate.source + if path.name.lower().endswith(".static.out"): + return _static_profile_rows(path, locate.line_id) + if path.is_file(): + deck = _deck_node_comment(_comment_head(path), path) + else: + return None + if deck is not None: + return {int(j): k + 1 for k, j in enumerate(deck.tolist()) if j > 0} + match = _FILE_LINE.search(path.name) + if match is None: + return None + static = path.with_name(path.name[: match.start()] + ".static.out") + if not static.is_file(): + return None + return _static_profile_rows(static, int(match.group(1))) + + +def _static_profile_rows(path: Path, line_id: int | None) -> dict[int, int] | None: + """Deck node -> ``Node`` of one line of a static profile with a ``DeckNode`` column.""" + profile = read_output(path) + if not isinstance(profile, StaticProfile) or "DeckNode" not in profile.channels: + return None + if line_id is None: + if len(profile.line_ids) != 1: + raise ValueError( + f"{path.name} lists several lines with a refined mesh; place deck-node " + "channels with the StaticProfile itself" + ) + line_id = profile.line_ids[0] + if line_id not in profile.line_ids: + return None + rows = profile.line(line_id) + return { + int(deck): int(node) + for deck, node in zip(rows.column("DeckNode"), rows.column("Node"), strict=True) + if deck > 0.0 + } + + +def _comment_head(path: Path) -> str: + """The leading ``#`` comment lines of a result file.""" + lines: list[str] = [] + with path.open(encoding="utf-8") as handle: + for line in handle: + if not line.startswith("#"): + break + lines.append(line.rstrip("\n")) + return "\n".join(lines) + + def _cumulative_arc(xyz: npt.NDArray[Any]) -> npt.NDArray[Any]: """Cumulative chord length from the first of ``(n_nodes, 3)`` points.""" return np.concatenate(([0.0], np.cumsum(np.linalg.norm(np.diff(xyz, axis=0), axis=1)))) @@ -991,7 +1124,7 @@ def _place( """Return the location kind and location of each field value.""" if locate is None: return field.location_kind, field.ids.astype(np.float64) - node_ids, arc = _node_arc(locate, time, interpolation, line_id) + node_ids, arc = _node_arc(locate, time, interpolation, line_id, field.deck_nodes) return "ArcLength", _assign(field, isinstance(locate, Mapping), node_ids, arc) @@ -1016,15 +1149,23 @@ def _assign( def _mean_node_arc( - locate: LocationSource, line_id: int | None, start: float | None, stop: float | None + locate: LocationSource, + line_id: int | None, + start: float | None, + stop: float | None, + deck_nodes: bool = False, ) -> tuple[npt.NDArray[Any], npt.NDArray[Any]]: """Node ids and their arc length, time-averaged over a window for a history.""" if isinstance(locate, (StaticProfile, Mapping)): - return _node_arc(locate, None, "linear", line_id) + return _node_arc(locate, None, "linear", line_id, deck_nodes) positions = line_positions( locate, # type: ignore[arg-type] line_id=line_id if isinstance(locate, TimeHistory) and not _per_line(locate) else None, ).period(start, stop) + if deck_nodes: + return _deck_node_positions( + locate, positions.node_ids, np.mean(positions.arc_length, axis=0) + ) return positions.node_ids, np.mean(positions.arc_length, axis=0) @@ -1085,7 +1226,7 @@ def line_range_graph( raise ValueError("a segment range graph needs node positions to place the segments") kind, location = "Node", field.ids.astype(np.float64) else: - node_ids, arc = _mean_node_arc(locate, line_id, start, stop) + node_ids, arc = _mean_node_arc(locate, line_id, start, stop, field.deck_nodes) kind, location = "ArcLength", _assign(field, isinstance(locate, Mapping), node_ids, arc) order = np.argsort(location, kind="stable") values = field.values[:, order] diff --git a/python/cabledyn/ranges.py b/python/cabledyn/ranges.py index 6cbee0eb..f823c8eb 100644 --- a/python/cabledyn/ranges.py +++ b/python/cabledyn/ranges.py @@ -17,10 +17,13 @@ cubic-Hermite element table (``.elements.out``). Node channels are written only for the nodes named in the deck ``OUTPUTS`` -section. Their positions along the line come from ``arc_length``: a static -profile of the same run (the node's static deformed arc length), an explicit -mapping from node number to arc length, or nothing, in which case the graph is -plotted against node number. +section and number deck nodes (1 at End A to 1 + the total ``NumSegs`` of the +line's sections at End B). Their positions along the line come from +``arc_length``: a static profile of the same run (the node's static deformed arc +length; on a line whose mesh the static solve refined, the deck node's row of +the profile, see :meth:`~cabledyn.StaticProfile.deck_node_arc_lengths`), an +explicit mapping from node number to arc length, or nothing, in which case the +graph is plotted against node number. """ from __future__ import annotations @@ -130,14 +133,8 @@ def node_locations( if arc_length is None: return "Node", np.asarray(node_ids, dtype=np.float64) if isinstance(arc_length, StaticProfile): - line = arc_length.line(line_id) - lookup = dict( - zip( - (int(node) for node in line.column("Node")), - (float(arc) for arc in line.column("ArcLength")), - strict=True, - ) - ) + # node channels number deck nodes; a refined line's profile locates them (DeckNode) + lookup = arc_length.deck_node_arc_lengths(line_id) elif isinstance(arc_length, Mapping): lookup = {int(node): float(arc) for node, arc in arc_length.items()} else: diff --git a/python/cabledyn/results.py b/python/cabledyn/results.py index 6366013a..b9cf14b7 100644 --- a/python/cabledyn/results.py +++ b/python/cabledyn/results.py @@ -865,11 +865,16 @@ class LineNodeHistory(TimeHistory): are those of :class:`cabledyn.OutputTable`, with ``values`` of shape ``(n_samples, 1 + 3 * n_nodes)``; positions are in metres. + The file lists every node of the line's final mesh. On a finite-EI line + whose mesh the static solve refined, a ``# DeckNode`` comment line names + the deck node of each (:attr:`deck_nodes`). + Raises ------ OutputFormatError If the node channels are malformed, not contiguous from ``Node1``, or - not in metres, or time does not strictly increase. + not in metres, time does not strictly increase, or a ``# DeckNode`` + line does not number the deck nodes of the file's nodes. """ def __post_init__(self) -> None: @@ -888,6 +893,31 @@ def __post_init__(self) -> None: units = {match.group(3) for match in parsed if match is not None} if units != {"m"}: raise OutputFormatError(f"{self.path}: line-node position channels must use metres") + deck = self.deck_nodes + if deck is not None: + named = deck[deck > 0] + if ( + deck.size != node_count + or np.any(deck < 0) + or deck[0] != 1 + or deck[-1] <= 0 + or not np.array_equal(named, np.arange(1, named.size + 1)) + ): + raise OutputFormatError( + f"{self.path}: the DeckNode line does not number the deck nodes of the " + f"{node_count} nodes 1, 2, ... from End A to End B" + ) + + @property + def deck_nodes(self) -> npt.NDArray[np.int64] | None: + """Deck node of each node of the file, or ``None`` for the deck mesh. + + ``(n_nodes,)`` deck node numbers (the ```` of the node channels of + a main output) from the file's ``# DeckNode`` line, 0 for a node a mesh + refinement added; ``None`` when the file has no such line (the line was + not refined, so its nodes are the deck nodes). + """ + return _deck_node_comment(self.title, self.path) @property def node_ids(self) -> tuple[int, ...]: @@ -1180,12 +1210,21 @@ class StaticProfile(OutputTable): :class:`cabledyn.OutputTable`, with ``values`` of shape ``(n_rows, n_channels)``. + A finite-EI line whose mesh the static solve refined lists every node of + its final mesh. The file then has a ``DeckNode`` column: the deck node of + each row (deck nodes run from 1 at End A to 1 + the total ``NumSegs`` of the + line's sections at End B), or 0 for a node the refinement added. The node + channels of a main output (``TenN``, ``LNpx``, ...) number deck + nodes; :meth:`deck_node_arc_lengths` places them. + Raises ------ OutputFormatError If a required column is missing, ``LineID`` or ``Node`` values are not - positive integers, a line's rows are not contiguous, or a line's arc - length or node order is not increasing. + positive integers, a line's rows are not contiguous, a line's arc + length or node order is not increasing, or a ``DeckNode`` column does + not number the deck nodes of a line in increasing order from 1 at its + first row to its last row. """ def __post_init__(self) -> None: @@ -1225,6 +1264,24 @@ def __post_init__(self) -> None: raise OutputFormatError( f"{self.path}: LineID {line_id} node order is not increasing" ) + if "DeckNode" in self.channels: + deck = self.column("DeckNode") + if np.any(deck < 0.0) or np.any(deck != np.floor(deck)): + raise OutputFormatError( + f"{self.path}: DeckNode values must be non-negative integers" + ) + for line_id in self.line_ids: + numbered = deck[self.column("LineID") == line_id] + named = numbered[numbered > 0.0] + if ( + numbered[0] != 1.0 + or numbered[-1] <= 0.0 + or np.any(named != np.arange(1, named.size + 1)) + ): + raise OutputFormatError( + f"{self.path}: LineID {line_id} DeckNode does not number the deck nodes " + "1, 2, ... from End A to End B" + ) @property def line_ids(self) -> tuple[int, ...]: @@ -1258,6 +1315,40 @@ def line(self, line_id: int) -> StaticProfile: self.path, self.title, self.channels, self.units, self.values[mask].copy() ) + def deck_node_arc_lengths(self, line_id: int) -> dict[int, float]: + """Return the static arc length of each deck node of one line. + + The node channels of a main output number deck nodes, from 1 at End A + to 1 + the total ``NumSegs`` of the line's sections at End B. On a line + whose mesh the static solve refined, the profile lists every node of the + final mesh and its ``DeckNode`` column locates the deck nodes among + them; otherwise the profile nodes are the deck nodes. + + Parameters + ---------- + line_id : int + One-based line identifier, as in the ``LineID`` column. + + Returns + ------- + dict[int, float] + Deck node number to its deformed arc length from End A, in metres. + + Raises + ------ + KeyError + If the profile has no rows for ``line_id``. + """ + line = self.line(line_id) + arc = line.column("ArcLength") + if "DeckNode" not in line.channels: + nodes = line.column("Node") + return {int(node): float(value) for node, value in zip(nodes, arc, strict=True)} + deck = line.column("DeckNode") + return { + int(node): float(value) for node, value in zip(deck, arc, strict=True) if node > 0.0 + } + def summary(self, line_id: int) -> StaticLineSummary: """Return core geometry and demand extrema for one line. @@ -1487,6 +1578,18 @@ def _check_not_device(table_path: Path) -> None: ) +def _deck_node_comment(title: str, path: Path | None = None) -> npt.NDArray[np.int64] | None: + """Deck node numbers of a ``# DeckNode`` comment line of a result title, if any.""" + for line in title.splitlines(): + tokens = line.split() + if len(tokens) >= 2 and tokens[0] == "#" and tokens[1] == "DeckNode": + try: + return np.asarray([int(token) for token in tokens[2:]], dtype=np.int64) + except ValueError as exc: + raise OutputFormatError(f"{path}: malformed DeckNode line") from exc + return None + + def _read_lines(table_path: Path) -> list[str]: """Return the lines of a UTF-8 text output file, failing with OutputFormatError.""" _check_not_device(table_path) diff --git a/python/tests/test_profiles.py b/python/tests/test_profiles.py index 479c07b3..53081156 100644 --- a/python/tests/test_profiles.py +++ b/python/tests/test_profiles.py @@ -10,7 +10,7 @@ import pytest from _design_data import TIME, write_main, write_static -from cabledyn import read_moordyn_line, read_output +from cabledyn import node_range_graph, read_moordyn_line, read_output from cabledyn.profiles import ( ArcProfile, LineField, @@ -463,6 +463,76 @@ def test_line_range_graph_of_main_output_and_static_profile(tmp_path): np.testing.assert_array_equal(moment.minimum, moment.maximum) +def _write_refined_static(path): + """Line 1 refined twice: deck nodes 1, 2, 3 are mesh nodes 1, 3, 5 (25 m apart).""" + lines = [ + "CableDyn standalone static configuration (deformed arc; public node order End A -> End B)", + "LineID\tNode\tArcLength\tX\tY\tZ\tTension\tCurvature\tBendMoment\tDeckNode", + "(-)\t(-)\t(m)\t(m)\t(m)\t(m)\t(N)\t(1/m)\t(N.m)\t(-)", + ] + for node in range(1, 6): + deck = (node + 1) // 2 if node % 2 else 0 + lines.append(f"1\t{node}\t{25.0 * (node - 1)}\t0\t0\t-50\t{1.0e5 * node}\t0\t0\t{deck}") + path.write_text("\n".join(lines) + "\n", encoding="ascii") + return read_output(path) + + +def test_main_output_node_channels_are_deck_nodes_on_a_refined_line(tmp_path): + # Ten1N3 names deck node 3 (End B), mesh node 5 of the refined line + main = _write_main_output(tmp_path / "run.out") + refined = _write_refined_static(tmp_path / "run.static.out") + assert "deck_node" not in available_quantities(refined, line_id=1) + by_static = profile_at(main, "tension", 10.0, line_id=1, positions=refined) + np.testing.assert_allclose(by_static.location, [0.0, 100.0]) + graph = line_range_graph(main, "tension", line_id=1, positions=refined) + np.testing.assert_allclose(graph.location, [0.0, 100.0]) + by_channels = node_range_graph(main, 1, "tension", arc_length=refined) + np.testing.assert_allclose(by_channels.location, [0.0, 100.0]) + # the static profile's own fields stay on its mesh nodes + own = profile_at(refined, "tension", line_id=1) + np.testing.assert_allclose(own.location, 25.0 * np.arange(5)) + # a per-line position file lists the refined mesh: the profile beside it locates the deck nodes + nodes = _write_nodes(tmp_path / "run.Line1.p.out") + by_file = profile_at(main, "tension", 1.0, line_id=1, positions=nodes) + np.testing.assert_allclose(by_file.location, [0.0, 4.0 * _chord(1.0)]) + by_file_graph = line_range_graph(main, "tension", line_id=1, positions=nodes) + mean_arc = np.mean([4.0 * _chord(t) for t in TIMES]) + np.testing.assert_allclose(by_file_graph.location, [0.0, mean_arc]) + alone = tmp_path / "alone" + alone.mkdir() + unrefined = _write_nodes(alone / "run.Line1.p.out") + by_alone = profile_at(main, "tension", 1.0, line_id=1, positions=unrefined) + np.testing.assert_allclose(by_alone.location, [0.0, 2.0 * _chord(1.0)]) + + +def test_line_positions_of_a_multi_line_refined_profile_keep_their_line(tmp_path): + # line 2 is meshed as the deck; line 1 is refined (deck nodes 1, 2, 3 are mesh nodes 1, 3, 5) + path = tmp_path / "run.static.out" + rows = [ + "CableDyn standalone static configuration (deformed arc; public node order End A -> End B)", + "LineID\tNode\tArcLength\tX\tY\tZ\tTension\tCurvature\tBendMoment\tDeckNode", + "(-)\t(-)\t(m)\t(m)\t(m)\t(m)\t(N)\t(1/m)\t(N.m)\t(-)", + ] + for node in range(1, 6): + deck = (node + 1) // 2 if node % 2 else 0 + arc = 25.0 * (node - 1) + rows.append(f"1\t{node}\t{arc}\t{arc}\t0\t-50\t{1.0e5 * node}\t0\t0\t{deck}") + for node in range(1, 4): + arc = 50.0 * (node - 1) + rows.append(f"2\t{node}\t{arc}\t{arc}\t10\t-50\t1e5\t0\t0\t{node}") + path.write_text("\n".join(rows) + "\n", encoding="ascii") + profile = read_output(path) + main = _write_main_output(tmp_path / "run.out") + positions = line_positions(profile, line_id=1) + assert positions.line_id == 1 + placed = profile_at(main, "tension", 10.0, line_id=1, positions=positions) + np.testing.assert_allclose(placed.location, [0.0, 100.0]) + # without the selected line the multi-line profile cannot name one map + ambiguous = LinePositions(None, positions.positions, positions.node_ids, positions.source) + with pytest.raises(ValueError, match="several lines"): + profile_at(main, "tension", 10.0, line_id=1, positions=ambiguous) + + def test_per_line_range_graph_takes_its_line_id_from_the_file_name(tmp_path): nodes = _write_nodes(tmp_path / "run.Line3.p.out") assert line_range_graph(nodes, "z").line_id == 3 diff --git a/python/tests/test_results.py b/python/tests/test_results.py index f213c8ca..22a9bdb0 100644 --- a/python/tests/test_results.py +++ b/python/tests/test_results.py @@ -729,6 +729,21 @@ def test_static_summary_without_curvature_and_with_zero_curvature(tmp_path): [[1, 1, 0.0], [2, 1, 0.0], [1, 2, 1.0]], "LineID 1 rows are not contiguous", ), + ( + ("LineID", "Node", "ArcLength", "DeckNode"), + [[1, 1, 0.0, 1], [1, 2, 1.0, 0.5]], + "DeckNode values must be non-negative integers", + ), + ( + ("LineID", "Node", "ArcLength", "DeckNode"), + [[1, 1, 0.0, 1], [1, 2, 1.0, 0], [1, 3, 2.0, 3]], + "LineID 1 DeckNode does not number the deck nodes", + ), + ( + ("LineID", "Node", "ArcLength", "DeckNode"), + [[1, 1, 0.0, 1], [1, 2, 1.0, 2], [1, 3, 2.0, 0]], + "LineID 1 DeckNode does not number the deck nodes", + ), ], ) def test_static_profile_validation(tmp_path, channels, rows, message): @@ -736,6 +751,22 @@ def test_static_profile_validation(tmp_path, channels, rows, message): StaticProfile(tmp_path / "s.out", "", channels, None, np.asarray(rows, dtype=float)) +def test_static_profile_deck_node_arc_lengths(tmp_path): + # line 1 refined twice: deck nodes 1, 2, 3 are mesh nodes 1, 3, 5; line 2 is the deck mesh + channels = ("LineID", "Node", "ArcLength", "DeckNode") + rows = [[1, n, 10.0 * (n - 1), (n + 1) // 2 if n % 2 else 0] for n in range(1, 6)] + rows += [[2, 1, 0.0, 1], [2, 2, 4.0, 2]] + profile = StaticProfile(tmp_path / "s.out", "", channels, None, np.asarray(rows, dtype=float)) + assert profile.deck_node_arc_lengths(1) == {1: 0.0, 2: 20.0, 3: 40.0} + assert profile.deck_node_arc_lengths(2) == {1: 0.0, 2: 4.0} + plain = StaticProfile( + tmp_path / "p.out", "", channels[:3], None, np.asarray([[1, 1, 0.0], [1, 2, 3.0]]) + ) + assert plain.deck_node_arc_lengths(1) == {1: 0.0, 2: 3.0} + with pytest.raises(KeyError, match="LineID 3"): + profile.deck_node_arc_lengths(3) + + # ---------------------------------------------------------------------------- plots and data frames diff --git a/src/CableDyn_CAPI.f90 b/src/CableDyn_CAPI.f90 index 7f50c96f..b2455028 100644 --- a/src/CableDyn_CAPI.f90 +++ b/src/CableDyn_CAPI.f90 @@ -16,7 +16,7 @@ MODULE CableDyn_CAPI USE CableDyn_DeckDriver, ONLY: CD_Init_Deck_System, CD_DECKDRV_OK, CD_DECKDRV_BADINPUT, CD_DECKDRV_SOLVEFAIL, & CD_Deck_Query_dtM, CD_DECK_NAMELEN, CD_Eval_Aggregate_Channel, & CD_Eval_Aggregate_Segment_Tensions, CD_Rigid6_Inventory, CD_Rod_Inventory, & - CD_Channel_Token_Parses + CD_Channel_Token_Parses, CD_Cable_Deck_Node USE CableDyn_OpenFAST_Aggregate, ONLY: CD_AGG_ModuleType, CD_AGG_Init_From_Deck, CD_AGG_NMovingPoints, & CD_AGG_UpdateStates_Moving, CD_AGG_Step_Moving, CD_AGG_CalcOutput, & CD_AGG_GetMovingPointMesh, CD_AGG_End, CD_AGG_IsInitialized, CD_AGG_OK, & @@ -90,7 +90,7 @@ MODULE CableDyn_CAPI CD_C_LINE_TENSION = 3_C_INT, CD_C_LINE_ACCELERATION = 4_C_INT, & CD_C_LINE_CURVATURE = 5_C_INT, CD_C_LINE_BEND_MOMENT = 6_C_INT, & CD_C_LINE_DECLINATION = 7_C_INT, CD_C_LINE_AZIMUTH = 8_C_INT, & - CD_C_LINE_SEGMENT_TENSION = 9_C_INT + CD_C_LINE_SEGMENT_TENSION = 9_C_INT, CD_C_LINE_DECK_NODE = 10_C_INT !> Capacity of the per-handle diagnostic retained for CableDyn_GetLastError. INTEGER, PARAMETER :: CD_C_MSG_LEN = 1024 @@ -1463,7 +1463,9 @@ SUBROUTINE CableDyn_GetLineValues(handle, index, quantity, out_ptr, n_out, err_s !! One quantity along line `index` (0-based) in public node order End A -> End B. !! quantity: CD_C_LINE_POSITION / VELOCITY / ACCELERATION (3 per node, xyz interleaved), !! TENSION / CURVATURE / BEND_MOMENT / DECLINATION / AZIMUTH (1 per node), or - !! SEGMENT_TENSION (1 per segment). n_out must equal the value count exactly. + !! SEGMENT_TENSION (1 per segment), or DECK_NODE (1 per node: the deck node of each node of the + !! line's final mesh, the J of the node channels; 0 for a node a refinement added). Every quantity + !! covers every node of the final mesh. n_out must equal the value count exactly. TYPE(C_PTR), VALUE :: handle, out_ptr INTEGER(C_INT), VALUE :: index, quantity, n_out INTEGER(C_INT), INTENT(OUT) :: err_stat @@ -1493,7 +1495,7 @@ SUBROUTINE CableDyn_GetLineValues(handle, index, quantity, out_ptr, n_out, err_s IF (quantity == CD_C_LINE_VELOCITY) field = 'v' IF (quantity == CD_C_LINE_ACCELERATION) field = 'a' CASE (CD_C_LINE_TENSION, CD_C_LINE_CURVATURE, CD_C_LINE_BEND_MOMENT, CD_C_LINE_DECLINATION, & - CD_C_LINE_AZIMUTH) + CD_C_LINE_AZIMUTH, CD_C_LINE_DECK_NODE) nvals = nnode CASE (CD_C_LINE_SEGMENT_TENSION) nvals = nnode - 1 @@ -1508,6 +1510,20 @@ SUBROUTINE CableDyn_GetLineValues(handle, index, quantity, out_ptr, n_out, err_s END IF CALL C_F_POINTER(out_ptr, out_c, [nvals]) + IF (quantity == CD_C_LINE_DECK_NODE) THEN + ! deck node of each mesh node: a refined finite-EI cable maps them; any other line is meshed + ! as the deck + DO node = 1, nnode + out_c(node) = REAL(node, C_DOUBLE) + IF (h%use_agg) THEN + IF (h%agg%line_is_cable(line_id)) out_c(node) = & + REAL(CD_Cable_Deck_Node(h%agg%cables(h%agg%line_obj_index(line_id)), node), C_DOUBLE) + END IF + END DO + CALL store_status(h, CD_C_OK, '') + RETURN + END IF + IF (quantity == CD_C_LINE_SEGMENT_TENSION) THEN BLOCK REAL(wp) :: ten(nvals) @@ -1534,7 +1550,7 @@ SUBROUTINE CableDyn_GetLineValues(handle, index, quantity, out_ptr, n_out, err_s SELECT CASE (quantity) CASE (CD_C_LINE_POSITION, CD_C_LINE_VELOCITY, CD_C_LINE_ACCELERATION) DO c = 1, 3 - CALL eval_token(h, 'L'//TRIM(stem)//field//xyz(c), val, err_stat) + CALL eval_token(h, 'L'//TRIM(stem)//field//xyz(c), val, err_stat, mesh_node=.TRUE.) IF (err_stat /= CD_C_OK) RETURN out_c(3*(node - 1) + c) = REAL(val, C_DOUBLE) END DO @@ -1550,7 +1566,7 @@ SUBROUTINE CableDyn_GetLineValues(handle, index, quantity, out_ptr, n_out, err_s CASE DEFAULT token = 'L'//TRIM(stem)//'Azi' END SELECT - CALL eval_token(h, token, val, err_stat) + CALL eval_token(h, token, val, err_stat, mesh_node=.TRUE.) IF (err_stat /= CD_C_OK) RETURN out_c(node) = REAL(val, C_DOUBLE) END DO @@ -2027,12 +2043,15 @@ SUBROUTINE collect_points(system) END SUBROUTINE collect_points END SUBROUTINE object_inventory - SUBROUTINE eval_token(h, token, val, err_stat) - !! Evaluate one channel token on the handle's model (aggregate or point route). + SUBROUTINE eval_token(h, token, val, err_stat, mesh_node) + !! Evaluate one channel token on the handle's model (aggregate or point route). A node token + !! names a deck node; mesh_node = .TRUE. reads it as a node of the line's final mesh instead + !! (CableDyn_GetLineValues lists every mesh node of a refined finite-EI line). TYPE(CD_C_Handle), POINTER, INTENT(INOUT) :: h CHARACTER(*), INTENT(IN) :: token REAL(wp), INTENT(OUT) :: val INTEGER(C_INT), INTENT(OUT) :: err_stat + LOGICAL, INTENT(IN), OPTIONAL :: mesh_node INTEGER :: es CHARACTER(CD_C_MSG_LEN) :: em @@ -2041,15 +2060,18 @@ SUBROUTINE eval_token(h, token, val, err_stat) IF (h%agg%has_rigid6) THEN CALL CD_Eval_Aggregate_Channel(token, h%agg%has_sys, h%agg%sys%fast%system, h%agg%cables, & h%agg%line_is_cable, h%agg%line_obj_index, val, es, em, & - cable_points=h%agg%cable_points, rigid_rt=h%agg%rigid6, ranges=h%agg%ranges) + cable_points=h%agg%cable_points, rigid_rt=h%agg%rigid6, ranges=h%agg%ranges, & + mesh_node=mesh_node) ELSE IF (h%agg%has_rod) THEN CALL CD_Eval_Aggregate_Channel(token, h%agg%has_sys, h%agg%sys%fast%system, h%agg%cables, & h%agg%line_is_cable, h%agg%line_obj_index, val, es, em, & - cable_points=h%agg%cable_points, rod_rt=h%agg%rod, ranges=h%agg%ranges) + cable_points=h%agg%cable_points, rod_rt=h%agg%rod, ranges=h%agg%ranges, & + mesh_node=mesh_node) ELSE CALL CD_Eval_Aggregate_Channel(token, h%agg%has_sys, h%agg%sys%fast%system, h%agg%cables, & h%agg%line_is_cable, h%agg%line_obj_index, val, es, em, & - cable_points=h%agg%cable_points, ranges=h%agg%ranges) + cable_points=h%agg%cable_points, ranges=h%agg%ranges, & + mesh_node=mesh_node) END IF ELSE IF (.NOT. (ALLOCATED(h%pt_obj) .AND. ALLOCATED(h%pt_is_cable))) THEN diff --git a/src/CableDyn_CAPI.h b/src/CableDyn_CAPI.h index 31253a3a..ed888f9f 100644 --- a/src/CableDyn_CAPI.h +++ b/src/CableDyn_CAPI.h @@ -135,16 +135,21 @@ int CableDyn_NLines(void *handle, int *err_stat); #define CD_C_OBJ_BODY 3 #define CD_C_OBJ_ROD 4 -/* Line quantities (the codes of the line-node output channels). */ +/* Line quantities (the codes of the line-node output channels). Every quantity covers every + * node of the line's final mesh; the node channels of CableDyn_EvalChannel (TenN, ...) + * name deck nodes, which CD_C_LINE_DECK_NODE locates on a refined finite-EI line. */ #define CD_C_LINE_POSITION 1 /* 3 per node, xyz interleaved [m] */ #define CD_C_LINE_VELOCITY 2 /* 3 per node [m/s] */ -#define CD_C_LINE_TENSION 3 /* 1 per node, TenN [N] */ +#define CD_C_LINE_TENSION 3 /* 1 per mesh node, as TenN [N] */ #define CD_C_LINE_ACCELERATION 4 /* 3 per node [m/s^2] */ #define CD_C_LINE_CURVATURE 5 /* 1 per node [1/m] */ #define CD_C_LINE_BEND_MOMENT 6 /* 1 per node [N.m], 0 when EI=0 */ #define CD_C_LINE_DECLINATION 7 /* 1 per node [deg] */ #define CD_C_LINE_AZIMUTH 8 /* 1 per node [deg] */ #define CD_C_LINE_SEGMENT_TENSION 9 /* 1 per segment, .t.out order [N] */ +#define CD_C_LINE_DECK_NODE 10 /* 1 per mesh node: its deck node J, 0 if added by a + * refinement (an earlier library rejects the + * code with CD_C_BAD_INPUT) */ int CableDyn_GetAbiMinor(void); int CableDyn_NObjects(void *handle, int kind, int *err_stat); @@ -152,7 +157,8 @@ int CableDyn_NObjects(void *handle, int kind, int *err_stat); * 2 Coupled, 3 Free, 4 Connect. Bodies: n_nodes 1. Rods: n_nodes = NumSegs+1. */ void CableDyn_GetObjectInfo(void *handle, int kind, int index, int *id, int *n_nodes, int *subtype, int *err_stat); -/* Nodes run End A -> End B; n_out must equal the value count exactly. */ +/* Every node of the line's final mesh, End A -> End B (node channels name deck nodes; see + * CD_C_LINE_DECK_NODE); n_out must equal the value count exactly. */ void CableDyn_GetLineValues(void *handle, int index, int quantity, double *out, int n_out, int *err_stat); /* pos, vel, force: 3 doubles each (NULL skips). force is the resultant of diff --git a/src/CableDyn_DeckDriver.f90 b/src/CableDyn_DeckDriver.f90 index 73328fbe..8596e50f 100644 --- a/src/CableDyn_DeckDriver.f90 +++ b/src/CableDyn_DeckDriver.f90 @@ -208,6 +208,8 @@ MODULE CableDyn_DeckDriver ! Both reuse the same private evaluators the standalone .out writers use, so a coupled run ! and the standalone driver report identical channel values on a shared configuration. PUBLIC :: CD_Eval_Aggregate_Channel, CD_Channel_Unit + ! The deck node of a node of a finite-EI cable's final mesh (the static-profile DeckNode column). + PUBLIC :: CD_Cable_Deck_Node ! In-process object queries of the C API (CableDyn_CAPI): segment tensions in the .t.out ! convention, and the body/rod inventories the Body/Rod channels resolve on. PUBLIC :: CD_Eval_Aggregate_Segment_Tensions, CD_Rigid6_Inventory, CD_Rod_Inventory, CD_Channel_Token_Parses @@ -1627,6 +1629,8 @@ RECURSIVE SUBROUTINE build_one_hermite_cable(ln, sections, types, points, opts, REAL(wp), ALLOCATABLE :: l0_am(:), ea_am(:), ei_am(:), w_am(:) INTEGER, ALLOCATABLE :: fixed_am(:) TYPE(CD_HermiteResolutionType) :: diag + ! Deck node -> final-mesh node map of the node output channels (deck_node_mesh_map). + INTEGER, ALLOCATABLE :: deck_map(:) ! ATTACHMENTS: the deck-mesh bare submerged weight and mesh (the static solve runs on the ! smeared equivalent first), and the attachment nodes on the final mesh. LOGICAL :: has_att @@ -2781,6 +2785,9 @@ RECURSIVE SUBROUTINE build_one_hermite_cable(ln, sections, types, points, opts, CALL remap_elem_by_reference_arc(cat, l0, l0_am) CALL remap_elem_by_reference_arc(ba_raw, l0, l0_am) END IF + ! The node output channels read deck nodes: map each onto the final mesh (set on the cable + ! once it is built below). + CALL deck_node_mesh_map(l0, l0_am, deck_map) CALL MOVE_ALLOC(l0_am, l0) CALL MOVE_ALLOC(ea_am, ea) CALL MOVE_ALLOC(ei_am, ei) @@ -2864,6 +2871,7 @@ RECURSIVE SUBROUTINE build_one_hermite_cable(ln, sections, types, points, opts, IF (es /= CD_HFMF_OK) THEN CALL fail(ErrStat, ErrMsg, 'finite-EI cable coupled-shell init failed: '//TRIM(em)); RETURN END IF + IF (ALLOCATED(deck_map)) CALL MOVE_ALLOC(deck_map, cable%deck_node) IF (ANY(ba > CD_ZERO)) THEN CALL CD_HFMF_Set_Axial_Damping(cable, ba, es, em) IF (es /= CD_HFMF_OK) THEN @@ -8442,6 +8450,42 @@ SUBROUTINE remap_elem_by_reference_arc(a, l0_parent, l0_child) CALL MOVE_ALLOC(b, a) END SUBROUTINE remap_elem_by_reference_arc + SUBROUTINE deck_node_mesh_map(l0_deck, l0_mesh, map) + !! The public node (End A = 1) of a finite-EI line's final mesh at each deck node, matched on + !! the reference arc from End A: map(J) = k when mesh node k lies within 1e-9 of the line length + !! of deck node J, else 0. l0_deck and l0_mesh are the element lengths of the deck mesh and of + !! the final mesh in internal order (End B first). The match uses the arc positions alone, so + !! any refinement that keeps the deck nodes, uniform or local, maps exactly. The map is left + !! unallocated when the final mesh is the deck mesh. + REAL(wp), INTENT(IN) :: l0_deck(:), l0_mesh(:) + INTEGER, ALLOCATABLE, INTENT(OUT) :: map(:) + REAL(wp) :: s_mesh(SIZE(l0_mesh) + 1), s_deck, tol + INTEGER :: nd, nm, j, k + + nd = SIZE(l0_deck) + nm = SIZE(l0_mesh) + IF (nd == nm) THEN + IF (.NOT. (MAXVAL(ABS(l0_deck - l0_mesh)) > CD_ZERO)) RETURN + END IF + s_mesh(1) = CD_ZERO + DO k = 1, nm + s_mesh(k + 1) = s_mesh(k) + l0_mesh(nm - k + 1) + END DO + tol = 1.0e-9_wp*MAX(SUM(l0_deck), s_mesh(nm + 1)) + ALLOCATE (map(nd + 1)) + map = 0 + k = 1 + s_deck = CD_ZERO + DO j = 1, nd + 1 + ! public deck element j - 1 is internal element nd - j + 2 + IF (j > 1) s_deck = s_deck + l0_deck(nd - j + 2) + DO WHILE (k < nm + 1 .AND. s_mesh(k) < s_deck - tol) + k = k + 1 + END DO + IF (ABS(s_mesh(k) - s_deck) <= tol) map(j) = k + END DO + END SUBROUTINE deck_node_mesh_map + SUBROUTINE finite_section_closure(ea, ei, mpl, diam, gas_in, gj_in, i_rt_in, i_rn_in, & gas, gj, rho_a, i_rt, i_rn, ErrStat, ErrMsg) !! Close deck-format finite-EI properties for the Cosserat dynamic model. @@ -25990,6 +26034,7 @@ SUBROUTINE write_hermite_static_profile(out_root, lines, cables, ErrStat, ErrMsg CHARACTER(*), INTENT(OUT) :: ErrMsg INTEGER :: unit, ios, li, node, nn + LOGICAL :: refined REAL(wp) :: s, xyz(3), xyz_prev(3), tension, curvature, bend_moment, declination, azimuth CHARACTER(NAMELEN) :: channel CHARACTER(LEN(out_root) + 16) :: path @@ -26005,11 +26050,19 @@ SUBROUTINE write_hermite_static_profile(out_root, lines, cables, ErrStat, ErrMsg CALL fail(ErrStat, ErrMsg, 'cannot open Hermite static profile: '//TRIM(path)); RETURN END IF tab = CHAR(9) + ! A line whose mesh the static solve refined lists every node of its final mesh; the DeckNode + ! column then names the deck node of each row (0: a node the refinement added). + refined = .FALSE. + DO li = 1, SIZE(cables) + refined = refined .OR. ALLOCATED(cables(li)%deck_node) + END DO WRITE (unit, '(A)') 'CableDyn standalone static configuration (deformed arc; public node order End A -> End B)' WRITE (unit, '(A)') 'LineID'//tab//'Node'//tab//'ArcLength'//tab//'X'//tab//'Y'//tab//'Z'//tab// & - 'Tension'//tab//'Curvature'//tab//'BendMoment'//tab//'Declination'//tab//'Inclination'//tab//'Azimuth' + 'Tension'//tab//'Curvature'//tab//'BendMoment'//tab//'Declination'//tab//'Inclination'//tab//'Azimuth'// & + TRIM(MERGE(tab//'DeckNode', REPEAT(' ', 9), refined)) WRITE (unit, '(A)') '(-)'//tab//'(-)'//tab//'(m)'//tab//'(m)'//tab//'(m)'//tab//'(m)'//tab// & - '(N)'//tab//'(1/m)'//tab//'(N.m)'//tab//'(deg)'//tab//'(deg)'//tab//'(deg)' + '(N)'//tab//'(1/m)'//tab//'(N.m)'//tab//'(deg)'//tab//'(deg)'//tab//'(deg)'// & + TRIM(MERGE(tab//'(-)', REPEAT(' ', 4), refined)) DO li = 1, SIZE(lines) nn = CD_HFMF_NNodes(cables(li)) @@ -26028,9 +26081,15 @@ SUBROUTINE write_hermite_static_profile(out_root, lines, cables, ErrStat, ErrMsg CALL eval_node('Dec', declination); IF (ErrStat /= CD_DECKDRV_OK) RETURN CALL eval_node('Azi', azimuth); IF (ErrStat /= CD_DECKDRV_OK) RETURN IF (node > 1) s = s + NORM2(xyz - xyz_prev) - WRITE (unit, '(I0,A,I0,10(A,ES15.7E3))') lines(li)%id, tab, node, tab, s, tab, xyz(1), tab, xyz(2), & - tab, xyz(3), tab, tension, tab, curvature, tab, bend_moment, tab, declination, & - tab, declination - 90.0_wp, tab, azimuth + IF (refined) THEN + WRITE (unit, '(I0,A,I0,10(A,ES15.7E3),A,I0)') lines(li)%id, tab, node, tab, s, tab, xyz(1), tab, xyz(2), & + tab, xyz(3), tab, tension, tab, curvature, tab, bend_moment, tab, declination, & + tab, declination - 90.0_wp, tab, azimuth, tab, CD_Cable_Deck_Node(cables(li), node) + ELSE + WRITE (unit, '(I0,A,I0,10(A,ES15.7E3))') lines(li)%id, tab, node, tab, s, tab, xyz(1), tab, xyz(2), & + tab, xyz(3), tab, tension, tab, curvature, tab, bend_moment, tab, declination, & + tab, declination - 90.0_wp, tab, azimuth + END IF xyz_prev = xyz END DO END DO @@ -26047,7 +26106,7 @@ SUBROUTINE eval_node(kind, value) ELSE WRITE (channel, '(A,I0,A,I0)') TRIM(kind), lines(li)%id, 'N', node END IF - CALL eval_cable_channel(cables(li), TRIM(channel), value, ErrStat, eval_msg) + CALL eval_cable_channel(cables(li), TRIM(channel), value, ErrStat, eval_msg, mesh_node=.TRUE.) IF (ErrStat /= CD_DECKDRV_OK) THEN CLOSE (unit, STATUS='DELETE') ErrMsg = 'CableDyn_DeckDriver: Hermite static-profile channel '//TRIM(channel)//' failed: '//TRIM(eval_msg) @@ -26338,6 +26397,15 @@ SUBROUTINE open_dynamic_hermite_line_outputs(out_root, lines, cables, pos_units, CALL fail(ErrStat, ErrMsg, 'cannot open Hermite line position output: '//TRIM(path)); RETURN END IF WRITE (pos_units(i), '(A)') '# CableDyn finite-EI Hermite line node positions; public node order EndA -> EndB' + IF (ALLOCATED(cables(i)%deck_node)) THEN + ! A line whose mesh the static solve refined lists every node of its final mesh: name the + ! deck node of each (0: a node the refinement added), as the static-profile DeckNode column + WRITE (pos_units(i), '(A)', ADVANCE='NO') '# DeckNode' + DO node = 1, cables(i)%line%nn + WRITE (pos_units(i), '(A,I0)', ADVANCE='NO') char_tab(), CD_Cable_Deck_Node(cables(i), node) + END DO + WRITE (pos_units(i), '(A)') '' + END IF WRITE (pos_units(i), '(A)', ADVANCE='NO') 'Time(s)' DO node = 1, cables(i)%line%nn WRITE (pos_units(i), '(A,A,I0,A)', ADVANCE='NO') char_tab(), 'Node', node, 'X(m)' @@ -31737,7 +31805,7 @@ END SUBROUTINE aggregate_tdp_value ! -------------------------------------------------------------------------- ! SUBROUTINE CD_Eval_Aggregate_Channel(ch, has_sys, system, cables, line_is_cable, line_obj_index, val, ErrStat, & - ErrMsg, cable_points, rigid_rt, rod_rt, ranges) + ErrMsg, cable_points, rigid_rt, rod_rt, ranges, mesh_node) !! Evaluate ONE deck OUTPUTS channel token against a built aggregate. The token's deck line !! id is resolved through the map to either an EI=0 system line (eval_system_line_channel) or !! a finite-EI cable (eval_cable_channel); Point

channels read the EI=0 system point state. @@ -31762,6 +31830,9 @@ SUBROUTINE CD_Eval_Aggregate_Channel(ch, has_sys, system, cables, line_is_cable, TYPE(CD_RodRuntimeType), INTENT(IN), OPTIONAL :: rod_rt ! TDP channels: the touchdown references fixed at initialization TYPE(CD_RangeSet), INTENT(IN), OPTIONAL :: ranges + ! A node channel names a deck node; mesh_node = .TRUE. reads it as a node of the line's final + ! mesh instead (eval_cable_channel), as the static profile and the C API line arrays do + LOGICAL, INTENT(IN), OPTIONAL :: mesh_node CHARACTER(NAMELEN) :: lo LOGICAL :: found @@ -31914,7 +31985,7 @@ SUBROUTINE CD_Eval_Aggregate_Channel(ch, has_sys, system, cables, line_is_cable, IF (line_obj_index(line_id) > SIZE(cables)) THEN CALL fail(ErrStat, ErrMsg, 'OUTPUT "'//TRIM(ch)//'": cable index out of range'); RETURN END IF - CALL eval_cable_channel(cables(line_obj_index(line_id)), ch, val, ErrStat, ErrMsg) + CALL eval_cable_channel(cables(line_obj_index(line_id)), ch, val, ErrStat, ErrMsg, mesh_node=mesh_node) ELSE IF (.NOT. has_sys) THEN CALL fail(ErrStat, ErrMsg, 'OUTPUT "'//TRIM(ch)//'": line maps to the EI=0 system but no system '// & @@ -32215,22 +32286,28 @@ SUBROUTINE sys_solvefail(ch, em, ErrStat, ErrMsg) ErrMsg = 'CableDyn_DeckDriver: OUTPUT "'//TRIM(ch)//'": '//TRIM(em) END SUBROUTINE sys_solvefail - SUBROUTINE eval_cable_channel(cable, ch, val, ErrStat, ErrMsg) + SUBROUTINE eval_cable_channel(cable, ch, val, ErrStat, ErrMsg, mesh_node) !! Evaluate one channel for a finite-EI Hermite power cable (CD_HFMF). Mirrors the driver's !! finite_model_channel_value but reads the cable's committed state directly from the CD_HFMF !! line (stride-6 DOFs: r at 6*(n-1)+1..3, tangent m at +4..6) and recovers the !! complete elastic plus Kelvin-Voigt axial resultant. Node ordering runs anchor (node 1, held) !! -> fairlead (node nn, the coupled endpoint), so deck End A = internal node nn. Bend moment is !! EI(node) * |kvec_current - kvec_reference|; the built cable's reference is straight - !! (kvec_reference = 0), so it reduces to EI * geometric curvature magnitude. + !! (kvec_reference = 0), so it reduces to EI * geometric curvature magnitude. A node channel + !! names a deck node (1 + the total NumSegs of the line's sections, End A first), read at its + !! node of the final mesh on a refined line (cable%deck_node); mesh_node = .TRUE. reads the + !! token's node as a node of the final mesh instead (the static profile and the C API line + !! arrays list every mesh node). TYPE(CD_HFMF_ModuleType), INTENT(INOUT) :: cable CHARACTER(*), INTENT(IN) :: ch REAL(wp), INTENT(OUT) :: val INTEGER, INTENT(OUT) :: ErrStat CHARACTER(*), INTENT(OUT) :: ErrMsg + LOGICAL, INTENT(IN), OPTIONAL :: mesh_node CHARACTER(NAMELEN) :: lo INTEGER :: line_id, node, kind, comp, nnode, nelem, inode, es + LOGICAL :: deck_numbering REAL(wp) :: sec_ten, sec_curv, sec_bend CHARACTER(200) :: em @@ -32272,6 +32349,19 @@ SUBROUTINE eval_cable_channel(cable, ch, val, ErrStat, ErrMsg) RETURN END IF CALL parse_line_node_channel(ch, line_id, node, kind, comp) + deck_numbering = ALLOCATED(cable%deck_node) + IF (PRESENT(mesh_node)) deck_numbering = deck_numbering .AND. .NOT. mesh_node + IF (deck_numbering) THEN + ! a refined line: the deck node's node of the final mesh + IF (node < 1 .OR. node > SIZE(cable%deck_node)) THEN + CALL fail(ErrStat, ErrMsg, 'OUTPUT "'//TRIM(ch)//'": node index out of range'); RETURN + END IF + IF (cable%deck_node(node) < 1) THEN + CALL fail_solve(ErrStat, ErrMsg, 'OUTPUT "'//TRIM(ch)//'": deck node '//TRIM(int_to_str(node))// & + ' is not a node of the refined mesh of the line'); RETURN + END IF + node = cable%deck_node(node) + END IF IF (node < 1 .OR. node > nnode) THEN CALL fail(ErrStat, ErrMsg, 'OUTPUT "'//TRIM(ch)//'": node index out of range'); RETURN END IF @@ -32357,6 +32447,24 @@ PURE FUNCTION cable_frame_is_identity(cable) RESULT(is_id) is_id = .NOT. (ABS(cable%frame_s) > CD_ZERO .OR. ABS(cable%frame_c - CD_ONE) > CD_ZERO) END FUNCTION cable_frame_is_identity + PURE INTEGER FUNCTION CD_Cable_Deck_Node(cable, node) RESULT(deck_node) + !! The deck node at public node `node` (End A = 1) of a finite-EI cable's final mesh: the + !! node itself when the mesh is the deck mesh, 0 for a node the refinement added (the + !! DeckNode column of the static profile). + TYPE(CD_HFMF_ModuleType), INTENT(IN) :: cable + INTEGER, INTENT(IN) :: node + INTEGER :: j + deck_node = node + IF (.NOT. ALLOCATED(cable%deck_node)) RETURN + deck_node = 0 + DO j = 1, SIZE(cable%deck_node) + IF (cable%deck_node(j) == node) THEN + deck_node = j + RETURN + END IF + END DO + END FUNCTION CD_Cable_Deck_Node + PURE FUNCTION cable_global_component(cable, v_local, comp) RESULT(val) !! One component of a cable-local vector expressed in the deck's global frame (the !! transpose of the cable's frame rotation about +z). Identity heading reads the diff --git a/src/CableDyn_OpenFAST_Aggregate.f90 b/src/CableDyn_OpenFAST_Aggregate.f90 index 991c352e..73f98480 100644 --- a/src/CableDyn_OpenFAST_Aggregate.f90 +++ b/src/CableDyn_OpenFAST_Aggregate.f90 @@ -56,6 +56,7 @@ MODULE CableDyn_OpenFAST_Aggregate USE CableDyn_HermiteCableDynamic, ONLY: CD_HermiteCable_Dyn_Profile_Enabled USE CableDyn_DeckDriver, ONLY: CD_DeckAggregateType, CD_Init_Deck_Aggregate, CD_End_Deck_Aggregate, & CD_DECKDRV_OK, CD_DECKDRV_BADINPUT, CD_Eval_Aggregate_Channel, & + CD_Cable_Deck_Node, & CD_Channel_Unit, CD_DECK_NAMELEN, CD_LineInitSummary, & DeckFailure, DeckLine, DeckPoint, CD_Fire_Deck_Failures, & CD_Replay_Deck_Failures, CD_Check_System_Plausibility, & @@ -2055,6 +2056,7 @@ SUBROUTINE CD_AGG_WriteStaticProfile(self, path, ErrStat, ErrMsg) CHARACTER(*), INTENT(OUT) :: ErrMsg INTEGER :: unit, ios, line_id, object_index, nnode, node, ndof, es + LOGICAL :: refined REAL(wp) :: s, xyz(3), xyz_prev(3), tension, curvature, bend_moment, declination, azimuth CHARACTER(CD_DECK_NAMELEN) :: ch CHARACTER(512) :: em @@ -2076,11 +2078,21 @@ SUBROUTINE CD_AGG_WriteStaticProfile(self, path, ErrStat, ErrMsg) END IF tab = CHAR(9) + ! A cable whose mesh the static solve refined lists every node of its final mesh; the DeckNode + ! column then names the deck node of each row (0: a node the refinement added). + refined = .FALSE. + IF (ALLOCATED(self%cables)) THEN + DO object_index = 1, SIZE(self%cables) + refined = refined .OR. ALLOCATED(self%cables(object_index)%deck_node) + END DO + END IF WRITE (unit, '(A)') 'CableDyn coupled static configuration (deformed arc; public node order End A -> End B)' WRITE (unit, '(A)') 'LineID'//tab//'Node'//tab//'ArcLength'//tab//'X'//tab//'Y'//tab//'Z'//tab// & - 'Tension'//tab//'Curvature'//tab//'BendMoment'//tab//'Declination'//tab//'Inclination'//tab//'Azimuth' + 'Tension'//tab//'Curvature'//tab//'BendMoment'//tab//'Declination'//tab//'Inclination'//tab//'Azimuth'// & + TRIM(MERGE(tab//'DeckNode', REPEAT(' ', 9), refined)) WRITE (unit, '(A)') '(-)'//tab//'(-)'//tab//'(m)'//tab//'(m)'//tab//'(m)'//tab//'(m)'//tab// & - '(N)'//tab//'(1/m)'//tab//'(N.m)'//tab//'(deg)'//tab//'(deg)'//tab//'(deg)' + '(N)'//tab//'(1/m)'//tab//'(N.m)'//tab//'(deg)'//tab//'(deg)'//tab//'(deg)'// & + TRIM(MERGE(tab//'(-)', REPEAT(' ', 4), refined)) DO line_id = 1, SIZE(self%line_obj_index) object_index = self%line_obj_index(line_id) @@ -2120,9 +2132,15 @@ SUBROUTINE CD_AGG_WriteStaticProfile(self, path, ErrStat, ErrMsg) CALL eval_node('Dec', declination); IF (ErrStat /= CD_AGG_OK) RETURN CALL eval_node('Azi', azimuth); IF (ErrStat /= CD_AGG_OK) RETURN IF (node > 1) s = s + NORM2(xyz - xyz_prev) - WRITE (unit, '(I0,A,I0,10(A,ES15.7E3))') line_id, tab, node, tab, s, tab, xyz(1), tab, xyz(2), & - tab, xyz(3), tab, tension, tab, curvature, tab, bend_moment, tab, declination, & - tab, declination - 90.0_wp, tab, azimuth + IF (refined) THEN + WRITE (unit, '(I0,A,I0,10(A,ES15.7E3),A,I0)') line_id, tab, node, tab, s, tab, xyz(1), tab, xyz(2), & + tab, xyz(3), tab, tension, tab, curvature, tab, bend_moment, tab, declination, & + tab, declination - 90.0_wp, tab, azimuth, tab, profile_deck_node() + ELSE + WRITE (unit, '(I0,A,I0,10(A,ES15.7E3))') line_id, tab, node, tab, s, tab, xyz(1), tab, xyz(2), & + tab, xyz(3), tab, tension, tab, curvature, tab, bend_moment, tab, declination, & + tab, declination - 90.0_wp, tab, azimuth + END IF xyz_prev = xyz END DO END DO @@ -2138,11 +2156,18 @@ SUBROUTINE eval_node(kind, value) ELSE WRITE (ch, '(A,I0,A,I0)') TRIM(kind), line_id, 'N', node END IF + ! every node of the line's final mesh, also on a refined cable CALL CD_Eval_Aggregate_Channel(TRIM(ch), self%has_sys, self%sys%fast%system, self%cables, & - self%line_is_cable, self%line_obj_index, value, es, em) + self%line_is_cable, self%line_obj_index, value, es, em, mesh_node=.TRUE.) IF (es /= CD_DECKDRV_OK) CALL profile_fail('channel '//TRIM(ch)//' failed: '//TRIM(em)) END SUBROUTINE eval_node + INTEGER FUNCTION profile_deck_node() RESULT(deck_node) + !! The deck node of the current row (an EI = 0 line is meshed as the deck). + deck_node = node + IF (self%line_is_cable(line_id)) deck_node = CD_Cable_Deck_Node(self%cables(object_index), node) + END FUNCTION profile_deck_node + SUBROUTINE profile_fail(message) CHARACTER(*), INTENT(IN) :: message ErrStat = CD_AGG_BADINPUT diff --git a/src/CableDyn_OpenFAST_HermiteFMF.f90 b/src/CableDyn_OpenFAST_HermiteFMF.f90 index a9dbec8e..66f14b96 100644 --- a/src/CableDyn_OpenFAST_HermiteFMF.f90 +++ b/src/CableDyn_OpenFAST_HermiteFMF.f90 @@ -133,6 +133,11 @@ MODULE CableDyn_OpenFAST_HermiteFMF LOGICAL :: tors_parent = .FALSE. INTEGER :: tors_index = 0 REAL(wp) :: tors_frame_parent(3, 2) = CD_ZERO + ! Deck node -> model node map of a line whose mesh the static solve refined: deck_node(J) is + ! the public node (End A = 1) of the final mesh at the reference arc of deck node J (1 + the + ! total NumSegs of the deck sections, End A first), 0 if no mesh node lies there. Unallocated + ! when the mesh is the deck mesh. The node output channels (TenN, ...) read deck nodes. + INTEGER, ALLOCATABLE :: deck_node(:) LOGICAL :: initialized = .FALSE. END TYPE CD_HFMF_ModuleType @@ -1723,6 +1728,7 @@ SUBROUTINE CD_HFMF_End(self) self%tors_parent = .FALSE. self%tors_index = 0 self%tors_frame_parent = CD_ZERO + IF (ALLOCATED(self%deck_node)) DEALLOCATE (self%deck_node) self%initialized = .FALSE. END SUBROUTINE CD_HFMF_End diff --git a/tests/test_anchor_uplift.py b/tests/test_anchor_uplift.py index b6be0c29..66fd076b 100644 --- a/tests/test_anchor_uplift.py +++ b/tests/test_anchor_uplift.py @@ -141,16 +141,18 @@ def check_anchor_point(label: str, root: Path, line_id: int, point_id: int) -> N def line_lengths(path: Path) -> np.ndarray: """Deformed chord length of a line at every row of a dynamic .Line.p.out file.""" - lines = path.read_text(encoding="utf-8").splitlines() - data = np.array([[float(v) for v in row.split()] for row in lines[2:] if row.strip()]) + # skip the comment lines (a refined line adds "# DeckNode") and the header row + lines = [row for row in path.read_text(encoding="utf-8").splitlines() if not row.startswith("#")] + data = np.array([[float(v) for v in row.split()] for row in lines[1:] if row.strip()]) xyz = data[:, 1:].reshape(data.shape[0], -1, 3) return np.linalg.norm(np.diff(xyz, axis=1), axis=2).sum(axis=1) def static_line_length(path: Path) -> float: """Deformed chord length of a line from a static .Line.p.out table (Node X Y Z).""" - lines = path.read_text(encoding="utf-8").splitlines() - data = np.array([[float(v) for v in row.split()] for row in lines[2:] if row.strip()]) + # skip the comment lines (a refined line adds "# DeckNode") and the header row + lines = [row for row in path.read_text(encoding="utf-8").splitlines() if not row.startswith("#")] + data = np.array([[float(v) for v in row.split()] for row in lines[1:] if row.strip()]) return float(np.linalg.norm(np.diff(data[:, 1:4], axis=0), axis=1).sum()) diff --git a/tests/test_c_api_shared.c b/tests/test_c_api_shared.c index ecd17d8a..1142f223 100644 --- a/tests/test_c_api_shared.c +++ b/tests/test_c_api_shared.c @@ -169,6 +169,9 @@ static int check_deck_step(const char *deck) CHECK(err == CD_C_BAD_INPUT, "mis-sized line buffer accepted"); CableDyn_GetLineValues(m, 0, CD_C_LINE_SEGMENT_TENSION, seg, nn - 1, &err); CHECK(err == CD_C_OK && seg[0] > 0.0, "segment tensions"); + /* an EI = 0 line is meshed as the deck: mesh node k is deck node k */ + CableDyn_GetLineValues(m, 0, CD_C_LINE_DECK_NODE, xyz, nn, &err); + CHECK(err == CD_C_OK && xyz[0] == 1.0 && xyz[nn - 1] == (double)nn, "deck nodes of a line"); CableDyn_GetLineValues(m, 0, CD_C_LINE_TENSION, xyz, nn, &err); ten0 = xyz[0]; CableDyn_EvalChannel(m, token, (int)strlen(token), &fair, &err); diff --git a/tests/test_node_channels_refined.py b/tests/test_node_channels_refined.py new file mode 100644 index 00000000..c9b44ea4 --- /dev/null +++ b/tests/test_node_channels_refined.py @@ -0,0 +1,358 @@ +#!/usr/bin/env python3 +# SPDX-License-Identifier: Apache-2.0 +# Copyright (c) 2026 Jae Hoon Seo, SMI Lab, Inha University +"""Node output channels name deck nodes on a finite-EI line whose mesh the static solve refined. + +The deck is ``tests/data/lazy_wave_touchdown_planar_coarse.dat`` with its top bare section cut +from 20 to 4 elements: the deck mesh (71 elements, 72 deck nodes) cannot resolve the curvature +of the equilibrium and the static solve refines it. ``TenN``, ``CurvN``, +``BendMomN`` and ``LN{px,py,pz,vx,..,Dec,Azi}`` must report deck node ``J`` (1 + +the total ``NumSegs`` of the sections, End A first), at its node of the refined mesh. Gates: + +* static, cubic-Hermite route: the refined profile ``.static.out`` lists every mesh node and + its ``DeckNode`` column names the deck nodes in order, each at the deck node's reference arc + (``.elements.out`` ``ReferenceArcStart``); every node channel equals the profile row of its + deck node, and that row is not row ``J`` (hang-off + 1, sag bend, mid-arch, touchdown, + three-quarter, End B); +* dynamic, cubic-Hermite route: at every output time ``LNp{x,y,z}`` equals the + ``.Line.p.out`` position of the deck node's mesh node, and the end nodes report the + ``FairTen``/``AnchTen`` end forces; +* mixed ``EI = 0`` + finite-EI route (the OpenFAST aggregate's channel evaluator and static + profile): the node channels of the cable at ``t = 0`` equal its profile rows of the deck + nodes, and the ``EI = 0`` line, never refined, numbers its rows as the deck; +* C API: ``CableDyn_EvalChannel`` reads deck nodes and ``CableDyn_GetLineValues`` every mesh + node of the same state; a node past the deck count is rejected; +* Python: ``StaticProfile.deck_node_arc_lengths``, ``node_range_graph`` and ``profile_at`` + place the deck-node channels at their deck node's arc length. + +usage: test_node_channels_refined.py --exe --deck --output

+ [--library ] +""" + +from __future__ import annotations + +import argparse +import os +import re +import shutil +import subprocess +import sys +from pathlib import Path + +import numpy as np + +sys.path.insert(0, str(Path(__file__).resolve().parents[1] / "python")) +from cabledyn import line_positions, node_range_graph, profile_at, read_output # noqa: E402 + +FAILURES: list[str] = [] +LINE = 4 +# (length, NumSegs) of the deck sections after the cut, End A first +SECTIONS = [(80.0, 4), (100.0, 25), (420.0, 42)] +# hang-off + 1, the buoyancy-section start (sag bend), mid-arch, touchdown, three-quarter, End B +NODES = [1, 2, 5, 18, 34, 54, 72] +STATIC_COLUMN = { + "Ten": "Tension", + "Curv": "Curvature", + "BendMom": "BendMoment", + "px": "X", + "py": "Y", + "pz": "Z", + "Dec": "Declination", + "Azi": "Azimuth", +} + + +def check(ok: bool, message: str) -> None: + print(("PASS: " if ok else "FAIL: ") + message) + if not ok: + FAILURES.append(message) + + +def deck_arcs() -> list[float]: + arcs = [0.0] + for length, nsegs in SECTIONS: + for _ in range(nsegs): + arcs.append(arcs[-1] + length / nsegs) + return arcs + + +def channel_names(dynamic: bool) -> list[str]: + names = [f"FairTen{LINE}", f"AnchTen{LINE}"] + kinematic = ["px", "py", "pz", "Dec", "Azi"] + (["vx", "vz", "ax", "az"] if dynamic else []) + for j in NODES: + names += [f"Ten{LINE}N{j}", f"Curv{LINE}N{j}", f"BendMom{LINE}N{j}"] + names += [f"L{LINE}N{j}{k}" for k in kinematic] + return names + + +def write_deck(source: Path, path: Path, *, outputs: str, tmax: float, mixed: bool = False) -> None: + text = source.read_text() + replaced = { + f"{LINE} bare 80.0 20": f"{LINE} bare 80.0 4", + f"{LINE} 7 8 -": f"{LINE} 7 8 {outputs}", + "0.0 TMax": f"{tmax} TMax", + f"FairTen{LINE}\n": "\n".join(channel_names(tmax > 0.0)) + "\n", + } + for old, new in replaced.items(): + if text.count(old) != 1: + raise SystemExit(f"{source.name}: expected one {old!r}") + text = text.replace(old, new) + if mixed: + # an EI = 0 chain from a second coupled point: the mixed EI = 0 + finite-EI route + extra = { + "buoy 0.29 59.53": "chain 0.10 150.0 8.0e8 0.0 0.0 0 0 0 0 1.2 0.4 1.0 0.5\nbuoy 0.29 59.53", + "8 Fixed 500.0 0.0 -200.0": "8 Fixed 500.0 0.0 -200.0\n9 Coupled -30.0 0.0 -20.0\n" + "10 Fixed -480.0 0.0 -200.0", + f"{LINE} 7 8 {outputs}": f"{LINE} 7 8 {outputs}\n5 9 10 -", + f"{LINE} bare 420.0 42": f"{LINE} bare 420.0 42\n5 chain 520.0 26", + f"FairTen{LINE}\n": f"FairTen{LINE}\nFairTen5\nTen5N2\nL5N14pz\n", + } + for old, new in extra.items(): + line = text.split(old, 1) + if len(line) != 2: + raise SystemExit(f"{source.name}: expected {old!r}") + text = new.join(line) + path.write_text(text) + + +def run(exe: Path, deck: Path, root: Path) -> None: + proc = subprocess.run( + [str(exe), deck.name, root.name], + cwd=deck.parent, + capture_output=True, + text=True, + timeout=600, + env={**os.environ, "OMP_NUM_THREADS": "1"}, + ) + if proc.returncode != 0: + print(proc.stdout[-4000:]) + print(proc.stderr[-4000:]) + raise SystemExit(f"{deck.name}: driver exit {proc.returncode}") + + +def mesh_rows(profile, line_id: int) -> dict[int, int]: + """Deck node -> 0-based row of the line in the static profile (its DeckNode column).""" + line = profile.line(line_id) + deck = line.column("DeckNode") + return {int(j): int(i) for i, j in enumerate(deck) if j > 0} + + +def reference_arcs(elements: Path, line_id: int) -> np.ndarray: + table = read_output(elements) + mask = table.column("LineID") == line_id + start = table.column("ReferenceArcStart")[mask] + end = table.column("ReferenceArcEnd")[mask] + return np.concatenate((start, end[-1:])) + + +def node_channel(name: str) -> tuple[int, str] | None: + match = re.fullmatch(rf"(Ten|Curv|BendMom){LINE}N(\d+)", name) + if match: + return int(match.group(2)), match.group(1) + match = re.fullmatch(rf"L{LINE}N(\d+)(\w+)", name) + if match: + return int(match.group(1)), match.group(2) + return None + + +def static_gates(exe: Path, source: Path, out: Path) -> dict[int, int]: + deck = out / "static.dat" + write_deck(source, deck, outputs="pt", tmax=0.0) + run(exe, deck, out / "static") + profile = read_output(out / "static.static.out") + line = profile.line(LINE) + nrows = line.values.shape[0] + check("DeckNode" in profile.channels, "a refined line's static profile carries the DeckNode column") + check(nrows > 72, f"the deck mesh is refined ({nrows - 1} elements from 71)") + rows = mesh_rows(profile, LINE) + check(sorted(rows) == list(range(1, 73)), "DeckNode names deck nodes 1 .. 72, End A first") + arcs = deck_arcs() + sref = reference_arcs(out / "static.elements.out", LINE) + check(sref.size == nrows, "the element table and the profile list the same mesh") + offset = max(abs(sref[rows[j]] - arcs[j - 1]) for j in rows) + check(offset < 1.0e-6, f"each DeckNode row lies at its deck node's reference arc (max {offset:.1e} m)") + check(all(rows[j] != j - 1 for j in NODES if j > 1), "the deck nodes are not the profile rows J") + check(rows[72] == nrows - 1, "End B is the last mesh node") + history = read_output(out / "static.out") + worst = 0.0 + for name in history.channels[1:]: + parsed = node_channel(name) + if parsed is None: + continue + j, kind = parsed + value = float(history.column(name)[0]) + expected = float(line.column(STATIC_COLUMN[kind])[rows[j]]) + worst = max(worst, abs(value - expected) / max(1.0, abs(expected))) + check(worst == 0.0, f"every static node channel is its deck node's profile row (max rel {worst:.1e})") + touchdown = float(history.column(f"Ten{LINE}N34")[0]) + print(f" Ten{LINE}N34 = {touchdown:.1f} N at mesh node {rows[34] + 1} (s = {arcs[33]:.0f} m)") + check( + float(history.column(f"Ten{LINE}N1")[0]) == float(history.column(f"FairTen{LINE}")[0]) + and float(history.column(f"Ten{LINE}N72")[0]) == float(history.column(f"AnchTen{LINE}")[0]), + "the end deck nodes report the FairTen/AnchTen end forces", + ) + # Python: deck-node channels placed at their deck node's static arc length + lookup = profile.deck_node_arc_lengths(LINE) + arc_column = line.column("ArcLength") + check( + all(lookup[j] == float(arc_column[rows[j]]) for j in rows) and len(lookup) == 72, + "StaticProfile.deck_node_arc_lengths gives each deck node's row", + ) + graph = node_range_graph(history, LINE, "tension", arc_length=profile) + expected = np.asarray([arc_column[rows[j]] for j in NODES]) + check(np.array_equal(graph.location, expected), "node_range_graph places deck nodes at their arc") + return rows + + +def dynamic_gates(exe: Path, source: Path, out: Path, rows: dict[int, int]) -> None: + deck = out / "dynamic.dat" + write_deck(source, deck, outputs="p", tmax=0.1) + run(exe, deck, out / "dynamic") + history = read_output(out / "dynamic.out") + positions = read_output(out / f"dynamic.Line{LINE}.p.out") + check(history.time.size == 5 and positions.time.size == 5, "the march writes t = 0 .. 0.1 s") + worst = 0.0 + for j in NODES: + for axis in "xyz": + value = history.column(f"L{LINE}N{j}p{axis}") + mesh = positions.column(f"Node{rows[j] + 1}{axis.upper()}(m)") + worst = max(worst, float(np.max(np.abs(value - mesh)))) + check(worst == 0.0, f"LNp equals the .p.out position of the deck node's mesh node ({worst:.1e} m)") + check( + np.array_equal(history.column(f"Ten{LINE}N1"), history.column(f"FairTen{LINE}")) + and np.array_equal(history.column(f"Ten{LINE}N72"), history.column(f"AnchTen{LINE}")), + "the end deck nodes report the end forces at every output time", + ) + static = read_output(out / "dynamic.static.out").line(LINE) + first = max( + abs(float(history.column(f"Ten{LINE}N{j}")[0]) - float(static.column("Tension")[rows[j]])) + for j in NODES + ) + check(first == 0.0, "the t = 0 node tensions are the static profile rows of the deck nodes") + # Python: a per-line position file places deck-node channels through the profile beside it + placed = profile_at(history, "tension", 0.1, line_id=LINE, positions=positions) + xyz = np.stack([positions.column(f"Node{k}{a}(m)")[-1] for k in range(1, rows[72] + 2) for a in "XYZ"]) + xyz = xyz.reshape(-1, 3) + chord = np.concatenate(([0.0], np.cumsum(np.linalg.norm(np.diff(xyz, axis=0), axis=1)))) + expected = np.asarray([chord[rows[j]] for j in NODES]) + check( + np.allclose(placed.location, expected, rtol=0.0, atol=1.0e-9), + "profile_at places deck-node channels with a per-line position file at their mesh nodes", + ) + # the per-line file names its deck nodes itself, so it places them without the profile + deck = positions.deck_nodes + check( + deck is not None + and deck.size == rows[72] + 1 + and all(int(deck[rows[j]]) == j for j in rows) + and int(np.count_nonzero(deck)) == 72, + "the .p.out DeckNode line names the deck node of every mesh node", + ) + alone = out / "alone" + alone.mkdir() + shutil.copy(out / f"dynamic.Line{LINE}.p.out", alone / f"dynamic.Line{LINE}.p.out") + lone = read_output(alone / f"dynamic.Line{LINE}.p.out") + by_file = profile_at(history, "tension", 0.1, line_id=LINE, positions=lone) + by_positions = profile_at(history, "tension", 0.1, line_id=LINE, positions=line_positions(lone)) + check( + np.allclose(by_file.location, expected, rtol=0.0, atol=1.0e-9) + and np.allclose(by_positions.location, expected, rtol=0.0, atol=1.0e-9), + "a per-line position file (or LinePositions read from it) places deck nodes on its own", + ) + + +def mixed_gates(exe: Path, source: Path, out: Path, rows: dict[int, int]) -> None: + deck = out / "mixed.dat" + write_deck(source, deck, outputs="-", tmax=0.05, mixed=True) + run(exe, deck, out / "mixed") + history = read_output(out / "mixed.out") + check(history.title.startswith("# CableDyn driver output (mixed aggregate"), "the deck runs on the mixed route") + profile = read_output(out / "mixed.static.out") + check("DeckNode" in profile.channels, "the mixed static profile carries the DeckNode column") + mixed_rows = mesh_rows(profile, LINE) + check(mixed_rows == rows, "the mixed route refines the cable to the same mesh") + chain = profile.line(5) + check( + np.array_equal(chain.column("DeckNode"), chain.column("Node")) and chain.values.shape[0] == 27, + "the EI = 0 line is not refined and numbers its rows as the deck", + ) + line = profile.line(LINE) + worst = 0.0 + for name in history.channels[1:]: + parsed = node_channel(name) + if parsed is None or parsed[1] not in STATIC_COLUMN: + continue + j, kind = parsed + expected = float(line.column(STATIC_COLUMN[kind])[rows[j]]) + worst = max(worst, abs(float(history.column(name)[0]) - expected) / max(1.0, abs(expected))) + check(worst == 0.0, f"mixed-route node channels at t = 0 are the deck nodes' profile rows ({worst:.1e})") + check( + float(history.column("Ten5N2")[0]) == float(chain.column("Tension")[1]) + and float(history.column("L5N14pz")[0]) == float(chain.column("Z")[13]), + "the EI = 0 line's node channels read its deck nodes", + ) + + +def capi_gates(library: Path, source: Path, out: Path, rows: dict[int, int]) -> None: + os.environ["CABLEDYN_LIBRARY"] = str(library) + from cabledyn import CableDyn, CableDynError + + deck = out / "capi.dat" + write_deck(source, deck, outputs="-", tmax=0.0) + with CableDyn(deck) as model: + line = model.line(LINE) + check(line.n_nodes == rows[72] + 1, "GetObjectInfo reports the refined mesh's node count") + tension = line.values("tension") + position = line.values("position") + same = all( + model.channel(f"Ten{LINE}N{j}") == float(tension[rows[j]]) + and model.channel(f"L{LINE}N{j}pz") == float(position[rows[j], 2]) + for j in NODES + ) + check(same, "EvalChannel reads the deck node, GetLineValues the mesh nodes of the same state") + try: + model.channel(f"Ten{LINE}N73") + rejected = False + except CableDynError: + rejected = True + check(rejected, "a node past the deck node count is rejected") + deck = line.deck_nodes + check( + deck.size == line.n_nodes + and all(int(deck[rows[j]]) == j for j in rows) + and int(np.count_nonzero(deck)) == 72, + "Line.deck_nodes (CD_C_LINE_DECK_NODE) locates the deck nodes among the mesh nodes", + ) + + +def main() -> int: + parser = argparse.ArgumentParser() + parser.add_argument("--exe", required=True, type=Path) + parser.add_argument("--deck", required=True, type=Path) + parser.add_argument("--output", required=True, type=Path) + parser.add_argument("--library", type=Path) + args = parser.parse_args() + out = args.output.resolve() + if out.exists(): + shutil.rmtree(out) + out.mkdir(parents=True) + exe = args.exe.resolve() + source = args.deck.resolve() + rows = static_gates(exe, source, out) + dynamic_gates(exe, source, out, rows) + mixed_gates(exe, source, out, rows) + if args.library is None: + print("SKIP: C API gates (no --library)") + elif args.library.is_file(): + capi_gates(args.library.resolve(), source, out, rows) + else: + check(False, f"--library {args.library} is not a file") + if FAILURES: + print(f"{len(FAILURES)} gate(s) failed") + return 1 + print("all gates passed") + return 0 + + +if __name__ == "__main__": + raise SystemExit(main()) diff --git a/tests/test_seabed_friction_aniso.f90 b/tests/test_seabed_friction_aniso.f90 index 79a9dd94..af966384 100644 --- a/tests/test_seabed_friction_aniso.f90 +++ b/tests/test_seabed_friction_aniso.f90 @@ -446,7 +446,7 @@ SUBROUTINE write_touchdown_deck(path, fric_rows, current, motion, long_run) END IF WRITE (u, '(A)') '--- OUTPUTS ---' IF (long) THEN - WRITE (u, '(A)') 'FairTen1 AnchTen1 L1N5px L1N5py L1N5pz L1N30px L1N30py L1N30pz L1N34py L1N38py L1N42py' + WRITE (u, '(A)') 'FairTen1 AnchTen1 L1N5px L1N5py L1N5pz L1N30px L1N30py L1N30pz L1N17py L1N20py L1N21py' ELSE WRITE (u, '(A)') 'FairTen1 AnchTen1 L1N5px L1N5py L1N5pz' END IF @@ -523,8 +523,8 @@ SUBROUTINE case_hermite_pull() CALL read_out('franiso_pull_highlat.out', db, nb) CALL require(na == nb .AND. na > 10, 'hermite-pull:rows') IF (na /= nb .OR. na <= 10) RETURN - ! grounded nodes 38 and 42 (of 45, node 0 at the fairlead) - WRITE (*, '(A,4ES14.6)') 'hermite sideways pull: grounded-node sway N38, N42 at low / high lateral mu (m): ', & + ! grounded deck nodes 20 and 21 (of 46, node 1 at the fairlead), 38 and 40 m along the line + WRITE (*, '(A,4ES14.6)') 'hermite sideways pull: grounded-node sway N20, N21 at low / high lateral mu (m): ', & da(11, na), da(12, na), db(11, nb), db(12, nb) CALL require(da(11, na) > 1.1_wp*db(11, nb) .AND. da(12, na) > 1.1_wp*db(12, nb) .AND. db(12, nb) > 0.0_wp, & 'hermite-pull:low-lateral-friction-lets-the-grounded-run-sway-more') diff --git a/validation/PAPER_REPRODUCTION.md b/validation/PAPER_REPRODUCTION.md index 77b36cc4..26c3f148 100644 --- a/validation/PAPER_REPRODUCTION.md +++ b/validation/PAPER_REPRODUCTION.md @@ -6,26 +6,29 @@ This record is for readers of the CableDyn journal article (Seo et al., *Ocean E 368 (Part 2), 128332, 2026) who want to know whether the current release reproduces its numbers. The article records the formulation as published. CableDyn keeps developing, and its defaults follow the most accurate and robust methods available. The article's methods stay selectable. The table -lists every quantitative result in the article that CableDyn computes, re-run with the v0.1.0 -release in two modes. +lists every quantitative result in the article that CableDyn computes, re-run in two modes, first +with the v0.1.0 release and again with the development source at revision 71158d5; the table +gives the 71158d5 values. | Mode | Settings | | --- | --- | -| Paper mode | `False alpha_force_blend`: forces evaluated at the generalised-α blended configuration, as in the article. `sequenced cable_statics`: the mesh-sequenced static route runs first. End tensions are the end element's axial tension. | +| Paper mode | `False alpha_force_blend`: forces evaluated at the generalised-α blended configuration, as in the article. `sequenced cable_statics`: the mesh-sequenced static route runs first. `element OutputRecovery`: node tensions are element-mean axial forces and curvatures the geometric Hermite curvature, as in the article. End tensions are the end element's axial tension. | | Defaults | Force-blended generalised-α (`True alpha_force_blend`). Static route starts from a catenary with continuation of the bending stiffness (`continuation cable_statics`). `FairTen`/`AnchTen` report the end force: the end element's force including axial damping, plus the end node's share of weight, seabed contact and drag at the actual velocity, without the end node's inertia. | -The two options apply to finite-EI cables only. Tension-only (EI = 0) lines use the same -solver in both modes, so for moorings the two columns differ only in the reported end -tension. Reference values from OrcaFlex, MoorDyn and closed-form solutions are the fixed values -used in the article; they were not re-run. The source revision recorded in the article's -provenance files, built with the same toolchain, regenerates the article's data files exactly, -so any difference in the paper-mode column comes from a change in CableDyn itself. +`alpha_force_blend` also selects the generalised-α scheme of tension-only (EI = 0) lines, so +moorings differ between the modes as well; `False alpha_force_blend` gives the article's EI = 0 +scheme. In paper mode every EI = 0 and finite-EI result at 71158d5 equals the v0.1.0 one in every +printed digit, except the two-point axial rule row. Reference values from OrcaFlex, MoorDyn and +closed-form solutions are the fixed values used in the article; they were not re-run. The +source revision recorded in the article's provenance files, built with the same toolchain, +regenerates the article's data files exactly, so any difference in the paper-mode column comes +from a change in CableDyn itself. **Outcome.** Of the 58 results, paper mode reproduces 53 within the article's printed precision. Three differ because of later robustness fixes, one of them only in the last printed digit. Two cannot be reproduced from the recorded inputs, even with the article's own source: the 800 m pretension and the count of -subdivided mooring motions. With the defaults, 16 results change because of a changed +subdivided mooring motions. With the defaults, 20 results change because of a changed default. One robustness result is worse with the defaults; see [Known difference](#known-difference). For moorings, the defaults column also shows the end-force channel where the article reported the end element's tension. For the dynamic @@ -37,7 +40,7 @@ Status codes in the notes: **R** reproduced; **D** changed by an intentional def mode reproduces); **F** changed by a robustness fix; **X** not reproducible from the recorded inputs; **W** worse agreement or robustness with the defaults. -| Quantity | Paper | Release, paper mode | Release, defaults | Reference | Note | +| Quantity | Paper | 71158d5, paper mode | 71158d5, defaults | Reference | Note | | --- | --- | --- | --- | --- | --- | | Axial patch force error | 1.10e-13 | 1.10e-13 | 1.10e-13 | closed form | R | | Circular-arc energy convergence order | 4.00 | 4.00 | 4.00 | 4 | R | @@ -55,8 +58,8 @@ inputs; **W** worse agreement or robustness with the defaults. | 200 m pretension; four-way band | 1206.2 kN; 1.1 % | 1206.2 kN; 1.1 % | 1206.2 kN; example-deck `FairTen` 1205.4 kN | design 1205, OrcaFlex 1199.2, MoorDyn-F 1212.0 kN | R | | 800 m pretension; three-solver spread; above design | 1868.8 kN; 0.7 %; ≈ 10 % | 1875.6 kN; 0.3 %; 10.1 % | `FairTen` 1881.5 kN; 0.3 %; 10.4 % | OrcaFlex 1881.5, MoorDyn-F 1875.9, design 1704 kN | X: the article's value came from an earlier, unrecorded mesh; the article's own source gives 1875.6 kN on the published deck; the conclusion is unchanged | | Mooring equilibrium profiles (Fig. 9) | — | identical geometry and element tensions | end node reports the end force | — | R | -| One-hour VolturnUS-S mean / SD / min / max | 1.41 / 0.26 / 1.81 / 1.04 % | 1.41 / 0.26 / 1.81 / 1.04 % | same; end force 0.28 / 0.25 / 0.15 / 0.43 % | OrcaFlex 2439.39 / 206.08 / 2057.86 / 2850.91 kN | R | -| One-hour Fourier amplitude, 90 s / 12 s | 0.83 / 2.10 % | 0.83 / 2.10 % | same; end force 0.27 / 1.13 % | OrcaFlex 228.57 / 178.80 kN | R | +| One-hour VolturnUS-S mean / SD / min / max | 1.41 / 0.26 / 1.81 / 1.04 % | 1.41 / 0.26 / 1.81 / 1.04 % | 1.41 / 0.27 / 1.46 / 1.05 %; end force 0.27 / 0.26 / 0.50 / 0.43 % | OrcaFlex 2439.39 / 206.08 / 2057.86 / 2850.91 kN | D: force-blended EI = 0 step; the mean is unchanged | +| One-hour Fourier amplitude, 90 s / 12 s | 0.83 / 2.10 % | 0.83 / 2.10 % | same; end force 0.27 / 1.14 % | OrcaFlex 228.57 / 178.80 kN | R | | Series-Kelvin cases | 12 recover stiffness; derivatives within 5e-6 | pass | pass | analytical, central differences | R | | Series-Kelvin 0.30 MBL ramp differences | 0.121 / 0.053 / 0.026 / 0.009 / < 0.001 % | same | same | MoorDyn | R | | Syrope residual, 14 cases | 0.70–1.16e-9 N | 0.70–1.16e-9 N | 0.70–1.16e-9 N | independent NumPy implementation | R | @@ -69,7 +72,7 @@ inputs; **W** worse agreement or robustness with the defaults. | 800 m cable solved directly on the final mesh | folded equilibria | mesh sequencing reaches the branch | continuation on the final mesh reaches the same branch | — | D: continuation-first static route | | Equal-order quadrature curvature change | ≤ 0.0020 % | 0.0020 % | 0.0020 % | six-point rule | R | | Three-point axial rule, negative minimum 80 / 800 m | 56.15 / 5.81 kN | 56.15 / 5.81 kN | 56.15 / 5.81 kN | — | R | -| Two-point axial rule | 937 / 820 kN; 800 m fails | 937 / 820 kN; 800 m converges (−280.5 kN) | same | — | F: the continuation route, also the fallback in paper mode, establishes the 800 m equilibrium | +| Two-point axial rule | 937 / 820 kN; 800 m fails | −922.7 / −810.3 kN; 800 m converges (−264.4 kN) | same | — | F: the continuation route, also the fallback in paper mode, establishes the 800 m equilibrium; the values moved with the seabed anchor-end weight-moment fix (v0.1.0: −937 / −820 / −280.5 kN). The large spurious compression under under-integration stands | | Converged dynamic meshes, 80/200/800 m | 240 / 480 / 960 | 240 / 480 / 960 | 480 / 480 / 960 | tensile | D: with the force blend the 240-element 80 m mesh reaches −0.15 kN | | Dynamic continuous axial minima | 0.037 / 0.562 / 1.76 kN | 0.037 / 0.563 / 1.76 kN | 0.94 / 0.54 / 1.24 kN | tensile | F at 200 m (same fix as the 200 m subdivision row); D with the defaults | | Dynamic peak curvature | 0.10254 / 0.08844 / 0.03899 /m | 0.10254 / 0.08844 / 0.03899 /m | 0.10247 / 0.08844 / 0.03899 /m | OrcaFlex 0.10279 / 0.08823 / 0.03881 /m | D (80 m) | @@ -92,11 +95,16 @@ inputs; **W** worse agreement or robustness with the defaults. | Regular-wave chain, mean / swing | 0.30 / 8.41 % | 0.30 / 8.41 % | same; `FairTen` 1.20 / 10.6 % | OrcaFlex effective tension | R | | Irregular-wave cable peak curvature | 0.215 % | 0.215 % | 0.215 % | OrcaFlex | R | | Irregular-wave hang-off tension mean/min/max | 0.192 / 0.186 / 0.108 % | 0.192 / 0.186 / 0.108 % | 0.214 / 0.198 / 0.158 % | OrcaFlex | D | -| Slack-to-taut Δt_CFL; peaks at 0.5–20 ms | 3.155 ms; 10.2248 … 10.5068 MN | same | same | 0.5 ms solution | R | -| Slack-to-taut changes; apparent order; 20 ms | 0.0048–2.7576 %; 2.69; 6.34 Δt_CFL | same | same | 0.5 ms solution | R | +| Slack-to-taut Δt_CFL; peaks at 0.5–20 ms | 3.155 ms; 10.2248 … 10.5068 MN | same | 3.155 ms; 10.2246 … 10.3821 MN | 0.5 ms solution | D: force-blended EI = 0 step | +| Slack-to-taut changes; apparent order; 20 ms | 0.0048–2.7576 %; 2.69; 6.34 Δt_CFL | same | 0.0010–1.5410 %; not defined; 6.34 Δt_CFL | 0.5 ms solution | D: see below the table | | 800 m curvature at 50 ms | 0.03899 /m | 0.03899 /m | 0.03899 /m | OrcaFlex 0.03881 /m | R | | Cable motion envelope at 0.05 s, 30 gated cases | all complete | 30 of 30 complete | 28 of 30 with plain steps; 30 of 30 with subdivision | — | W: see [Known difference](#known-difference) | -| Mooring motion envelope at 0.1 s | subdivision only for the two most severe semitaut motions | subdivision for three semitaut motions (6 m/12 s, 10 m/14 s, 5 m/7 s) | same | — | X: the article's source gives the same three; all-chain needs none | +| Mooring motion envelope at 0.1 s | subdivision only for the two most severe semitaut motions | subdivision for three semitaut motions (6 m/12 s, 10 m/14 s, 5 m/7 s) | a different set; severe-motion peaks changed | — | X: the article's source gives the same three; all-chain needs none. D with the defaults: see [Known difference](#known-difference) | + +With the default force blend the slack-to-taut peaks lie within 1.55 % of the 0.5 ms solution at +every step from 0.5 to 20 ms (within 0.05 % up to 5 ms), without a monotone trend; both blends +converge to the same 0.25 ms peak (10.2246 MN); the article's convergence order (2.69) refers to +the configuration blend (paper mode). The table covers every result the article prints from a CableDyn calculation. Values derived only from reference codes are not listed: the MoorDyn-F native-mesh difference, its refinement @@ -124,6 +132,22 @@ six margin probes complete in both modes. The defaults subdivide 6 intervals in paper mode 4 intervals in 4 cases. The solver is not broken, but under the article's single-step protocol the default scheme has less convergence margin. +**Mooring motion envelope with the default force blend.** With the defaults, a different set of +mooring motions needs step subdivision at the article's 0.1 s envelope step, and the peaks of the +severe motions changed. Against converged 0.5 / 0.25 ms references (configuration blend = paper +mode, force blend = defaults, both at 0.1 s): + +| Case | Reference | Configuration blend | Force blend | +| --- | --- | --- | --- | +| 200 m semitaut surge 10 m/14 s, anchor max | 2950–2975 kN | 8084 kN (+173 %) | 3584 kN (+21 %) | +| 200 m semitaut surge 5 m/7 s, anchor max | 4208–4277 kN | 9042 kN (+113 %) | 5799 kN (+36 %) | +| 80 m all-chain heave 5 m/7 s, fairlead max | 1724–1787 kN | 1723 kN (−2 %) | 1538 kN (−13 %) | +| 80 m all-chain heave 5 m/7 s, anchor max | 1494–1585 kN | 1468 kN (−4 %) | 1246 kN (−19 %) | + +The snap is not resolved at 0.1 s, which the run notes. The force blend removes the spurious +semitaut spikes but underestimates the all-chain heave peaks at that step. Confirm peak tensions +with a smaller `dtM`. + **Hang-off curvature near an unresolved boundary layer.** This is not an article result. At the 800 m hang-off node, where the article reports η_b = 1.63 and omits the bend moment, the maximum dynamic curvature is 1.6e-3 /m with the defaults and 1.3e-4 /m in paper mode. The @@ -185,6 +209,18 @@ dynamic test programs use the default force blend. For paper mode, add `test_l4_lazywave_coupled`, `test_l1_hermite_beam_vibration` and `test_l1_hermite_energy_stability`. +The tension-only (EI = 0) test programs use the default force blend as well. For paper mode, set +`force_blend = .FALSE.` in the `GenAlphaConfig` passed to the EI = 0 step (for example +`dcfg%force_blend = .FALSE.`, or `cfg%force_blend = .FALSE.`) before the march. This applies to +`test_snap_load`, `test_l3_orcaflex_wave_dynamic`, `test_l3_longduration_mooring`, +`test_l2_2_dynamic_parity`, `test_viscoelastic`, `test_syrope`, `test_l1_string` and +`test_l1_energy_stability`. Deck runs (`test_l2_lozon80_mooring`, `test_l2_lozon200_semitaut` +and the driver) take `False alpha_force_blend` from `OPTIONS`. + +**Toolchain.** Built with gfortran, the development source gives the same paper-mode values as +v0.1.0 built with gfortran. One count depends on the toolchain: with gfortran the 800 m paper-mode +run subdivides 0 of 1200 intervals (v0.1.0 as well), where the table records 1 of 1200. + **Deck runs.** The static cable profiles use the example decks, which carry the article's refined meshes (1024, 952 and 1024 elements): @@ -201,9 +237,15 @@ For paper mode, add these rows to `OPTIONS`: ```text sequenced cable_statics False alpha_force_blend +element OutputRecovery ``` -`alpha_force_blend` matters only for dynamic runs. For the quadrature and refinement study, use +`alpha_force_blend` matters only for dynamic runs. The finite-EI node tension, curvature and +bend moment of the deck channels, `.static.out` and the range graphs are recovered from nodal +equilibrium by default; the article reported the element-mean axial force and the geometric +Hermite curvature, which `element OutputRecovery` restores. The test programs of this record +read the geometric curvature (`CD_HermiteCable_Dyn_Curvature_Exact`), so their numbers do not +depend on this option. For the quadrature and refinement study, use the article's starting meshes: | Cable | Segments per section | Multiples run | diff --git a/validation/scripts/orcaflex_discrete_modules_reference.py b/validation/scripts/orcaflex_discrete_modules_reference.py index 78628fc5..b3f03839 100644 --- a/validation/scripts/orcaflex_discrete_modules_reference.py +++ b/validation/scripts/orcaflex_discrete_modules_reference.py @@ -135,16 +135,27 @@ def cabledyn_profile( subprocess.run( [str(exe), "modules.dat", "modules"], cwd=work, check=True, capture_output=True ) + # columns by header name: a refined line adds a DeckNode column + header: list[str] = [] rows = [] for line in (work / "modules.static.out").read_text(encoding="utf-8").splitlines(): + fields = line.split() + if fields[:1] == ["LineID"]: + header = fields + continue try: - values = [float(v) for v in line.split()] + values = [float(v) for v in fields] except ValueError: continue - if len(values) == 12: - rows.append(values) - rows.sort(key=lambda r: r[1]) - return [r[3] for r in rows], [r[5] for r in rows], [r[7] for r in rows], rows[0][6] + if header and len(values) == len(header): + rows.append(dict(zip(header, values, strict=True))) + rows.sort(key=lambda r: r["Node"]) + return ( + [r["X"] for r in rows], + [r["Z"] for r in rows], + [r["Curvature"] for r in rows], + rows[0]["Tension"], + ) def compare( From b687d09d9061a27558d8000d36d0650006ee4222 Mon Sep 17 00:00:00 2001 From: Jae Hoon Seo Date: Tue, 20 Oct 2026 05:54:52 +0900 Subject: [PATCH 18/31] feat(openfast): warn when line nodes lie outside the SeaState wave grid (#24) SeaState evaluates its wave kinematics on a grid (X_HalfWidth, Y_HalfWidth, Z_Depth) and clamps a point outside it to the boundary. The r-test MD_Shared SeaState inputs, reused by the OpenFAST tutorial and examples/openfast, span 100 m and 40 m depth, so the moorings (840 m out, 200 m deep) took boundary kinematics without a message. The CableDyn shell now checks the positions it samples, at the static equilibrium and every mooring step until it has warned once, and prints one warning with the number of submerged nodes outside the grid, the farthest node per direction and the SeaState inputs to enlarge. Waves are checked in x, y and depth, a SeaState current in depth only; under Wheeler stretching the depth checked is the one SeaState interpolates at (also for a current-only host mode). A run with host waves or current refuses a nonzero MSL2SWL, since the mooring samples SeaState at positions relative to the mean sea level. FAST.Farm and still water check nothing, and after the warning the check costs nothing. The tutorial and examples/openfast now enlarge the grid (half-widths 900 m, Z_Depth to the seabed) and quote their results for it: with the MD_Shared grid the line-1 fairlead tension standard deviation was 18 % too high (0.136 against 0.115 MN). Signed-off-by: Jae Hoon Seo --- CHANGELOG.md | 15 ++ doc/openfast.rst | 73 ++++++++- doc/troubleshooting.rst | 16 +- doc/tutorial_openfast.rst | 89 ++++++---- examples/openfast/README.md | 31 +++- src/openfast/CableDyn_OF.f90 | 262 +++++++++++++++++++++++++++++- tests/test_openfast_aggregate.f90 | 2 +- 7 files changed, 438 insertions(+), 50 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 99f92999..ba564c6f 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -150,6 +150,21 @@ All notable changes to CableDyn are recorded in this file. The format follows standalone driver and the C API refuse `CoupledPinned` rods by name; FAST.Farm decks still refuse rods, OpenFAST linearisation still refuses rods, and `CoupledPinned` bodies remain unsupported. See the manual's OpenFAST page (Lifecycle features). +- A warning when line nodes of a coupled OpenFAST run (`CompMooring = 5`) lie outside the + SeaState wave-kinematics grid (`X_HalfWidth`, `Y_HalfWidth`, `Z_Depth`). SeaState gives such a + node the kinematics of the grid boundary: waves out of phase beyond a half-width, and + kinematics that are too strong below `Z_Depth`. Its fluid load was therefore wrong without + any message. CableDyn now checks its nodes at the static equilibrium and at every CableDyn + step. At the first node outside the grid it prints one warning with the number of nodes, + the farthest node in each direction and the SeaState inputs to enlarge. Only nodes in the + water are checked (a cable or jumper above the free surface carries no fluid load), and + nodes below a grid that reaches the seabed (`Z_Depth` equal to the water depth, its + default) are not reported. + The OpenFAST tutorial and `examples/openfast/README.md` now enlarge the r-test `MD_Shared` + grid (`X_HalfWidth = 100 m`, `Z_Depth = 40 m`), which covers the platform but not the + moorings, and quote their results for the enlarged grid. With the `MD_Shared` grid, the + line-1 fairlead tension standard deviation of the tutorial was 18 % too high. See the + manual's OpenFAST page (SeaState grid). ### Changed diff --git a/doc/openfast.rst b/doc/openfast.rst index 92f0c401..941f7a94 100644 --- a/doc/openfast.rst +++ b/doc/openfast.rst @@ -78,7 +78,7 @@ Time step ``DT`` is the OpenFAST glue step; ``dtM`` is CableDyn's committed step. With no deck ``dtM``, CableDyn targets 0.1 s rounded to a whole number of glue steps and holds its loads (zero-order hold) between commits. ``dtM = DT`` solves every glue step. The console reports the result, for -example ``CableDyn time step dtM = 2.50000E-02 s (1 x glue DT; deck dtM )``. A deck ``dtM`` +example ``CableDyn time step dtM = 2.50000E-02 s (1 x glue DT; deck dtM)``. A deck ``dtM`` larger than ``DT`` but not a whole multiple of it is never coarsened: CableDyn uses the largest multiple of ``DT`` that does not exceed it and reports a warning with both values (``dtM = 0.025`` with ``DT = 0.01`` runs at 0.02 s), matching MoorDyn, which only ever shortens its step to fit the @@ -98,6 +98,72 @@ WaterKin file can select file waves, a file depth-dependent current, host waves, current independently where the field is separable. Unsupported or double-counted combinations fail during initialisation. The selector matrix is in :doc:`options` and :doc:`driver_format`. +SeaState grid +~~~~~~~~~~~~~ + +SeaState computes the wave and current kinematics on a grid set in its input file and +interpolates them at the line nodes: ``X_HalfWidth`` and ``Y_HalfWidth`` about the origin, +``Z_Depth`` below the still-water level, and ``NX``, ``NY``, ``NZ`` grid points (``NZ`` is +spaced more finely near the surface). A node outside the grid gets the kinematics of the +nearest grid boundary point, so its fluid load is wrong: beyond a half-width the waves are +out of phase, and below ``Z_Depth`` the wave and current kinematics are those of the grid +bottom, which are too strong. A SeaState file written for the platform alone usually covers +only the platform. The r-test ``MD_Shared`` file used in :doc:`tutorial_openfast` has +``X_HalfWidth = Y_HalfWidth = 100 m``, ``Z_Depth = 40 m`` and ``NZ = 2``, while the anchors lie +838 m from the platform on a 200 m seabed. Size the grid for the lines: + +* ``X_HalfWidth`` and ``Y_HalfWidth`` beyond the farthest anchor or cable end, with margin for + the platform offset; +* ``Z_Depth`` equal to the water depth (``"default"``); nodes on the seabed are then inside the + grid; and +* ``NX``, ``NY`` and ``NZ`` raised with the extents to keep the grid spacing: a horizontal + spacing of about a tenth of the peak wavelength or less. A long-crested sea (``WaveDirMod = + 0``) that travels along x does not vary in y, so ``NY = 2`` is enough for it. + +SeaState holds the whole time history of the grid in memory, so memory and initialisation time +grow with (2 ``NX`` − 1)(2 ``NY`` − 1) ``NZ`` ``WaveTMax`` / ``WaveDT``. For the +IEA-15MW case of :doc:`tutorial_openfast` (Hs 6 m, Tp 12 s, ``WaveTMax = 4800 s``, +``WaveDT = 0.2 s``), ``X_HalfWidth = Y_HalfWidth = 900``, the default ``Z_Depth``, ``NX = 37`` +(25 m spacing), ``NY = 2`` and ``NZ = 11`` needs about 4.6 GB. Halving the spacing (``NX = 73``) +or using ``NZ = 16`` changes the 10–70 s platform and fairlead-tension statistics by less than +0.1 %. The ``MD_Shared`` grid gives a line-1 fairlead tension standard deviation 18 % too high +(0.136 MN instead of 0.115 MN). + +CableDyn compares its nodes with the grid at the static equilibrium and at every CableDyn step. +At the first node found outside it prints one warning and continues: + +.. code-block:: text + + WARNING: CableDyn mooring module: 147 of the 153 CableDyn sampling nodes in the water lie + outside the SeaState wave-kinematics grid at t = 0 s (warned once). SeaState clamps them to + the grid boundary, so their fluid kinematics and loads are not physical. Farthest: x = -837.6 + m (grid |x| <= X_HalfWidth = 100 m); y = 725.38 m (grid |y| <= Y_HalfWidth = 100 m); z = + -200.01 m (grid z >= -Z_Depth = -40 m). In the SeaState input file enlarge X_HalfWidth, + Y_HalfWidth and Z_Depth (Z_Depth at most WtrDpth + MSL2SWL, its default) to cover the lines + with margin for their motion, and raise NX, NY and NZ to keep the grid spacing. + +Only nodes in the water are checked: a node above the free surface carries no fluid load, +whatever kinematics SeaState would give it, so a suspended cable or jumper above the water may +leave the grid. A node counts as in the water at or below the free-surface elevation sampled +for it, which also decides its wetting in CableDyn (the still-water level when the host waves +are off), and, without wave stretching (``WaveStMod = 0``), at or below the still-water level, +above which SeaState gives zero kinematics without reading the grid. Only the directions in +which nodes leave the grid are listed. Waves are checked in all three +directions and a SeaState current (uniform in x and y) only in depth; under Wheeler stretching +(``WaveStMod = 3``) the depth checked is the one SeaState interpolates at, the node depth mapped +linearly from the range between the seabed and the local wave elevation onto the range between +the seabed and the still-water level (with the elevation SeaState sampled, also when only the +host current is used). A dynamic current field (an InflowWind-driven current) is read on its +own grid; when that field is gridded, a separate one-time warning reports nodes outside its +vertical extent or lateral half-width. SeaState measures its field from the still-water level, and the +mooring samples it at positions relative to the mean sea level, so a run with host waves or +current from SeaState refuses a nonzero ``MSL2SWL`` at initialisation (a deck that takes +both from WaterKin does not query SeaState and is not affected). Excursions smaller than +1 % of the grid spacing at the boundary are ignored, and so are nodes below a grid that reaches +the seabed (``Z_Depth = WtrDpth + MSL2SWL``): they are in the seabed, where the kinematics of the +grid bottom are the right ones. FAST.Farm runs, which use still water, and SeaState fields +without waves or current are not checked. + Run and confirm --------------- @@ -193,8 +259,9 @@ Example files The turbine sub-models are not part of this repository. :doc:`tutorial_openfast` gives the exact steps to fetch them from OpenFAST's ``r-test`` (``glue-codes/fast-farm/MD_Shared`` at revision -``dd5feaaaa500ba7283140107806300d551cff0a7``) and to reset that farm model's turbine-1 initial -pose to a single turbine at the origin. +``dd5feaaaa500ba7283140107806300d551cff0a7``), to reset that farm model's turbine-1 initial +pose to a single turbine at the origin, and to enlarge its SeaState grid to cover the moorings +(see *SeaState grid*). Mixed moorings and power cables ------------------------------- diff --git a/doc/troubleshooting.rst b/doc/troubleshooting.rst index 2ef21c85..30b6a095 100644 --- a/doc/troubleshooting.rst +++ b/doc/troubleshooting.rst @@ -521,6 +521,8 @@ Warnings and notes that do not stop a run :header-rows: 1 :widths: 42 58 + * - Message + - Cause and fix * - ``Note: line is torsionally restrained at one end only; ... no torsion is solved`` - with the other end free to twist the line carries no torque, so the torsion columns of the restrained end have no effect. Restrain both ends to solve torsion. @@ -529,9 +531,17 @@ Warnings and notes that do not stop a run - the static twist stage of a torsional line. A non-zero descent count means the straight or untwisted branch was unstable at the imposed twist and the solve moved to a buckled shape; check the shape and the ``Twist`` channel. - - * - Message - - Cause and fix + * - ``WARNING: CableDyn mooring module: of the CableDyn sampling nodes in the water + lie outside the SeaState wave-kinematics grid at t = ... s (warned once)`` (OpenFAST) + - the SeaState grid (``X_HalfWidth``, ``Y_HalfWidth``, ``Z_Depth``) does not cover the + lines in the water (nodes above the free surface carry no fluid load and are not + counted), and SeaState gives the nodes outside it the kinematics of the grid boundary: waves + out of phase beyond a half-width, kinematics that are too strong below ``Z_Depth``. The + message names the farthest node in each direction. Enlarge the listed inputs in the + SeaState file past the farthest anchor (``Z_Depth`` to the water depth, its default) and + raise ``NX``, ``NY``, ``NZ`` to keep the spacing. A SeaState file written for the + platform alone, such as the r-test ``MD_Shared`` file, triggers it. See + :ref:`openfast:SeaState grid` for sizes and memory. * - ``WARNING: line type ... sinks ... m into the seabed ...; kBot is soft for this line`` - a grounded run of this type would sink deeper than its own diameter into the penalty seabed. Raise ``kBot``; the default ``1.0e5`` embeds a heavy chain by about half its diff --git a/doc/tutorial_openfast.rst b/doc/tutorial_openfast.rst index 425ad77d..0b04142a 100644 --- a/doc/tutorial_openfast.rst +++ b/doc/tutorial_openfast.rst @@ -10,8 +10,8 @@ CableDyn results, compare against stock MoorDyn in the same binary, and add a la cable. **Needs:** ``openfast.exe`` from the release, the ``examples`` folder, and Git (or a browser) to -fetch the turbine model · **Run time:** about 5 s for 70 s of simulation (the MoorDyn comparison run -takes a few minutes) +fetch the turbine model · **Run time:** under half a minute for 70 s of simulation, about a +third of it SeaState generating the wave grid (the MoorDyn comparison run takes a few minutes) .. contents:: :local: @@ -75,8 +75,8 @@ The folder now holds, among others: ``HydroData\``, ``Airfoils\``, … - the turbine and platform model from ``MD_Shared`` -3. Make the model a single turbine at the origin ------------------------------------------------- +3. Prepare the turbine model +---------------------------- ``MD_Shared`` is a two-turbine FAST.Farm case. Its turbine-1 files start the platform at its farm pose (20.3 m surge, 180° yaw, small roll/pitch/heave) and set HydroDyn's reference yaw @@ -102,6 +102,28 @@ This sets ``PtfmSurge``, ``PtfmSway``, ``PtfmHeave``, ``PtfmRoll``, ``PtfmPitch` 321 MN fairlead tension. Always read the initial fairlead tensions before trusting a coupled run. +``MD_Shared``'s ``SeaState.dat`` computes the wave kinematics on a grid that covers only the +platform: ``X_HalfWidth = Y_HalfWidth = 100 m``, ``Z_Depth = 40 m``, ``NX = NY = NZ = 2``. The +mooring lines reach anchors 838 m away on the 200 m seabed, and SeaState gives every line node +outside the grid the kinematics of the grid boundary. Enlarge the grid to cover the lines: + +.. code-block:: powershell + + $ss = 'SeaState.dat' + (Get-Content $ss) -replace '^\s*\S+(\s+[XY]_HalfWidth\s)', ' 900$1' ` + -replace '^\s*\S+(\s+Z_Depth\s)', ' "default"$1' ` + -replace '^\s*\S+(\s+NX\s)', ' 37$1' ` + -replace '^\s*\S+(\s+NZ\s)', ' 11$1' | + Set-Content $ss -Encoding ascii + +This sets ``X_HalfWidth`` and ``Y_HalfWidth`` to 900 m, ``Z_Depth`` to the water depth, 37 grid +points along each half of x (25 m spacing) and 11 in depth. ``NY`` stays 2 because the +long-crested sea travels along x and does not vary in y. SeaState then needs about 4.6 GB of +memory and several seconds to generate the grid. Without this step the run still completes, but +CableDyn warns that 147 of its 153 line nodes lie outside the SeaState wave-kinematics grid, and +the line-1 fairlead tension standard deviation comes out 18 % too high. Grid sizing is +described in :ref:`openfast:SeaState grid`. + 4. How CableDyn is wired in --------------------------- @@ -148,7 +170,7 @@ The CableDyn part of the console (other modules' lines trimmed): Running CableDyn (v0.1.1, 2026-10-09). CableDyn: geometrically nonlinear cable & mooring dynamics for floating wind. ... - CableDyn time step dtM = 2.50000E-02 s (1 x glue DT; deck dtM ) + CableDyn time step dtM = 2.50000E-02 s (1 x glue DT; deck dtM) Parsing CableDyn input file: .\CableDyn_UMaine.dat CableDyn: SeaState wave/current kinematics drive the mooring hydro (153 sampling nodes, refreshed every mooring step). @@ -163,16 +185,14 @@ The CableDyn part of the console (other modules' lines trimmed): ... CableDyn initialization completed. Requested CableDyn OUTPUTS at t = 0 s (equilibrium pose, SeaState kinematics at t = 0): - FairTen1 = 2.43621E+06 (N) - AnchTen1 = 1.35173E+06 (N) + FairTen1 = 2.43752E+06 (N) + AnchTen1 = 1.35164E+06 (N) FairIncl1 = 55.685 (deg) ... These values are also the t = 0 CableDyn columns in the OpenFAST output file. Time: 0 of 70 seconds. ... - Total Real Time: 4.63 seconds Simulated Time: 70 seconds - Time Ratio (Sim/CPU): 15.887 OpenFAST terminated normally. @@ -180,13 +200,14 @@ Check, in order: #. ``Running CableDyn (`` — the CableDyn-enabled executable is in use. A stock OpenFAST rejects ``CompMooring = 5`` during input validation. -#. The line inventory (3 lines, 6 points) and ``dtM``. +#. The line inventory (3 lines, 6 points) and ``dtM``, and no ``WARNING: CableDyn mooring module: + ... lie outside the SeaState wave-kinematics grid`` line (step 3). #. The initial fairlead tensions: 2.437 MN per line, with the line tangent 55.7° below horizontal, as in the standalone ``spread_3line_chain.dat`` of :doc:`tutorial_spread`. The tension is the magnitude of the line-end force, which includes the fairlead node's share of the chain weight, so the force points slightly steeper, 56.3° below horizontal, with a horizontal component of 1.351 MN. -#. The ``OUTPUTS`` at t = 0: ``FairTen1`` reads 2.436 MN, 0.04 % below the equilibrium value +#. The ``OUTPUTS`` at t = 0: ``FairTen1`` reads 2.4375 MN, 0.02 % above the equilibrium value above. The equilibrium is solved before the SeaState kinematics act, and at t = 0 the wave kinematics add their hydrodynamic load on the fairlead end node. In still water (``WaveMod = 0``) the two values are equal. ``.CD.static.out`` holds the equilibrium, and the @@ -218,8 +239,8 @@ Check, in order: Time FairTen1 AnchTen1 FairIncl1 AnchIncl1 FairTen2 ... (s) (N) (N) (deg) (deg) (N) ... - 0.0000000E+00 2.436210E+06 1.351729E+06 5.568478E+01 -1.961023E-02 2.435610E+06 ... - 2.5000000E-02 2.434498E+06 1.352272E+06 5.568418E+01 -1.957846E-02 2.433048E+06 ... + 0.0000000E+00 2.437520E+06 1.351636E+06 5.568478E+01 -1.961023E-02 2.436576E+06 ... + 2.5000000E-02 2.438082E+06 1.351645E+06 5.568463E+01 -1.961023E-02 2.435530E+06 ... CableDyn channels are chosen in the deck's ``OUTPUTS`` section (keep its closing ``END``), not in the ``.fst`` ``OutList``. Channel names and units: :doc:`outputs`; sign and angle conventions: @@ -254,30 +275,30 @@ the main ``.out``. Statistics over 10–70 s from the two main output files: - CableDyn std - MoorDyn std * - ``PtfmSurge`` (m) - - 0.893 - - 0.893 - - 1.364 - - 1.363 + - 0.899 + - 0.899 + - 1.380 + - 1.378 * - ``PtfmHeave`` (m) - −1.030 - −1.030 - - 1.216 - - 1.215 + - 1.221 + - 1.221 * - ``PtfmPitch`` (deg) - - 1.497 - - 1.497 - - 1.382 - - 1.381 + - 1.496 + - 1.496 + - 1.390 + - 1.390 * - fairlead tension, line 1 (MN) - - 2.452 - - 2.452 - - 0.136 - - 0.136 + - 2.456 + - 2.456 + - 0.115 + - 0.116 * - fairlead tension, line 2 (MN) - - 2.376 - - 2.376 - - 0.069 - - 0.069 + - 2.372 + - 2.372 + - 0.064 + - 0.064 The platform motions agree to within 0.2 %, the mean fairlead tensions to within 0.01 % and their standard deviations to within 0.5 %. Both codes report the fairlead tension as the force @@ -319,7 +340,7 @@ seabed. Copy it into the case folder and point a copy of the ``.fst`` at it: force [Fx, Fy, Fz]: [1230, 0, -11858] N, inclination=84.078 deg line tangent: inclination=83.943 deg, declination=173.94 deg, azimuth=0 deg ... - Curv4N38 = 9.01821E-02 (1/m) + Curv4N38 = 9.01822E-02 (1/m) BendMom4N38 = 1794.6 (N.m) CableDyn found the cable's touchdown and lazy-wave shape by itself: in @@ -339,9 +360,9 @@ Exercises ``MD_Shared`` InflowWind and AeroDyn files are already present) and compare the mean surge and line-1 tension with the parked case. 2. **Supercycling.** Remove the ``dtM`` row from ``CableDyn_UMaine.dat``. The console now - reports ``dtM = 0.1 s (4 x glue DT; the default )``, the run takes about 3 s instead of 5 s, + reports ``dtM = 0.1 s (4 x glue DT; the default)``, CableDyn solves once per four glue steps, and ``.CD.out`` has one row per 0.1 s. Here the line-1 tension statistics over 10–70 s barely - move (mean 2.453 MN, std 0.136 MN, against 2.452 and 0.136 MN); verify that for your own + move (mean 2.456 MN, std 0.116 MN, against 2.456 and 0.115 MN); verify that for your own quantities before adopting a coarser step. 3. **Still water.** Set ``WaveMod = 0`` in ``SeaState.dat``. Without waves the platform settles toward its still-water pose (mean heave −1.1 m, pitch 1.5°) with a decaying heave–pitch diff --git a/examples/openfast/README.md b/examples/openfast/README.md index 0ba76238..b0bae7a4 100644 --- a/examples/openfast/README.md +++ b/examples/openfast/README.md @@ -46,6 +46,23 @@ $hd = 'IEA-15-240-RWT-UMaineSemi_HydroDynT1.dat' The initial CableDyn fairlead tensions are then the ~2.4 MN chain pretension. +The `MD_Shared` `SeaState.dat` computes the wave kinematics on a grid that covers only the +platform (`X_HalfWidth = Y_HalfWidth = 100 m`, `Z_Depth = 40 m`), while the anchors lie 838 m +away on the 200 m seabed. SeaState gives every line node outside the grid the kinematics of the +grid boundary, and CableDyn warns about it. Enlarge the grid: + +```powershell +$ss = 'SeaState.dat' +(Get-Content $ss) -replace '^\s*\S+(\s+[XY]_HalfWidth\s)', ' 900$1' ` + -replace '^\s*\S+(\s+Z_Depth\s)', ' "default"$1' ` + -replace '^\s*\S+(\s+NX\s)', ' 37$1' ` + -replace '^\s*\S+(\s+NZ\s)', ' 11$1' | + Set-Content $ss -Encoding ascii +``` + +SeaState then needs about 4.6 GB of memory. The values in this file are for the enlarged grid. +Grid sizing is described in the manual's OpenFAST page (SeaState grid). + ## Run ```powershell @@ -66,7 +83,7 @@ The force is the one the line exerts on the fairlead, including the end node's s chain weight, so it is slightly steeper than the line tangent. These are the static-equilibrium values, also written to `.CD.static.out`. The requested `OUTPUTS` printed below them are the t = 0 values, which add the load of the SeaState wave kinematics at t = 0 on the end node: -`FairTen1` reads 2.43621E+06 N. In still water the two agree. +`FairTen1` reads 2.43752E+06 N. In still water the two agree. For the power-cable case, copy `../iea15mw_umaine_mixed_cabledyn.dat` beside the template and point `MooringFile` at it. @@ -109,12 +126,12 @@ The channels to read for an ALS check: - The static equilibrium of every line is in `.CD.static.out`. In the `MD_Shared` JONSWAP sea (Hs 6 m, Tp 12 s, travelling along +X) line 1 is the only line on -the up-wave side. Before the break the fairlead tensions are 2.44 MN and `PtfmSurge` stays within -−2.4 to 2.8 m. After it the platform drifts down-wave: `PtfmSurge` reaches 147 m by t = 400 s and -is still growing, because the two remaining anchors lie down-wave of the platform. The intact -lines slacken as it approaches them (`FairTen2` mean 1.29 MN over 300–400 s, no peak above the -2.50 MN at the break). Run longer (`TMax`) to reach the new equilibrium. The 400 s run takes -about 26 s. +the up-wave side. Before the break the line-1 fairlead tension averages 2.44 MN and `PtfmSurge` +stays within −2.5 to 3.6 m. After it the platform drifts down-wave: `PtfmSurge` reaches 147 m by +t = 400 s and is still growing, because the two remaining anchors lie down-wave of the platform. +The intact lines slacken as it approaches them (`FairTen2` mean 1.29 MN over 300–400 s, no peak +above the 2.51 MN at the break). Run longer (`TMax`) to reach the new equilibrium. The 400 s run +takes about 60 s. ## Notes diff --git a/src/openfast/CableDyn_OF.f90 b/src/openfast/CableDyn_OF.f90 index 854f534c..9443f1b5 100644 --- a/src/openfast/CableDyn_OF.f90 +++ b/src/openfast/CableDyn_OF.f90 @@ -111,6 +111,7 @@ MODULE CableDyn CD_Recompute_System_Acceleration, CD_SYSTEM_OK USE SeaSt_WaveField, ONLY: WaveField_GetNodeWaveKin USE SeaSt_WaveField_Types, ONLY: WaveMod_None + USE IfW_FlowField_Types, ONLY: Grid3D_FieldType IMPLICIT NONE @@ -191,6 +192,10 @@ MODULE CableDyn LOGICAL :: use_extfluid = .FALSE. INTEGER(IntKi) :: nfluid = 0 REAL(wp), ALLOCATABLE :: fx_xyz(:,:), fx_vel(:,:), fx_acc(:,:), fx_wl(:), fx_pd(:) + ! TRUE once the warning that sampling nodes lie outside the SeaState wave-kinematics + ! grid has been issued: one warning per run (check_wavefield_grid). + LOGICAL :: grid_warned = .FALSE. + LOGICAL :: curr_grid_warned = .FALSE. !< the dynamic current-field grid check has warned ! CHECKPOINT-RESTART identity: serial is the generation stamp minted at ! Init/rebuild and mirrored into other%restart_serial; t_commit is the time of the ! last committed mooring advance, mirrored into other%t_commit. A restored @@ -804,7 +809,7 @@ SUBROUTINE CD_Init(InitInp, u, p, x, xd, z, other, y, m, DTcoupling, InitOut, Er ! wave-capable-at-ZERO-fields build -- a still-water start under a declared sea ! state. Seeding after the static solve matches the stock-MoorDyn convention: ! the IC is the still-water equilibrium, wave kinematics act from t = 0. - CALL sample_wavefield( Inst(id), p, m, 0.0_DbKi, ErrStat2, ErrMsg2 ) + CALL sample_wavefield( Inst(id), p, m, 0.0_DbKi, ErrStat2, ErrMsg2, at_init=.TRUE. ) CALL SetErrStat( ErrStat2, ErrMsg2, ErrStat, ErrMsg, RoutineName ) IF (ErrStat >= AbortErrLev) RETURN END IF @@ -1690,7 +1695,7 @@ SUBROUTINE CD_UpdateStates( t, n, u, t_array, p, x, xd, z, other, m, ErrStat, Er END SUBROUTINE CD_UpdateStates !---------------------------------------------------------------------------------------------------------------------------------- - SUBROUTINE sample_wavefield( inst_e, p, m, t_sample, ErrStat, ErrMsg ) + SUBROUTINE sample_wavefield( inst_e, p, m, t_sample, ErrStat, ErrMsg, at_init ) !! Sample the SeaState WaveField at every mooring line node's committed position -- !! fluid velocity (waves + current), fluid acceleration, and the local free-surface !! elevation -- and prescribe them to the aggregate for the coming advance. Nodes @@ -1703,20 +1708,29 @@ SUBROUTINE sample_wavefield( inst_e, p, m, t_sample, ErrStat, ErrMsg ) REAL(DbKi), INTENT(IN ) :: t_sample INTEGER(IntKi), INTENT( OUT) :: ErrStat CHARACTER(*), INTENT( OUT) :: ErrMsg + LOGICAL, OPTIONAL, INTENT(IN ) :: at_init !< the Init seeding call (see check_wavefield_grid) character(*), parameter :: RoutineName = 'sample_wavefield' INTEGER(IntKi) :: i, l, es, nodeInWater, n_current_nodes + LOGICAL :: init_call REAL(SiKi) :: zeta1, zeta2, zeta, pdyn, fv(3), fa(3), famcf(3) REAL(SiKi) :: wave_zeta1, wave_zeta2, wave_zeta, wave_pdyn REAL(SiKi) :: wave_fv(3), wave_fa(3), wave_famcf(3) REAL(wp) :: profile_fv(3), steady_fv_wp(3), grid_z REAL(SiKi) :: steady_fv(3), grid_fv(3), grid_weight + ! the SeaState free-surface elevation as sampled at each node (kept also when the host + ! waves are off and fx_wl takes the still-water level): SeaState's Wheeler stretching + ! interpolates the current at the depth mapped with it. Only the grid check reads it, so + ! it exists only until that check has warned. + REAL(wp), ALLOCATABLE :: wl_sampled(:) CHARACTER(512) :: em INTEGER(IntKi) :: ErrStat2 CHARACTER(ErrMsgLen) :: ErrMsg2 ErrStat = ErrID_None ErrMsg = '' + init_call = .FALSE. + IF (PRESENT(at_init)) init_call = at_init IF (.NOT. ASSOCIATED(p%WaveField)) THEN CALL SetErrStat( ErrID_Fatal, 'CableDyn mooring module: the WaveField pointer is null but '// & 'SeaState kinematics were requested at Init.', ErrStat, ErrMsg, RoutineName ) @@ -1727,6 +1741,19 @@ SUBROUTINE sample_wavefield( inst_e, p, m, t_sample, ErrStat, ErrMsg ) CALL SetErrStat( ErrID_Fatal, 'CableDyn mooring module: '//TRIM(em), ErrStat, ErrMsg, RoutineName ) RETURN END IF + ! SeaState measures its wave field and grid from the still-water level, and its node + ! queries take SWL-relative positions; the mooring samples it at positions relative to the + ! mean sea level, which coincide only for MSL2SWL = 0. Checked here, where the deck's + ! WaterKin policy has decided whether SeaState is queried at all. + IF ((inst_e%agg%host_wave_enabled .OR. inst_e%agg%host_current_enabled) .AND. & + ABS(p%WaveField%MSL2SWL) > 0.0_ReKi) THEN + CALL SetErrStat( ErrID_Fatal, 'CableDyn mooring module: SeaState MSL2SWL = '// & + TRIM(Num2LStr(p%WaveField%MSL2SWL))//' m is not supported with host waves or '// & + 'current: the mooring samples SeaState at positions relative to the mean sea '// & + 'level. Set MSL2SWL = 0, or take the waves and current from the deck (WaterKin).', & + ErrStat, ErrMsg, RoutineName ) + RETURN + END IF IF ((inst_e%agg%host_wave_enabled .NEQV. inst_e%agg%host_current_enabled) .AND. & p%WaveField%Current_InitInput%CurrMod == 2_IntKi) THEN CALL SetErrStat( ErrID_Fatal, 'CableDyn mooring module: WaterKin requests separate host wave/current '// & @@ -1734,6 +1761,7 @@ SUBROUTINE sample_wavefield( inst_e, p, m, t_sample, ErrStat, ErrMsg ) ErrStat, ErrMsg, RoutineName ) RETURN END IF + IF (.NOT. inst_e%grid_warned) ALLOCATE (wl_sampled(inst_e%nfluid)) DO i = 1, inst_e%nfluid IF (.NOT. inst_e%agg%host_wave_enabled .AND. .NOT. inst_e%agg%host_current_enabled) THEN ! An explicit WaterKin file may disable both host components even @@ -1750,6 +1778,7 @@ SUBROUTINE sample_wavefield( inst_e, p, m, t_sample, ErrStat, ErrMsg ) CALL SetErrStat( ErrStat2, ErrMsg2, ErrStat, ErrMsg, RoutineName ) IF (ErrStat >= AbortErrLev) RETURN END IF + IF (ALLOCATED(wl_sampled)) wl_sampled(i) = REAL(zeta, wp) steady_fv = 0.0_SiKi IF (nodeInWater /= 0_IntKi .AND. & (.NOT. inst_e%agg%host_wave_enabled .OR. .NOT. inst_e%agg%host_current_enabled)) THEN @@ -1828,6 +1857,14 @@ SUBROUTINE sample_wavefield( inst_e, p, m, t_sample, ErrStat, ErrMsg ) inst_e%fx_pd(i) = 0.0_wp IF (inst_e%agg%host_wave_enabled) inst_e%fx_pd(i) = REAL(pdyn, wp) END DO + ! Grid coverage: checked on the positions just sampled (with their free-surface + ! elevations), at Init (the static equilibrium) and then every mooring step until the one + ! warning has been issued. + IF (.NOT. inst_e%grid_warned) THEN + CALL check_wavefield_grid( inst_e, p%WaveField, t_sample, init_call, wl_sampled, ErrStat2, ErrMsg2 ) + CALL SetErrStat( ErrStat2, ErrMsg2, ErrStat, ErrMsg, RoutineName ) + END IF + IF (.NOT. inst_e%curr_grid_warned) CALL check_current_field_grid( inst_e, p%WaveField, t_sample ) CALL CD_AGG_SetFluidFields( inst_e%agg, inst_e%fx_vel, inst_e%fx_acc, inst_e%fx_wl, es, em, & dynamic_pressure=inst_e%fx_pd ) IF (es /= CD_AGG_OK) THEN @@ -1835,6 +1872,225 @@ SUBROUTINE sample_wavefield( inst_e, p, m, t_sample, ErrStat, ErrMsg ) END IF END SUBROUTINE sample_wavefield +!---------------------------------------------------------------------------------------------------------------------------------- + SUBROUTINE check_wavefield_grid( inst_e, wf, t_sample, at_init, wl_sampled, ErrStat, ErrMsg ) + !! Warn, once per run, when sampling nodes lie outside the SeaState wave-kinematics grid. + !! The volume grid spans X_HalfWidth and Y_HalfWidth about the origin of the global frame + !! the nodes are sampled in (FAST.Farm runs in still water and never samples) and Z_Depth + !! below the SWL. Beyond it SeaState clamps the position to the grid boundary (GridInterp + !! SetIndex horizontally, the depth mapping of WaveField_Interp_Setup4D vertically), so + !! the node receives the kinematics of the nearest boundary point -- out of phase + !! horizontally, too strong below Z_Depth. SeaState's own clamping notice is generic, names + !! no node, and is issued once, at the Init sample, where the glue drops it. The extents are + !! read from the WaveField's volume-grid parameters, i.e. exactly the grid the sampler + !! interpolates. Excursions below 1 % of the boundary grid spacing are ignored. Below a + !! grid that reaches the seabed (Z_Depth = WtrDpth + MSL2SWL, the SeaState maximum) a node + !! is in the seabed and the seabed kinematics are the right ones. SeaState's current is + !! uniform in x and y, so the horizontal check applies to waves only. + !! + !! Only nodes in the water are checked: a node above the free surface carries no fluid + !! load whatever kinematics it is given, so a suspended cable or jumper above the water + !! outside the grid is no error. A node is in the water at or below the free-surface + !! elevation just sampled for it (fx_wl; the still-water level when the host waves are + !! off), which decides its wetting in CableDyn, and, without wave stretching + !! (WaveStMod = 0), at or below the still-water level too, above which SeaState gives a + !! node zero kinematics without reading the grid. Called after the nodes' sampling, on the + !! positions just sampled. Cost: a few comparisons per node per mooring step until the + !! warning. at_init marks the Init call, at the static equilibrium (t = 0). + !! + !! The message states first that it is given once, so that a caller's message buffer that + !! cuts its tail keeps that; the farthest-node details are left out if the message would not + !! fit the remaining length of ErrMsg. + TYPE(CD_OF_Instance), INTENT(INOUT) :: inst_e + TYPE(SeaSt_WaveFieldType), INTENT(IN ) :: wf + REAL(DbKi), INTENT(IN ) :: t_sample + LOGICAL, INTENT(IN ) :: at_init + REAL(wp), INTENT(IN ) :: wl_sampled(:) !< SeaState elevation as sampled per node + INTEGER(IntKi), INTENT( OUT) :: ErrStat + CHARACTER(*), INTENT( OUT) :: ErrMsg + + character(*), parameter :: RoutineName = 'check_wavefield_grid' + LOGICAL :: waves, grid_current, check_xy(2), check_z, outside + INTEGER(IntKi) :: i, k, nout, nin, nwet, room + REAL(wp) :: lo(2), hi(2), tol(2), zbot, tol_z, ex, ex_max(3), at_max(3), surface + REAL(wp) :: zq, dep + CHARACTER(11) :: inp(3), res(3) + CHARACTER(1024) :: farthest, enlarge, refine + CHARACTER(:), ALLOCATABLE :: head, msg + + ErrStat = ErrID_None + ErrMsg = '' + waves = inst_e%agg%host_wave_enabled .AND. wf%WaveMod /= WaveMod_None + grid_current = inst_e%agg%host_current_enabled .AND. wf%Current_InitInput%CurrMod /= 0_IntKi + IF (.NOT. (waves .OR. grid_current)) RETURN + DO k = 1, 2 + check_xy(k) = waves .AND. wf%VolGridParams%n(k + 1) > 1_IntKi + lo(k) = REAL(wf%VolGridParams%pZero(k + 1), wp) + hi(k) = lo(k) + REAL(wf%VolGridParams%n(k + 1) - 1_IntKi, wp)*REAL(wf%VolGridParams%delta(k + 1), wp) + tol(k) = 0.01_wp*REAL(wf%VolGridParams%delta(k + 1), wp) + END DO + ! the vertical grid is cosine-spaced in delta(4); its bottom interval is Z_Depth*sin(delta(4)) + zbot = -REAL(wf%GridDepth, wp) + tol_z = 0.01_wp*REAL(wf%GridDepth, wp)*SIN(REAL(wf%VolGridParams%delta(4), wp)) + check_z = wf%VolGridParams%n(4) > 1_IntKi .AND. & + REAL(wf%GridDepth, wp) < REAL(wf%EffWtrDpth, wp) - tol_z + IF (.NOT. (ANY(check_xy) .OR. check_z)) RETURN + + nout = 0_IntKi + nwet = 0_IntKi + ex_max = 0.0_wp + at_max = 0.0_wp + DO i = 1, inst_e%nfluid + ! nodes above the free surface carry no fluid load (see above) + surface = inst_e%fx_wl(i) + IF (wf%WaveStMod == 0_IntKi) surface = MIN(surface, 0.0_wp) + IF (inst_e%fx_xyz(3, i) > surface) CYCLE + nwet = nwet + 1_IntKi + outside = .FALSE. + DO k = 1, 2 + IF (.NOT. check_xy(k)) CYCLE + ex = MAX(lo(k) - inst_e%fx_xyz(k, i), inst_e%fx_xyz(k, i) - hi(k)) + IF (ex > tol(k)) THEN + outside = .TRUE. + IF (ex > ex_max(k)) THEN + ex_max(k) = ex + at_max(k) = inst_e%fx_xyz(k, i) + END IF + END IF + END DO + IF (check_z) THEN + ! SeaState interpolates at the node depth, or under Wheeler stretching (WaveStMod 3) at + ! the depth mapped linearly from [-EffWtrDpth, wave elevation] to [-EffWtrDpth, 0] with + ! the elevation it sampled -- also for the current of a current-only host mode, whose + ! fx_wl is the still-water level + zq = inst_e%fx_xyz(3, i) + IF (wf%WaveMod /= WaveMod_None .AND. wf%WaveStMod == 3_IntKi) THEN + dep = REAL(wf%EffWtrDpth, wp) + IF (dep + wl_sampled(i) > 0.0_wp) zq = MIN(dep*(dep + zq)/(dep + wl_sampled(i)) - dep, 0.0_wp) + END IF + ex = zbot - zq + IF (ex > tol_z) THEN + outside = .TRUE. + IF (ex > ex_max(3)) THEN + ex_max(3) = ex + at_max(3) = inst_e%fx_xyz(3, i) + END IF + END IF + END IF + IF (outside) nout = nout + 1_IntKi + END DO + IF (nout == 0_IntKi) RETURN + + ! the farthest node per direction, and the SeaState inputs that would cover it + nin = 0_IntKi + farthest = '' + IF (ex_max(1) > 0.0_wp) THEN + farthest = TRIM(farthest)//'; x = '//TRIM(Num2LStr(at_max(1)))//' m (grid |x| <= X_HalfWidth = '// & + TRIM(Num2LStr(0.5_wp*(hi(1) - lo(1))))//' m)' + nin = nin + 1_IntKi + inp(nin) = 'X_HalfWidth' + res(nin) = 'NX' + END IF + IF (ex_max(2) > 0.0_wp) THEN + farthest = TRIM(farthest)//'; y = '//TRIM(Num2LStr(at_max(2)))//' m (grid |y| <= Y_HalfWidth = '// & + TRIM(Num2LStr(0.5_wp*(hi(2) - lo(2))))//' m)' + nin = nin + 1_IntKi + inp(nin) = 'Y_HalfWidth' + res(nin) = 'NY' + END IF + IF (ex_max(3) > 0.0_wp) THEN + farthest = TRIM(farthest)//'; z = '//TRIM(Num2LStr(at_max(3)))//' m (grid z >= -Z_Depth = '// & + TRIM(Num2LStr(zbot))//' m)' + nin = nin + 1_IntKi + inp(nin) = 'Z_Depth' + res(nin) = 'NZ' + END IF + enlarge = TRIM(inp(1)) + refine = TRIM(res(1)) + DO k = 2, nin + IF (k == nin) THEN + enlarge = TRIM(enlarge)//' and '//TRIM(inp(k)) + refine = TRIM(refine)//' and '//TRIM(res(k)) + ELSE + enlarge = TRIM(enlarge)//', '//TRIM(inp(k)) + refine = TRIM(refine)//', '//TRIM(res(k)) + END IF + END DO + IF (ex_max(3) > 0.0_wp) enlarge = TRIM(enlarge)//' (Z_Depth at most WtrDpth + MSL2SWL, its default)' + + inst_e%grid_warned = .TRUE. + head = 'CableDyn mooring module: '//TRIM(Num2LStr(nout))//' of the '//TRIM(Num2LStr(nwet))// & + ' CableDyn sampling nodes in the water lie outside the SeaState wave-kinematics grid at t = '// & + TRIM(Num2LStr(t_sample))//' s (warned once). SeaState clamps them to the grid boundary, so '// & + 'their fluid kinematics and loads are not physical.' + msg = head//' Farthest: '//TRIM(farthest(3:))//'. In the SeaState input file enlarge '//TRIM(enlarge)// & + ' to cover the lines with margin for their motion, and raise '//TRIM(refine)// & + ' to keep the grid spacing.' + ! SetErrStat appends the message to ErrMsg after a line break and the routine name + room = LEN(ErrMsg) - LEN_TRIM(ErrMsg) - LEN(RoutineName) - 2 + IF (LEN(msg) > room) msg = head//' Enlarge '//TRIM(enlarge)//' in the SeaState input file.' + CALL SetErrStat( ErrID_Warn, msg, ErrStat, ErrMsg, RoutineName ) + ! The OpenFAST glue does not print module initialization warnings (FAST_InitializeAll_T + ! passes its status on to FAST_InitMappings, which resets it), so the Init check also + ! writes the warning to the screen, as the deck dtM warning does. A warning raised + ! during the time march reaches the screen through the glue's error check. + IF (at_init) CALL WrScr( ' WARNING: '//msg ) + END SUBROUTINE check_wavefield_grid + + SUBROUTINE check_current_field_grid( inst_e, wf, t_sample ) + !! A dynamically populated current field (an InflowWind-driven MHK current, hasCurrField) is + !! not read on the SeaState grid: InflowWind reads it on its own field at the node position + !! shifted up by the water depth (the field's z = 0 is the seabed). For a gridded (Grid3D) + !! field, warn once when submerged sampling nodes lie outside its vertical extent + !! [GridBase, GridBase + 2 ZHWid] or its lateral half-width YHWid (in the field's frame, + !! rotated about its reference position when the box is rotated), where InflowWind + !! extrapolates or stops. Other field types have no extent to check. + TYPE(CD_OF_Instance), INTENT(INOUT) :: inst_e + TYPE(SeaSt_WaveFieldType), INTENT(IN ) :: wf + REAL(DbKi), INTENT(IN ) :: t_sample + INTEGER(IntKi) :: i, nout + REAL(wp) :: zlo, zhi, yhw, dep, tol, pos(3), rel(3), yw, zw, surface, ez, ey + CHARACTER(1024):: msg + + IF (.NOT. (inst_e%agg%host_current_enabled .AND. wf%hasCurrField)) RETURN + IF (wf%CurrField%FieldType /= Grid3D_FieldType) RETURN + dep = REAL(wf%EffWtrDpth, wp) + zlo = REAL(wf%CurrField%Grid3D%GridBase, wp) + zhi = zlo + 2.0_wp*REAL(wf%CurrField%Grid3D%ZHWid, wp) + yhw = REAL(wf%CurrField%Grid3D%YHWid, wp) + tol = 1.0E-6_wp*MAX(1.0_wp, dep) + nout = 0_IntKi + ez = 0.0_wp + ey = 0.0_wp + DO i = 1, inst_e%nfluid + surface = MIN(inst_e%fx_wl(i), 0.0_wp) + IF (inst_e%fx_xyz(3, i) > MAX(inst_e%fx_wl(i), surface)) CYCLE + pos = [inst_e%fx_xyz(1, i), inst_e%fx_xyz(2, i), inst_e%fx_xyz(3, i) + dep] + IF (wf%CurrField%RotateWindBox) THEN + rel = MATMUL(REAL(wf%CurrField%RotToWind, wp), pos - REAL(wf%CurrField%RefPosition, wp)) + & + REAL(wf%CurrField%RefPosition, wp) + ELSE + rel = pos + END IF + yw = rel(2) + zw = rel(3) + IF (zw < zlo - tol .OR. zw > zhi + tol .OR. ABS(yw) > yhw + tol) THEN + nout = nout + 1_IntKi + ez = MAX(ez, zlo - zw, zw - zhi) + ey = MAX(ey, ABS(yw) - yhw) + END IF + END DO + IF (nout == 0_IntKi) RETURN + inst_e%curr_grid_warned = .TRUE. + WRITE (msg, '(A,I0,A,ES10.3,A,ES10.3,A,ES10.3,A,ES10.3,A,ES10.3,A,ES10.3,A)') & + 'CableDyn mooring module: ', nout, ' submerged CableDyn sampling node(s) lie outside the '// & + 'InflowWind current-field grid at t = ', REAL(t_sample, wp), ' s (warned once): the field covers '// & + 'z = ', zlo, ' to ', zhi, ' m above the seabed and |y| <= ', yhw, ' m; the farthest node is ', & + MAX(ez, 0.0_wp), ' m outside in z and ', MAX(ey, 0.0_wp), & + ' m in y. InflowWind extrapolates or stops there; enlarge the current-field grid to cover the lines.' + CALL WrScr( TRIM(msg) ) + END SUBROUTINE check_current_field_grid + !---------------------------------------------------------------------------------------------------------------------------------- SUBROUTINE CD_CalcOutput( t, u, p, x, xd, z, other, y, m, ErrStat, ErrMsg ) REAL(DbKi) , INTENT(IN ) :: t @@ -3816,6 +4072,8 @@ SUBROUTINE release_instance( k, ErrStat, ErrMsg ) Inst(k)%fx_wl, Inst(k)%fx_pd) Inst(k)%use_extfluid = .FALSE. Inst(k)%nfluid = 0 + Inst(k)%grid_warned = .FALSE. + Inst(k)%curr_grid_warned = .FALSE. ! close the CableDyn-owned committed-step record (flushes the final rows) IF (Inst(k)%native_un > 0) THEN CLOSE (Inst(k)%native_un) diff --git a/tests/test_openfast_aggregate.f90 b/tests/test_openfast_aggregate.f90 index c2a04914..c3a2a6da 100644 --- a/tests/test_openfast_aggregate.f90 +++ b/tests/test_openfast_aggregate.f90 @@ -3687,7 +3687,7 @@ SUBROUTINE case_external_fluid_report() !! they agree; the host fields then act from t = 0 and change the t = 0 channel, while the !! summary keeps the equilibrium value. The OpenFAST shell prints the summary, writes the !! static profile before it seeds the t = 0 fields and labels the t = 0 outputs; in the - !! IEA-15MW JONSWAP example the summary reads 2.43712 MN and the t = 0 FairTen1 2.43621 MN. + !! IEA-15MW JONSWAP example the summary reads 2.43712 MN and the t = 0 FairTen1 2.43752 MN. TYPE(CD_AGG_ModuleType) :: agg REAL(wp), PARAMETER :: DT = 0.05_wp REAL(wp), ALLOCATABLE :: fu(:, :), fud(:, :), wl(:) From d2387ee0b63853995d9897850252cebed0cc24b2 Mon Sep 17 00:00:00 2001 From: Jae Hoon Seo Date: Tue, 20 Oct 2026 07:25:41 +0900 Subject: [PATCH 19/31] feat(dynamics): sub-step EI = 0 steps that turn or snap taut (#25) At coarse steps the snap peaks of tension-only (EI = 0) lines were set by the time step rather than the physics: segments rotating several degrees per step left all-chain snap peaks 10-20 % low and semitaut peaks high, under any scheme. After a line step converges, it is now re-solved from the same committed state in sub-steps along the quintic end-motion boundary when a taut segment turned more than ei0_substep_angle (1 deg; at least 4 sub-steps, at most ei0_substep_max = 16) or a segment snapped from slack to taut above a quarter of the largest start tension at an axial Courant number above 1. ei0_substeps off restores the previous results bit for bit; paper mode (False alpha_force_blend) turns it off. Lines with an active junction DOF of the monolithic body scheme (the default for decks with bodies, rods or Free/Connect points) are not sub-stepped. At dtM = 0.1 s the Lozon all-chain heave peaks move from -14.7 / -17.2 % to -3.8 / -7.7 % of the converged values and the semitaut anchor peaks from +16 / +26 % to within about 4 %; Bergdahl, the snap-load study, the one-hour VolturnUS-S and the L2/L3 parity records are unchanged. The kept dashpot share of a segment slack at the step start is bounded by its own one-step dissipation plus the end share's credit, continuously, with a consistent tangent. The documentation now states that the undamped light-cable reproducer has no converged snap peak (converged finite-EI runs give 0.093 / 0.057 MN) and recommends physical axial damping or finite EI for converged snap peaks. Signed-off-by: Jae Hoon Seo --- ARCHITECTURE.md | 11 +- CHANGELOG.md | 124 +++- VALIDATION.md | 38 +- doc/capi.rst | 6 +- doc/driver_format.md | 3 + doc/modeling.rst | 21 + doc/options.rst | 57 +- doc/theory.rst | 114 +++- doc/troubleshooting.rst | 51 +- examples/cabledyn_options_reference.dat | 4 + python/cabledyn/deck_file.py | 28 + python/tests/test_deck_file.py | 15 + src/CableDyn_DeckDriver.f90 | 91 ++- src/CableDyn_Dynamic.f90 | 79 ++- src/CableDyn_Model.f90 | 624 ++++++++++++++++-- src/CableDyn_OpenFAST_Aggregate.f90 | 18 +- src/CableDyn_System.f90 | 81 ++- src/openfast/CableDyn_OF.f90 | 23 +- tests/test_deck_driver.f90 | 12 + tests/test_ei0_slack_dynamics.f90 | 223 ++++++- tests/test_model.f90 | 334 +++++++++- tests/test_syrope.f90 | 118 +++- validation/experiments/bergdahl/README.md | 8 +- .../experiments/bergdahl/provenance.json | 10 +- .../bergdahl/refinement_summary.csv | 4 +- .../bergdahl/refinement_summary.json | 22 +- 26 files changed, 1961 insertions(+), 158 deletions(-) diff --git a/ARCHITECTURE.md b/ARCHITECTURE.md index e7e2c77a..082923e3 100644 --- a/ARCHITECTURE.md +++ b/ARCHITECTURE.md @@ -193,7 +193,16 @@ The effective tangent is `(1 − α_m)/(β Δt²) M + (1 − α_f) K_q + 1e-14, 30 iterations, 12 backtracks. A non-converged step, or on the Hermite path an under-resolved one, is repeated by internal subdivision (4, 16, … up to `recovery_max_substeps`) along a C² quintic boundary trajectory that ends on the -host time. +host time. On `EI = 0` lines `CD_Step_Model` also re-solves a converged step in +`max(4, ceil(turn/ei0_substep_angle))` sub-steps on the same trajectory when a +taut segment turned by more than `ei0_substep_angle` or a slack segment snapped +taut while the step does not resolve its axial wave (`ei0_substeps auto`, the +default; at most `ei0_substep_max`). It restores the committed kinematics and +constitutive and friction states first (`commit_state_copy`, the one list of +that state in `CableDyn_Model`) and keeps the plain step when a sub-step fails. +The sub-steps of a recovered step, the halves of a line-system step halved by +`CD_Step_System`, and the lines attached to the objects of the monolithic +body/point step are taken as given. ### Bodies, rods, and points diff --git a/CHANGELOG.md b/CHANGELOG.md index ba564c6f..4cd9946e 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -100,10 +100,13 @@ All notable changes to CableDyn are recorded in this file. The format follows step before and after, ten times the largest tension anywhere on the line one step before and after, and the largest tension of the initial state. The first spike of a line is reported as a warning, once per line, and the run summary counts them. The run ends with a note when a - taut segment turned by more than 1° in one step (the mean and standard deviation of the - tension err by about 1 % and more above it; 1.3 % at 2.9° on a heaving chain), and when - segments snapped taut while the axial wave crosses a segment more than once per step, so the - snap peaks are not resolved in time. The standalone driver also prints a note for a dynamic + taut segment turned by more than 1° in one solver step (with `ei0_substeps auto`, see Changed, + 1.1 times the larger of 1° and `ei0_substep_angle`; the sub-steps of a sub-stepped or + recovered step count as steps; the mean and standard deviation of the tension err by about + 1 % and more above it, 1.3 % at 2.9° on a heaving chain, and near 6° per step snap-load peaks + come out 10 to 20 % low with either generalised-α blend), and when segments snapped taut + while the axial wave crosses a segment more than once per solver step, so the snap peaks are + not resolved in time. The standalone driver also prints a note for a dynamic deck with `rhoInf` above 0.95, on the missing numerical dissipation. See the manual's troubleshooting page. - Anchor uplift channels for the drag-anchor check of a catenary mooring (no vertical load at @@ -168,6 +171,92 @@ All notable changes to CableDyn are recorded in this file. The format follows ### Changed +- Tension-only (`EI = 0`) lines resolve fast segment rotation and slack-to-taut snaps by + sub-stepping, on by default (new OPTIONS `ei0_substeps auto|off`, `ei0_substep_angle` + (default 1°) and `ei0_substep_max` (default 16), checked when the line is initialised; the + Python deck reader applies the same rules). A converged step in which a segment that ends it + taut (above 0.1 % of the largest step-start tension) turned by more than + `ei0_substep_angle`, or a segment slack at its start ends it above a quarter of that tension + while the step does not resolve the axial wave over it (the wave crosses the segment more + than once per step), is solved again from the same committed state in + `max(4, ceil(turn/angle))` equal sub-steps, at most `ei0_substep_max`, with the end motion on + the quintic of the recovering step and the last sub-step on the given end state; output and + coupling times are unchanged. The tensions are those of the run audit (the elastic tension, + or that of the viscoelastic or Syrope law), and the step-start tension is taken as at least + 0.1 % of the line's initial tension, so a line slack all over does not count barely taut + segments. At `dtM` 0.1 s a taut segment of the Lozon 80 m + all-chain mooring turns by up to 6° per step in 5 m / 7 s heave, and the snap-load peaks of + both generalised-α blends came out 10 to 20 % low. The release cap was not the cause: it acts + in 0.3 % of the element steps, never within 0.5 s of a peak, and the cycle maxima with and + without it agree to within 1 %; the peaks followed the algorithmic damping (28 and 31 % low at + `rhoInf` 0, 10 and 40 % high at 0.6). Over seven runs whose amplitude differs by up to 3e-4, + against 0.5 and 0.25 ms runs, the fairlead and anchor maxima move from 15 and 17 % low to 4 and + 8 % low (the configuration blend of 0.1.1 gave 10 and 18 % low), and the anchor maxima of + the 200 m semitaut mooring in 10 m / 14 s and 5 m / 7 s surge from 16 and 26 % high to 4 % + high and 2 % low (over thirteen runs 5 % high and 0.3 % low, single runs from 4 % low to + 21 % high). A single run at that step varies by 15 to 20 points, so a single comparison + can make either blend look accurate. The decision depends only on the committed state, the + step inputs and the line's initial tension, so restarts repeat it; when a sub-step does not + converge the plain step's own result is kept, and a step recovered after a stall or a half + of a line-system step halved after a failure takes its sub-steps as given (when the halves + fail too, the full step is re-run as the nominal step, sub-steps included). It applies on + every route that steps `EI = 0` lines (standalone lines and line systems, OpenFAST, + FAST.Farm and the C API, whose raw lines always take it) except the lines attached to the + bodies, rods and points of the monolithic body and point coupling, which needs the end + reaction and tangent of the nominal step. `monolithic bodyScheme` is the default of every + standalone deck with `Rigid6` bodies, `Point3` buoys, rods or `Free`/`Connect` points on + `EI = 0` lines, so those lines are not sub-stepped there: 7 of the 21 shipped `EI = 0` + dynamic example decks run this way, and none of them notes an unresolved segment turn. A + line of such a deck whose ends are all fixed or anchored is sub-stepped, `staggered + bodyScheme` sub-steps them all, and the standalone driver notes the exclusion once per run. + `False alpha_force_blend` (paper mode) turns it off unless the deck sets it, so the paper + reproduction is unchanged. A step that triggers costs its plain step and usually four + sub-steps, at most the plain step and three passes of `ei0_substep_max` sub-steps (49 line + solves at the default), and that once for every sub-step where bodies or rods sub-cycle the + lines (`staggered bodyScheme`, coupled runs); the OpenMP loop over the lines of a system + hands them out dynamically, which leaves every line's result unchanged. The standalone + driver reports the sub-stepped steps per line ("solved N of the M line step(s) it + examined"), OpenFAST and FAST.Farm print the counts (steps sub-stepped, largest count, steps + that needed more than `ei0_substep_max`, steps that kept the plain step) at the end of the + run, and `CD_AGG_Get_Substep_Counts` returns them to an aggregate host as 64-bit integers. + Only committed steps count: a step rolled back and taken again (a line-system halving, a + stall recovery, a corrector or a junction iteration) counts once. Over the shipped examples + 19 of the 21 `EI = 0` dynamic decks are unchanged bit for bit; in the two `als_volturnus` + line-break decks the pre-failure anchor snap at 250 s, a single-step peak at `dtM` 0.05 s, + moves from 2.145 to 1.918 MN (1.963 MN converged) and from 2.262 to 2.158 MN (2.334 MN + converged), with the other tension statistics within 0.02 %. The 20-run Lozon mooring + envelope at `dtM` 0.1 s takes 1.67 times as long (1.6 to 2.5 times on the 5 m / 7 s and + 10 m / 14 s motions; the steps that do not trigger cost only the measurement), and the + examples whose steps never trigger run as before. Of the reproducers of the force-blend + entry below, the semi-taut chain–polyester leg in 15 m surge now peaks at 4.65 MN at the + anchor at `dtM` 0.05 s (5.74 MN before, 4.6 MN at 0.0025 s), the Syrope line at 1.81 MN + (1.64 MN before, 1.78 MN at 1 and 2.5 ms), the lightly damped viscoelastic light cable at + 0.062 MN at the anchor (0.085 MN before, 0.082 to 0.095 MN at 0.5 to 2.5 ms; its snap is not + resolved at 0.1 s, and over seven runs whose amplitude differs by up to 3e-4 it peaks at + 0.056 to 0.079 MN with the sub-steps and 0.056 to 0.085 MN without) and the shipped + viscoelastic polyester at 1.80 MN as before (in its steps recovered after a stall, taken as + given, a segment now turns by up to 2.0° per solver step, which the run notes); the light + cable stays at 0.092 / 0.106 MN at `dtM` 0.1 s and its largest segment tension at `dtM` + 0.01 s moves from 0.107 to 0.095 MN. Its fairlead and anchor peaks at `dtM` 2.5 ms move from + 0.099 / 0.091 to 0.102 / 0.119 MN, and on the stiff seabed at `dtM` 0.05 s from 0.52 / 0.67 + to 0.62 / 0.86 MN. None of these is a converged peak: the undamped `EI = 0` cable has no + converged snap peak (see the force-blend entry below; converged finite-EI runs give 0.093 / + 0.057 MN). At a step that does not resolve the axial wave the sub-steps resolve more of the + segment rattle of this undamped cable and can raise isolated spikes, as its anchor peak at + 2.5 ms shows. At `dtM` 0.5 ms, where the step resolves the wave, the cable takes no sub-step, + with or without physical axial damping (`BA` 5.06e5 N·s), and its results equal those taken + as given bit for bit; without the axial-wave condition on the snap trigger `auto` sub-stepped + 8081 of the 60000 steps of that run and raised its anchor peak from 0.116 to 0.52 MN. `ei0_substep_max` and `ei0_substep_angle` do not change these runs. Validation: + the Bergdahl matrix at its 0.3125 ms step resolves the axial wave over a segment and takes no + sub-step, so its maxima are unchanged bit for bit (RMSE 1.58 N, MAPE 3.13 %, Pearson 0.993, + Lin concordance 0.989); of its refinement runs the 0.1 m mesh moves the T = 1.25 s mean + cycle maximum from 68.33 to 68.35 N (largest mesh-halving change 0.52 % to 0.56 %) and the + 0.625 ms step from 72.2 to 69.5 N. The WD0050/A2 cell of the L2-2 parity moves within its + recorded range (largest OrcaFlex summary difference 0.091 to 0.093, MoorDyn-C metric 0.078 + to 0.076); the other L2-2 cells, the one-hour VolturnUS-S record, the L3-2 regular-wave + comparison and the snap-load verification are unchanged bit for bit (the latter two step + the generalised-α kernel directly). `off ei0_substeps` gives the previous results bit for + bit. - Finite-EI node tension, curvature and bend moment are recovered from nodal equilibrium. The `TenN`, `CurvN` and `BendMomN` channels, the `Tension`, `Curvature` and `BendMoment` columns of the static profile and the range graph, and the `.t.out` segment @@ -368,8 +457,9 @@ All notable changes to CableDyn are recorded in this file. The format follows work to the motion than its strain energy. Both happened silently at the default `rhoInf = 0.4`, at every `dtM` from 0.002 to 0.2 s, on realistic input: a light, axially stiff cable (80 kg/m, EA 8e8 N) under 3 m heave reported 4.2 MN at the fairlead and 3.4 MN at the - anchor (`dtM` 0.0025 s) and 20 MN at the anchor (`dtM` 0.1 s), against 0.1 to 0.18 MN at - `rhoInf = 0`, at `dtM` down to 0.25 ms and with a finite-EI model; the same cable in an `Hs` + anchor (`dtM` 0.0025 s) and 20 MN at the anchor (`dtM` 0.1 s), where converged finite-EI + runs of the same cable give 0.093 MN at the fairlead and 0.057 MN at the anchor; the same + cable in an `Hs` 8 m JONSWAP sea 0.41 MN at the anchor against 0.043 MN; the shipped viscoelastic polyester in 15 m surge 2.69 MN against 1.80 MN; a semi-taut chain–polyester leg 9.5 MN at the anchor against 4.6 MN; and a line on a stiff seabed failed the plausibility guard. The step now blends @@ -393,10 +483,21 @@ All notable changes to CableDyn are recorded in this file. The format follows the dashpot's end share, so that the whole blend of a segment ending slack returns at most its strain energy unless that end share alone returns more (in the test chain it returned up to 2750 times that with only the elastic share capped); a damped segment that ends taut beyond - that band keeps the plain force blend. The seabed contact of + that band keeps the plain force blend. A damped segment slack at the step start keeps its + step-start dashpot force under a cap too, so that this kept share returns at most the + dashpot's own one-step dissipation `T_d,n |l̇_n| Δt` plus the end share's credit (up to 46 + times that in the test chain before). The seabed contact of a node that lifts off within a step is not capped (see the manual's theory page). At the - default `rhoInf` the reproducers now give 0.10 / 0.09 MN, 0.092 / 0.106 MN, 0.075 / 0.043 MN - and 1.80 MN, as their references, and the stiff-seabed line runs to completion; the + default `rhoInf` the light cable now peaks at 0.10 / 0.09 MN at `dtM` 0.0025 s and at 0.092 / + 0.106 MN at 0.1 s, the same cable in the JONSWAP sea at 0.075 / 0.043 MN and the + viscoelastic polyester at 1.80 MN, as at 0.0025 s; the stiff-seabed line runs to completion. + The light-cable figures are not converged peaks. The undamped `EI = 0` deck has no converged + snap peak: the peak rises as `dtM` falls (0.32 to 0.46 MN at microsecond steps, also with an + explicit lumped-mass solver), as single segments rattle, and falls with mesh refinement at a + fixed `dtM`; its 20 ms averages converge to 0.083 / 0.047 MN, the slack-to-taut event, and + converged finite-EI runs give 0.093 MN at the fairlead and 0.057 MN at the anchor. On the + stiff seabed the `EI = 0` peak does not converge either (0.74 to 0.95 MN at coarse steps, + 1.2 to 1.4 MN at 0.025 to 0.05 ms). The chain–polyester anchor snap peaks at 5.7 MN at `dtM` 0.05 s, a single-step peak (4.6 MN at 0.0025 s) that the new snap note reports. On a linear element the scheme is unchanged, so taut lines keep their accuracy: every MoorDyn-C, OrcaFlex, analytic and experimental comparison that @@ -410,7 +511,10 @@ All notable changes to CableDyn are recorded in this file. The format follows `EI = 0` dynamic decks (one more force evaluation per step and about 4 % more Newton iterations). `False alpha_force_blend`, which until now applied to finite-EI lines only, selects the former scheme for `EI = 0` lines as well. Lines that the C API builds without a - deck (`CableDyn_InitLine`, `CableDyn_InitLines`) always take the force blend. + deck (`CableDyn_InitLine`, `CableDyn_InitLines`) always take the force blend. The figures + of this entry take every step as given, as `off ei0_substeps` now does; the rotation- and + snap-resolved sub-steps of the default (under Changed) move the snap peaks among them, for + example the chain–polyester anchor to 4.65 MN and the viscoelastic light cable to 0.062 MN. - `modified_newton` on `EI = 0` lines (with or without the force blend, so also under `False alpha_force_blend`) rebuilds the tangent when an iterate reduces the residual by less than a factor four, as the manual states; it had kept the first tangent for the whole step, diff --git a/VALIDATION.md b/VALIDATION.md index 7d7ce2b9..3626f377 100644 --- a/VALIDATION.md +++ b/VALIDATION.md @@ -259,7 +259,8 @@ initialisation. mean, 0.26% in std, 0.50 / 0.43% in minimum / maximum, and 0.27% (90 s) / 1.14% (12 s) in Fourier amplitude**. The end-element tension carries the 1.28% static offset of L2-V in its mean and extremes. The force-blended `EI = 0` step moved the - minimum by +7 kN (0.15% before) and the other statistics by at most 0.01%. + minimum by +7 kN (0.15% before) and the other statistics by at most 0.01%; no step of this + drive needs the rotation- and snap-resolved sub-steps, so they leave it unchanged bit for bit. - **L-fig curvature overlay**: `l3_lazywave_dynamic` writes each site's along-arc curvature profile. [`validation/scripts/curvature_profile_overlay.py`](https://github.com/SMI-Lab-Inha/CableDyn/blob/main/validation/scripts/curvature_profile_overlay.py) @@ -291,12 +292,16 @@ scripts, results, and source provenance are in has RMSE 1.58 N, mean absolute percentage error 3.13%, Pearson correlation 0.993, and Lin concordance 0.989. Two phase-averaged measured histories have waveform RMSEs of 5.95% and 2.54% of their force ranges; these two were computed with the - executable of the 2026-10-09 record (the configuration-blended `EI = 0` step), because the + executable of the 2026-10-09 record (the configuration-blended `EI = 0` step, without + sub-steps), because the article supplement's `expData.dat` they need was not available for the rerun (see the experiment's README and `provenance.json`). Halving the mesh length - and the time step changes the mean cycle maximum by at most 0.52% and 0.19%. The - 0.3125 ms step resolves the segment axial modes that the snap loads excite; at - 1.25 ms the maxima are 2–15% higher and vary from cycle to cycle. + and the time step changes the mean cycle maximum by at most 0.56% and 0.19%. The + 0.3125 ms step resolves the segment axial modes that the snap loads excite (and the axial + wave over a segment, so the matrix takes no rotation- and snap-resolved sub-step and equals + the run taken as given bit for bit); at + 0.625 ms the T = 1.25 s maxima are 2.4% higher (6.5% with every step taken as given), and + at 1.25 ms they are 2–15% higher and vary from cycle to cycle. ## L4 coupled OpenFAST @@ -380,6 +385,17 @@ scripts, results, and source provenance are in 30 ms in a sweep); the peak is within **1.5%** of the 0.5 ms sub-CFL reference (1.1% at 10 ms, 0.05% at 5 ms). Before the force-blended `EI = 0` step these were 2.76 / 0.62 / 0.16%; the 2.76% at 20 ms is the value published as 2.7% (truncated). + The test steps the generalised-α kernel itself, without the rotation- and snap-resolved + sub-steps of the line models (next item). +- **Snap-load peaks at a coarse step** (Lozon moorings, `dtM = 0.1 s`): over seven runs whose + motion amplitude differs by up to 3e-4 (the snap peaks of a single run vary by 15–20 + points at this step), against 0.5 and 0.25 ms runs, the fairlead and anchor maxima of the + 80 m all-chain mooring in 5 m / 7 s heave are 15% and 17% low when every step is taken as + given (`off ei0_substeps`) and 4% and 8% low with the default `auto`; the anchor maxima of + the 200 m semitaut mooring in 10 m / 14 s and 5 m / 7 s surge are 16% and 26% high and + 4% high and 2% low (over thirteen runs 5% high and 0.3% low; single runs from 4% low to 21% + high). In 5 m / 7 s surge the 80 m maxima are within 2.5% either way. On the + 0.1 s output grid the converged run itself reads the 80 m heave maxima 5% low. - **Implicit and explicit steps**: on the matched near-taut snap, MoorDyn-C's explicit RK2 needs `dtM ≲ 1 ms`, as expected of an explicit scheme at this line stiffness; CableDyn's implicit step remains stable at **20 ms**. @@ -673,10 +689,14 @@ feedback re-converge each step (three-seed DLC-1.1, L4-1b, <0.6%). **Prescribed-motion moorings.** The Lozon all-chain catenary and semitaut chain–polyester moorings are driven through the same surge-and-heave envelope at -`dtM = 0.1 s`. The all-chain mooring needs no step subdivision and takes 0.7–1.1 ms -of wall time per 0.1 s step with at most 16 Newton iterations; the stiffer composite -subdivides about 1.4% of steps at the severe and extreme excursions and takes less -than 3.3 ms per step. +`dtM = 0.1 s` (72 s each). All 20 runs complete. With the default `ei0_substeps auto`, +the steps in which a taut segment turns by more than 1° or a segment snaps taut are +solved in 4 to 7 sub-steps: none to 3% of the steps in the 3 m / 10 s and 8 m / 20 s +motions, 31–75% in the 5 m / 7 s and 10 m / 14 s ones. The march takes 0.24–0.94 ms of +wall time per 0.1 s step for the all-chain mooring and 0.32–1.2 ms for the composite, +1.67 times the plain steps over the 20 runs (1.6 to 2.5 times on the 5 m / 7 s and +10 m / 14 s motions), and the recovering step +subdivides at most 12 of the 720 intervals of a run. **Coupled OpenFAST sea states.** In the full IEA-15 MW VolturnUS-S model with SeaState JONSWAP waves, the all-chain mooring completes `Hs = 10 m`, `Tp = 14 s` diff --git a/doc/capi.rst b/doc/capi.rst index 19c90a50..c0cafceb 100644 --- a/doc/capi.rst +++ b/doc/capi.rst @@ -1048,8 +1048,10 @@ The Newton settings are fixed at their defaults: relative residual tolerance :math:`10^{-8}`, at most 30 iterations per step, and at most 12 line-search backtracks. So is the generalised-α scheme: these lines always take the force-blended step (``alpha_force_blend`` ``True``, with the release cap on a tension-only line, -:doc:`theory`). They cannot select the configuration blend of 0.1.1 and earlier -(``False alpha_force_blend``), which only a deck sets, through ``CableDyn_InitDeck``. +:doc:`theory`), with the rotation- and snap-resolved sub-steps of ``ei0_substeps auto`` at +their default settings (:doc:`options`). They cannot select the configuration blend of 0.1.1 +and earlier (``False alpha_force_blend``) or ``off ei0_substeps``, which only a deck sets, +through ``CableDyn_InitDeck``. ``CableDyn_InitLines`` ~~~~~~~~~~~~~~~~~~~~~~ diff --git a/doc/driver_format.md b/doc/driver_format.md index e934d6cb..83c23521 100644 --- a/doc/driver_format.md +++ b/doc/driver_format.md @@ -1026,6 +1026,9 @@ syntax form. The most frequently edited keywords are: | `tensile_safety` | `False`, `warn`, or `True`; audits the element-mean axial force (three-point Gauss mean of the signed axial resultant, averaged over an element and its two neighbours). `True` rejects. `warn` commits the state, counts accepted-step events, and reports the worst force, threshold, element and time (the printed `xi` is always 0.5, the element centre) | `False` | | `tensile_strain_tolerance` | non-negative strain band for the dynamic tensile audit | `2e-6` | | `recovery_max_substeps` | integer from 4 to 65536; maximum step subdivision for dynamic-step recovery on tension-only and bending lines. Internal prescribed states lie on one C2 quintic trajectory and land on the nominal coupling endpoint. The standalone summary reports recovered intervals and the largest subdivision used | `1024` | +| `ei0_substeps` | `auto` or `off`. `auto` solves a converged `EI = 0` step again in `max(4, ceil(turn/ei0_substep_angle))` equal sub-steps (at most `ei0_substep_max`) when a segment that ends it taut turned by more than `ei0_substep_angle`, or a segment slack at its start ends it above a quarter of the largest step-start tension while the step does not resolve the axial wave over it; the end motion follows the C2 quintic of the recovering step, and output and coupling times are unchanged. `off` takes every step as given. The lines attached to the bodies, rods and points of the monolithic body and point coupling (the default `bodyScheme` of decks with them) are not sub-stepped | `auto` (`off` with `False alpha_force_blend`) | +| `ei0_substep_angle` | real in (0, 90], deg; largest taut-segment turn per step before `auto` sub-steps it | `1.0` | +| `ei0_substep_max` | integer from 2 to 1024; most sub-steps `auto` takes for one step | `16` | | `axial_quadrature_order` | Gauss order 1–6 for the finite-EI axial energy; a value different from the bending order gives selective integration | `4` | | `bending_quadrature_order` | Gauss order 1–6 for the finite-EI curvature energy | `4` | | `dynamic_solver rel abs max_iter backtracks [rhoInf]` | dynamic Newton controls; keyword-first syntax, unlike scalar rows. `EI = 0` solves use all four; standalone finite-EI decks use `rel` and `max_iter` (coupled cables: see the OPTIONS reference). Choose them for the mesh and load case; the 952-element Gulf of Maine example uses `1e-4 1e-14 100 12` | `1e-8 1e-14 30 12` | diff --git a/doc/modeling.rst b/doc/modeling.rst index 2ce56278..45bc5616 100644 --- a/doc/modeling.rst +++ b/doc/modeling.rst @@ -140,6 +140,27 @@ only because its stability limit forces a step of that size; the implicit solver (Orcina) shows a similar plateau (about 0.5 %). When snap-tension histories matter, use the coarsest mesh that resolves the line shape and refine ``dtM`` toward :math:`l/(2c)`, rather than refining both. +At a much coarser ``dtM`` the step no longer resolves the rotation of the line during a snap, +and the peaks follow the algorithmic damping (10 to 20 % low at 6° of segment turn per step). +By default (``ei0_substeps auto``) such steps of an ``EI = 0`` line are solved in sub-steps, +which brings the Lozon mooring snap peaks at ``dtM = 0.1 s`` within 8 % on average; single +peaks at that step still vary by 15 to 20 points with tiny changes of the motion, so compare +ensembles or refine ``dtM`` before drawing conclusions from one peak. The driver reports the +sub-stepped steps per line and notes a turn per step it did not resolve (see +:doc:`options`, ``ei0_substeps``). + +The snap peaks of an undamped tension-only line do not converge in time or mesh: its single +segments rattle against the stiff axial spring, and the peak rises as ``dtM`` falls. On a light, +axially stiff cable (80 kg/m, EA 8e8 N, 2 m segments) in 3 m heave it rises from about 0.1 MN at +``dtM = 2.5 ms`` to 0.32 to 0.46 MN at microsecond steps, also with an explicit lumped-mass +solver, while converged finite-EI runs give 0.093 MN at the fairlead and 0.057 MN at the anchor. +To obtain converged peaks, give such lines physical axial damping, ``BA`` as a material +property in N·s (the negative, per-segment damping-ratio form changes with the mesh: it halves +with each halving of the segment length), or model them with finite ``EI``. With ``BA = 0`` and +a ``dtM`` that does not resolve the axial wave over a segment, the sub-steps of +``ei0_substeps auto`` resolve more of the segment rattle and can raise isolated spikes (at +``dtM = 2.5 ms`` the anchor peak of that cable rises from 0.091 to 0.119 MN); at a ``dtM`` that +resolves the wave a snap does not trigger them, and at 0.5 ms the cable takes no sub-step. 6. Establish the static initial condition ----------------------------------------- diff --git a/doc/options.rst b/doc/options.rst index d573b6e4..f01f4ee6 100644 --- a/doc/options.rst +++ b/doc/options.rst @@ -353,6 +353,57 @@ rejected as unknown. The dynamic Newton controls are set with ``dynamic_solver`` recovered intervals and the largest subdivision count used - both - ``1024 recovery_max_substeps`` + * - ``ei0_substeps`` / ``ei0substeps`` + - word + - ``auto``; ``off`` with ``False alpha_force_blend`` + - ``auto`` or ``off``. ``auto``: a converged step of an ``EI = 0`` line in which a segment + that ends the step taut (above 0.1 % of the largest step-start tension) turned by more + than ``ei0_substep_angle``, or a segment slack at the start of the step ended it above a + quarter of the largest step-start tension while the step does not resolve the axial wave + over the segment (the wave crosses it more than once per step), is solved again from the + same committed state in ``max(4, ceil(turn/ei0_substep_angle))`` equal sub-steps (at most + ``ei0_substep_max``). The tensions are those of the run audit (the elastic tension, or that + of the viscoelastic or Syrope law), and the step-start tension is taken as at least 0.1 % + of the line's initial tension, so a line slack all over at the step start does not count + barely taut segments. The end motion inside the step follows + the C2 quintic of the recovering step and the last sub-step lands on the given end state; + the output and coupling times are unchanged. At ``dtM = 0.1`` s a taut segment of the + Lozon 80 m all-chain mooring turns by up to 6 deg per step in 5 m / 7 s heave, and both + generalised-α blends then give snap-load peaks 10 to 20 % low; with ``auto`` they are 4 % + and 8 % low on average, within 4 % of the converged run sampled at the same 0.1 s output + times, at 1.6 to 2.5 times the wall time of the plain steps on the 5 m / 7 s and + 10 m / 14 s motions (1.67 times over the 20-case Lozon mooring envelope). A step that + triggers costs its plain step and usually four sub-steps, at most the plain step and + three passes of ``ei0_substep_max`` sub-steps (49 line solves at the default) when the + sub-stepped interval is measured again and that pass fails; where bodies or rods + sub-cycle the lines ``n`` times per ``dtM`` (``staggered bodyScheme``, coupled runs), + each sub-cycle is such a step, so the worst case is ``n (1 + 3 ei0_substep_max)`` line + solves per ``dtM``. If a sub-step does not converge, the plain step's own result is + kept. ``off`` takes every step as given, as before this option. ``monolithic + bodyScheme`` is the default of every standalone deck with ``Rigid6`` bodies, ``Point3`` + buoys, rods or ``Free``/``Connect`` points on ``EI = 0`` lines (7 of the shipped example + decks): its junction Newton needs the end reaction and tangent of the whole step, so the + lines attached to those objects and points are not sub-stepped (a line whose ends are all + fixed or anchored is), and the driver notes it once per run; ``staggered bodyScheme`` + sub-steps them. The standalone driver reports the sub-stepped steps per line, and + OpenFAST and FAST.Farm runs report them at the end of the run. The settings are checked + when the line is initialised. See :doc:`theory` + - both (``EI = 0`` lines) + - ``off ei0_substeps`` + * - ``ei0_substep_angle`` / ``ei0substepangle`` + - real, deg + - ``1.0`` + - finite, in ``(0, 90]``. Largest chord turn of a taut segment in one step before + ``ei0_substeps auto`` sub-steps it + - both (``EI = 0`` lines) + - ``1.0 ei0_substep_angle`` + * - ``ei0_substep_max`` / ``ei0substepmax`` + - integer, – + - ``16`` + - integer from 2 to 1024. Most sub-steps ``ei0_substeps auto`` takes for one step; a step + whose turn needs more is solved in this many, and the run notes it + - both (``EI = 0`` lines) + - ``16 ei0_substep_max`` Finite-EI cable controls ------------------------ @@ -389,7 +440,8 @@ Finite-EI cable controls earlier. On ``EI = 0`` lines ``False`` lets a segment that turns taut within a step carry the stretch extrapolated past the blended state, and lets a release create energy: on a light, axially stiff cable (80 kg/m, EA 8e8 N) under 3 m heave the fairlead peaks at - 4.2 MN against 0.10 MN with ``True`` (see :doc:`theory`). On finite-EI lines the blended + 4.2 MN against 0.10 MN with ``True`` at ``dtM = 2.5`` ms (converged finite-EI runs give + 0.093 MN; see :doc:`theory`). On finite-EI lines the blended tangent vectors are shortened while the line rotates and raise the mean tension at large ``dtM``: on the Lozon Gulf of Mexico 80 m cable in 3 m surge the mean hang-off tension is 12511 / 10097 / 9507 / 9360 N at @@ -398,7 +450,8 @@ Finite-EI cable controls (``True``) or 0.1 deg (``False``) in one step. A dynamic run with a torsional line (``END CONNECTIONS`` ``TorsStiffness`` at both ends) needs ``True``. The lines the raw C API builds without a deck (``CableDyn_InitLine``, ``CableDyn_InitLines``) always use - ``True``: their only integrator setting is ``rho_inf`` (:doc:`capi`) + ``True``: their only integrator setting is ``rho_inf`` (:doc:`capi`). ``False`` also + turns ``ei0_substeps`` off unless the deck sets it - standalone and coupled (finite-EI and ``EI = 0`` lines) - ``False alpha_force_blend`` * - ``cable_statics`` / ``cablestatics`` diff --git a/doc/theory.rst b/doc/theory.rst index 2a61acce..eb199e87 100644 --- a/doc/theory.rst +++ b/doc/theory.rst @@ -1487,14 +1487,19 @@ difference (:math:`\partial p/\partial \mathbf{d}_{n+1} = -\mathbf{t}_n`). With state crosses the rest length, so the residual stays continuous in :math:`\mathbf{q}_{n+1}`. A cap on the slack end states alone would jump there, by up to :math:`\alpha_f T_n` for a turned element. The cap does not act on an element that ends above :math:`\alpha_f/(1 - \alpha_f)\,T_n` -(0.4 :math:`T_n`), nor on one that keeps its direction and ends taut, nor on one slack at -:math:`t_n`: those elements, every element going taut (where the force blend dissipates), and +(0.4 :math:`T_n`), nor on one that keeps its direction and ends taut, nor (but for the share of +its dashpot, below) on one slack at :math:`t_n`: those elements, every element going taut (where the force blend dissipates), and every line that allows compression keep the force blend. In the slack-cable case above the internal forces created 2.7e8 J over 20 s with the configuration blend, 6.7e7 J with the force blend alone, 0.19 J with a cap on :math:`e_n - e_{n+1}` (the turn of the releasing segments) and -4e-4 J (round-off) with the projected cap. The fairlead peak is 0.10 MN. The snap is not -resolved in time: with the cap the peak ranges from 0.10 to 0.18 MN over :math:`\Delta t` from -2.5 to 0.25 ms, against 0.13 to 0.19 MN at :math:`\rho_\infty = 0`. For a linear element the +4e-4 J (round-off) with the projected cap. The fairlead peak is 0.10 MN at +:math:`\Delta t` = 2.5 ms, which is not a converged peak. The undamped ``EI = 0`` deck has no +converged snap peak: the peak rises as :math:`\Delta t` falls (0.32 to 0.46 MN at microsecond +steps, also with an explicit lumped-mass solver), as single segments rattle, and falls with +mesh refinement at a fixed step; its 20 ms averages converge to 0.083 MN at the fairlead and +0.047 MN at the anchor, the slack-to-taut event, and converged finite-EI runs give 0.093 MN at +the fairlead and 0.057 MN at the anchor (see :doc:`modeling`, snap loads on slack lines). For +a linear element the force blend and the cap reduce to the configuration blend, so the linear spectral properties and the second-order accuracy are unchanged. @@ -1524,7 +1529,11 @@ segments (the snap is not resolved at that step, so the peak depends on round-of compilers and platforms give other values) and at 0.145 MN without it, against 0.082 to 0.095 MN at :math:`\Delta t` from 0.5 to 2.5 ms. A taut Syrope line in 4 m surge that goes slack peaks at 1.64 MN at 0.1 s, against 1.78 MN at 1 and 2.5 ms, with or -without the cap. +without the cap. These figures take every step as given (``off ei0_substeps``); with the +rotation- and snap-resolved sub-steps of the default (below) the two lines peak at 0.062 MN and +1.81 MN. A single peak of an unresolved snap says little: over seven runs whose heave amplitude +differs by up to :math:`3\times10^{-4}` the viscoelastic anchor peaks at 0.056 to 0.079 MN +(mean 0.063 MN) with the sub-steps and at 0.056 to 0.085 MN (mean 0.065 MN) without them. An elastic segment with axial damping (``BA``) also keeps :math:`\alpha_f T_{d,n}` along :math:`\mathbf{t}_n`, :math:`T_{d,n}` the tension of its dashpot at :math:`t_n`. A segment that @@ -1554,6 +1563,26 @@ so the force-blended dashpot of a taut segment keeps the standard generalised-α which a linear dashpot is dissipative; :math:`\phi` is continuous, and so is the capped force. The viscoelastic law keeps its total tension, dashpots included, as :math:`T_n` (above). +A damped segment slack at :math:`t_n` (:math:`T_n = 0`, :math:`e_n \le 0`) whose ends separate +there keeps :math:`\alpha_f T_{d,n}` along :math:`\mathbf{t}_n` with no strain energy behind it, +and returns :math:`\alpha_f T_{d,n} p` when the step turns or reverses its ends. It has no +:math:`W_n` (and an empty band, :math:`\phi = 1`); its budget is the dashpot's own one-step +dissipation :math:`W_d = T_{d,n}\,|\dot l_n|\,\Delta t`, :math:`\dot l_n` the dashpot's +elongation rate at :math:`t_n` (the axial rate, less :math:`l_n \dot l_0/l_0` while the line +pays out), so that :math:`T_{d,n} = (BA/l_0)\,\dot l_n` and :math:`W_d > 0` whenever +:math:`T_{d,n} \ne 0`. When :math:`p > 0` the kept force :math:`\alpha_f T_{d,n}` is replaced by +:math:`(W_d + N_d)/p` when that is smaller, with the end share's credit +:math:`N_d = \max((1 - \alpha_f) T_{d,n+1} p_{n+1}, 0)`, and the tangent takes the difference as +above (a compressive :math:`T_{d,n}` is capped alike when :math:`p < 0`). The kept dashpot share +of an element slack at the step start returns at most its own one-step dissipation +:math:`T_{d,n} |\dot l_n| \Delta t` plus the end share's credit. The capped force grows without +bound as :math:`p \to 0^+`, so it is continuous there; it acts only where +:math:`\alpha_f |p| > |\dot l_n| \Delta t`, a turn or reversal well beyond the step-start motion +whose end share does little work (a reversal along the chord feeds the end share's dashpot, +whose credit covers it). In the test chain the kept share returned up to 46 times +:math:`W_d + N_d` before the cap covered slack starts. Taut-start and undamped segments are +unchanged. + The one-sided seabed contact is not capped. A node that leaves the floor within a step keeps :math:`\alpha_f` of its step-start contact force :math:`N_n` for the whole step: over a lift-off distance :math:`d` it returns at most :math:`\alpha_f N_n d` to the motion, against the energy @@ -1654,6 +1683,62 @@ the interval-start and target position, velocity, and acceleration. If the halve complete the interval, the interval-start state is restored and the full step is re-run, so no partly subdivided state is ever committed. +**Rotation- and snap-resolved sub-steps** (``ei0_substeps auto``, the default). A converged +``EI = 0`` step is measured against its committed start: the largest chord turn +:math:`\theta` of a segment that ends the step above :math:`10^{-3}\,T_\text{max}`, the +largest step-start tension, and whether a segment slack at the start ends above +:math:`T_\text{max}/4` while the axial wave crosses it more than once in the step +(:math:`\Delta t\,c/l_0 > 1`, :math:`c` from the dynamic axial stiffness as in the run audit +below); a step that resolves the axial wave resolves the snap as given. The tensions are those +the run audit takes, the elastic tension of a plain segment and the law's tension of a +viscoelastic or Syrope one, with the step's unstretched lengths, and :math:`T_\text{max}` is at +least :math:`10^{-3}` of the line's initial tension, so a line slack all over at the step start +does not count barely taut segments. (A floor at the initial tension itself raised the snap +threshold in the slack phases of the Lozon semitaut line below, whose anchor peaks then came +out up to 29 % high.) A +segment slack at the step start counts for the turn: counting only segments taut at both ends +of the step left the Lozon semitaut anchor peaks (below) up to 5 % high on average and up to +25 % high in single runs. When :math:`\theta` exceeds ``ei0_substep_angle`` +:math:`\theta_s` (default 1°), or such a snap occurred, the interval is solved again from the +same committed state, constitutive and friction states included, in +:math:`n = \max(4, \lceil\theta/\theta_s\rceil)` equal sub-steps, at most ``ei0_substep_max`` +(default 16), with the prescribed motion on the quintic trajectory of the recovery above and +the last sub-step on the target state. The trial step under-turns a line whose rotation it does +not resolve, so the sub-stepped interval is measured again; when its turn needs more sub-steps +it is solved once more with them. If a sub-step does not converge, the plain step's own +result is kept. A step recovered after a stall (above) and the halves of a line-system step +halved after a failure take their sub-steps as given; when the halves fail too, the full step +is re-run as the nominal step, sub-steps included. The decision uses only the committed state, +the step inputs and the line's initial tension, so a restart repeats it, and the host time +grid, output and coupling times are unchanged. Every route that steps ``EI = 0`` lines uses it +(standalone lines and line systems, OpenFAST, FAST.Farm and the C API), except the lines +attached to the bodies, rods and points of the monolithic body and point coupling, whose +junction Newton needs the end reaction and condensed end tangent of the nominal step (a line of +such a deck whose ends are all fixed or anchored is sub-stepped); ``off`` takes every step as +given, and ``False alpha_force_blend`` turns it off unless the deck sets it. A step that +triggers costs the plain step and usually four sub-steps; at most it costs the plain step and +three passes of ``ei0_substep_max`` sub-steps, once for each object sub-step where bodies or +rods sub-cycle the lines. + +At ``dtM`` 0.1 s a taut segment of the Lozon 80 m all-chain mooring turns by up to 6° per step +under 5 m / 7 s heave. Over seven runs whose heave amplitude differs by up to +:math:`3\times10^{-4}` (the snap peaks at that step vary by 15 to 20 points from one run to the +next), the fairlead and anchor maxima are then 15 % and 17 % below a 0.25 ms run with the force +blend and 10 % and 18 % below it with the configuration blend; the release cap acts in 0.3 % of +the element steps, never within 0.5 s of a peak, and removing it changes the cycle maxima by less +than 1 %. The peaks follow the algorithmic damping instead: 28 % and 31 % low at +:math:`\rho_\infty = 0`, 10 % and 40 % high at 0.6. With ``auto`` they are 4 % and 8 % low +(1 % high and 4 % low against the reference sampled on the same 0.1 s output grid), and the +anchor maxima of the 200 m semitaut mooring in 10 m / 14 s and 5 m / 7 s surge, 16 % and 26 % +high taken as given, are 4 % high and 2 % low (over thirteen runs 5 % high and 0.3 % low, single +runs from 4 % low to 21 % high). +Two or three sub-steps of a step that turned by 1 to 3° left those anchor peaks 8 % high on +average (up to 22 %); four bring them within 3 %, hence the minimum. Resolving the sub-steps +of a step recovered after a stall as well left them 9 % high, so the recovery takes its sub-steps +as given. Over the 20 motions of the Lozon mooring envelope at ``dtM`` 0.1 s the march takes +1.67 times as long as with plain steps, 1.6 to 2.5 times on the 5 m / 7 s and 10 m / 14 s +motions. + **Step size.** Being implicit, the scheme is not bound by the explicit axial-wave limit. In the snap-load verification a slack line snapping to about 10 MN integrates stably at :math:`\Delta t = 20\,\mathrm{ms}`, well above the explicit limit of 3.2 ms, with the peak @@ -1662,13 +1747,18 @@ response of interest and, for explicitly integrated points and bodies (below), t stability limit. The standalone driver audits every ``EI = 0`` line on the initial state and at each output step, and reports at the end of the run: -- the largest turn of the chord of a taut segment in one step. Above 1 deg it prints a note: - against a 3.125 ms reference on chain catenaries under 5 m heave, 10 m surge and 15 m sway - and on a light laid cable under 10 m sway, the mean and standard deviation of the fairlead - tension err by 0.9 % at 1.2 deg per step (sway, standard deviation), and by 0.6 % at - 1.4 deg and 1.3 % at 2.9 deg (heave, mean), in proportion with the turn; +- the steps ``ei0_substeps auto`` solved in sub-steps, with the largest count, those that needed + more than ``ei0_substep_max``, and those that kept the plain step; +- the largest turn of the chord of a taut segment in one solver step (the sub-steps of a + sub-stepped or recovered step count as steps). Above 1 deg it prints a note (with ``auto`` + above 1.1 times the larger of 1 deg and ``ei0_substep_angle``): against a 3.125 ms reference + on chain catenaries under 5 m heave, 10 m surge and 15 m sway and on a light laid cable under + 10 m sway, the mean and standard deviation of the fairlead tension err by 0.9 % at 1.2 deg per + step (sway, standard deviation), and by 0.6 % at 1.4 deg and 1.3 % at 2.9 deg (heave, mean), + in proportion with the turn, and at about 6 deg per step snap-load peaks come out 10 to 20 % + low (above); - segments that go from slack to taut above the initial tension in one step while the axial - wave crosses a segment more than once per step (:math:`\Delta t\,c/l_0 > 1`, + wave crosses a segment more than once per solver step (:math:`\Delta t\,c/l_0 > 1`, :math:`c = \sqrt{EA/m}` with the dynamic stiffness of the segment, :math:`EA_D` of a viscoelastic segment and :math:`\alpha + \beta T` of a Syrope one): the snap peaks are then not resolved in time, and the note asks for a confirmation at a smaller ``dtM``; diff --git a/doc/troubleshooting.rst b/doc/troubleshooting.rst index 30b6a095..bbe679ab 100644 --- a/doc/troubleshooting.rst +++ b/doc/troubleshooting.rst @@ -571,15 +571,50 @@ Warnings and notes that do not stop a run * - ``Note: line ...: a nodal tangent turned up to ... deg in one step`` - the time-step audit of a finite-EI line: above 0.25° per step (0.1° with ``False alpha_force_blend``) the mean tension can err by about 1 %. Reduce ``dtM``. - * - ``Note: line ...: a taut segment turned up to ... deg in one step`` - - the time-step audit of an ``EI = 0`` line: above 1° per step the mean and standard - deviation of the tension can err by about 1 % (1.3 % at 2.9° on a heaving chain). Reduce - ``dtM`` if that matters for the result. + * - ``Note: line ...: a taut segment turned up to ... deg in one solver step`` + - the time-step audit of an ``EI = 0`` line, per solver step (the sub-steps of a + sub-stepped step count as steps): above 1° per step the mean and standard deviation of + the tension can err by about 1 % (1.3 % at 2.9° on a heaving chain), and near 6° per step + snap-load peaks come out 10 to 20 % low with either generalised-α blend. With + ``off ei0_substeps`` set ``auto`` (the default) or reduce ``dtM``; with ``auto`` the note + means steps it did not resolve (more than ``ei0_substep_max`` needed, a step recovered + after a stall or a half of a line-system step halved after a failure, whose sub-steps + are taken as given, a step that kept its plain result because a sub-step failed, or a + line attached to a body, rod or point of the monolithic body and point coupling, which + is not sub-stepped): reduce ``dtM``. + * - ``Note: line ...: ei0_substeps auto solved ... of the ... line step(s) it examined in sub-steps`` + - information: the steps in which a taut segment turned by more than ``ei0_substep_angle`` + or a segment snapped from slack to taut were solved in sub-steps (see + ``ei0_substeps``). Only committed steps count: a step that is rolled back and taken + again (a line-system step halved after a stall, a step recovered after a stall, a + corrector or a re-solved coupling step) counts once, as it is finally taken, so the + steps examined can be fewer than the line's steps. A companion note counts the steps + that needed more than ``ei0_substep_max`` sub-steps, and another the steps that kept the + plain step's result because a sub-step did not converge. OpenFAST and FAST.Farm print the + same counts, summed over the lines, as ``CableDyn: ei0_substeps auto solved ...`` at the + end of the run. + * - ``Note: ei0_substeps auto does not sub-step the EI = 0 lines attached to the bodies, rods and points of the monolithic body/point step`` + - information, once per run of a deck with ``monolithic bodyScheme`` coupling, the default + of every standalone deck with ``Rigid6`` bodies, ``Point3`` buoys, rods or + ``Free``/``Connect`` points on ``EI = 0`` lines (7 of the shipped example decks): the + lines attached to those objects and points are stepped inside the junction Newton and + taken whole at each monolithic step (``dtM``, divided by ``accuracy bodySubstep``, the + default, to resolve the body-mooring modes), so their rotation and snaps are resolved + only as far as that step resolves them; a line whose ends are all fixed or anchored is + sub-stepped as usual. Reduce ``dtM`` when the segment-turn note above appears for them, + or select ``staggered bodyScheme``, which sub-steps them. * - ``Note: line ...: ... segment step(s) went from slack to taut above the initial tension`` - - snap loads on an ``EI = 0`` line at a ``dtM`` that does not resolve the axial wave over a - segment: the peak is set by a single step (a 15 m surge of a semi-taut chain–polyester - line peaks at 5.7 MN at ``dtM`` 0.05 s against 4.6 MN at 0.0025 s). The run is valid; - confirm design peaks with a smaller ``dtM``. + - snap loads on an ``EI = 0`` line at a solver step that does not resolve the axial wave + over a segment: the peak is set by a single step. A 15 m surge of a semi-taut + chain–polyester line peaks at 4.65 MN at ``dtM`` 0.05 s with the default sub-steps + (5.7 MN with ``off ei0_substeps``) against 4.6 MN at 0.0025 s. The run is valid; confirm + design peaks with a smaller ``dtM``. On a line without axial damping (``BA = 0``) the + snap peaks do not converge in time or mesh, as single segments rattle; a smaller ``dtM`` + raises them, and at a ``dtM`` that does not resolve the axial wave the sub-steps of + ``ei0_substeps auto`` can raise isolated spikes. Give + the line physical axial damping (``BA`` in N·s, not the per-segment damping-ratio form, + which changes with the mesh) or finite ``EI`` to obtain converged peaks (see + :doc:`modeling`). * - ``Warning: line ...: segment ... carried ... N at t = ... s for a single step, ... times the largest tension on the line one step before and after`` - a non-physical tension spike: the tension of one segment (elastic, viscoelastic or diff --git a/examples/cabledyn_options_reference.dat b/examples/cabledyn_options_reference.dat index 2d264baf..dabeaebe 100644 --- a/examples/cabledyn_options_reference.dat +++ b/examples/cabledyn_options_reference.dat @@ -45,6 +45,9 @@ True alpha_force_blend - Generalised-alpha force blend, finite-EI and EI=0 False tensile_safety - Element-mean axial-force audit {False; warn; True=reject} [default: False] 2.0e-6 tensile_strain_tolerance - Dynamic audit strain band [default: 2.0e-6] 1024 recovery_max_substeps - Internal dynamic-step recovery ceiling {4..65536} [default: 1024] +auto ei0_substeps - EI=0 sub-steps for segment rotation and slack-taut snaps {auto; off} [default: auto; off with False alpha_force_blend] +1.0 ei0_substep_angle - Largest taut-segment turn per EI=0 step before sub-stepping (deg) {0 str | None: if value.lower() in {"equilibrium", "element"} else "must be equilibrium or element" ) + if key == "ei0_substeps": + return None if value.lower() in {"auto", "off"} else "must be auto or off" + if key == "ei0_substep_angle": + try: + numeric = _native_float(value) + except ValueError: + return "must lie in (0, 90] deg" + return ( + None if math.isfinite(numeric) and 0.0 < numeric <= 90.0 else "must lie in (0, 90] deg" + ) + if key == "ei0_substep_max": + try: + numeric = _native_float(value) + except ValueError: + return "must be an integer in [2, 1024]" + if not math.isfinite(numeric): + return "must be an integer in [2, 1024]" + nearest = round(numeric) + integer_tolerance = 16.0 * math.ulp(1.0) * max(1.0, abs(numeric)) + if abs(numeric - nearest) > integer_tolerance or not 2 <= nearest <= 1024: + return "must be an integer in [2, 1024]" + return None if key in {"axial_quadrature_order", "bending_quadrature_order"}: try: numeric = _native_float(value) diff --git a/python/tests/test_deck_file.py b/python/tests/test_deck_file.py index 2760d72a..c8c783b6 100644 --- a/python/tests/test_deck_file.py +++ b/python/tests/test_deck_file.py @@ -666,6 +666,14 @@ def test_unknown_scalar_option_keyword_fails_closed(tmp_path): ("maybe", "alpha_force_blend", "native boolean"), ("relaxed", "cable_statics", "continuation or sequenced"), ("nodal", "OutputRecovery", "equilibrium or element"), + ("on", "ei0_substeps", "auto or off"), + ("0", "ei0_substep_angle", r"\(0, 90\] deg"), + ("91", "ei0SubstepAngle", r"\(0, 90\] deg"), + ("NaN", "ei0_substep_angle", r"\(0, 90\] deg"), + ("1", "ei0_substep_max", r"integer in \[2, 1024\]"), + ("2.5", "ei0_substep_max", r"integer in \[2, 1024\]"), + ("1025", "ei0SubstepMax", r"integer in \[2, 1024\]"), + ("2048.5", "ei0_substep_max", r"integer in \[2, 1024\]"), ], ) def test_invalid_scalar_option_values_fail_closed(tmp_path, value, keyword, message): @@ -741,6 +749,13 @@ def test_zero_e_exponent_waterkin_mode_is_accepted(tmp_path): "sequenced cableStatics", "equilibrium OutputRecovery", "element output_recovery", + "auto ei0_substeps", + "off ei0Substeps", + "0.5 ei0_substep_angle", + "90 ei0SubstepAngle", + "2 ei0_substep_max", + "1024 ei0SubstepMax", + "1.9999999999999998 ei0_substep_max", ], ) def test_native_scalar_option_vocabulary_is_accepted(tmp_path, row): diff --git a/src/CableDyn_DeckDriver.f90 b/src/CableDyn_DeckDriver.f90 index 8596e50f..497f5ffd 100644 --- a/src/CableDyn_DeckDriver.f90 +++ b/src/CableDyn_DeckDriver.f90 @@ -51,7 +51,7 @@ MODULE CableDyn_DeckDriver USE CableDyn_Syrope, ONLY: CD_SYROPE_WC_LINEAR, CD_SYROPE_WC_QUADRATIC, CD_SYROPE_WC_EXP, & CD_SyropeType, CD_Syrope_Init, CD_Syrope_End, & CD_Syrope_Static_Tension, CD_Syrope_Slow_For_Tension, CD_SYROPE_OK - USE CableDyn_Dynamic, ONLY: GenAlphaConfig, CD_DYN_OK + USE CableDyn_Dynamic, ONLY: GenAlphaConfig, CD_DYN_OK, CD_EI0_SUBSTEPS_OFF, CD_EI0_SUBSTEPS_AUTO USE CableDyn_Model, ONLY: CD_ModelType, CD_Init_Line_Model, CD_End_Model, CD_Model_NCoupledDOF, CD_Model_NDOF, & CD_Get_Model_CoupledDofs, CD_Get_Model_State, CD_Get_Model_Tension, & CD_Get_Model_EndForces, & @@ -606,6 +606,12 @@ MODULE CableDyn_DeckDriver ! Generalised-alpha blend of the finite-EI dynamics (alpha_force_blend): force blend ! (default) or the configuration blend f_int(q_alpha_f). LOGICAL :: alpha_force_blend = CD_HC_FORCE_BLEND_DEFAULT + ! Rotation- and snap-resolved sub-stepping of the EI=0 lines (ei0_substeps): -1 not set + ! (auto with the force blend, off with False alpha_force_blend), else CD_EI0_SUBSTEPS_OFF + ! or CD_EI0_SUBSTEPS_AUTO; the turn per step it allows (deg) and its sub-step cap. + INTEGER :: ei0_substeps = -1 + REAL(wp) :: ei0_substep_angle = 1.0_wp + INTEGER :: ei0_substep_max = 16 ! Finite-EI static route order (cable_statics): 'continuation' (default) solves the ! catenary-seeded EI continuation first and the mesh-sequenced route as its fallback; ! 'sequenced' runs the mesh-sequenced route first. @@ -7632,6 +7638,13 @@ SUBROUTINE init_one_model(ln, sections, types, points, opts, model, ErrStat, Err dynamic_cfg%armijo_max_backtracks = opts%dynamic_backtracks dynamic_cfg%modified_newton = opts%dynamic_modified_newton dynamic_cfg%force_blend = opts%alpha_force_blend + ! ei0_substeps not set: auto with the force blend; the configuration blend (paper mode) + ! takes every step as given, as the article did + dynamic_cfg%ei0_substeps = opts%ei0_substeps + IF (opts%ei0_substeps < 0) dynamic_cfg%ei0_substeps = MERGE(CD_EI0_SUBSTEPS_AUTO, CD_EI0_SUBSTEPS_OFF, & + opts%alpha_force_blend) + dynamic_cfg%ei0_substep_angle = opts%ei0_substep_angle + dynamic_cfg%ei0_substep_max = opts%ei0_substep_max CALL CD_Build_Line_Mesh(secs, lts, .TRUE., conn, l0, ea, mpl, diam, es, em) IF (es /= CD_LINE_OK) THEN CALL fail(ErrStat, ErrMsg, 'line mesh for model init: '//TRIM(em)); RETURN @@ -13041,6 +13054,37 @@ SUBROUTINE apply_option(line, opts, ErrStat, ErrMsg) CALL rd_bool(val, opts%adaptive_mesh, ErrStat, ErrMsg) CASE ('alpha_force_blend', 'alphaforceblend') CALL rd_bool(val, opts%alpha_force_blend, ErrStat, ErrMsg) + CASE ('ei0_substeps', 'ei0substeps') + SELECT CASE (TRIM(to_lower(val))) + CASE ('auto') + opts%ei0_substeps = CD_EI0_SUBSTEPS_AUTO + CASE ('off') + opts%ei0_substeps = CD_EI0_SUBSTEPS_OFF + CASE DEFAULT + CALL fail(ErrStat, ErrMsg, 'OPTION ei0_substeps "'//TRIM(val)//'" must be auto or off') + END SELECT + CASE ('ei0_substep_angle', 'ei0substepangle') + CALL rd(val, x1, ErrStat, ErrMsg) + IF (ErrStat == 0) THEN + IF (.NOT. (IEEE_IS_FINITE(x1) .AND. x1 > CD_ZERO .AND. x1 <= 90.0_wp)) THEN + CALL fail(ErrStat, ErrMsg, 'OPTION ei0_substep_angle must lie in (0, 90] deg'); RETURN + END IF + opts%ei0_substep_angle = x1 + END IF + CASE ('ei0_substep_max', 'ei0substepmax') + CALL rd(val, x1, ErrStat, ErrMsg) + IF (ErrStat == 0) THEN + ! the rule of the Python deck reader: an integer to within 16 ulp, whose nearest integer + ! lies in [2, 1024] (a value beyond 2048 in magnitude fails either test there) + IF (.NOT. IEEE_IS_FINITE(x1) .OR. ABS(x1) > 2048.0_wp) THEN + CALL fail(ErrStat, ErrMsg, 'OPTION ei0_substep_max must be an integer in [2, 1024]'); RETURN + END IF + IF (ABS(x1 - REAL(NINT(x1), wp)) > 16.0_wp*EPSILON(CD_ONE)*MAX(CD_ONE, ABS(x1)) .OR. & + NINT(x1) < 2 .OR. NINT(x1) > 1024) THEN + CALL fail(ErrStat, ErrMsg, 'OPTION ei0_substep_max must be an integer in [2, 1024]'); RETURN + END IF + opts%ei0_substep_max = NINT(x1) + END IF CASE ('cable_statics', 'cablestatics') SELECT CASE (TRIM(to_lower(val))) CASE ('continuation') @@ -18004,6 +18048,15 @@ SUBROUTINE write_multibody_dynamic_out(deck_path, out_root, channels, types, bod IF (mb%implicit .AND. mb%n_steps_imp > 0) THEN WRITE (*, '(A,F6.2,A,I0,A,I0)') ' Monolithic body/point step: mean outer iterations ', & REAL(mb%n_outer, wp)/REAL(mb%n_steps_imp, wp), ', max ', mb%max_outer, ', step halvings ', mb%n_subdiv + ! the junction Newton needs the nominal step's end reaction and tangent of every line + ! attached to a body, rod or point it solves, so ei0_substeps auto leaves those line steps + ! whole (noted once per run); a line with no such end is sub-stepped as usual + IF (mb%has_sys) THEN + IF (ANY(mb%system%lines(:)%cfg%ei0_substeps == CD_EI0_SUBSTEPS_AUTO)) & + WRITE (*, '(A)') ' Note: ei0_substeps auto does not sub-step the EI = 0 lines attached to the '// & + 'bodies, rods and points of the monolithic body/point step (it needs the end reaction and tangent '// & + 'of the whole step); reduce dtM to resolve their rotation and snaps.' + END IF END IF CALL CD_Classify_Dynamic_Completion('multibody dynamic run', nstep, miss_count, max_consecutive_miss, & first_miss_time, last_miss_time, converged, ErrStat, ErrMsg) @@ -27468,16 +27521,44 @@ SUBROUTINE report_model_audit(model, line_id, dt) REAL(wp), INTENT(IN) :: dt REAL(wp), PARAMETER :: EI0_TURN_NOTE = 1.0_wp INTEGER :: ios - IF (model%audit_max_turn > EI0_TURN_NOTE) THEN + LOGICAL :: auto + CHARACTER(200) :: remedy + REAL(wp) :: turn_note + auto = model%cfg%ei0_substeps == CD_EI0_SUBSTEPS_AUTO + IF (auto .AND. model%sub_stats%events > 0) THEN + WRITE (output_unit, '(A,I0,A,I0,A,I0,A,I0,A)', IOSTAT=ios) ' Note: line ', line_id, & + ': ei0_substeps auto solved ', model%sub_stats%events, ' of the ', model%sub_stats%calls, & + ' line step(s) it examined in sub-steps to resolve segment rotation and slack-to-taut snaps (at most ', & + model%sub_stats%max_used, ' sub-steps per step).' + IF (model%sub_stats%capped > 0) WRITE (output_unit, '(A,I0,A,I0,A,I0,A)', IOSTAT=ios) ' Note: line ', & + line_id, ': ', model%sub_stats%capped, ' step(s) needed more than ei0_substep_max = ', & + model%cfg%ei0_substep_max, ' sub-steps; raise it or reduce dtM.' + END IF + IF (auto .AND. model%sub_stats%fallbacks > 0) WRITE (output_unit, '(A,I0,A,I0,A)', IOSTAT=ios) & + ' Note: line ', line_id, ': ', model%sub_stats%fallbacks, & + ' step(s) kept the whole step because a resolving sub-step did not converge.' + ! with ei0_substeps auto a step is solved in sub-steps whose average turn is at most + ! ei0_substep_angle; a single sub-step can turn slightly more + turn_note = EI0_TURN_NOTE + IF (auto) turn_note = 1.1_wp*MAX(EI0_TURN_NOTE, model%cfg%ei0_substep_angle) + IF (model%audit_max_turn > turn_note) THEN + ! per solver step: the sub-steps of a resolved or recovered step count as steps + IF (auto) THEN + remedy = 'steps ei0_substeps auto did not resolve (beyond ei0_substep_max, recovered after a '// & + 'stall, or in a monolithic body or point coupling step): reduce dtM.' + ELSE + remedy = 'set ei0_substeps auto (the default) or reduce dtM.' + END IF WRITE (output_unit, '(A,I0,A,F7.3,A)', IOSTAT=ios) ' Note: line ', line_id, ': a taut segment turned up to ', & - model%audit_max_turn, ' deg in one step; a smaller dtM would resolve the line''s rotation (tension '// & - 'mean and standard-deviation errors of about 1 % and more above 1 deg per step).' + model%audit_max_turn, ' deg in one solver step. Above about 1 deg per step the tension mean and '// & + 'standard deviation err by about 1 % and more, and at about 6 deg per step snap-load peaks come out '// & + '10 to 20 % low with either generalised-alpha blend: '//TRIM(remedy) END IF IF (model%audit_snaps > 0 .AND. model%audit_snap_courant > CD_ONE) THEN WRITE (output_unit, '(A,I0,A,I0,A,ES9.2,A,F0.1,A)', IOSTAT=ios) ' Note: line ', line_id, ': ', & model%audit_snaps, ' segment step(s) went from slack to taut above the initial tension; at dtM =', & dt, ' s the axial wave crosses a segment up to ', model%audit_snap_courant, & - ' times per step, so the snap-load peaks are not resolved in time: confirm peak tensions with a '// & + ' times per solver step, so the snap-load peaks are not resolved in time: confirm peak tensions with a '// & 'smaller dtM.' END IF IF (model%audit_spikes > 1) THEN diff --git a/src/CableDyn_Dynamic.f90 b/src/CableDyn_Dynamic.f90 index e7646397..06274e55 100644 --- a/src/CableDyn_Dynamic.f90 +++ b/src/CableDyn_Dynamic.f90 @@ -82,6 +82,15 @@ MODULE CableDyn_Dynamic !! + alpha_f r(q_n, v_n); .FALSE. evaluates them at the !! blended configuration (q_alpha, v_alpha). The finite-EI !! paths have their own setting. + ! Rotation- and snap-resolved sub-stepping of an EI=0 line model (CD_Step_Model of + ! CableDyn_Model; the kernel step here does not read these). With CD_EI0_SUBSTEPS_AUTO a + ! converged step whose taut segments turned by more than ei0_substep_angle degrees, or in + ! which a segment went from slack to taut with a large tension, is solved again from the + ! same committed state in max(4, ceil(turn/ei0_substep_angle)) equal sub-steps, at most + ! ei0_substep_max; CD_EI0_SUBSTEPS_OFF takes every step as given. + INTEGER :: ei0_substeps = 1 !! CD_EI0_SUBSTEPS_AUTO (1) or CD_EI0_SUBSTEPS_OFF (0) + REAL(wp) :: ei0_substep_angle = 1.0_wp !! largest turn of a taut segment per step, deg, (0, 90] + INTEGER :: ei0_substep_max = 16 !! sub-step cap per step, [2, 1024] END TYPE GenAlphaConfig TYPE :: CD_CableGenAlphaWorkspace @@ -224,6 +233,9 @@ MODULE CableDyn_Dynamic INTEGER, PARAMETER, PUBLIC :: CD_DYN_BADINPUT = 1 INTEGER, PARAMETER, PUBLIC :: CD_DYN_SINGULAR = 2 INTEGER, PARAMETER, PUBLIC :: CD_DYN_ALLOCFAIL = 3 + ! GenAlphaConfig%ei0_substeps + INTEGER, PARAMETER, PUBLIC :: CD_EI0_SUBSTEPS_OFF = 0 + INTEGER, PARAMETER, PUBLIC :: CD_EI0_SUBSTEPS_AUTO = 1 ABSTRACT INTERFACE SUBROUTINE CD_Cable_Dynamic_Load_Proc(q, v, force, jac_q, jac_v, ErrStat, ErrMsg) @@ -2077,7 +2089,8 @@ SUBROUTINE apply_release_cap(q_eval, Rout, effout, effbandout) !! For an elastic element T^_1 = T_1: its blend returns at most W_0 over every step (an !! element that ends slack carries the discrete energy gradient W_0/p and returns exactly !! W_0), and the cap acts on a taut end state only when the element turned and - !! T_1 < alpha_f/(1 - alpha_f) T_0. An element slack at t_n keeps the force blend. + !! T_1 < alpha_f/(1 - alpha_f) T_0. An element slack at t_n keeps the force blend, but for + !! the kept share of its dashpot (below). !! N >= W_0/2 always (k e_0 <= T_0), so 4 alpha_f p <= e_0 is a sufficient test of an !! inactive cap. The residual and the tangent are corrected by the difference. !! An element whose axial law a load callback carries (ea = 0, T_0 from start_tension) is @@ -2107,17 +2120,34 @@ SUBROUTINE apply_release_cap(q_eval, Rout, effout, effbandout) !! dashpot, the cap is the one above, so the force-blended dashpot of a taut line keeps the !! standard generalised-alpha treatment. The weight is continuous, so is the capped force; !! the tangent carries dT_d,1/dq_{n+1} through v_{n+1} (gamma/(beta dt)). + !! An element with a dashpot that is slack at t_n (T_0 = 0, e_0 <= 0) keeps only + !! alpha_f T_d,0 along t_0, which returns alpha_f T_d,0 p, with no strain energy behind it, + !! when the step reverses or turns its ends against the step-start rate. Its budget is the + !! dashpot's own one-step dissipation W_d = T_d,0 ldot_0 dt, ldot_0 = l0 T_d,0/BA the + !! dashpot's elongation rate at t_n (the axial rate less the paid-out rate l_n l0_dot/l0; + !! the axial rate itself without payout), so W_d > 0 whenever T_d,0 /= 0. When + !! alpha_f T_d,0 p > 0 exceeds W_d + N_d, N_d = max((1 - alpha_f) T_d,1 p_1, 0) the end + !! share's credit (phi = 1: the band of a slack start is empty), the element carries + !! (W_d + N_d)/p instead of alpha_f T_d,0 along t_0, so the kept dashpot share of an + !! element slack at the step start returns at most its own one-step dissipation + !! T_d,0 |ldot_0| dt plus the end share's credit. The capped force grows without bound as + !! p -> 0 (W_d > 0), so the force is continuous there; alpha_f |p| <= |ldot_0| dt is a + !! sufficient test of an inactive cap. The same law covers a compressive T_d,0 (p < 0). REAL(wp), INTENT(IN) :: q_eval(:) REAL(wp), INTENT(INOUT) :: Rout(:) REAL(wp), INTENT(INOUT), OPTIONAL :: effout(:, :), effbandout(:, :) INTEGER :: e, na, nb, i, j, gi(6), fi, fj REAL(wp) :: d1(3), l1, e1, e0, t0, p, p1, num, ln, k0, ten1, cosang, dg, delta, t1(3), g(3), blk(3, 3), sgn - REAL(wp) :: band, phi, dphi, td1, dv(3), dp1(3), dtd1(3), kc - LOGICAL :: taut_end, damped + REAL(wp) :: band, phi, dphi, td1, dv(3), dp1(3), dtd1(3), kc, credit + LOGICAL :: taut_end, damped, slack band = alpha_f/(CD_ONE - alpha_f) DO e = 1, n_elem t0 = tension_n(e) - IF (.NOT. t0 > CD_ZERO) CYCLE + ! an element slack at t_n is capped only for the kept share of a step-start dashpot force + slack = .NOT. t0 > CD_ZERO + IF (slack) THEN + IF (.NOT. (dcoef_n(e) > CD_ZERO .AND. ABS(damp_n(e)) > CD_ZERO)) CYCLE + END IF na = elem_conn(1, e) nb = elem_conn(2, e) d1 = q_eval(3*nb - 2:3*nb) - q_eval(3*na - 2:3*na) @@ -2125,10 +2155,43 @@ SUBROUTINE apply_release_cap(q_eval, Rout, effout, effbandout) ! projected shortening p = l_n - t_0 . d_1 (l_n = l0 + e_0); the common case, an element ! that does not release, is decided here without a root p = e0 + (l0(e) - (chord_n(1, e)*d1(1) + chord_n(2, e)*d1(2) + chord_n(3, e)*d1(3))) - ! a damped element whose end state lies below the band edge l0 + band e_0 - damped = dcoef_n(e) > CD_ZERO - IF (damped) damped = d1(1)*d1(1) + d1(2)*d1(2) + d1(3)*d1(3) < (l0(e) + band*e0)**2 - IF (damped) THEN + ! a damped element taut at t_n whose end state lies below the band edge l0 + band e_0 + damped = .FALSE. + IF (.NOT. slack) THEN + damped = dcoef_n(e) > CD_ZERO + IF (damped) damped = d1(1)*d1(1) + d1(2)*d1(2) + d1(3)*d1(3) < (l0(e) + band*e0)**2 + END IF + IF (slack) THEN + ! the kept dashpot share alpha_f T_d,0 returns work only when T_d,0 p > 0, and stays + ! within W_d = T_d,0^2 dt/(BA/l0) while alpha_f |p| <= |ldot_0| dt + IF (.NOT. damp_n(e)*p > CD_ZERO) CYCLE + IF (alpha_f*ABS(p)*dcoef_n(e) <= ABS(damp_n(e))*dt) CYCLE + l1 = NORM2(d1) + IF (.NOT. l1 > CD_ZERO) CYCLE + ln = l0(e) + e0 + t1 = d1/l1 + cosang = t1(1)*chord_n(1, e) + t1(2)*chord_n(2, e) + t1(3)*chord_n(3, e) + p1 = (l1 - ln) + 0.5_wp*ln*((t1(1) - chord_n(1, e))**2 + (t1(2) - chord_n(2, e))**2 + & + (t1(3) - chord_n(3, e))**2) + dv = v_eval(3*nb - 2:3*nb) - v_eval(3*na - 2:3*na) + td1 = dcoef_n(e)*(DOT_PRODUCT(t1, dv) - l1*rl0dot_n(e)) + credit = (CD_ONE - alpha_f)*td1*p1 + num = damp_n(e)*damp_n(e)*dt/dcoef_n(e) + MAX(credit, CD_ZERO) + dg = num/p + IF (ABS(dg) >= alpha_f*ABS(damp_n(e))) CYCLE + delta = dg - alpha_f*damp_n(e) + Rout(3*na - 2:3*na) = Rout(3*na - 2:3*na) - delta*chord_n(:, e) + Rout(3*nb - 2:3*nb) = Rout(3*nb - 2:3*nb) + delta*chord_n(:, e) + IF (.NOT. (PRESENT(effout) .OR. PRESENT(effbandout))) CYCLE + ! d(delta)/d(x_b) = g, d(delta)/d(x_a) = -g: dp/dd_1 = -t_0, and while the credit is + ! positive dp_1/dd_1 and dT_d,1/dx_b as on the taut damped path + g = (num/(p*p))*chord_n(:, e) + IF (credit > CD_ZERO) THEN + dp1 = t1 - (ln/l1)*(chord_n(:, e) - cosang*t1) + dtd1 = dcoef_n(e)*((dv - DOT_PRODUCT(t1, dv)*t1)/l1 + (gamma/(beta*dt) - rl0dot_n(e))*t1) + g = g + ((CD_ONE - alpha_f)/p)*(td1*dp1 + p1*dtd1) + END IF + ELSE IF (damped) THEN IF (.NOT. p > CD_ZERO) CYCLE l1 = NORM2(d1) IF (.NOT. l1 > CD_ZERO) CYCLE diff --git a/src/CableDyn_Model.f90 b/src/CableDyn_Model.f90 index 9e3971ad..a3198b82 100644 --- a/src/CableDyn_Model.f90 +++ b/src/CableDyn_Model.f90 @@ -55,8 +55,10 @@ MODULE CableDyn_Model CD_Cable_Added_Mass, CD_Cable_Added_Mass_Matrix, CD_Cable_Added_Mass_Force, & CD_Added_Mass_Element, CD_Added_Mass_Element_Matrix, CD_Added_Mass_Element_Force USE CableDyn_Dynamic, ONLY: GenAlphaConfig, CD_CableGenAlphaWorkspace, CD_Clear_GenAlpha_Workspace, & - CD_Cable_Initial_Acceleration, CD_Cable_Gen_Alpha_Step, CD_DYN_OK, CD_DYN_ALLOCFAIL + CD_Cable_Initial_Acceleration, CD_Cable_Gen_Alpha_Step, CD_DYN_OK, CD_DYN_ALLOCFAIL, & + CD_EI0_SUBSTEPS_AUTO, CD_EI0_SUBSTEPS_OFF USE CableDyn_Mesh, ONLY: CD_Partition_Free_Dofs, CD_Validate_Connectivity + USE, INTRINSIC :: ISO_FORTRAN_ENV, ONLY: int64 USE CableDyn_Linalg, ONLY: CD_Solve_Dense_As_Banded, CD_Solve_Dense_As_Banded_Multiple, CD_Factor_Banded, & CD_Solve_Factored_Banded_Multiple USE CableDyn_Profile, ONLY: CD_Profile_Count_Line_Step @@ -64,10 +66,12 @@ MODULE CableDyn_Model PRIVATE PUBLIC :: CD_ModelType + PUBLIC :: CD_SubstepStats PUBLIC :: CD_Init_Model PUBLIC :: CD_Init_Line_Model PUBLIC :: CD_Step_Model PUBLIC :: CD_Step_Model_Recovering + PUBLIC :: CD_Get_Model_Substep_Counts PUBLIC :: CD_End_Model PUBLIC :: CD_Model_NCoupledDOF PUBLIC :: CD_Model_NDOF @@ -112,6 +116,44 @@ MODULE CableDyn_Model INTEGER, PARAMETER, PUBLIC :: CD_MODEL_NOT_INITIALIZED = 3 INTEGER, PARAMETER, PUBLIC :: CD_MODEL_ALLOCFAIL = 4 INTEGER, PARAMETER :: MODEL_DEFAULT_MAX_SUBSTEPS = 1024 + ! Rotation- and snap-resolved sub-stepping (CD_Step_Model, cfg%ei0_substeps). The tension + ! scale of a step is the largest step-start tension, floored at SUB_TAUT_FRACTION of the + ! line's initial tension (sub_t_init, the largest at CD_Init_Model): a line slack all over at + ! the step start would otherwise count any segment that ends it barely taut. (Flooring at the + ! initial tension itself raised the snap threshold in the slack phases of the Lozon semitaut + ! line, whose anchor snap peaks then came out up to 29 % high.) A segment that ends the step + ! taut above SUB_TAUT_FRACTION of the scale counts for the turn (the run audit's floor), also + ! when it was slack at the start: + ! counting only segments taut at both ends left the Lozon semitaut anchor snap peaks up to + ! 25 % high. One slack at the step start that ends above SUB_SNAP_FRACTION of the scale is a + ! snap when the step does not resolve its axial wave (dt c/l0 > 1, c from the dynamic axial + ! stiffness; a step that does resolves the snap as given). A step solved in sub-steps takes + ! at least SUB_SNAP_STEPS of them: on the Lozon semitaut line two or three sub-steps of a step + ! that turned 1 to 3 deg left the anchor snap peaks 8 % high on average (up to 22 %), four + ! brought them within 3 % of the converged run. The tensions are those the run audit takes: + ! the dynamic EA times the strain of an elastic segment, the law's tension of a viscoelastic + ! or Syrope one. + REAL(wp), PARAMETER :: SUB_TAUT_FRACTION = 1.0e-3_wp, SUB_SNAP_FRACTION = 0.25_wp + INTEGER, PARAMETER :: SUB_SNAP_STEPS = 4 + + ! The state a line step commits, as the sub-stepping (CD_Step_Model) saves it in its two + ! slots. commit_state_copy holds the one list of that state. + TYPE :: CD_ModelCommitSlot + REAL(wp), ALLOCATABLE :: q(:), v(:), a(:), ve_dl_1(:), syrope_slow(:), syrope_tmax(:) + REAL(wp), ALLOCATABLE :: fr_anchor(:, :) + END TYPE CD_ModelCommitSlot + + ! Diagnostics of the rotation- and snap-resolved sub-stepping (CD_Step_Model): calls counts + ! the steps it examined, events those it solved in sub-steps (max_used the largest count), + ! capped those whose turn needed more than cfg%ei0_substep_max, fallbacks those that returned + ! to the plain step after a sub-step failed, remeasured those whose sub-stepped interval + ! needed more sub-steps and was solved again. Only committed steps count: the line system + ! rolls these back with the line states (CableDyn_System), and a stalled step that + ! CD_Step_Model_Recovering takes again in its rungs (as given) is not counted. + TYPE :: CD_SubstepStats + INTEGER(int64) :: calls = 0, events = 0, capped = 0, fallbacks = 0, remeasured = 0 + INTEGER :: max_used = 1 + END TYPE CD_SubstepStats TYPE :: CD_ModelType !! Persistent positions-only EI=0 model state and immutable mesh/properties. @@ -309,6 +351,31 @@ MODULE CableDyn_Model REAL(wp) :: audit_snap_courant = CD_ZERO INTEGER :: audit_snaps = 0, audit_spikes = 0, audit_spike_elem = 0 REAL(wp) :: audit_spike_time = CD_ZERO, audit_spike_tension = CD_ZERO, audit_spike_ratio = CD_ZERO + ! audit_hmax: the largest single solver step committed since the last audit (the nominal + ! step, or a sub-step of the resolved or the recovering step); the audit measures turns and + ! axial wave crossings per solver step with it. Diagnostics only. + REAL(wp) :: audit_hmax = CD_ZERO + ! Rotation- and snap-resolved sub-stepping (CD_Step_Model): sub_stats its diagnostics and + ! sub_stats_rollback their twin at the last save of the system-rollback state + ! (CableDyn_System). sub_t_init is the line's initial tension, which floors the tension + ! scale of a step (SUB_TAUT_FRACTION of it; the largest segment tension at CD_Init_Model, a + ! parameter of the line, copied with the model). The other sub_* arrays are scratch: + ! sub_slot(1) the committed state at the step start, sub_slot(2) the state the plain step + ! reached, sub_t0 and sub_t1 the segment tensions at the step start and end, and + ! sub_pq/pv/pa the sub-step boundary motion. + TYPE(CD_SubstepStats) :: sub_stats, sub_stats_rollback + REAL(wp) :: sub_t_init = CD_ZERO + ! audit_hmax at the last save of the system-rollback state (CableDyn_System) + REAL(wp) :: audit_hmax_rollback = CD_ZERO + TYPE(CD_ModelCommitSlot) :: sub_slot(2) + REAL(wp), ALLOCATABLE :: sub_t0(:), sub_t1(:), sub_pq(:), sub_pv(:), sub_pa(:) + ! TEST-ONLY hooks of the sub-stepping, never set by a production caller: sub_test_fail > 0 + ! makes sub-step number sub_test_fail of every sub-stepped pass report a failure, and + ! sub_test_repeat solves the first sub-stepped pass twice (the second from the restored + ! committed state), which must not change the result; sub_test_more makes the re-measure of + ! every sub-stepped interval ask for one more sub-step. + INTEGER :: sub_test_fail = 0 + LOGICAL :: sub_test_repeat = .FALSE., sub_test_more = .FALSE. END TYPE CD_ModelType CONTAINS @@ -438,6 +505,17 @@ SUBROUTINE CD_Init_Model(model, q0, v0, elem_conn, l0, ea, rho_a, tension_only, CALL fail(ErrStat, ErrMsg, 'l0, ea, and rho_a must be finite and positive') RETURN END IF + ! the rotation- and snap-resolved sub-stepping settings (CD_Step_Model reads them per step) + IF (cfg%ei0_substeps /= CD_EI0_SUBSTEPS_AUTO .AND. cfg%ei0_substeps /= CD_EI0_SUBSTEPS_OFF) THEN + CALL fail(ErrStat, ErrMsg, 'cfg%ei0_substeps must be CD_EI0_SUBSTEPS_AUTO or CD_EI0_SUBSTEPS_OFF') + RETURN + END IF + IF (.NOT. (CD_Is_Finite(cfg%ei0_substep_angle) .AND. cfg%ei0_substep_angle > CD_ZERO .AND. & + cfg%ei0_substep_angle <= 90.0_wp .AND. cfg%ei0_substep_max >= 2 .AND. & + cfg%ei0_substep_max <= 1024)) THEN + CALL fail(ErrStat, ErrMsg, 'ei0_substep_angle must lie in (0, 90] deg and ei0_substep_max in [2, 1024]') + RETURN + END IF IF (ANY(elem_conn < 1) .OR. ANY(elem_conn > n_dof/3)) THEN CALL fail(ErrStat, ErrMsg, 'elem_conn contains a node index outside q0') RETURN @@ -1262,6 +1340,8 @@ SUBROUTINE CD_Init_Model(model, q0, v0, elem_conn, l0, ea, rho_a, tension_only, RETURN END IF model%initialized = .TRUE. + ! the line's initial tension, the floor of the tension scale of the sub-stepping (sub_count) + model%sub_t_init = initial_tension(model) CONTAINS @@ -1843,12 +1923,442 @@ SUBROUTINE CD_Init_Line_Model(model, anchor, fairlead, line_types, sections, gra END SUBROUTINE CD_Init_Line_Model SUBROUTINE CD_Step_Model(model, dt, converged, stalled, n_iter, ErrStat, ErrMsg, & - prescribed_q, prescribed_v, prescribed_a) - !! Advance the persistent model by one generalized-alpha step. Optional - !! prescribed_q/v/a arrays are full model-sized vectors; only entries in - !! model%fixed_dofs are consumed by CableDyn_Dynamic. On successful or stalled - !! dynamics returns, the model owns the returned state. On solver failure, the - !! underlying step contract preserves the previous state. + prescribed_q, prescribed_v, prescribed_a, as_given) + !! Advance the persistent model over dt. Optional prescribed_q/v/a arrays are full + !! model-sized vectors at the end of the step; only entries in model%fixed_dofs are + !! consumed by CableDyn_Dynamic. On successful or stalled dynamics returns, the model owns + !! the returned state. On solver failure, the underlying step contract preserves the + !! previous state. + !! + !! Rotation- and snap-resolved sub-stepping (cfg%ei0_substeps = CD_EI0_SUBSTEPS_AUTO, the + !! default; the settings are checked by CD_Init_Model): the step is solved as given; when it + !! converges and a segment that ends it taut turned by more than cfg%ei0_substep_angle + !! degrees, or a segment slack at its start ends it above SUB_SNAP_FRACTION of the tension + !! scale while the step does not resolve its axial wave (see SUB_SNAP_FRACTION), the + !! interval is solved again from the same committed state in + !! n = max(SUB_SNAP_STEPS, ceil(turn/angle)) equal sub-steps, at most cfg%ei0_substep_max. + !! The trial step under-turns a line whose rotation it does not resolve, so the sub-stepped + !! interval is measured again and, when its turn needs more sub-steps, solved once more with + !! them. The prescribed end motion inside the interval follows the C2 quintic of + !! CD_Step_Model_Recovering and the last sub-step lands on the given end state exactly. The + !! decision depends only on the committed state, the step's inputs and the line's initial + !! tension (a parameter of the line), so a run restarted from a checkpoint repeats it. If a + !! sub-step fails, the plain step's own result is returned. A step of the monolithic junction + !! coupling (the end query armed, CD_Set_Model_EndQuery) is never sub-stepped: its caller + !! needs the end reaction and tangent of the nominal step. as_given = .TRUE. takes the step + !! as given as well: the stall recoveries of CD_Step_Model_Recovering and CD_Step_System, + !! whose sub-steps are themselves part of a recovery, pass it. + TYPE(CD_ModelType), INTENT(INOUT) :: model + REAL(wp), INTENT(IN) :: dt + LOGICAL, INTENT(OUT) :: converged, stalled + INTEGER, INTENT(OUT) :: n_iter, ErrStat + CHARACTER(*), INTENT(OUT) :: ErrMsg + REAL(wp), INTENT(IN), OPTIONAL :: prescribed_q(:), prescribed_v(:), prescribed_a(:) + LOGICAL, INTENT(IN), OPTIONAL :: as_given + INTEGER :: nsub, nsub2, iter_trial + LOGICAL :: has_pres, resolve, capped, capped2, ok + + has_pres = PRESENT(prescribed_q) .AND. PRESENT(prescribed_v) .AND. PRESENT(prescribed_a) + resolve = model%initialized .AND. model%cfg%ei0_substeps == CD_EI0_SUBSTEPS_AUTO .AND. & + .NOT. model%dynamic_workspace%end_request + IF (resolve .AND. PRESENT(as_given)) resolve = .NOT. as_given + ! partial prescribed motion: the plain step reports the input error + IF (resolve) resolve = has_pres .OR. .NOT. (PRESENT(prescribed_q) .OR. PRESENT(prescribed_v) .OR. & + PRESENT(prescribed_a)) + IF (resolve) THEN + resolve = sub_alloc(model, has_pres) + IF (resolve) THEN + CALL sub_store(model, 1) + ! the segment tensions at the step start, for the trigger (sub_count) + CALL sub_tensions_scratch(model, 0) + END IF + END IF + IF (.NOT. resolve) THEN + ! absent optional arguments stay absent + CALL step_model_plain(model, dt, converged, stalled, n_iter, ErrStat, ErrMsg, & + prescribed_q=prescribed_q, prescribed_v=prescribed_v, prescribed_a=prescribed_a) + IF (ErrStat == CD_MODEL_OK) model%audit_hmax = MAX(model%audit_hmax, dt) + RETURN + END IF + + CALL step_model_plain(model, dt, converged, stalled, n_iter, ErrStat, ErrMsg, & + prescribed_q=prescribed_q, prescribed_v=prescribed_v, prescribed_a=prescribed_a) + IF (ErrStat /= CD_MODEL_OK) RETURN + model%sub_stats%calls = model%sub_stats%calls + 1 + nsub = 1 + capped = .FALSE. + IF (converged) CALL sub_count(model, dt, nsub, capped) + IF (nsub <= 1) THEN + model%audit_hmax = MAX(model%audit_hmax, dt) + RETURN + END IF + ! keep the plain step's result: it is returned should a sub-step fail + CALL sub_store(model, 2) + iter_trial = n_iter + + ! Solve the interval again from the committed state in nsub sub-steps. The trial step + ! under-turns a line whose rotation it does not resolve, so the sub-stepped interval is + ! measured again: when its turn needs more sub-steps, it is solved once more with them (and + ! the first count is kept should that fail). + CALL run_substeps(nsub, ok) + IF (ok .AND. model%sub_test_repeat) CALL run_substeps(nsub, ok) + IF (ok) THEN + CALL sub_count(model, dt, nsub2, capped2) + IF (model%sub_test_more) nsub2 = MAX(nsub2, MIN(model%cfg%ei0_substep_max, nsub + 1)) + IF (nsub2 > nsub) THEN + model%sub_stats%remeasured = model%sub_stats%remeasured + 1 + CALL run_substeps(nsub2, ok) + IF (ok) THEN + nsub = nsub2 + capped = capped2 + ELSE + CALL run_substeps(nsub, ok) + END IF + END IF + END IF + IF (ok) THEN + converged = .TRUE. + stalled = .FALSE. + ErrStat = CD_MODEL_OK + ErrMsg = '' + model%sub_stats%events = model%sub_stats%events + 1 + IF (capped) model%sub_stats%capped = model%sub_stats%capped + 1 + model%sub_stats%max_used = MAX(model%sub_stats%max_used, nsub) + model%audit_hmax = MAX(model%audit_hmax, dt/REAL(nsub, wp)) + RETURN + END IF + ! a sub-step failed: return the plain step's own (converged) result + CALL sub_load(model, 2) + converged = .TRUE. + stalled = .FALSE. + n_iter = iter_trial + ErrStat = CD_MODEL_OK + ErrMsg = '' + model%sub_stats%fallbacks = model%sub_stats%fallbacks + 1 + model%audit_hmax = MAX(model%audit_hmax, dt) + + CONTAINS + + SUBROUTINE run_substeps(n, ok_run) + !! The interval from the committed state (slot 1) in n equal sub-steps, the prescribed + !! end motion on the C2 quintic of the interval, the last sub-step on the given end state. + INTEGER, INTENT(IN) :: n + LOGICAL, INTENT(OUT) :: ok_run + INTEGER :: k, it_k, es_k + LOGICAL :: conv_k, stall_k + REAL(wp) :: h + CHARACTER(300) :: em_k + CALL sub_load(model, 1) + h = dt/REAL(n, wp) + ok_run = .TRUE. + DO k = 1, n + IF (has_pres) THEN + IF (k == n) THEN + model%sub_pq = prescribed_q + model%sub_pv = prescribed_v + model%sub_pa = prescribed_a + ELSE + CALL quintic_model_boundary_state(model%sub_slot(1)%q, model%sub_slot(1)%v, model%sub_slot(1)%a, & + prescribed_q, prescribed_v, prescribed_a, dt, & + REAL(k, wp)/REAL(n, wp), model%sub_pq, model%sub_pv, model%sub_pa) + END IF + CALL step_model_plain(model, h, conv_k, stall_k, it_k, es_k, em_k, prescribed_q=model%sub_pq, & + prescribed_v=model%sub_pv, prescribed_a=model%sub_pa) + ELSE + CALL step_model_plain(model, h, conv_k, stall_k, it_k, es_k, em_k) + END IF + IF (k == model%sub_test_fail) conv_k = .FALSE. + IF (es_k /= CD_MODEL_OK .OR. .NOT. conv_k) THEN + ok_run = .FALSE. + RETURN + END IF + n_iter = MAX(n_iter, it_k) + END DO + END SUBROUTINE run_substeps + END SUBROUTINE CD_Step_Model + + LOGICAL FUNCTION sub_alloc(model, has_pres) RESULT(ok) + !! Allocate the sub-stepping scratch on first use: two slots of the state a step commits + !! (CD_ModelCommitSlot), the step-start and end segment tensions and the sub-step boundary + !! motion. .FALSE. when it cannot be allocated (the step is then taken as given). + TYPE(CD_ModelType), INTENT(INOUT) :: model + LOGICAL, INTENT(IN) :: has_pres + INTEGER :: istat, k + ok = .FALSE. + istat = 0 + DO k = 1, 2 + ASSOCIATE (s => model%sub_slot(k)) + IF (.NOT. sized(s%q, model%n_dof)) THEN + IF (ALLOCATED(s%q)) DEALLOCATE (s%q, s%v, s%a) + ALLOCATE (s%q(model%n_dof), s%v(model%n_dof), s%a(model%n_dof), STAT=istat) + IF (istat /= 0) RETURN + END IF + IF (model%has_viscoelastic) THEN + IF (.NOT. sized(s%ve_dl_1, SIZE(model%ve_dl_1))) THEN + IF (ALLOCATED(s%ve_dl_1)) DEALLOCATE (s%ve_dl_1) + ALLOCATE (s%ve_dl_1(SIZE(model%ve_dl_1)), STAT=istat) + IF (istat /= 0) RETURN + END IF + END IF + IF (model%has_syrope) THEN + IF (.NOT. sized(s%syrope_slow, SIZE(model%syrope_slow))) THEN + IF (ALLOCATED(s%syrope_slow)) DEALLOCATE (s%syrope_slow, s%syrope_tmax) + ALLOCATE (s%syrope_slow(SIZE(model%syrope_slow)), s%syrope_tmax(SIZE(model%syrope_tmax)), STAT=istat) + IF (istat /= 0) RETURN + END IF + END IF + IF (model%has_seabed_friction) THEN + IF (ALLOCATED(s%fr_anchor)) THEN + IF (SIZE(s%fr_anchor, 1) /= SIZE(model%fr_anchor, 1) .OR. & + SIZE(s%fr_anchor, 2) /= SIZE(model%fr_anchor, 2)) DEALLOCATE (s%fr_anchor) + END IF + IF (.NOT. ALLOCATED(s%fr_anchor)) THEN + ALLOCATE (s%fr_anchor(SIZE(model%fr_anchor, 1), SIZE(model%fr_anchor, 2)), STAT=istat) + IF (istat /= 0) RETURN + END IF + END IF + END ASSOCIATE + END DO + IF (.NOT. sized(model%sub_t0, model%n_elem)) THEN + IF (ALLOCATED(model%sub_t0)) DEALLOCATE (model%sub_t0) + ALLOCATE (model%sub_t0(model%n_elem), STAT=istat) + IF (istat /= 0) RETURN + END IF + IF (.NOT. sized(model%sub_t1, model%n_elem)) THEN + IF (ALLOCATED(model%sub_t1)) DEALLOCATE (model%sub_t1) + ALLOCATE (model%sub_t1(model%n_elem), STAT=istat) + IF (istat /= 0) RETURN + END IF + IF (has_pres) THEN + IF (.NOT. sized(model%sub_pq, model%n_dof)) THEN + IF (ALLOCATED(model%sub_pq)) DEALLOCATE (model%sub_pq, model%sub_pv, model%sub_pa) + ALLOCATE (model%sub_pq(model%n_dof), model%sub_pv(model%n_dof), model%sub_pa(model%n_dof), STAT=istat) + IF (istat /= 0) RETURN + END IF + END IF + ok = .TRUE. + CONTAINS + LOGICAL FUNCTION sized(x, n) RESULT(yes) + REAL(wp), ALLOCATABLE, INTENT(IN) :: x(:) + INTEGER, INTENT(IN) :: n + yes = ALLOCATED(x) + IF (yes) yes = SIZE(x) == n + END FUNCTION sized + END FUNCTION sub_alloc + + SUBROUTINE commit_state_copy(model, to_model, q, v, a, ve_dl_1, syrope_slow, syrope_tmax, fr_anchor) + !! The one list of the state a line step commits: the kinematics, the viscoelastic dl_1, the + !! Syrope slow strain and running maximum tension, and the friction anchors. to_model = + !! .FALSE. saves the model's state into the arrays given, .TRUE. returns the model to them. + !! Every snapshot of the committed state in this module goes through here (the sub-step + !! slots of CD_Step_Model, save_recovery_state and restore_recovery_state). A state a step + !! comes to commit (such as the segment length of a line under active tension control) is + !! added here, as an optional array its snapshots pass; the rollback of the line system + !! (CableDyn_System: save_line_states, restore_line_states, CD_System_Snapshot and the + !! frame snapshot of CD_Step_System) lists the same state and must follow. An optional array + !! is passed as an allocatable that is allocated with the state it holds, so it is absent + !! (not allocated) exactly when the model does not carry that state. + TYPE(CD_ModelType), INTENT(INOUT) :: model + LOGICAL, INTENT(IN) :: to_model + REAL(wp), INTENT(INOUT) :: q(:), v(:), a(:) + REAL(wp), INTENT(INOUT), OPTIONAL :: ve_dl_1(:), syrope_slow(:), syrope_tmax(:), fr_anchor(:, :) + IF (to_model) THEN + model%q = q + model%v = v + model%a = a + IF (model%has_viscoelastic .AND. PRESENT(ve_dl_1)) model%ve_dl_1 = ve_dl_1 + IF (model%has_syrope .AND. PRESENT(syrope_slow) .AND. PRESENT(syrope_tmax)) THEN + model%syrope_slow = syrope_slow + model%syrope_tmax = syrope_tmax + END IF + IF (model%has_seabed_friction .AND. PRESENT(fr_anchor)) model%fr_anchor = fr_anchor + ELSE + q = model%q + v = model%v + a = model%a + IF (model%has_viscoelastic .AND. PRESENT(ve_dl_1)) ve_dl_1 = model%ve_dl_1 + IF (model%has_syrope .AND. PRESENT(syrope_slow) .AND. PRESENT(syrope_tmax)) THEN + syrope_slow = model%syrope_slow + syrope_tmax = model%syrope_tmax + END IF + IF (model%has_seabed_friction .AND. PRESENT(fr_anchor)) fr_anchor = model%fr_anchor + END IF + END SUBROUTINE commit_state_copy + + SUBROUTINE sub_store(model, slot) + !! Save the state a step commits into slot 1 (the step start) or 2 (the plain step's result). + TYPE(CD_ModelType), INTENT(INOUT) :: model + INTEGER, INTENT(IN) :: slot + CALL commit_state_copy(model, .FALSE., model%sub_slot(slot)%q, model%sub_slot(slot)%v, model%sub_slot(slot)%a, & + model%sub_slot(slot)%ve_dl_1, model%sub_slot(slot)%syrope_slow, & + model%sub_slot(slot)%syrope_tmax, model%sub_slot(slot)%fr_anchor) + END SUBROUTINE sub_store + + SUBROUTINE sub_load(model, slot) + !! Return the model to the state saved in slot (sub_store). + TYPE(CD_ModelType), INTENT(INOUT) :: model + INTEGER, INTENT(IN) :: slot + CALL commit_state_copy(model, .TRUE., model%sub_slot(slot)%q, model%sub_slot(slot)%v, model%sub_slot(slot)%a, & + model%sub_slot(slot)%ve_dl_1, model%sub_slot(slot)%syrope_slow, & + model%sub_slot(slot)%syrope_tmax, model%sub_slot(slot)%fr_anchor) + END SUBROUTINE sub_load + + SUBROUTINE sub_tensions(model, tension) + !! The segment tensions at the model's committed state as the run audit takes them + !! (CD_Audit_Model_Step): the dynamic EA times the strain of an elastic segment, the law's + !! tension of a viscoelastic or Syrope segment (model_law_tensions; the static EA times the + !! strain where the law cannot be evaluated). + TYPE(CD_ModelType), INTENT(IN) :: model + REAL(wp), INTENT(OUT) :: tension(:) + INTEGER :: e, na, nb, es + REAL(wp) :: strain + CHARACTER(160) :: em + DO e = 1, model%n_elem + na = model%elem_conn(1, e) + nb = model%elem_conn(2, e) + strain = NORM2(model%q(3*nb - 2:3*nb) - model%q(3*na - 2:3*na))/model%l0(e) - CD_ONE + IF (model%ea_dyn(e) > CD_ZERO) THEN + tension(e) = model%ea_dyn(e)*strain + ELSE + tension(e) = model%ea(e)*strain + END IF + END DO + IF (model%has_viscoelastic .OR. model%has_syrope) CALL model_law_tensions(model, tension, es, em) + END SUBROUTINE sub_tensions + + SUBROUTINE sub_tensions_scratch(model, which) + !! sub_tensions into the scratch of the sub-stepping, sub_t0 (which = 0, the step start) or + !! sub_t1 (1, the step end). The array is moved out of the model while the tensions are + !! evaluated (the law evaluation reads the model), which allocates nothing. + TYPE(CD_ModelType), INTENT(INOUT) :: model + INTEGER, INTENT(IN) :: which + REAL(wp), ALLOCATABLE :: tension(:) + IF (which == 0) THEN + CALL MOVE_ALLOC(model%sub_t0, tension) + CALL sub_tensions(model, tension) + CALL MOVE_ALLOC(tension, model%sub_t0) + ELSE + CALL MOVE_ALLOC(model%sub_t1, tension) + CALL sub_tensions(model, tension) + CALL MOVE_ALLOC(tension, model%sub_t1) + END IF + END SUBROUTINE sub_tensions_scratch + + REAL(wp) FUNCTION initial_tension(model) RESULT(t_init) + !! The largest segment tension of the model's committed state (sub_tensions), 0 when none + !! is positive: the line's initial tension when CD_Init_Model sets it. + TYPE(CD_ModelType), INTENT(IN) :: model + REAL(wp), ALLOCATABLE :: tension(:) + INTEGER :: istat + t_init = CD_ZERO + ALLOCATE (tension(model%n_elem), STAT=istat) + IF (istat /= 0) RETURN + CALL sub_tensions(model, tension) + IF (CD_All_Finite(tension)) t_init = MAX(CD_ZERO, MAXVAL(tension)) + END FUNCTION initial_tension + + REAL(wp) FUNCTION segment_wave_stiffness(model, e, tension) RESULT(stiff) + !! The axial stiffness of segment e that sets its wave speed: the dynamic EA of an elastic + !! segment, the fast spring of a law (EA_D of the viscoelastic law, alpha + beta*T of the + !! Syrope law at the segment tension T); the static EA if the law's value is unavailable. + TYPE(CD_ModelType), INTENT(IN) :: model + INTEGER, INTENT(IN) :: e + REAL(wp), INTENT(IN) :: tension + REAL(wp) :: ea_d_eff, ea_1_eff + INTEGER :: es + CHARACTER(200) :: em + stiff = model%ea_dyn(e) + IF (stiff > CD_ZERO) RETURN + stiff = model%ea(e) + IF (model%has_viscoelastic) THEN + IF (model%ve_mode(e) /= 0) THEN + CALL model_viscoelastic_coeffs(model, e, ea_d_eff, ea_1_eff, es, em) + IF (es == CD_MODEL_OK .AND. ea_d_eff > CD_ZERO) stiff = ea_d_eff + RETURN + END IF + END IF + IF (model%has_syrope) THEN + IF (model%syrope_is(e)) & + stiff = model%syrope_type(e)%alpha + model%syrope_type(e)%beta*MAX(tension, CD_ZERO) + END IF + END FUNCTION segment_wave_stiffness + + SUBROUTINE sub_count(model, dt, nsub, capped) + !! The sub-step count of a converged step over dt (model%q) from the committed state (slot 1, + !! its segment tensions in sub_t0): 1, or max(SUB_SNAP_STEPS, ceil(turn/angle)) when + !! turn > angle, at most cfg%ei0_substep_max (capped when the turn needs more), turn the + !! largest chord turn of a segment that ends the step above SUB_TAUT_FRACTION of the tension + !! scale (the largest step-start tension, at least SUB_TAUT_FRACTION of sub_t_init); at least + !! SUB_SNAP_STEPS when a segment slack at the start ends above SUB_SNAP_FRACTION of the scale + !! and its axial wave crosses it more than once in dt. The tensions are those of + !! sub_tensions. The strains use model%l0, the lengths the step itself uses + !! (CD_Update_Model_SegmentLength sets them before the step); a length that changes within + !! the step would need its step-start value for the start state here. + TYPE(CD_ModelType), INTENT(INOUT) :: model + REAL(wp), INTENT(IN) :: dt + INTEGER, INTENT(OUT) :: nsub + LOGICAL, INTENT(OUT) :: capped + REAL(wp), PARAMETER :: DEG = 57.295779513082320876798154814105_wp + INTEGER :: e, na, nb, nmax + REAL(wp) :: d0(3), d1(3), l_s, l_e, scale, te, c, turn, ratio, courant + LOGICAL :: snap + nsub = 1 + capped = .FALSE. + CALL sub_tensions_scratch(model, 1) + scale = MAX(CD_ZERO, SUB_TAUT_FRACTION*model%sub_t_init) + IF (CD_All_Finite(model%sub_t0)) scale = MAX(scale, MAXVAL(model%sub_t0)) + turn = CD_ZERO + snap = .FALSE. + DO e = 1, model%n_elem + na = model%elem_conn(1, e) + nb = model%elem_conn(2, e) + d1 = model%q(3*nb - 2:3*nb) - model%q(3*na - 2:3*na) + l_e = NORM2(d1) + IF (.NOT. l_e > model%l0(e)) CYCLE + te = model%sub_t1(e) + d0 = model%sub_slot(1)%q(3*nb - 2:3*nb) - model%sub_slot(1)%q(3*na - 2:3*na) + l_s = NORM2(d0) + IF (.NOT. snap .AND. l_s <= model%l0(e) .AND. te > SUB_SNAP_FRACTION*scale) THEN + courant = dt*SQRT(segment_wave_stiffness(model, e, te)/model%rho_a(e))/model%l0(e) + IF (courant > CD_ONE) snap = .TRUE. + END IF + IF (te > SUB_TAUT_FRACTION*scale .AND. l_s > CD_ZERO) THEN + c = DOT_PRODUCT(d0, d1)/(l_s*l_e) + turn = MAX(turn, ACOS(MAX(-CD_ONE, MIN(CD_ONE, c)))*DEG) + END IF + END DO + nmax = model%cfg%ei0_substep_max + IF (turn > model%cfg%ei0_substep_angle) THEN + ratio = turn/model%cfg%ei0_substep_angle + IF (ratio > REAL(nmax, wp)) THEN + nsub = nmax + capped = .TRUE. + ELSE + nsub = MIN(nmax, MAX(SUB_SNAP_STEPS, CEILING(ratio))) + END IF + END IF + IF (snap) nsub = MAX(nsub, MIN(SUB_SNAP_STEPS, nmax)) + END SUBROUTINE sub_count + + SUBROUTINE CD_Get_Model_Substep_Counts(model, calls, events, max_used, capped, fallbacks) + !! Diagnostics of the rotation- and snap-resolved sub-stepping (CD_Step_Model, + !! CD_SubstepStats): the steps it examined, those it solved in sub-steps (the largest count + !! used), those whose turn needed more than cfg%ei0_substep_max, and those that kept the + !! plain step after a sub-step failed. + TYPE(CD_ModelType), INTENT(IN) :: model + INTEGER(int64), INTENT(OUT) :: calls, events, capped, fallbacks + INTEGER, INTENT(OUT) :: max_used + calls = model%sub_stats%calls + events = model%sub_stats%events + max_used = model%sub_stats%max_used + capped = model%sub_stats%capped + fallbacks = model%sub_stats%fallbacks + END SUBROUTINE CD_Get_Model_Substep_Counts + + SUBROUTINE step_model_plain(model, dt, converged, stalled, n_iter, ErrStat, ErrMsg, & + prescribed_q, prescribed_v, prescribed_a) + !! One generalized-alpha step of the model over dt, as given (CD_Step_Model without its + !! resolved sub-stepping). TYPE(CD_ModelType), INTENT(INOUT) :: model REAL(wp), INTENT(IN) :: dt LOGICAL, INTENT(OUT) :: converged, stalled @@ -2192,7 +2702,7 @@ SUBROUTINE model_added_mass_band(q, accel, free, kl, ku, M_add_a, M_add_band, dM ErrStat, ErrMsg, need_tangent=need_tangent) ErrStat = as_dyn_callback_status(ErrStat) END SUBROUTINE model_added_mass_band - END SUBROUTINE CD_Step_Model + END SUBROUTINE step_model_plain SUBROUTINE CD_Step_Model_Recovering(model, dt, converged, stalled, n_iter, ErrStat, ErrMsg, & prescribed_q, prescribed_v, prescribed_a, max_substeps, substeps_used) @@ -2217,7 +2727,8 @@ SUBROUTINE CD_Step_Model_Recovering(model, dt, converged, stalled, n_iter, ErrSt INTEGER :: recovery_cap, nsub, k, es, iter_sub, max_iter_seen LOGICAL :: has_pres, conv_sub, stall_sub, rung_ok - REAL(wp) :: subdt, fraction + REAL(wp) :: subdt, fraction, hmax0 + TYPE(CD_SubstepStats) :: stats0 REAL(wp), ALLOCATABLE :: pq(:), pv(:), pa(:) CHARACTER(300) :: em, first_em @@ -2262,6 +2773,8 @@ SUBROUTINE CD_Step_Model_Recovering(model, dt, converged, stalled, n_iter, ErrSt END IF CALL save_recovery_state(model) + hmax0 = model%audit_hmax + stats0 = model%sub_stats IF (has_pres) THEN CALL CD_Step_Model(model, dt, converged, stalled, n_iter, ErrStat, ErrMsg, & prescribed_q=prescribed_q, prescribed_v=prescribed_v, prescribed_a=prescribed_a) @@ -2280,6 +2793,8 @@ SUBROUTINE CD_Step_Model_Recovering(model, dt, converged, stalled, n_iter, ErrSt first_em = ErrMsg CALL restore_recovery_state(model) + ! the stalled attempt is not committed: the rungs that replace it take their steps as given + model%sub_stats = stats0 IF (has_pres) THEN ALLOCATE (pq(model%n_dof), pv(model%n_dof), pa(model%n_dof), STAT=es) IF (es /= 0) THEN @@ -2294,6 +2809,11 @@ SUBROUTINE CD_Step_Model_Recovering(model, dt, converged, stalled, n_iter, ErrSt nsub = 4 DO CALL restore_recovery_state(model) + ! the audit measures the solver steps of the rung that completes + model%audit_hmax = hmax0 + ! the rungs take their sub-steps as given (step_model_plain, as CD_Step_System's halving + ! does with as_given): resolving them as well (sub-steps of sub-steps) left the anchor snap + ! peaks of the Lozon semitaut line 9 % high on average subdt = dt/REAL(nsub, wp) rung_ok = .TRUE. es = CD_MODEL_OK @@ -2308,10 +2828,10 @@ SUBROUTINE CD_Step_Model_Recovering(model, dt, converged, stalled, n_iter, ErrSt pv = prescribed_v pa = prescribed_a END IF - CALL CD_Step_Model(model, subdt, conv_sub, stall_sub, iter_sub, es, em, & - prescribed_q=pq, prescribed_v=pv, prescribed_a=pa) + CALL step_model_plain(model, subdt, conv_sub, stall_sub, iter_sub, es, em, & + prescribed_q=pq, prescribed_v=pv, prescribed_a=pa) ELSE - CALL CD_Step_Model(model, subdt, conv_sub, stall_sub, iter_sub, es, em) + CALL step_model_plain(model, subdt, conv_sub, stall_sub, iter_sub, es, em) END IF max_iter_seen = MAX(max_iter_seen, iter_sub) IF (es /= CD_MODEL_OK .OR. .NOT. conv_sub) THEN @@ -2323,6 +2843,7 @@ SUBROUTINE CD_Step_Model_Recovering(model, dt, converged, stalled, n_iter, ErrSt converged = .TRUE. stalled = .FALSE. n_iter = max_iter_seen + model%audit_hmax = MAX(hmax0, subdt) IF (PRESENT(substeps_used)) substeps_used = nsub ErrStat = CD_MODEL_OK ErrMsg = '' @@ -2359,29 +2880,19 @@ SUBROUTINE CD_Step_Model_Recovering(model, dt, converged, stalled, n_iter, ErrSt END SUBROUTINE CD_Step_Model_Recovering SUBROUTINE save_recovery_state(model) + !! Save the committed state into the recovery snapshot (commit_state_copy). TYPE(CD_ModelType), INTENT(INOUT) :: model - model%recovery_q0 = model%q - model%recovery_v0 = model%v - model%recovery_a0 = model%a - IF (model%has_viscoelastic) model%recovery_ve_dl_1 = model%ve_dl_1 - IF (model%has_syrope) THEN - model%recovery_syrope_slow = model%syrope_slow - model%recovery_syrope_tmax = model%syrope_tmax - END IF - IF (model%has_seabed_friction) model%recovery_fr_anchor = model%fr_anchor + CALL commit_state_copy(model, .FALSE., model%recovery_q0, model%recovery_v0, model%recovery_a0, & + model%recovery_ve_dl_1, model%recovery_syrope_slow, model%recovery_syrope_tmax, & + model%recovery_fr_anchor) END SUBROUTINE save_recovery_state SUBROUTINE restore_recovery_state(model) + !! Return the model to the recovery snapshot (commit_state_copy). TYPE(CD_ModelType), INTENT(INOUT) :: model - model%q = model%recovery_q0 - model%v = model%recovery_v0 - model%a = model%recovery_a0 - IF (model%has_viscoelastic) model%ve_dl_1 = model%recovery_ve_dl_1 - IF (model%has_syrope) THEN - model%syrope_slow = model%recovery_syrope_slow - model%syrope_tmax = model%recovery_syrope_tmax - END IF - IF (model%has_seabed_friction) model%fr_anchor = model%recovery_fr_anchor + CALL commit_state_copy(model, .TRUE., model%recovery_q0, model%recovery_v0, model%recovery_a0, & + model%recovery_ve_dl_1, model%recovery_syrope_slow, model%recovery_syrope_tmax, & + model%recovery_fr_anchor) model%ve_dt = CD_ZERO END SUBROUTINE restore_recovery_state @@ -4815,13 +5326,18 @@ SUBROUTINE CD_Audit_Model_Step(model, time, dt, new_spike) REAL(wp), PARAMETER :: TURN_TAUT_FRACTION = 1.0e-3_wp INTEGER, PARAMETER :: SPIKE_MIN_ELEMS = 3 INTEGER :: e, na, nb, istat, es - REAL(wp) :: d(3), ell, strain, u(3), c, line_max, tn + REAL(wp) :: d(3), ell, strain, u(3), c, line_max, tn, h REAL(wp), ALLOCATABLE :: law(:) LOGICAL :: fresh, laws CHARACTER(160) :: em new_spike = .FALSE. IF (.NOT. model%initialized .OR. model%n_elem < 1) RETURN + ! the largest solver step since the last audit (sub-steps of the resolved or recovering + ! step): turns and axial wave crossings are measured per solver step + h = dt + IF (model%audit_hmax > CD_ZERO) h = MIN(dt, model%audit_hmax) + model%audit_hmax = CD_ZERO fresh = .NOT. (ALLOCATED(model%audit_t) .AND. ALLOCATED(model%audit_u) .AND. ALLOCATED(model%audit_now)) IF (.NOT. fresh) fresh = SIZE(model%audit_t, 1) /= model%n_elem IF (fresh) THEN @@ -4881,13 +5397,13 @@ SUBROUTINE CD_Audit_Model_Step(model, time, dt, new_spike) model%audit_t(e, 1) > TURN_TAUT_FRACTION*model%audit_floor .AND. model%audit_t(e, 1) > CD_ZERO) & model%audit_max_turn = MAX(model%audit_max_turn, & ACOS(MAX(-CD_ONE, MIN(CD_ONE, DOT_PRODUCT(u, model%audit_u(:, e)))))* & - (180.0_wp/ACOS(-CD_ONE))) + (180.0_wp/ACOS(-CD_ONE))*(h/dt)) ! slack at the previous state, taut above the initial tension scale now IF (model%audit_t(e, 1) >= CD_ZERO .AND. .NOT. model%audit_t(e, 1) > CD_ZERO .AND. & model%audit_now(e) > model%audit_floor) THEN model%audit_snaps = model%audit_snaps + 1 - c = SQRT(wave_stiffness(e)/model%rho_a(e)) - model%audit_snap_courant = MAX(model%audit_snap_courant, dt*c/model%l0(e)) + c = SQRT(segment_wave_stiffness(model, e, model%audit_now(e))/model%rho_a(e)) + model%audit_snap_courant = MAX(model%audit_snap_courant, h*c/model%l0(e)) END IF END IF model%audit_u(:, e) = u @@ -4926,29 +5442,6 @@ LOGICAL FUNCTION law_element(k) RESULT(is_law) IF (model%has_syrope .AND. .NOT. is_law) is_law = model%syrope_is(k) END FUNCTION law_element - REAL(wp) FUNCTION wave_stiffness(k) RESULT(stiff) - !! The axial stiffness of segment k that sets its wave speed: EA of an elastic segment, - !! the fast spring of a law (EA_D of the viscoelastic law, alpha + beta*T of the Syrope - !! law at the segment tension T); the static EA if the law's value is unavailable. - INTEGER, INTENT(IN) :: k - REAL(wp) :: ea_d_eff, ea_1_eff - INTEGER :: es_k - CHARACTER(200) :: em_k - stiff = model%ea_dyn(k) - IF (stiff > CD_ZERO) RETURN - stiff = model%ea(k) - IF (model%has_viscoelastic) THEN - IF (model%ve_mode(k) /= 0) THEN - CALL model_viscoelastic_coeffs(model, k, ea_d_eff, ea_1_eff, es_k, em_k) - IF (es_k == CD_MODEL_OK .AND. ea_d_eff > CD_ZERO) stiff = ea_d_eff - RETURN - END IF - END IF - IF (model%has_syrope) THEN - IF (model%syrope_is(k)) stiff = model%syrope_type(k)%alpha + & - model%syrope_type(k)%beta*MAX(model%audit_now(k), CD_ZERO) - END IF - END FUNCTION wave_stiffness END SUBROUTINE CD_Audit_Model_Step SUBROUTINE clear_model_audit(model) @@ -4968,6 +5461,14 @@ SUBROUTINE clear_model_audit(model) model%audit_spike_time = CD_ZERO model%audit_spike_tension = CD_ZERO model%audit_spike_ratio = CD_ZERO + model%audit_hmax = CD_ZERO + model%audit_hmax_rollback = CD_ZERO + ! the sub-stepping diagnostics and test hooks start afresh with the model + model%sub_stats = CD_SubstepStats() + model%sub_stats_rollback = CD_SubstepStats() + model%sub_test_fail = 0 + model%sub_test_repeat = .FALSE. + model%sub_test_more = .FALSE. END SUBROUTINE clear_model_audit SUBROUTINE CD_End_Model(model, ErrStat, ErrMsg) @@ -5005,6 +5506,13 @@ SUBROUTINE CD_End_Model(model, ErrStat, ErrMsg) IF (ALLOCATED(model%v_rollback)) DEALLOCATE (model%v_rollback) IF (ALLOCATED(model%a_rollback)) DEALLOCATE (model%a_rollback) IF (ALLOCATED(model%recovery_q0)) DEALLOCATE (model%recovery_q0) + model%sub_slot(1) = CD_ModelCommitSlot() + model%sub_slot(2) = CD_ModelCommitSlot() + IF (ALLOCATED(model%sub_t0)) DEALLOCATE (model%sub_t0) + IF (ALLOCATED(model%sub_t1)) DEALLOCATE (model%sub_t1) + IF (ALLOCATED(model%sub_pq)) DEALLOCATE (model%sub_pq) + IF (ALLOCATED(model%sub_pv)) DEALLOCATE (model%sub_pv) + IF (ALLOCATED(model%sub_pa)) DEALLOCATE (model%sub_pa) IF (ALLOCATED(model%recovery_v0)) DEALLOCATE (model%recovery_v0) IF (ALLOCATED(model%recovery_a0)) DEALLOCATE (model%recovery_a0) IF (ALLOCATED(model%f_ext_rollback)) DEALLOCATE (model%f_ext_rollback) @@ -5159,6 +5667,7 @@ SUBROUTINE CD_Copy_Model(src, dst, ErrStat, ErrMsg) work%added_mass_can = src%added_mass_can work%added_mass_cat = src%added_mass_cat work%cfg = src%cfg + work%sub_t_init = src%sub_t_init CALL copy_int2(src%elem_conn, work%elem_conn, 'elem_conn', ErrStat, ErrMsg) IF (ErrStat /= CD_MODEL_OK) RETURN @@ -5372,6 +5881,7 @@ SUBROUTINE commit_model_copy(from, to) to%added_mass_can = from%added_mass_can to%added_mass_cat = from%added_mass_cat to%cfg = from%cfg + to%sub_t_init = from%sub_t_init CALL MOVE_ALLOC(from%elem_conn, to%elem_conn) CALL MOVE_ALLOC(from%fixed_dofs, to%fixed_dofs) diff --git a/src/CableDyn_OpenFAST_Aggregate.f90 b/src/CableDyn_OpenFAST_Aggregate.f90 index 73f98480..2abb1d4f 100644 --- a/src/CableDyn_OpenFAST_Aggregate.f90 +++ b/src/CableDyn_OpenFAST_Aggregate.f90 @@ -40,6 +40,7 @@ MODULE CableDyn_OpenFAST_Aggregate !! generalised-alpha step carries the Init dt, from the mooring columns). USE CableDyn_Precision, ONLY: wp, CD_ZERO, CD_ONE, CD_All_Finite USE CableDyn_FatalReport, ONLY: CD_Fatal_Thread_Init + USE, INTRINSIC :: ISO_FORTRAN_ENV, ONLY: int64 USE CableDyn_Linalg, ONLY: CD_Blas_Runtime_Check, CD_LINALG_OK USE CableDyn_OpenFAST_FMF, ONLY: CD_FMF_ModuleType, CD_FMF_Init_From_System, CD_FMF_NMovingPoints, & CD_FMF_GetPointMesh, CD_FMF_UpdateStates, & @@ -75,7 +76,8 @@ MODULE CableDyn_OpenFAST_Aggregate CD_Rod_ScatterHostPoints, CD_Rod_HostWrench, CD_Rod_Stage, CD_Rod_Unstage, & CD_Deck_Range_Sample_Aggregate, CD_Deck_Range_Write USE CableDyn_RangeOutput, ONLY: CD_RangeSet, CD_Range_End - USE CableDyn_System, ONLY: CD_System_NLines, CD_System_Line_NDOF, CD_Get_System_Line_State, & + USE CableDyn_System, ONLY: CD_Get_System_Substep_Counts, CD_System_NLines, CD_System_Line_NDOF, & + CD_Get_System_Line_State, & CD_Update_System_Line_SegmentLength, & CD_Update_System_Line_Hydro_Fields, CD_SYSTEM_OK, & CD_System_NHydroPoints, CD_Get_System_HydroPoint_Positions, & @@ -105,6 +107,7 @@ MODULE CableDyn_OpenFAST_Aggregate PUBLIC :: CD_AGG_CalcOutput PUBLIC :: CD_AGG_End PUBLIC :: CD_AGG_NFailures + PUBLIC :: CD_AGG_Get_Substep_Counts PUBLIC :: CD_AGG_Get_Failure_Flags, CD_AGG_Set_Failure_Flags PUBLIC :: CD_AGG_NCtrlChans, CD_AGG_Apply_LineControl PUBLIC :: CD_AGG_IsInitialized @@ -1767,6 +1770,19 @@ INTEGER FUNCTION CD_AGG_NFailures(self) RESULT(n) IF (ALLOCATED(self%failures)) n = SIZE(self%failures) END FUNCTION CD_AGG_NFailures + SUBROUTINE CD_AGG_Get_Substep_Counts(self, calls, events, max_used, capped, fallbacks) + !! The rotation- and snap-resolved sub-stepping diagnostics of the EI=0 lines of the + !! aggregate (CD_Get_System_Substep_Counts; all zero without EI=0 lines): line steps + !! examined, solved in sub-steps (max_used the largest count), beyond ei0_substep_max, and + !! kept the plain step's result after a sub-step failed. + TYPE(CD_AGG_ModuleType), INTENT(IN) :: self + INTEGER(int64), INTENT(OUT) :: calls, events, capped, fallbacks + INTEGER, INTENT(OUT) :: max_used + calls = 0; events = 0; max_used = 1; capped = 0; fallbacks = 0 + IF (self%has_sys) CALL CD_Get_System_Substep_Counts(self%sys%fast%system, calls, events, max_used, capped, & + fallbacks) + END SUBROUTINE CD_AGG_Get_Substep_Counts + SUBROUTINE CD_AGG_End(self, ErrStat, ErrMsg) !! Release all owned resources. Idempotent by design (CD_FMF_End / CD_HFMF_End are safe !! on uninitialized members). diff --git a/src/CableDyn_System.f90 b/src/CableDyn_System.f90 index 64ef1782..34dcc24a 100644 --- a/src/CableDyn_System.f90 +++ b/src/CableDyn_System.f90 @@ -10,6 +10,7 @@ MODULE CableDyn_System !! bypassing it. Rigid6 bodies and rods are marched over a system by the deck driver. USE CableDyn_Precision, ONLY: wp, CD_ZERO, CD_All_Finite, CD_Is_Finite USE CableDyn_FatalReport, ONLY: CD_Fatal_Thread_Init + USE, INTRINSIC :: ISO_FORTRAN_ENV, ONLY: int64 USE CableDyn_Model, ONLY: CD_ModelType, CD_Model_Is_Initialized, CD_End_Model, & CD_Model_NCoupledDOF, CD_Model_NDOF, CD_Model_NElem, & CD_Get_Model_CoupledDofs, CD_Get_Model_CoupledMotion, & @@ -21,6 +22,7 @@ MODULE CableDyn_System CD_Get_Model_EndNodeTangent, CD_Set_Model_EndQuery, CD_Get_Model_EndQuery, & CD_Update_Model_SegmentLength, & CD_Update_Model_CoupledMotion, CD_Update_Model_Interior_State, CD_Step_Model, & + CD_Get_Model_Substep_Counts, CD_SubstepStats, & CD_Calc_Model_CoupledLoads, CD_Recompute_Model_Acceleration, & CD_Calc_Model_CoupledKinematicDerivatives, & CD_Calc_Model_CoupledAccelDerivative, CD_Update_Model_CoupledAccelDerivative, & @@ -47,6 +49,7 @@ MODULE CableDyn_System PUBLIC :: CD_SystemPointType PUBLIC :: CD_LineEndpointBinding PUBLIC :: CD_System_Fallback_Count + PUBLIC :: CD_Get_System_Substep_Counts PUBLIC :: CD_System_Fallback_Reset PUBLIC :: CD_System_Snapshot PUBLIC :: CD_System_Restore @@ -218,6 +221,9 @@ MODULE CableDyn_System ! Stick-slip seabed friction anchors join the snapshot ((x, y) per node, concatenated ! over the friction lines; sized like snap_q, of which it uses two thirds at most). REAL(wp), ALLOCATABLE :: snap_fr_anchor(:) + ! the sub-stepping diagnostics of every line (CD_SubstepStats): they roll back with the + ! states, so a restored and re-advanced step counts once + TYPE(CD_SubstepStats), ALLOCATABLE :: snap_sub(:) LOGICAL :: snap_valid = .FALSE. END TYPE CD_SystemType @@ -453,6 +459,7 @@ SUBROUTINE CD_End_System(system, ErrStat, ErrMsg) IF (ALLOCATED(system%snap_ve_dl_1)) DEALLOCATE (system%snap_ve_dl_1) IF (ALLOCATED(system%snap_syrope_slow)) DEALLOCATE (system%snap_syrope_slow, system%snap_syrope_tmax) IF (ALLOCATED(system%snap_fr_anchor)) DEALLOCATE (system%snap_fr_anchor) + IF (ALLOCATED(system%snap_sub)) DEALLOCATE (system%snap_sub) system%snap_valid = .FALSE. system%initialized = .FALSE. system%n_lines = 0 @@ -1251,7 +1258,8 @@ RECURSIVE SUBROUTINE CD_Step_System(system, dt, q_coupled, v_coupled, a_coupled, LOGICAL :: conv2, stall2 CHARACTER(160) :: em REAL(wp), ALLOCATABLE :: q0(:), v0(:), a0(:), qm(:), vm(:), am(:), qs(:), vs(:), as(:) - REAL(wp), ALLOCATABLE :: dl1s(:), slows(:), tmaxs(:), frs(:, :) + REAL(wp), ALLOCATABLE :: dl1s(:), slows(:), tmaxs(:), frs(:, :), hmaxs(:) + TYPE(CD_SubstepStats), ALLOCATABLE :: subs(:) converged = .FALSE. stalled = .FALSE. @@ -1310,13 +1318,22 @@ RECURSIVE SUBROUTINE CD_Step_System(system, dt, q_coupled, v_coupled, a_coupled, n_team = line_team_size(system) !$OMP PARALLEL DEFAULT(SHARED) PRIVATE(i) NUM_THREADS(n_team) IF(n_team > 1) CALL CD_Fatal_Thread_Init() ! this thread can report its own stack overflow - !$OMP DO SCHEDULE(STATIC) + ! DYNAMIC: a line that is sub-stepped (CD_Step_Model) costs several of its plain steps, so the + ! lines take unequal times; each line's result does not depend on the thread that steps it + !$OMP DO SCHEDULE(DYNAMIC) DO i = 1, system%n_lines + ! the halves of a stall recovery (0 < depth < MAX_SUBDIV) take their steps as given, as the + ! rungs of CD_Step_Model_Recovering do: no rotation- and snap-resolved sub-steps of + ! sub-steps. The plain full-dt rerun at the depth floor (depth = MAX_SUBDIV) steps every line + ! as the nominal step (depth 0) does, so its result is that of the step without the + ! fallback; the junction step (JUNCTION_NO_SUBDIV = MAX_SUBDIV) likewise, its armed lines + ! being taken as given by CD_Step_Model itself CALL CD_Step_Model(system%lines(i), dt, system%line_converged(i), system%line_stalled(i), & system%line_iter(i), system%line_stat(i), system%line_msg(i), & prescribed_q=system%lines(i)%q_prescribed_work, & prescribed_v=system%lines(i)%v_prescribed_work, & - prescribed_a=system%lines(i)%a_prescribed_work) + prescribed_a=system%lines(i)%a_prescribed_work, & + as_given=depth > 0 .AND. depth < MAX_SUBDIV) END DO !$OMP END DO !$OMP END PARALLEL @@ -1375,7 +1392,8 @@ RECURSIVE SUBROUTINE CD_Step_System(system, dt, q_coupled, v_coupled, a_coupled, IF (system%lines(i)%has_syrope) nsy = nsy + SIZE(system%lines(i)%syrope_slow) IF (CD_Model_Has_Friction(system%lines(i))) nfr = nfr + SIZE(system%lines(i)%fr_anchor, 2) END DO - ALLOCATE (qs(ntot), vs(ntot), as(ntot), dl1s(nve), slows(nsy), tmaxs(nsy), frs(2, nfr)) + ALLOCATE (qs(ntot), vs(ntot), as(ntot), dl1s(nve), slows(nsy), tmaxs(nsy), frs(2, nfr), & + hmaxs(system%n_lines), subs(system%n_lines)) lo = 1 lo_ve = 1 lo_sy = 1 @@ -1385,6 +1403,10 @@ RECURSIVE SUBROUTINE CD_Step_System(system, dt, q_coupled, v_coupled, a_coupled, qs(lo:hi) = system%lines(i)%q vs(lo:hi) = system%lines(i)%v as(lo:hi) = system%lines(i)%a + ! the run audit's largest solver step and the sub-stepping diagnostics restore with the + ! states, so the halves of a fallback that does not complete leave no trace + hmaxs(i) = system%lines(i)%audit_hmax + subs(i) = system%lines(i)%sub_stats lo = hi + 1 IF (CD_Model_Has_Friction(system%lines(i))) THEN ne = SIZE(system%lines(i)%fr_anchor, 2) @@ -1427,6 +1449,8 @@ RECURSIVE SUBROUTINE CD_Step_System(system, dt, q_coupled, v_coupled, a_coupled, system%lines(i)%q = qs(lo:hi) system%lines(i)%v = vs(lo:hi) system%lines(i)%a = as(lo:hi) + system%lines(i)%audit_hmax = hmaxs(i) + system%lines(i)%sub_stats = subs(i) lo = hi + 1 IF (CD_Model_Has_Friction(system%lines(i))) THEN ne = SIZE(system%lines(i)%fr_anchor, 2) @@ -1491,7 +1515,7 @@ SUBROUTINE CD_Step_System_Junction(system, dt, q_coupled, v_coupled, a_coupled, LOGICAL, INTENT(IN), OPTIONAL :: level_dofs(:) INTEGER :: i, j, k, lo, nc, nf LOGICAL :: valid, fresh - LOGICAL, ALLOCATABLE :: act(:), lev(:) + LOGICAL, ALLOCATABLE :: act(:), lev(:), armed(:) REAL(wp), ALLOCATABLE :: r(:), kl(:, :) loads = CD_ZERO @@ -1509,6 +1533,11 @@ SUBROUTINE CD_Step_System_Junction(system, dt, q_coupled, v_coupled, a_coupled, END IF fresh = .TRUE. IF (PRESENT(refresh)) fresh = refresh + ! A line with no active junction DOF (both ends on fixed or anchored points) adds nothing to + ! the junction loads and tangent: its end query stays unarmed, so CD_Step_Model sub-steps + ! it as on any other route (its loads at the inactive DOFs are not returned). Every other + ! line is armed and taken as given. + ALLOCATE (armed(system%n_lines)) DO i = 1, system%n_lines lo = system%line_off(i) nc = system%line_off(i + 1) - lo @@ -1520,7 +1549,10 @@ SUBROUTINE CD_Step_System_Junction(system, dt, q_coupled, v_coupled, a_coupled, act(j) = active(system%coupled_dof_map(lo + j - 1)) IF (PRESENT(level_dofs)) lev(j) = level_dofs(system%coupled_dof_map(lo + j - 1)) END DO - IF (PRESENT(levels)) THEN + armed(i) = ANY(act) + IF (.NOT. armed(i)) THEN + CALL CD_Set_Model_EndQuery(system%lines(i), .FALSE.) + ELSE IF (PRESENT(levels)) THEN CALL CD_Set_Model_EndQuery(system%lines(i), .TRUE., act, warm, fresh, levels, lev) ELSE CALL CD_Set_Model_EndQuery(system%lines(i), .TRUE., act, warm, fresh) @@ -1531,6 +1563,7 @@ SUBROUTINE CD_Step_System_Junction(system, dt, q_coupled, v_coupled, a_coupled, JUNCTION_NO_SUBDIV) IF (ErrStat == CD_SYSTEM_OK .AND. converged) THEN DO i = 1, system%n_lines + IF (.NOT. armed(i)) CYCLE lo = system%line_off(i) nc = system%line_off(i + 1) - lo nf = SIZE(system%lines(i)%fixed_dofs) @@ -2940,6 +2973,11 @@ SUBROUTINE save_line_states(system, ErrStat, ErrMsg) system%lines(i)%q_rollback = system%lines(i)%q system%lines(i)%v_rollback = system%lines(i)%v system%lines(i)%a_rollback = system%lines(i)%a + ! the run audit's largest solver step rolls back too: a rolled-back (stalled) full step + ! must not count when its halves are what the line commits + system%lines(i)%audit_hmax_rollback = system%lines(i)%audit_hmax + ! the sub-stepping diagnostics likewise: a rolled-back step is not counted + system%lines(i)%sub_stats_rollback = system%lines(i)%sub_stats ! the viscoelastic dl_1 state advances with every committed line step, so ! it must roll back with q/v/a (a line that stepped can be rolled back ! when a sibling line or the coupled point solve fails) @@ -2967,6 +3005,8 @@ SUBROUTINE restore_line_states(system) system%lines(i)%q = system%lines(i)%q_rollback system%lines(i)%v = system%lines(i)%v_rollback system%lines(i)%a = system%lines(i)%a_rollback + system%lines(i)%audit_hmax = system%lines(i)%audit_hmax_rollback + system%lines(i)%sub_stats = system%lines(i)%sub_stats_rollback IF (system%lines(i)%has_viscoelastic) & system%lines(i)%ve_dl_1 = system%lines(i)%ve_dl_1_rollback IF (system%lines(i)%has_syrope) THEN @@ -3092,6 +3132,10 @@ SUBROUTINE CD_System_Snapshot(system, ErrStat, ErrMsg) RESHAPE(system%lines(i)%fr_anchor, [2*SIZE(system%lines(i)%fr_anchor, 2)]) lo = hi + 1 END DO + IF (.NOT. ALLOCATED(system%snap_sub)) ALLOCATE (system%snap_sub(system%n_lines)) + DO i = 1, system%n_lines + system%snap_sub(i) = system%lines(i)%sub_stats + END DO IF (ALLOCATED(system%points)) system%snap_points = system%points IF (ALLOCATED(system%bindings)) system%snap_bindings = system%bindings IF (ALLOCATED(system%coupled_dof_map)) system%snap_map = system%coupled_dof_map @@ -3155,6 +3199,11 @@ SUBROUTINE CD_System_Restore(system, ErrStat, ErrMsg) [2, SIZE(system%lines(i)%fr_anchor, 2)]) lo = hi + 1 END DO + IF (ALLOCATED(system%snap_sub)) THEN + DO i = 1, system%n_lines + system%lines(i)%sub_stats = system%snap_sub(i) + END DO + END IF IF (ALLOCATED(system%snap_points)) system%points = system%snap_points ! Roll the detach topology back with the states: a failure fired after the ! snapshot un-fires (its row will re-trigger on the re-advance). @@ -3206,6 +3255,26 @@ SUBROUTINE CD_System_Restore(system, ErrStat, ErrMsg) END IF END SUBROUTINE CD_System_Restore + SUBROUTINE CD_Get_System_Substep_Counts(system, calls, events, max_used, capped, fallbacks) + !! The rotation- and snap-resolved sub-stepping diagnostics of the EI=0 lines + !! (CD_Get_Model_Substep_Counts) summed over the lines (max_used: the largest count). + TYPE(CD_SystemType), INTENT(IN) :: system + INTEGER(int64), INTENT(OUT) :: calls, events, capped, fallbacks + INTEGER, INTENT(OUT) :: max_used + INTEGER(int64) :: c, e, k, f + INTEGER :: i, m + calls = 0; events = 0; max_used = 1; capped = 0; fallbacks = 0 + IF (.NOT. ALLOCATED(system%lines)) RETURN + DO i = 1, SIZE(system%lines) + CALL CD_Get_Model_Substep_Counts(system%lines(i), c, e, m, k, f) + calls = calls + c + events = events + e + max_used = MAX(max_used, m) + capped = capped + k + fallbacks = fallbacks + f + END DO + END SUBROUTINE CD_Get_System_Substep_Counts + PURE FUNCTION CD_System_Fallback_Count() RESULT(n) !! Subdivision-retry entries since the last CD_System_Fallback_Reset (see the !! module-level tripwire note). diff --git a/src/openfast/CableDyn_OF.f90 b/src/openfast/CableDyn_OF.f90 index 9443f1b5..f280770e 100644 --- a/src/openfast/CableDyn_OF.f90 +++ b/src/openfast/CableDyn_OF.f90 @@ -76,7 +76,7 @@ MODULE CableDyn CD_AGG_Step_Moving, CD_AGG_CalcOutput, CD_AGG_GetMovingPointMesh, & CD_AGG_Snapshot, CD_AGG_Restore, & CD_AGG_NMovingPoints, CD_AGG_NDynamicPoints, CD_AGG_Refresh_PointMesh, & - CD_AGG_NFailures, & + CD_AGG_NFailures, CD_AGG_Get_Substep_Counts, & CD_AGG_HasRigid6, CD_AGG_HasRod, & CD_AGG_Rigid6_MirrorSize, CD_AGG_Get_Rigid6_States, & CD_AGG_Set_Rigid6_States, & @@ -2390,6 +2390,7 @@ END SUBROUTINE CD_CalcContStateDeriv !---------------------------------------------------------------------------------------------------------------------------------- SUBROUTINE CD_End(u, p, x, xd, z, other, y, m, ErrStat , ErrMsg) + USE, INTRINSIC :: ISO_FORTRAN_ENV, ONLY: int64 TYPE(CD_InputType) , INTENT(INOUT) :: u TYPE(CD_ParameterType) , INTENT(INOUT) :: p TYPE(CD_ContinuousStateType) , INTENT(INOUT) :: x @@ -2404,6 +2405,9 @@ SUBROUTINE CD_End(u, p, x, xd, z, other, y, m, ErrStat , ErrMsg) character(*), parameter :: RoutineName = 'CD_End' INTEGER(IntKi) :: ErrStat2 INTEGER :: hn_step, hn_resid, hn_solve, hn_am, hn_alloc, hn_tan + INTEGER(int64) :: sb_calls, sb_events, sb_capped, sb_fallbacks + INTEGER :: sb_max, sb_ios + CHARACTER(24) :: sb_txt(5) REAL(wp) :: ht_step, ht_resid, ht_eff, ht_solve, ht_am, ht_tan CHARACTER(ErrMsgLen) :: ErrMsg2 @@ -2413,6 +2417,23 @@ SUBROUTINE CD_End(u, p, x, xd, z, other, y, m, ErrStat , ErrMsg) IF (ALLOCATED(Inst)) THEN IF (m%CDInst >= 1 .AND. m%CDInst <= SIZE(Inst)) THEN IF (Inst(m%CDInst)%active) THEN + ! the rotation- and snap-resolved sub-steps of the EI=0 lines (ei0_substeps), as the + ! standalone driver reports them + CALL CD_AGG_Get_Substep_Counts( Inst(m%CDInst)%agg, sb_calls, sb_events, sb_max, sb_capped, & + sb_fallbacks ) + IF (sb_events > 0 .OR. sb_fallbacks > 0) THEN + ! 64-bit counts, written here (Num2LStr takes the default integer kind) + WRITE (sb_txt(1), '(I0)', IOSTAT=sb_ios) sb_events + WRITE (sb_txt(2), '(I0)', IOSTAT=sb_ios) sb_calls + WRITE (sb_txt(3), '(I0)', IOSTAT=sb_ios) sb_max + WRITE (sb_txt(4), '(I0)', IOSTAT=sb_ios) sb_capped + WRITE (sb_txt(5), '(I0)', IOSTAT=sb_ios) sb_fallbacks + CALL WrScr( ' CableDyn: ei0_substeps auto solved '//TRIM(sb_txt(1))//' of the '// & + TRIM(sb_txt(2))//' EI = 0 line step(s) it examined in sub-steps (at most '// & + TRIM(sb_txt(3))//' sub-steps per step); '//TRIM(sb_txt(4))// & + ' needed more than ei0_substep_max; '//TRIM(sb_txt(5))// & + ' kept the whole step after a sub-step did not converge.' ) + END IF IF (Inst(m%CDInst)%prof_enabled) THEN CALL WrScr( ' CableDyn profile: init_s='// & TRIM(Num2LStr(REAL(Inst(m%CDInst)%prof_t_init, DbKi)))// & diff --git a/tests/test_deck_driver.f90 b/tests/test_deck_driver.f90 index 75ff7106..ff565bac 100644 --- a/tests/test_deck_driver.f90 +++ b/tests/test_deck_driver.f90 @@ -1655,6 +1655,13 @@ PROGRAM test_deck_driver CALL expect_badinput('deck_badtentol.dat', deck_with_bad_tensile_tolerance(), 'negative tensile tolerance') CALL expect_badinput('deck_badrecovery.dat', deck_with_bad_recovery_cap(), 'non-finite recovery cap') CALL expect_badinput('deck_fracrecovery.dat', deck_with_fractional_recovery_cap(), 'fractional recovery cap') + ! the ei0 sub-stepping options take the Python deck reader's rules: ei0_substep_max is an integer + ! to within 16 ulp whose nearest integer lies in [2, 1024] + CALL expect_badinput('deck_ei0mode.dat', deck_with_ei0_option('on ei0_substeps'), 'invalid ei0_substeps') + CALL expect_badinput('deck_ei0angle.dat', deck_with_ei0_option('0 ei0_substep_angle'), 'zero ei0_substep_angle') + CALL expect_badinput('deck_ei0max.dat', deck_with_ei0_option('1025 ei0_substep_max'), 'ei0_substep_max above 1024') + CALL expect_badinput('deck_ei0maxfr.dat', deck_with_ei0_option('2.5 ei0_substep_max'), 'fractional ei0_substep_max') + CALL expect_badinput('deck_ei0maxbig.dat', deck_with_ei0_option('2048.5 ei0_substep_max'), 'large ei0_substep_max') CALL expect_badinput('deck_body.dat', deck_with_bodies(), 'Rigid6 BODY') CALL expect_badinput('deck_ei.dat', deck_with_finite_ei(), 'finite-EI section') CALL expect_badinput('deck_badgj.dat', deck_with_bad_native_finite_ei(), 'explicit finite-EI') @@ -7170,4 +7177,9 @@ CHARACTER(900) FUNCTION deck_with_fractional_recovery_cap() RESULT(s) '4.5 recovery_max_substeps' END FUNCTION deck_with_fractional_recovery_cap + CHARACTER(900) FUNCTION deck_with_ei0_option(row) RESULT(s) + CHARACTER(*), INTENT(IN) :: row + s = 'badei0'//NEW_LINE('a')//'--- OPTIONS ---'//NEW_LINE('a')//row + END FUNCTION deck_with_ei0_option + END PROGRAM test_deck_driver diff --git a/tests/test_ei0_slack_dynamics.f90 b/tests/test_ei0_slack_dynamics.f90 index 167883b1..195ef517 100644 --- a/tests/test_ei0_slack_dynamics.f90 +++ b/tests/test_ei0_slack_dynamics.f90 @@ -5,8 +5,10 @@ PROGRAM test_ei0_slack_dynamics !! Tension-only (EI = 0) lines that go slack and snap taut, at the default rhoInf = 0.4: !! 1. A light, axially stiff cable (80 kg/m, EA 8e8 N, 115 x 2 m segments) under 3 m / 10 s !! heave at dtM 0.1 s. The configuration-blended step reported 0.61 MN at the fairlead and - !! 20 MN at the anchor against about 0.1 MN (rhoInf 0 and small-step references); the - !! force blend stays below 0.2 MN. + !! 20 MN at the anchor; the force blend stays below 0.2 MN. This undamped EI = 0 deck has + !! no converged snap peak (it rises as dtM falls, to 0.32-0.46 MN at microsecond steps, as + !! single segments rattle); converged finite-EI runs give 0.093 MN at the fairlead and + !! 0.057 MN at the anchor, so the bounds catch a spike or a lost snap, not a reference. !! 2. The same cable at dtM 0.01 s, where the force blend alone still fed a rattle of !! single-step segment spikes (2.3 MN by 24 s) through the energy a release creates; !! with the release cap every segment stays below 0.2 MN. @@ -14,8 +16,10 @@ PROGRAM test_ei0_slack_dynamics !! 1.80 MN at the fairlead (2.69 MN configuration-blended), as at dtM 0.0025 s. !! 4. The run audit of the driver (stdout of the executable given as the first argument): !! the configuration blend (False alpha_force_blend) of case 1 warns of a non-physical - !! tension spike, the force blend does not; rhoInf above 0.95 prints its note; a 10 m - !! sway at dtM 0.2 s prints the segment-turn advisory; the unresolved slack-to-taut + !! tension spike and is not sub-stepped, the force blend does not warn; rhoInf above + !! 0.95 prints its note; a 10 m sway at dtM 0.2 s prints the segment-turn advisory with + !! off ei0_substeps, and with the default auto is sub-stepped instead (reported; the turn + !! per solver step drops from about 6 deg to about 1.3 deg); the unresolved slack-to-taut !! snaps of case 1 print the snap note. !! 5. The Newton tangent of the force-blended step against a central finite difference of its !! residual (the step's probe_q hook), on a three-segment tension-only chain with one fixed @@ -53,6 +57,12 @@ PROGRAM test_ei0_slack_dynamics !! 9. A lightly damped viscoelastic version of the light cable at dtM 0.1 s (the cap on its !! law segments) and a long taut Syrope line in 4 m surge that goes slack: no spike !! warning, and peaks within the band of small-step references. + !! 10. An elastic segment with an axial dashpot that is slack at t_n and whose ends separate + !! (or approach) there, then turn or reverse within the step: the kept dashpot share + !! returns at most the dashpot's one-step dissipation T_d,n |ldot_n| dt plus the end + !! share's credit (it returned many times that before the cap covered slack starts), a + !! slack segment with no step-start dashpot force keeps the plain blend, and the tangent + !! of a capped row matches the finite difference on the banded and the dense path. USE CableDyn_Precision, ONLY: wp USE CableDyn_DeckDriver, ONLY: CD_Run_Deck_Driver, CD_DECKDRV_OK USE CableDyn_Dynamic, ONLY: GenAlphaConfig, CD_CableGenAlphaWorkspace, CD_Cable_Gen_Alpha_Step, CD_DYN_OK @@ -87,6 +97,7 @@ PROGRAM test_ei0_slack_dynamics CALL case_law_release_cap() CALL case_law_damped_release() CALL case_damped_elastic_release() + CALL case_slack_dashpot_release() CALL case_load_share_tangent() CALL case_warm_resolve_reuse() CALL case_light_cable_coarse_step() @@ -288,6 +299,28 @@ LOGICAL FUNCTION file_contains(path, needle) RESULT(found) CLOSE (u) END FUNCTION file_contains + REAL(wp) FUNCTION noted_turn(path) RESULT(turn) + !! The turn (deg) of the run audit's segment-turn note in a driver log, 0 without the note. + CHARACTER(*), INTENT(IN) :: path + CHARACTER(*), PARAMETER :: KEY = 'a taut segment turned up to' + INTEGER :: u, ios, i + CHARACTER(4096) :: line + turn = 0.0_wp + OPEN (NEWUNIT=u, FILE=path, STATUS='OLD', ACTION='READ', IOSTAT=ios) + IF (ios /= 0) RETURN + DO + READ (u, '(A)', IOSTAT=ios) line + IF (ios /= 0) EXIT + i = INDEX(line, KEY) + IF (i > 0) THEN + READ (line(i + LEN(KEY):), *, IOSTAT=ios) turn + IF (ios /= 0) turn = -1.0_wp + EXIT + END IF + END DO + CLOSE (u) + END FUNCTION noted_turn + SUBROUTINE echo_tail(path, n) !! Print the last n lines of a log (the reason a driver run stopped). CHARACTER(*), INTENT(IN) :: path @@ -606,6 +639,7 @@ END SUBROUTINE case_viscoelastic_surge SUBROUTINE case_run_audit() LOGICAL :: ok + REAL(wp) :: turn_off, turn_auto CHARACTER(64) :: opts(4) ! the configuration blend of case 1: its spikes are reported once, as a warning. Its ! non-physical spikes make the run chaotic: whether it completes or a later spike stops it @@ -648,20 +682,44 @@ SUBROUTINE case_run_audit() CALL require(ok, 'audit:rhoinf-run') CALL require(file_contains('ei0slack_audit_rho.log', 'Note: rhoInf = 0.990 leaves almost no numerical'), & 'audit:rhoinf-note') - ! a 10 m sway at dtM 0.2 s turns the segments by several degrees per step + ! a 10 m sway at dtM 0.2 s turns the segments by several degrees per step: taken as given + ! (off ei0_substeps) the run notes the turn CALL write_motion('ei0slack_sway.txt', 1, [5.0_wp, 0.0_wp, -14.0_wp], 2, 10.0_wp, 10.0_wp, 10.0_wp, & 0.2_wp, 20.0_wp) opts(1) = '0.2 dtM' opts(2) = '20.0 TMax' opts(3) = 'ei0slack_sway.txt motionFile' - opts(4) = '' + opts(4) = 'off ei0_substeps' CALL write_deck('ei0slack_audit_sway.dat', CABLE, [205.0_wp, 0.0_wp, -80.0_wp], [5.0_wp, 0.0_wp, -14.0_wp], & 230.0_wp, 115, 80.0_wp, '-', opts) CALL run_driver_logged('ei0slack_audit_sway.dat', 'ei0slack_audit_sway', 'ei0slack_audit_sway.log', ok) CALL require(ok, 'audit:sway-run') CALL require(file_contains('ei0slack_audit_sway.log', 'Note: line 1: a taut segment turned up to'), & 'audit:segment-turn-note') + CALL require(file_contains('ei0slack_audit_sway.log', 'set ei0_substeps auto'), 'audit:segment-turn-remedy') CALL require(.NOT. file_contains('ei0slack_audit_sway.log', 'Warning: line'), 'audit:sway-no-warning') + ! the default (auto) sub-steps those steps: the run reports the sub-stepping, and the turn + ! per solver step drops to about 1 deg (the steps recovered after a stall take their four + ! sub-steps as given, so a note may remain for them): 1.27 deg against 6.21 deg taken as + ! given (gfortran, Windows). A step left unresolved turns by the full step's turn, a + ! recovered one by a quarter of it, so half the turn taken as given separates the two + ! without depending on which steps round-off makes stall + opts(4) = '' + CALL write_deck('ei0slack_audit_sway_auto.dat', CABLE, [205.0_wp, 0.0_wp, -80.0_wp], & + [5.0_wp, 0.0_wp, -14.0_wp], 230.0_wp, 115, 80.0_wp, '-', opts) + CALL run_driver_logged('ei0slack_audit_sway_auto.dat', 'ei0slack_audit_sway_auto', & + 'ei0slack_audit_sway_auto.log', ok) + CALL require(ok, 'audit:sway-auto-run') + CALL require(file_contains('ei0slack_audit_sway_auto.log', 'ei0_substeps auto solved'), 'audit:substep-note') + turn_off = noted_turn('ei0slack_audit_sway.log') + turn_auto = noted_turn('ei0slack_audit_sway_auto.log') + WRITE (*, '(A,F7.3,A,F7.3,A)') ' sway at dtM 0.2 s: largest turn per solver step ', turn_off, ' deg (off), ', & + turn_auto, ' deg (auto)' + CALL require(turn_off > 4.0_wp .AND. turn_auto >= 0.0_wp .AND. turn_auto < 0.5_wp*turn_off, & + 'audit:sway-auto-resolved-turn') + ! the configuration blend (paper mode) takes every step as given + CALL require(.NOT. file_contains('ei0slack_audit_cfg.log', 'ei0_substeps auto solved'), & + 'audit:configuration-blend-not-sub-stepped') END SUBROUTINE case_run_audit ! ------------------------------------------------------------------------------------------ @@ -1155,6 +1213,141 @@ SUBROUTINE damped_tangent_case(label, qn, vn, q1, l0, ea, ad, t0) CALL fd_tangent_check(label, qn, vn, z, q1, l0, ea, [2.0_wp, 3.0_wp, 1.5_wp], .FALSE., axial_damping=ad) END SUBROUTINE damped_tangent_case + SUBROUTINE case_slack_dashpot_release() + !! The dashpot segment of case_damped_elastic_release slack at t_n (e_n = -1.6 mm), its far + !! end moving at +-0.05, 0.5 or 2 m/s along the chord (dashpot tension T_d,n = BA rate/l0, a + !! compressive one for the negative rate), turning by 0 to 180 degrees within the step and + !! ending slack or taut. The kept share alpha_f T_d,n t_n returns T_k p (T_k the kept + !! tension the residual carries, p the projected shortening): at most + !! W_d + N_d, W_d = T_d,n ldot_n dt the dashpot's one-step dissipation and + !! N_d = max((1 - alpha_f) T_d,n+1 p_n+1, 0) the end share's credit. Without the cap (no + !! axial_damping) it returns alpha_f T_d,n p, up to 46 times W_d + N_d on these rows (the cap + !! acts where the end share does little work: turns that end near the projection of the + !! step-start chord; a reversal along the chord feeds the end share's dashpot instead). + !! A slack segment with no step-start dashpot + !! force keeps the plain blend, and the tangent matches the finite difference where the + !! cap acts. + REAL(wp), PARAMETER :: L0(3) = [1.0_wp, 1.2_wp, 0.8_wp], EA(3) = [1.0e6_wp, 1.5e6_wp, 0.8e6_wp] + REAL(wp), PARAMETER :: DIRS(3, 3) = RESHAPE([1.0_wp, 0.2_wp, 0.1_wp, 0.3_wp, 1.0_wp, -0.2_wp, & + -0.2_wp, 0.4_wp, 1.0_wp], [3, 3]) + REAL(wp), PARAMETER :: THETA(8) = [0.0_wp, 2.0_wp, 5.0_wp, 20.0_wp, 45.0_wp, 90.0_wp, 135.0_wp, 180.0_wp] + REAL(wp), PARAMETER :: S1(9) = [-0.5_wp, -0.1_wp, -0.01_wp, -2.0e-3_wp, -1.0e-4_wp, 1.0e-4_wp, & + 1.0e-3_wp, 0.01_wp, 0.05_wp] + REAL(wp), PARAMETER :: OFS(5) = [-0.02_wp, -0.003_wp, 0.0_wp, 0.003_wp, 0.02_wp] + REAL(wp), PARAMETER :: RATE(4) = [0.05_wp, 0.5_wp, 2.0_wp, -0.5_wp], DT = 0.05_wp, RHO = 0.4_wp + REAL(wp), PARAMETER :: BA = 2.0e4_wp, AD(3) = [0.0_wp, 0.0_wp, BA] + REAL(wp), PARAMETER :: RHO_TINY(3) = [1.0e-12_wp, 1.0e-12_wp, 1.0e-12_wp] + REAL(wp) :: qn(12), q1(12), vn(12), z(12), v1(12), R(12), Rp(12), K(9, 9), tn(3), u(3), dir(3) + REAL(wp) :: d0(3), d1(3), t1(3), l1, td0, td1, p, p1, am, af, beta, gamma, wd, nd, tk, wk, wu + REAL(wp) :: worst, unc_ratio, unc_excess, dev + INTEGER :: i, j, ir, nact, nrow + CALL reset_chain_load() + cb_dash_elem = 3 + cb_ba_dash = BA + cb_l0_dash = L0(3) + am = (2.0_wp*RHO - 1.0_wp)/(RHO + 1.0_wp) + af = RHO/(RHO + 1.0_wp) + beta = 0.25_wp*(1.0_wp - am + af)**2 + gamma = 0.5_wp - am + af + CALL chain_nodes(DIRS, [0.010_wp, 0.020_wp, -0.002_wp], L0, qn) + z = 0.0_wp + d0 = qn(10:12) - qn(7:9) + tn = d0/NORM2(d0) + u = [tn(2), -tn(1), 0.0_wp] + u = u/NORM2(u) + worst = -HUGE(1.0_wp) + unc_ratio = 0.0_wp + unc_excess = 0.0_wp + nact = 0 + nrow = 0 + DO ir = 1, SIZE(RATE) + vn = 0.0_wp + vn(10:12) = RATE(ir)*tn + td0 = BA*RATE(ir)/L0(3) + wd = td0*RATE(ir)*DT + DO i = 1, SIZE(THETA) + DO j = 1, SIZE(S1) + SIZE(OFS) + dir = COS(THETA(i)*PI/180.0_wp)*tn + SIN(THETA(i)*PI/180.0_wp)*u + IF (j <= SIZE(S1)) THEN + l1 = L0(3)*(1.0_wp + S1(j)) + ELSE + ! the end near the projection of the step-start chord (p_n+1 ~ OFS): a turn whose + ! end share does little work, where the cap acts + l1 = MAX(NORM2(d0)*COS(THETA(i)*PI/180.0_wp) + OFS(j - SIZE(S1)), 0.05_wp*L0(3)) + END IF + q1 = qn + q1(10:12) = qn(7:9) + l1*dir + CALL probe_chain(qn, vn, z, q1, L0, EA, RHO_TINY, .TRUE., R, K, axial_damping=AD) + CALL probe_chain(qn, vn, z, q1, L0, EA, RHO_TINY, .TRUE., Rp, K) + v1 = gamma/(beta*DT)*(q1 - qn) + (1.0_wp - gamma/beta)*vn + v1(1:3) = 0.0_wp + d1 = q1(10:12) - q1(7:9) + l1 = NORM2(d1) + t1 = d1/l1 + p = NORM2(d0) - DOT_PRODUCT(tn, d1) + p1 = l1 - DOT_PRODUCT(t1, d0) + td1 = BA*DOT_PRODUCT(t1, v1(10:12) - v1(7:9))/L0(3) + nd = MAX((1.0_wp - af)*td1*p1, 0.0_wp) + ! the kept tension: alpha_f T_d,n plus the cap's correction along t_n at node b + tk = af*td0 + DOT_PRODUCT(R(10:12) - Rp(10:12), tn) + wk = tk*p + wu = af*td0*p + nrow = nrow + 1 + IF (MAXVAL(ABS(R(10:12) - Rp(10:12))) > 1.0e-9_wp*ABS(td0)) nact = nact + 1 + worst = MAX(worst, (wk - (wd + nd))/wd) + unc_ratio = MAX(unc_ratio, wu/(wd + nd)) + unc_excess = MAX(unc_excess, (wu - (wd + nd))/wd) + IF (j > SIZE(S1)) CYCLE + IF (THETA(i) == 0.0_wp .AND. S1(j)*RATE(ir) > 0.0_wp) THEN + ! a segment that keeps its direction and moves on at its step-start sense: uncapped + CALL require(MAXVAL(ABS(R(10:12) - Rp(10:12))) == 0.0_wp, 'slack-dashpot:same-sense-uncapped') + END IF + END DO + END DO + END DO + WRITE (*, '(A,I0,A,I0,A,ES10.3,A,ES10.3,A,ES10.3)') ' slack dashpot: cap active at ', nact, ' of ', nrow, & + ' rows; kept-share work over W_d + N_d, / W_d: ', worst, ' (uncapped ', unc_excess, & + '; uncapped / (W_d + N_d) up to ', unc_ratio + CALL require(nact >= 20, 'slack-dashpot:cap-active') + CALL require(unc_ratio > 10.0_wp, 'slack-dashpot:uncapped-exceeds') + CALL require(worst <= 1.0e-9_wp, 'slack-dashpot:bound') + ! a slack segment with no step-start dashpot force (ends at rest along the chord) keeps the + ! plain blend bit for bit, reversed or not + vn = 0.0_wp + vn(10:12) = 0.5_wp*u + q1 = qn + q1(10:12) = qn(7:9) - 0.9_wp*L0(3)*tn + CALL probe_chain(qn, vn, z, q1, L0, EA, RHO_TINY, .TRUE., R, K, axial_damping=AD) + CALL probe_chain(qn, vn, z, q1, L0, EA, RHO_TINY, .TRUE., Rp, K) + dev = MAXVAL(ABS(R - Rp)) + CALL require(dev == 0.0_wp, 'slack-dashpot:no-start-dashpot-uncapped') + ! the tangent where the cap acts: turning 60 degrees with the end at p_n+1 = 3 mm (end + ! share pushing, no credit) and 20 mm (a positive credit), extending at 0.5 m/s at t_n + vn = 0.0_wp + vn(10:12) = 0.5_wp*tn + dir = COS(PI/3.0_wp)*tn + SIN(PI/3.0_wp)*u + q1 = qn + q1(10:12) = qn(7:9) + (0.5_wp*NORM2(d0) + 3.0e-3_wp)*dir + CALL slack_tangent_case('slack-dashpot-no-credit', qn, vn, q1, L0, EA, AD, BA*0.5_wp/L0(3)) + q1(10:12) = qn(7:9) + (0.5_wp*NORM2(d0) + 2.0e-2_wp)*dir + CALL slack_tangent_case('slack-dashpot-credit', qn, vn, q1, L0, EA, AD, BA*0.5_wp/L0(3)) + CALL reset_chain_load() + END SUBROUTINE case_slack_dashpot_release + + SUBROUTINE slack_tangent_case(label, qn, vn, q1, l0, ea, ad, td0) + !! A capped row of case_slack_dashpot_release: the cap is active, and the tangent matches + !! the finite difference on both paths. + CHARACTER(*), INTENT(IN) :: label + REAL(wp), INTENT(IN) :: qn(12), vn(12), q1(12), l0(3), ea(3), ad(3), td0 + REAL(wp) :: Ra(12), Rb(12), Kd(9, 9), z(12) + z = 0.0_wp + CALL probe_chain(qn, vn, z, q1, l0, ea, [1.0e-12_wp, 1.0e-12_wp, 1.0e-12_wp], .TRUE., Ra, Kd, axial_damping=ad) + CALL probe_chain(qn, vn, z, q1, l0, ea, [1.0e-12_wp, 1.0e-12_wp, 1.0e-12_wp], .TRUE., Rb, Kd) + CALL require(MAXVAL(ABS(Ra(10:12) - Rb(10:12))) > 1.0e-2_wp*ABS(td0), label//':cap-active') + CALL fd_tangent_check(label, qn, vn, z, q1, l0, ea, [2.0_wp, 3.0_wp, 1.5_wp], .TRUE., axial_damping=ad) + CALL fd_tangent_check(label, qn, vn, z, q1, l0, ea, [2.0_wp, 3.0_wp, 1.5_wp], .FALSE., axial_damping=ad) + END SUBROUTINE slack_tangent_case + SUBROUTINE law_cap_config(label, strain_n, strain_1, dirs_trial) CHARACTER(*), INTENT(IN) :: label REAL(wp), INTENT(IN) :: strain_n(3), strain_1(3) @@ -1423,16 +1616,18 @@ SUBROUTINE case_law_slack_runs() REAL(wp) :: fair, anch, seg_min ! the light cable as a lightly damped viscoelastic line, 3 m heave at dtM 0.1 s: anchor ! 8.2e4 to 9.5e4 N and fairlead 0.97e5 to 1.02e5 N at dtM 0.5 to 2.5 ms; without the cap - ! on its law segments 1.45e5 N at the anchor. At 0.1 s the anchor snap is not resolved in - ! time (the run notes it), so its peak depends on round-off: 8.5e4 N with gfortran on - ! Windows, other values on other platforms. The upper bound is the check of the cap; the - ! lower bound only asks that the snap reaches the anchor. + ! on its law segments 1.45e5 N at the anchor, both taking every step as given. At 0.1 s the + ! anchor snap is not resolved in time (the run notes it), so its peak depends on round-off: + ! 8.5e4 N with gfortran on Windows, other values on other platforms. The run takes every + ! step as given (off ei0_substeps), as the 1.45e5 N without the cap was measured, so the + ! upper bound checks the cap against that figure; the lower bound only asks that the snap + ! reaches the anchor. The sub-steps of the default are checked on this law by test_syrope. CALL write_motion('ei0slack_heave_ve.txt', 1, [5.0_wp, 0.0_wp, -14.0_wp], 3, 3.0_wp, 10.0_wp, 10.0_wp, & 0.1_wp, 40.0_wp) opts(1) = '0.1 dtM' opts(2) = '40.0 TMax' opts(3) = 'ei0slack_heave_ve.txt motionFile' - opts(4) = '' + opts(4) = 'off ei0_substeps' CALL write_deck('ei0slack_ve_light.dat', CABLE_VE, [205.0_wp, 0.0_wp, -80.0_wp], [5.0_wp, 0.0_wp, -14.0_wp], & 230.0_wp, 115, 80.0_wp, 't', opts) CALL run_driver_logged('ei0slack_ve_light.dat', 'ei0slack_ve_light', 'ei0slack_ve_light.log', ok) @@ -1447,7 +1642,9 @@ SUBROUTINE case_law_slack_runs() CALL require(fair > 8.0e4_wp .AND. fair < 1.2e5_wp, 've-slack:fairlead-peak') CALL require(.NOT. file_contains('ei0slack_ve_light.log', 'Warning: line'), 've-slack:no-spike-warning') ! a taut Syrope line in 4 m surge that goes slack, dtM 0.1 s: fairlead 1.78 MN at dtM 1 and - ! 2.5 ms + ! 2.5 ms; 1.81 MN with the default sub-steps, 1.64 MN taking every step as given and + ! 1.67 MN with the configuration blend (gfortran, Windows). The bounds catch a spike or a + ! lost snap, not the round-off-dependent peak of the unresolved snap CALL write_syrope_files() CALL write_motion('ei0slack_surge_syr.txt', 1, [5.0_wp, 0.0_wp, -14.0_wp], 1, 4.0_wp, 10.0_wp, 10.0_wp, & 0.1_wp, 40.0_wp) @@ -1459,7 +1656,7 @@ SUBROUTINE case_law_slack_runs() WRITE (*, '(A,ES10.3,A,ES10.3,A)') ' Syrope line, 4 m surge, dtM 0.1 s: FairTen1 max ', fair, & ' N, smallest segment tension ', seg_min, ' N' CALL require(seg_min <= 0.0_wp, 'syrope-slack:goes-slack') - CALL require(fair > 1.5e6_wp .AND. fair < 1.95e6_wp, 'syrope-slack:fairlead-peak') + CALL require(fair > 1.4e6_wp .AND. fair < 2.3e6_wp, 'syrope-slack:fairlead-peak') CALL require(.NOT. file_contains('ei0slack_syrope.log', 'Warning: line'), 'syrope-slack:no-spike-warning') END SUBROUTINE case_law_slack_runs diff --git a/tests/test_model.f90 b/tests/test_model.f90 index da2b20ca..b8063fcd 100644 --- a/tests/test_model.f90 +++ b/tests/test_model.f90 @@ -10,7 +10,7 @@ PROGRAM test_model !! End releases the model cleanly. USE CableDyn_Precision, ONLY: wp USE CableDyn_Bathymetry, ONLY: CD_BathymetryType, CD_Init_Bathymetry, CD_End_Bathymetry, CD_BATHY_OK - USE CableDyn_Dynamic, ONLY: GenAlphaConfig + USE CableDyn_Dynamic, ONLY: GenAlphaConfig, CD_EI0_SUBSTEPS_OFF USE CableDyn_SeabedContact, ONLY: CD_SEABED_CONTACT_BLEND USE CableDyn_Line, ONLY: CD_LineType, CD_LineSection, CD_Build_Line_Mesh, CD_Nodal_Seabed_Stiffness, CD_LINE_OK USE CableDyn_Static, ONLY: CableSolverConfig @@ -27,7 +27,7 @@ PROGRAM test_model CD_Recompute_Model_Acceleration, & CD_Copy_Model, & CD_MODEL_OK, CD_MODEL_BADINPUT, CD_MODEL_SOLVEFAIL, CD_MODEL_NOT_INITIALIZED, & - CD_Update_Model_SegmentLength + CD_Update_Model_SegmentLength, CD_Set_Model_EndQuery USE CableDyn_Loads, ONLY: CD_Assemble_Distributed_Load USE CableDyn_Assemble, ONLY: CD_Assemble_Cable_Mass USE CableDyn_Hydro, ONLY: CD_Cable_Added_Mass_Matrix @@ -47,6 +47,9 @@ PROGRAM test_model CALL case_prescribed_step_updates_state() CALL case_recovery_common_path() CALL case_recovery_subdivision_path() + CALL case_resolved_substeps() + CALL case_substep_paths() + CALL case_substep_snap_only() CALL case_coupled_load_sign() CALL case_coupled_motion_update() CALL case_external_load_update() @@ -521,6 +524,333 @@ SUBROUTINE case_recovery_common_path() CALL CD_End_Model(plain, es, em) END SUBROUTINE case_recovery_common_path + SUBROUTINE case_resolved_substeps() + !! Rotation-resolved sub-stepping of CD_Step_Model (cfg%ei0_substeps auto, the default): a + !! pretensioned 8-segment line whose End B moves on a 0.6 m circle at 2 s (from rest, after a 1 s ramp) turns its + !! segments by several degrees per 0.1 s step. The resolved march solves those steps in + !! sub-steps, lands on the prescribed end state exactly, is closer to a plain march at dt/8 + !! than the plain march at dt, and repeats bit for bit from a copy of its state (a restart). + !! With off, or with an angle no step reaches, every step is the plain step bit for bit; a + !! junction step (end query armed) is never sub-stepped (it matches the plain march to the + !! Newton tolerance: its warm start differs); invalid settings fail at CD_Init_Model. + INTEGER, PARAMETER :: NE = 8, NN = NE + 1, NDOF = 3*NN, NSTEP = 30, NFINE = 8 + REAL(wp), PARAMETER :: DT = 0.1_wp + TYPE(CD_ModelType) :: auto_m, off_m, wide_m, twin_m, junc_m, fine_m, bad_m + TYPE(GenAlphaConfig) :: cfg, bad_cfg + INTEGER :: conn(2, NE), fixed(6), es, n_iter, k, j + REAL(wp) :: l0(NE), ea(NE), rho_a(NE), q0(NDOF), v0(NDOF), f_ext(NDOF) + REAL(wp) :: pq(NDOF), pv(NDOF), pa(NDOF), err_auto, err_off + LOGICAL :: conv, stalled, all_conv, lands, twin_ok + CHARACTER(240) :: em + + CALL straight_cable(NE, conn, l0, ea, rho_a, q0, fixed) + v0 = 0.0_wp + f_ext = 0.0_wp + CALL CD_Init_Model(auto_m, q0, v0, conn, l0, ea, rho_a, .TRUE., f_ext, fixed, cfg, es, em) + CALL require(es == CD_MODEL_OK, 'resolved:init: '//TRIM(em)) + IF (es /= CD_MODEL_OK) RETURN + CALL CD_Copy_Model(auto_m, off_m, es, em) + off_m%cfg%ei0_substeps = CD_EI0_SUBSTEPS_OFF + CALL CD_Copy_Model(auto_m, wide_m, es, em) + wide_m%cfg%ei0_substep_angle = 90.0_wp + CALL CD_Copy_Model(auto_m, junc_m, es, em) + CALL CD_Copy_Model(off_m, fine_m, es, em) + + all_conv = .TRUE. + lands = .TRUE. + twin_ok = .FALSE. + DO k = 1, NSTEP + CALL circle_end_motion(q0, pq, pv, pa, REAL(k, wp)*DT) + CALL CD_Step_Model(auto_m, DT, conv, stalled, n_iter, es, em, prescribed_q=pq, prescribed_v=pv, prescribed_a=pa) + all_conv = all_conv .AND. es == CD_MODEL_OK .AND. conv + lands = lands .AND. ALL(auto_m%q(fixed) == pq(fixed)) .AND. ALL(auto_m%v(fixed) == pv(fixed)) .AND. & + ALL(auto_m%a(fixed) == pa(fixed)) + CALL CD_Step_Model(off_m, DT, conv, stalled, n_iter, es, em, prescribed_q=pq, prescribed_v=pv, prescribed_a=pa) + all_conv = all_conv .AND. es == CD_MODEL_OK .AND. conv + CALL CD_Step_Model(wide_m, DT, conv, stalled, n_iter, es, em, prescribed_q=pq, prescribed_v=pv, prescribed_a=pa) + all_conv = all_conv .AND. es == CD_MODEL_OK .AND. conv + CALL CD_Set_Model_EndQuery(junc_m, .TRUE.) + CALL CD_Step_Model(junc_m, DT, conv, stalled, n_iter, es, em, prescribed_q=pq, prescribed_v=pv, prescribed_a=pa) + CALL CD_Set_Model_EndQuery(junc_m, .FALSE.) + all_conv = all_conv .AND. es == CD_MODEL_OK .AND. conv + DO j = 1, NFINE + CALL circle_end_motion(q0, pq, pv, pa, (REAL(k - 1, wp) + REAL(j, wp)/REAL(NFINE, wp))*DT) + CALL CD_Step_Model(fine_m, DT/REAL(NFINE, wp), conv, stalled, n_iter, es, em, prescribed_q=pq, & + prescribed_v=pv, prescribed_a=pa) + all_conv = all_conv .AND. es == CD_MODEL_OK .AND. conv + END DO + IF (k == NSTEP/2) THEN + ! a restart: a copy of the committed state continues the march + CALL CD_Copy_Model(auto_m, twin_m, es, em) + CALL require(es == CD_MODEL_OK, 'resolved:copy: '//TRIM(em)) + ELSE IF (k > NSTEP/2) THEN + CALL circle_end_motion(q0, pq, pv, pa, REAL(k, wp)*DT) + CALL CD_Step_Model(twin_m, DT, conv, stalled, n_iter, es, em, prescribed_q=pq, prescribed_v=pv, & + prescribed_a=pa) + all_conv = all_conv .AND. es == CD_MODEL_OK .AND. conv + END IF + END DO + twin_ok = ALL(twin_m%q == auto_m%q) .AND. ALL(twin_m%v == auto_m%v) .AND. ALL(twin_m%a == auto_m%a) + err_auto = MAXVAL(ABS(auto_m%q - fine_m%q)) + err_off = MAXVAL(ABS(off_m%q - fine_m%q)) + WRITE (*, '(A,I0,A,I0,A,I0,A,ES10.3,A,ES10.3,A)') ' resolved sub-steps: ', auto_m%sub_stats%events, ' of ', & + auto_m%sub_stats%calls, ' steps (at most ', auto_m%sub_stats%max_used, '); position error against dt/8 ', err_auto, & + ' m (plain ', err_off, ' m)' + CALL require(all_conv, 'resolved:converged') + CALL require(auto_m%sub_stats%events > 0 .AND. auto_m%sub_stats%max_used >= 4, 'resolved:sub-stepped') + CALL require(lands, 'resolved:lands-on-prescribed-end') + CALL require(err_auto < 0.75_wp*err_off, 'resolved:closer-to-fine-march') + CALL require(twin_ok, 'resolved:restart-bit-identical') + CALL require(off_m%sub_stats%calls == 0 .AND. off_m%sub_stats%events == 0, 'resolved:off-not-examined') + CALL require(wide_m%sub_stats%events == 0 .AND. ALL(wide_m%q == off_m%q) .AND. ALL(wide_m%v == off_m%v) .AND. & + ALL(wide_m%a == off_m%a), 'resolved:untriggered-is-plain') + CALL require(junc_m%sub_stats%calls == 0 .AND. MAXVAL(ABS(junc_m%q - off_m%q)) < 1.0e-6_wp, & + 'resolved:junction-not-sub-stepped') + ! the settings are checked once, at CD_Init_Model + bad_cfg = cfg + bad_cfg%ei0_substep_angle = 0.0_wp + CALL CD_Init_Model(bad_m, q0, v0, conn, l0, ea, rho_a, .TRUE., f_ext, fixed, bad_cfg, es, em) + CALL require(es == CD_MODEL_BADINPUT .AND. INDEX(em, 'ei0_substep_angle') > 0, 'resolved:invalid-angle') + bad_cfg = cfg + bad_cfg%ei0_substep_max = 1025 + CALL CD_Init_Model(bad_m, q0, v0, conn, l0, ea, rho_a, .TRUE., f_ext, fixed, bad_cfg, es, em) + CALL require(es == CD_MODEL_BADINPUT .AND. INDEX(em, 'ei0_substep_max') > 0, 'resolved:invalid-max') + bad_cfg = cfg + bad_cfg%ei0_substeps = 7 + CALL CD_Init_Model(bad_m, q0, v0, conn, l0, ea, rho_a, .TRUE., f_ext, fixed, bad_cfg, es, em) + CALL require(es == CD_MODEL_BADINPUT .AND. INDEX(em, 'ei0_substeps') > 0, 'resolved:invalid-mode') + CALL CD_End_Model(auto_m, es, em) + CALL CD_End_Model(off_m, es, em) + CALL CD_End_Model(wide_m, es, em) + CALL CD_End_Model(twin_m, es, em) + CALL CD_End_Model(junc_m, es, em) + CALL CD_End_Model(fine_m, es, em) + CALL CD_End_Model(bad_m, es, em) + END SUBROUTINE case_resolved_substeps + + SUBROUTINE case_substep_paths() + !! The paths of the resolved sub-stepping on a line that carries viscoelastic segments and + !! seabed friction (the 8-segment line of case_resolved_substeps resting 1 cm into a flat + !! seabed, End B on the 0.6 m circle): (1) solving the first sub-stepped pass twice, the + !! second from the restored committed state (TEST-ONLY sub_test_repeat), changes nothing bit + !! for bit, so the restore covers the kinematics, the viscoelastic dl_1 state and the + !! friction anchors; (2) a sub-step that fails (TEST-ONLY sub_test_fail) returns the plain + !! step's own result, the run then equals the run with ei0_substeps off bit for bit; (3) a + !! cap of four sub-steps at a 0.05 deg angle is reached and counted; (4) a re-measured + !! interval that needs more sub-steps (TEST-ONLY sub_test_more: one more) is solved again + !! with them and lands on the prescribed end state. + INTEGER, PARAMETER :: NE = 8, NN = NE + 1, NDOF = 3*NN, NSTEP = 30 + REAL(wp), PARAMETER :: DT = 0.1_wp + INTEGER, PARAMETER :: SUB_MIN = 4 ! the fewest sub-steps of a sub-stepped step + TYPE(CD_ModelType) :: auto_m, rep_m, fb_m, off_m, cap_m, more_m + TYPE(GenAlphaConfig) :: cfg + INTEGER :: conn(2, NE), fixed(6), es, n_iter, k + REAL(wp) :: l0(NE), ea(NE), rho_a(NE), q0(NDOF), v0(NDOF), f_ext(NDOF), kn(NN), cn(NN) + REAL(wp) :: ve_ead(NE), ve_ba(NE), ve_bad(NE), pq(NDOF), pv(NDOF), pa(NDOF), dl1_0(NE), fr_0(2, NN) + LOGICAL :: conv, stalled, all_conv, more_lands + CHARACTER(240) :: em + + more_lands = .TRUE. + CALL straight_cable(NE, conn, l0, ea, rho_a, q0, fixed) + v0 = 0.0_wp + f_ext = 0.0_wp + kn = 1.0e4_wp + cn = 1.0e2_wp + ! the even segments are viscoelastic (Es | Ed, Bs | Bd) + ve_ead = 0.0_wp + ve_ba = 0.0_wp + ve_bad = 0.0_wp + ve_ead(2:NE:2) = 2.0e6_wp + ve_ba(2:NE:2) = 1.0e5_wp + ve_bad(2:NE:2) = 1.0e3_wp + CALL CD_Init_Model(auto_m, q0, v0, conn, l0, ea, rho_a, .TRUE., f_ext, fixed, cfg, es, em, & + seabed_z_floor=0.01_wp, seabed_kn=kn, seabed_cn=cn, seabed_mu=0.5_wp, & + ve_ea_d=ve_ead, ve_ba=ve_ba, ve_ba_d=ve_bad) + CALL require(es == CD_MODEL_OK, 'substep-paths:init: '//TRIM(em)) + IF (es /= CD_MODEL_OK) RETURN + dl1_0 = auto_m%ve_dl_1 + fr_0 = auto_m%fr_anchor + CALL CD_Copy_Model(auto_m, rep_m, es, em) + rep_m%sub_test_repeat = .TRUE. + CALL CD_Copy_Model(auto_m, fb_m, es, em) + fb_m%sub_test_fail = 2 + CALL CD_Copy_Model(auto_m, off_m, es, em) + off_m%cfg%ei0_substeps = CD_EI0_SUBSTEPS_OFF + CALL CD_Copy_Model(auto_m, cap_m, es, em) + cap_m%cfg%ei0_substep_angle = 0.05_wp + cap_m%cfg%ei0_substep_max = 4 + CALL CD_Copy_Model(auto_m, more_m, es, em) + more_m%sub_test_more = .TRUE. + all_conv = .TRUE. + DO k = 1, NSTEP + CALL circle_end_motion(q0, pq, pv, pa, REAL(k, wp)*DT) + CALL CD_Step_Model(auto_m, DT, conv, stalled, n_iter, es, em, prescribed_q=pq, prescribed_v=pv, prescribed_a=pa) + all_conv = all_conv .AND. es == CD_MODEL_OK .AND. conv + CALL CD_Step_Model(rep_m, DT, conv, stalled, n_iter, es, em, prescribed_q=pq, prescribed_v=pv, prescribed_a=pa) + all_conv = all_conv .AND. es == CD_MODEL_OK .AND. conv + CALL CD_Step_Model(fb_m, DT, conv, stalled, n_iter, es, em, prescribed_q=pq, prescribed_v=pv, prescribed_a=pa) + all_conv = all_conv .AND. es == CD_MODEL_OK .AND. conv + CALL CD_Step_Model(off_m, DT, conv, stalled, n_iter, es, em, prescribed_q=pq, prescribed_v=pv, prescribed_a=pa) + all_conv = all_conv .AND. es == CD_MODEL_OK .AND. conv + CALL CD_Step_Model(cap_m, DT, conv, stalled, n_iter, es, em, prescribed_q=pq, prescribed_v=pv, prescribed_a=pa) + all_conv = all_conv .AND. es == CD_MODEL_OK .AND. conv + CALL CD_Step_Model(more_m, DT, conv, stalled, n_iter, es, em, prescribed_q=pq, prescribed_v=pv, & + prescribed_a=pa) + all_conv = all_conv .AND. es == CD_MODEL_OK .AND. conv + more_lands = more_lands .AND. ALL(more_m%q(fixed) == pq(fixed)) + END DO + WRITE (*, '(A,I0,A,I0,A,I0,A,I0,A,I0,A)') ' sub-step paths: ', auto_m%sub_stats%events, ' of ', auto_m%sub_stats%calls, & + ' steps sub-stepped, ', auto_m%sub_stats%remeasured, ' re-measured; fallback ', fb_m%sub_stats%fallbacks, & + ', capped ', cap_m%sub_stats%capped, ' steps' + CALL require(all_conv, 'substep-paths:converged') + CALL require(auto_m%sub_stats%events > 0, 'substep-paths:sub-stepped') + CALL require(ANY(auto_m%ve_dl_1 /= dl1_0) .AND. ANY(auto_m%fr_anchor /= fr_0), 'substep-paths:states-move') + CALL require(ALL(rep_m%q == auto_m%q) .AND. ALL(rep_m%v == auto_m%v) .AND. ALL(rep_m%a == auto_m%a) .AND. & + ALL(rep_m%ve_dl_1 == auto_m%ve_dl_1) .AND. ALL(rep_m%fr_anchor == auto_m%fr_anchor), & + 'substep-paths:restore-is-complete') + CALL require(fb_m%sub_stats%events == 0 .AND. fb_m%sub_stats%fallbacks > 0, 'substep-paths:fallback-counted') + CALL require(ALL(fb_m%q == off_m%q) .AND. ALL(fb_m%v == off_m%v) .AND. ALL(fb_m%a == off_m%a) .AND. & + ALL(fb_m%ve_dl_1 == off_m%ve_dl_1) .AND. ALL(fb_m%fr_anchor == off_m%fr_anchor), & + 'substep-paths:fallback-is-the-plain-step') + CALL require(cap_m%sub_stats%capped > 0 .AND. cap_m%sub_stats%max_used == 4, 'substep-paths:cap') + CALL require(more_m%sub_stats%remeasured == more_m%sub_stats%events .AND. more_m%sub_stats%events > 0 .AND. & + more_m%sub_stats%max_used >= SUB_MIN + 1 .AND. more_lands .AND. & + ANY(more_m%q /= auto_m%q), 'substep-paths:re-measured') + CALL CD_End_Model(auto_m, es, em) + CALL CD_End_Model(rep_m, es, em) + CALL CD_End_Model(fb_m, es, em) + CALL CD_End_Model(off_m, es, em) + CALL CD_End_Model(cap_m, es, em) + CALL CD_End_Model(more_m, es, em) + END SUBROUTINE case_substep_paths + + SUBROUTINE case_substep_snap_only() + !! The snap trigger alone, on straight 4-segment lines whose End B is pulled along the line in + !! one 0.05 s step (no turn in any step; the axial wave crosses a segment 15 times per step): + !! (1) a line 5 % slack all over (step-start and initial tension 0) snaps taut and is solved + !! in four sub-steps, and with ei0_substeps off it is taken as given; (2) on a line whose + !! End A half is taut (52.6 kN) and End B half 20 % slack, the taut half recoils and snaps the + !! slack half taut: with End B pulled 0.2 m its segments end at 0.42 of the step-start tension, + !! above a quarter of it (a snap, four sub-steps), with End B held at 0.22, below it (the plain + !! step, bit for bit); (3) on the 5 % slack line made 1000 times heavier + !! the axial wave crosses a segment 0.48 times per step, so the step resolves the snap as + !! given and is not sub-stepped. + INTEGER, PARAMETER :: NE = 4, NN = NE + 1, NDOF = 3*NN + REAL(wp), PARAMETER :: DT = 0.05_wp + TYPE(CD_ModelType) :: auto_m, off_m + INTEGER :: conn(2, NE), fixed(6), es + REAL(wp) :: l0(NE), ea(NE), rho_a(NE), q0(NDOF), pq(NDOF) + REAL(wp) :: t_start, t_end_big, t_end_small + LOGICAL :: ok, auto_ok, off_ok + CHARACTER(240) :: em + + CALL straight_cable(NE, conn, l0, ea, rho_a, q0, fixed) + ! (1) slack all over + l0 = 1.05_wp + CALL snap_pull(conn, l0, ea, rho_a, q0, fixed, DT, 0.5_wp, auto_m, off_m, pq, auto_ok, off_ok) + WRITE (*, '(A,I0,A,I0,A)') ' snap-only trigger, slack line: ', auto_m%sub_stats%events, & + ' step(s) sub-stepped, at most ', auto_m%sub_stats%max_used, ' sub-steps' + CALL require(auto_ok .AND. off_ok, 'snap-only:converged') + CALL require(auto_m%sub_stats%events == 1 .AND. auto_m%sub_stats%max_used == 4, 'snap-only:four-sub-steps') + CALL require(ALL(auto_m%q(fixed) == pq(fixed)), 'snap-only:lands-on-end-state') + CALL require(off_m%sub_stats%events == 0 .AND. ANY(off_m%q /= auto_m%q), 'snap-only:off-takes-the-step') + ! (2) partly taut: the floor is the step-start tension of the taut half + l0(1:2) = 0.95_wp + l0(3:4) = 1.20_wp + t_start = ea(1)*(1.0_wp/0.95_wp - 1.0_wp) + CALL snap_pull(conn, l0, ea, rho_a, q0, fixed, DT, 0.2_wp, auto_m, off_m, pq, auto_ok, off_ok) + t_end_big = slack_half_tension(off_m, ea, l0) + ok = auto_ok .AND. off_ok .AND. auto_m%sub_stats%events == 1 .AND. auto_m%sub_stats%max_used == 4 + CALL snap_pull(conn, l0, ea, rho_a, q0, fixed, DT, 0.0_wp, auto_m, off_m, pq, auto_ok, off_ok) + t_end_small = slack_half_tension(off_m, ea, l0) + WRITE (*, '(A,F6.3,A,F6.3,A)') ' snap-only trigger, partly taut line: the slack half ends at ', & + t_end_big/t_start, ' (End B pulled 0.2 m) and ', t_end_small/t_start, ' (held) of the step-start tension' + CALL require(t_end_big > 0.25_wp*t_start .AND. t_end_small > 0.0_wp .AND. t_end_small < 0.25_wp*t_start, & + 'snap-partly-taut:pulls-cross-the-threshold') + CALL require(ok, 'snap-partly-taut:above-threshold-sub-stepped') + CALL require(auto_ok .AND. off_ok .AND. auto_m%sub_stats%calls == 1 .AND. auto_m%sub_stats%events == 0 .AND. & + ALL(auto_m%q == off_m%q) .AND. ALL(auto_m%v == off_m%v) .AND. ALL(auto_m%a == off_m%a), & + 'snap-partly-taut:below-threshold-plain') + ! (3) a step that resolves the axial wave takes the snap as given + l0 = 1.05_wp + rho_a = 1.0e3_wp*rho_a + CALL snap_pull(conn, l0, ea, rho_a, q0, fixed, DT, 0.5_wp, auto_m, off_m, pq, auto_ok, off_ok) + CALL require(auto_ok .AND. off_ok .AND. auto_m%sub_stats%calls == 1 .AND. auto_m%sub_stats%events == 0 .AND. & + ALL(auto_m%q == off_m%q) .AND. slack_half_tension(off_m, ea, l0) > 0.0_wp, 'snap-resolved-wave:plain') + CALL CD_End_Model(auto_m, es, em) + CALL CD_End_Model(off_m, es, em) + END SUBROUTINE case_substep_snap_only + + SUBROUTINE snap_pull(conn, l0, ea, rho_a, q0, fixed, dt, dx, auto_m, off_m, pq, ok_auto, ok_off) + !! case_substep_snap_only: a fresh pair of models (auto, off) of the straight line at rest, + !! End B pulled along the line by dx in one step of dt. + INTEGER, INTENT(IN) :: conn(:, :), fixed(:) + REAL(wp), INTENT(IN) :: l0(:), ea(:), rho_a(:), q0(:), dt, dx + TYPE(CD_ModelType), INTENT(INOUT) :: auto_m, off_m + REAL(wp), INTENT(OUT) :: pq(:) + LOGICAL, INTENT(OUT) :: ok_auto, ok_off + TYPE(GenAlphaConfig) :: cfg + INTEGER :: n_it, es, n + LOGICAL :: conv, stalled + REAL(wp) :: pv(SIZE(q0)), pa(SIZE(q0)), zero(SIZE(q0)) + CHARACTER(240) :: em + n = SIZE(q0) + zero = 0.0_wp + CALL CD_Init_Model(auto_m, q0, zero, conn, l0, ea, rho_a, .TRUE., zero, fixed, cfg, es, em) + CALL require(es == CD_MODEL_OK, 'snap-only:init: '//TRIM(em)) + CALL CD_Copy_Model(auto_m, off_m, es, em) + off_m%cfg%ei0_substeps = CD_EI0_SUBSTEPS_OFF + pq = q0 + pv = 0.0_wp + pa = 0.0_wp + pq(n - 2) = q0(n - 2) + dx + CALL CD_Step_Model(auto_m, dt, conv, stalled, n_it, es, em, prescribed_q=pq, prescribed_v=pv, prescribed_a=pa) + ok_auto = es == CD_MODEL_OK .AND. conv + CALL CD_Step_Model(off_m, dt, conv, stalled, n_it, es, em, prescribed_q=pq, prescribed_v=pv, prescribed_a=pa) + ok_off = es == CD_MODEL_OK .AND. conv + END SUBROUTINE snap_pull + + REAL(wp) FUNCTION slack_half_tension(m, ea, l0) RESULT(t_max) + !! case_substep_snap_only: the largest tension of segments 3 and 4 (EA times the strain). + TYPE(CD_ModelType), INTENT(IN) :: m + REAL(wp), INTENT(IN) :: ea(:), l0(:) + INTEGER :: e + t_max = 0.0_wp + DO e = 3, 4 + t_max = MAX(t_max, ea(e)*(NORM2(m%q(3*e + 1:3*e + 3) - m%q(3*e - 2:3*e))/l0(e) - 1.0_wp)) + END DO + END FUNCTION slack_half_tension + + SUBROUTINE circle_end_motion(q0, pq, pv, pa, t) + !! End A held, End B (the last node) on the circle x_B + R r(t) (0, sin wt, 1 - cos wt), + !! R = 0.6 m, period 2 s, r the C2 quintic ramp over the first second, so the motion starts + !! from rest (case_resolved_substeps). + REAL(wp), INTENT(IN) :: q0(:), t + REAL(wp), INTENT(OUT) :: pq(:), pv(:), pa(:) + REAL(wp), PARAMETER :: RADIUS = 0.6_wp, PERIOD = 2.0_wp, RAMP = 1.0_wp + REAL(wp) :: w, u, r, rd, rdd, g(2), gd(2), gdd(2) + INTEGER :: n + n = SIZE(q0) + w = 2.0_wp*ACOS(-1.0_wp)/PERIOD + u = MIN(t/RAMP, 1.0_wp) + r = 10.0_wp*u**3 - 15.0_wp*u**4 + 6.0_wp*u**5 + rd = 0.0_wp + rdd = 0.0_wp + IF (t < RAMP) THEN + rd = (30.0_wp*u**2 - 60.0_wp*u**3 + 30.0_wp*u**4)/RAMP + rdd = (60.0_wp*u - 180.0_wp*u**2 + 120.0_wp*u**3)/RAMP**2 + END IF + g = RADIUS*[SIN(w*t), 1.0_wp - COS(w*t)] + gd = RADIUS*w*[COS(w*t), SIN(w*t)] + gdd = RADIUS*w*w*[-SIN(w*t), COS(w*t)] + pq = q0 + pv = 0.0_wp + pa = 0.0_wp + pq(n - 1:n) = q0(n - 1:n) + r*g + pv(n - 1:n) = rd*g + r*gd + pa(n - 1:n) = rdd*g + 2.0_wp*rd*gd + r*gdd + END SUBROUTINE circle_end_motion + SUBROUTINE case_recovery_subdivision_path() !! Find a bounded, deterministic prescribed-motion increment for which the !! deliberately small nonlinear-iteration allowance rejects the full diff --git a/tests/test_syrope.f90 b/tests/test_syrope.f90 index 25d8054b..31658bc6 100644 --- a/tests/test_syrope.f90 +++ b/tests/test_syrope.f90 @@ -16,7 +16,7 @@ PROGRAM test_syrope CD_Syrope_Slow_At_Mean, CD_Syrope_Check_Range, CD_Syrope_Branch_Divider, & CD_SYROPE_OK, CD_SYROPE_NWC, & CD_SYROPE_WC_LINEAR, CD_SYROPE_WC_QUADRATIC, CD_SYROPE_WC_EXP - USE CableDyn_Dynamic, ONLY: GenAlphaConfig + USE CableDyn_Dynamic, ONLY: GenAlphaConfig, CD_EI0_SUBSTEPS_OFF USE CableDyn_Static, ONLY: CableSolverConfig USE CableDyn_Line, ONLY: CD_LineType, CD_LineSection USE CableDyn_Model, ONLY: CD_ModelType, CD_Init_Model, CD_Init_Line_Model, CD_Step_Model, CD_End_Model, & @@ -73,6 +73,7 @@ PROGRAM test_syrope CALL case_model_held() CALL case_syrope_accessor_roundtrip() CALL case_model_mixed_ve_syrope() + CALL case_substeps_restore_law_states() CALL case_line_model_syrope() CALL case_admissibility() CALL case_ic_rest_point() @@ -685,6 +686,121 @@ SUBROUTINE case_model_mixed_ve_syrope() CALL CD_Syrope_End(td) END SUBROUTINE case_model_mixed_ve_syrope + SUBROUTINE case_substeps_restore_law_states() + !! The rotation-resolved sub-stepping of a model carrying a Syrope and a viscoelastic + !! element (case_model_mixed_ve_syrope, the viscoelastic element 1000 times stiffer so that + !! its law tension counts as taut against the 0.8 MN of the Syrope element), node 2 free and + !! node 3 driven on a 0.4 m circle at 2 s, so the chords turn by more than a degree per + !! 0.02 s step: solving the first + !! sub-stepped pass twice, the second from the restored committed state (TEST-ONLY + !! sub_test_repeat), changes nothing bit for bit, Syrope slow strain and running maximum and + !! viscoelastic dl_1 included; a failing sub-step (TEST-ONLY sub_test_fail) returns the plain + !! step, the run then equals the run with ei0_substeps off bit for bit. + REAL(wp), PARAMETER :: L0E = 1.0_wp, EPS = 0.026_wp, DL = 0.03_wp, DT = 0.02_wp, R = 0.4_wp + INTEGER, PARAMETER :: NSTEP = 40 + TYPE(CD_SyropeType) :: td, stype(2) + TYPE(CD_ModelType) :: auto_m, rep_m, fb_m, off_m + TYPE(GenAlphaConfig) :: cfg + INTEGER :: conn(2, 2), fixed(6), es, k, n_iter + REAL(wp) :: l0(2), eav(2), rho_a(2), q0(9), v0(9), f_ext(9), pq(9), pv(9), pa(9) + REAL(wp) :: ve_ead(2), ve_ba(2), ve_bad(2), sslow(2), stmax(2), w, t, slow0(2), dl0(2) + LOGICAL :: sis(2), conv, stalled, all_conv + CHARACTER(200) :: em + CALL CD_Syrope_Init(td, OWC_EPS, OWC_TEN, CD_SYROPE_WC_LINEAR, 0.6_wp, 0.0_wp, & + ALPHA, BETA, C1, C2, es, em) + CALL require(es == CD_SYROPE_OK, 'substep-law:type-init') + conn(:, 1) = [1, 2] + conn(:, 2) = [2, 3] + l0 = L0E + eav = [1.0e8_wp, 1.0e5_wp] + rho_a = 50.0_wp + q0 = 0.0_wp + q0(4) = L0E*(1.0_wp + EPS) + q0(7) = q0(4) + L0E*(1.0_wp + DL) + v0 = 0.0_wp + f_ext = 0.0_wp + fixed = [1, 2, 3, 7, 8, 9] + sis = [.TRUE., .FALSE.] + stype(1) = td + stype(2) = td + sslow = [0.021_wp, 0.0_wp] + stmax = [2.0e6_wp, 0.0_wp] + ve_ead = [0.0_wp, 4.0e5_wp] + ve_ba = [0.0_wp, 7.0_wp] + ve_bad = [0.0_wp, 3.0_wp] + CALL CD_Init_Model(auto_m, q0, v0, conn, l0, eav, rho_a, .TRUE., f_ext, fixed, cfg, es, em, & + ve_ea_d=ve_ead, ve_ba=ve_ba, ve_ba_d=ve_bad, & + syrope_is=sis, syrope_type=stype, syrope_slow0=sslow, syrope_tmax0=stmax) + CALL require(es == CD_MODEL_OK, 'substep-law:init: '//TRIM(em)) + IF (es /= CD_MODEL_OK) RETURN + slow0 = auto_m%syrope_slow + dl0 = auto_m%ve_dl_1 + CALL CD_Copy_Model(auto_m, rep_m, es, em) + rep_m%sub_test_repeat = .TRUE. + CALL CD_Copy_Model(auto_m, fb_m, es, em) + fb_m%sub_test_fail = 1 + CALL CD_Copy_Model(auto_m, off_m, es, em) + off_m%cfg%ei0_substeps = CD_EI0_SUBSTEPS_OFF + w = 2.0_wp*ACOS(-1.0_wp)/2.0_wp + all_conv = .TRUE. + DO k = 1, NSTEP + ! node 3 on the circle q0(7:9) + R ramp(t) (0, sin wt, 1 - cos wt), ramped over the first second + t = REAL(k, wp)*DT + CALL ramped_circle(t, q0, w, R, pq, pv, pa) + CALL CD_Step_Model(auto_m, DT, conv, stalled, n_iter, es, em, prescribed_q=pq, prescribed_v=pv, prescribed_a=pa) + all_conv = all_conv .AND. es == CD_MODEL_OK .AND. conv + CALL CD_Step_Model(rep_m, DT, conv, stalled, n_iter, es, em, prescribed_q=pq, prescribed_v=pv, prescribed_a=pa) + all_conv = all_conv .AND. es == CD_MODEL_OK .AND. conv + CALL CD_Step_Model(fb_m, DT, conv, stalled, n_iter, es, em, prescribed_q=pq, prescribed_v=pv, prescribed_a=pa) + all_conv = all_conv .AND. es == CD_MODEL_OK .AND. conv + CALL CD_Step_Model(off_m, DT, conv, stalled, n_iter, es, em, prescribed_q=pq, prescribed_v=pv, prescribed_a=pa) + all_conv = all_conv .AND. es == CD_MODEL_OK .AND. conv + END DO + WRITE (*, '(A,I0,A,I0,A,I0,A)') ' sub-steps with Syrope and viscoelastic states: ', auto_m%sub_stats%events, & + ' of ', auto_m%sub_stats%calls, ' steps sub-stepped, ', fb_m%sub_stats%fallbacks, ' failing-sub-step fallbacks' + CALL require(all_conv, 'substep-law:converged') + CALL require(auto_m%sub_stats%events > 0, 'substep-law:sub-stepped') + CALL require(ANY(auto_m%syrope_slow /= slow0) .AND. ANY(auto_m%ve_dl_1 /= dl0), 'substep-law:states-move') + CALL require(ALL(rep_m%q == auto_m%q) .AND. ALL(rep_m%v == auto_m%v) .AND. ALL(rep_m%a == auto_m%a) .AND. & + ALL(rep_m%syrope_slow == auto_m%syrope_slow) .AND. & + ALL(rep_m%syrope_tmax == auto_m%syrope_tmax) .AND. ALL(rep_m%ve_dl_1 == auto_m%ve_dl_1), & + 'substep-law:restore-is-complete') + CALL require(fb_m%sub_stats%fallbacks > 0 .AND. ALL(fb_m%q == off_m%q) .AND. ALL(fb_m%v == off_m%v) .AND. & + ALL(fb_m%a == off_m%a) .AND. ALL(fb_m%syrope_slow == off_m%syrope_slow) .AND. & + ALL(fb_m%syrope_tmax == off_m%syrope_tmax) .AND. ALL(fb_m%ve_dl_1 == off_m%ve_dl_1), & + 'substep-law:fallback-is-the-plain-step') + CALL CD_End_Model(auto_m, es, em) + CALL CD_End_Model(rep_m, es, em) + CALL CD_End_Model(fb_m, es, em) + CALL CD_End_Model(off_m, es, em) + CALL CD_Syrope_End(td) + END SUBROUTINE case_substeps_restore_law_states + + SUBROUTINE ramped_circle(time, q0, w, R, pq, pv, pa) + !! Node 3 (DOFs 7:9) on the circle q0 + R ramp(t) (0, sin wt, 1 - cos wt), the C2 quintic + !! ramp over the first second (case_substeps_restore_law_states). + REAL(wp), INTENT(IN) :: time, q0(:), w, R + REAL(wp), INTENT(OUT) :: pq(:), pv(:), pa(:) + REAL(wp) :: u, r5, rd, rdd, g(2), gd(2), gdd(2) + u = MIN(time, 1.0_wp) + r5 = 10.0_wp*u**3 - 15.0_wp*u**4 + 6.0_wp*u**5 + rd = 0.0_wp + rdd = 0.0_wp + IF (time < 1.0_wp) THEN + rd = 30.0_wp*u**2 - 60.0_wp*u**3 + 30.0_wp*u**4 + rdd = 60.0_wp*u - 180.0_wp*u**2 + 120.0_wp*u**3 + END IF + g = R*[SIN(w*time), 1.0_wp - COS(w*time)] + gd = R*w*[COS(w*time), SIN(w*time)] + gdd = R*w*w*[-SIN(w*time), COS(w*time)] + pq = q0 + pv = 0.0_wp + pa = 0.0_wp + pq(8:9) = q0(8:9) + r5*g + pv(8:9) = rd*g + r5*gd + pa(8:9) = rdd*g + 2.0_wp*rd*gd + r5*gdd + END SUBROUTINE ramped_circle + SUBROUTINE case_line_model_syrope() !! The line-object build path with the Syrope pass-through: a straight, !! zero-gravity Syrope line built through CD_Init_Line_Model (which runs the diff --git a/validation/experiments/bergdahl/README.md b/validation/experiments/bergdahl/README.md index 1d7a615b..29b3335f 100644 --- a/validation/experiments/bergdahl/README.md +++ b/validation/experiments/bergdahl/README.md @@ -73,7 +73,7 @@ results and the checksum of the executable used. The calculated force is `FairTe at the upper line end. Across the 30 conditions, the cycle maxima have an RMSE of 1.58 N, a mean absolute percentage error of 3.13%, a mean bias of +0.46 N, a Pearson correlation of 0.993 and a Lin concordance coefficient of 0.989. For the two waveform conditions, halving the nominal -element length and the time step changes the mean cycle maximum by no more than 0.52% and +element length and the time step changes the mean cycle maximum by no more than 0.56% and 0.19%, respectively, and the phase-averaged force histories have RMSEs of 5.95% and 2.54% of the measured force range (computed with the executable of the 2026-10-09 record; see `provenance.json`). The waveform CSVs carry the measured phase averages computed from the @@ -86,7 +86,11 @@ modes up to about 2c/l ≈ 3500 rad/s. The force maxima are snap loads, which co step only once the step resolves these modes, roughly dtM ≲ l/(2c) ≈ 0.29 ms (see "Snap loads on slack lines" in the [modelling guide](https://cabledyn.readthedocs.io/en/latest/modeling.html)). At a coarser step the maxima do not settle: at the T = 1.25 s, 0.20 m condition they are -72.2 N at 0.625 ms, against 68.0 N at 0.3125 ms and 67.8 N at 0.15625 ms. Coarse steps also +69.5 N at 0.625 ms (72.2 N with every step taken as given, `off ei0_substeps`), against +68.0 N at 0.3125 ms and 67.8 N at 0.15625 ms. At 0.3125 ms and below the step resolves the +axial wave over a 0.2 m segment, so the rotation- and snap-resolved sub-steps of +`ei0_substeps auto` take no part in the primary matrix (its results equal those taken as +given); the 0.1 m mesh at 0.3125 ms and the 0.625 ms step use them. Coarse steps also leave the maxima sensitive to the Newton tolerance and to small changes in the solver's iteration path. With a 1.25 ms step and a relative tolerance of 1e-5, the five cycle maxima of a condition have standard deviations of up to 1.6 N, their means are 2–15% above the converged diff --git a/validation/experiments/bergdahl/provenance.json b/validation/experiments/bergdahl/provenance.json index 6569d610..9cdba7c6 100644 --- a/validation/experiments/bergdahl/provenance.json +++ b/validation/experiments/bergdahl/provenance.json @@ -1,8 +1,8 @@ { "CableDyn_release": "v0.1.1+dev (unreleased)", - "validation_date": "2026-10-16", + "validation_date": "2026-10-19", "executable_name": "cabledyn.exe", - "executable_sha256": "78a3fed9390fd77392a1dcaec244f79f9174d9e2e94e4b3032fb53c7b8bd4395", + "executable_sha256": "88d2bba2da6fb0801656d4bacd30e9d0e916f768c7047161457edea324274c66", "compiler": "GNU Fortran 16.2.0", "build_type": "Release", "platform": "Windows 11 x86-64", @@ -12,7 +12,7 @@ "completed_cases": 30, "nonlinear_misses": 0, "refinement_cases": 8, - "maximum_spatial_refinement_difference_percent": 0.5236270564721716, + "maximum_spatial_refinement_difference_percent": 0.5580722740928493, "maximum_temporal_refinement_difference_percent": 0.18888172026785752, "force_maxima_sha256": "978889378964c6d6749bc27c11d99d6584956e3c8eac146ae79bf5f7a05e2e95", "aggregate_metrics_sha256": "35d800fa34137a3a1500cbd0081a490bc1b61cf636cfef5a923b5c18947ba1a7", @@ -20,6 +20,6 @@ "waveform_T1p25_sha256": "65c8c846636c378b800bb3c7a95ccd2bde766d789af3cdffce26a2e688e1a134", "waveform_T3p50_sha256": "b3ca65ebfc1d61b5510e54876fc11d1604fc18ffcca3eab523dc7d67f50da4d8", "waveform_metrics_sha256": "2803a57cb7726f966a00e00bf6eb070231b9c702ae67a81685da50991d0adb11", - "waveform_note": "Waveform metrics were computed with the executable of the 2026-10-09 validation (sha256 71090e2e28c9e1d99c5180d05a395ebcc891a77cc5294d315a57c691904745ac); the force-blended EI = 0 step of this development build was not rerun on them because the article supplement's expData.dat, which reduce_bergdahl_waveforms.py reads, was not available. The measured phase averages are those of expData.dat, as carried in the waveform CSVs.", - "refinement_summary_sha256": "b3ef33659ba852ce8b6667032a9f2c44bf0336d988c29c2a80fddc2ab4053859" + "waveform_note": "Waveform metrics were computed with the executable of the 2026-10-09 validation (sha256 71090e2e28c9e1d99c5180d05a395ebcc891a77cc5294d315a57c691904745ac); the development builds since then (the force-blended EI = 0 step and its rotation- and snap-resolved sub-steps) were not rerun on them because the article supplement's expData.dat, which reduce_bergdahl_waveforms.py reads, was not available. The measured phase averages are those of expData.dat, as carried in the waveform CSVs.", + "refinement_summary_sha256": "9039f6c9b91ed2d15d7c609dd8d2300eef34d0363700487a8dfc0a8f15be1087" } diff --git a/validation/experiments/bergdahl/refinement_summary.csv b/validation/experiments/bergdahl/refinement_summary.csv index ddbd61e6..24985b11 100644 --- a/validation/experiments/bergdahl/refinement_summary.csv +++ b/validation/experiments/bergdahl/refinement_summary.csv @@ -1,3 +1,3 @@ period_s,radius_m,force_h0p400_dt0p0003125_N,force_h0p200_dt0p0003125_N,force_h0p100_dt0p0003125_N,force_h0p200_dt0p00015625_N,force_h0p200_dt0p000625_N,spatial_difference_h0p400_dt0p0003125_percent,spatial_difference_h0p200_dt0p0003125_percent,temporal_difference_h0p200_dt0p0003125_percent,temporal_difference_h0p200_dt0p000625_percent -1.25,0.2,68.15018140000001,67.9673104,68.32507899999999,67.8391746,72.2422804,-0.25597862828666473,-0.5236270564721716,0.18888172026785752,6.490506150704244 -3.5,0.2,52.3714018,52.35406759999999,52.345151599999994,52.3533266,53.9582166,0.0501482930083001,0.01703309614638552,0.0014153828383290867,3.0654976564564618 +1.25,0.2,68.15018140000001,67.9673104,68.3487458,67.8391746,69.497535,-0.2905165232746598,-0.5580722740928493,0.18888172026785752,2.4445468415236173 +3.5,0.2,52.3714018,52.35406759999999,52.342603399999994,52.3533266,53.2401192,0.05501904400881702,0.021902234996585834,0.0014153828383290867,1.6938610353749701 diff --git a/validation/experiments/bergdahl/refinement_summary.json b/validation/experiments/bergdahl/refinement_summary.json index f5f934c3..26d26521 100644 --- a/validation/experiments/bergdahl/refinement_summary.json +++ b/validation/experiments/bergdahl/refinement_summary.json @@ -4,7 +4,7 @@ "temporal_reference_time_step_s": 0.00015625, "primary_nominal_element_length_m": 0.2, "primary_time_step_s": 0.0003125, - "maximum_primary_spatial_difference_percent": 0.5236270564721716, + "maximum_primary_spatial_difference_percent": 0.5580722740928493, "maximum_primary_temporal_difference_percent": 0.18888172026785752, "rows": [ { @@ -12,26 +12,26 @@ "radius_m": 0.2, "force_h0p400_dt0p0003125_N": 68.15018140000001, "force_h0p200_dt0p0003125_N": 67.9673104, - "force_h0p100_dt0p0003125_N": 68.32507899999999, + "force_h0p100_dt0p0003125_N": 68.3487458, "force_h0p200_dt0p00015625_N": 67.8391746, - "force_h0p200_dt0p000625_N": 72.2422804, - "spatial_difference_h0p400_dt0p0003125_percent": -0.25597862828666473, - "spatial_difference_h0p200_dt0p0003125_percent": -0.5236270564721716, + "force_h0p200_dt0p000625_N": 69.497535, + "spatial_difference_h0p400_dt0p0003125_percent": -0.2905165232746598, + "spatial_difference_h0p200_dt0p0003125_percent": -0.5580722740928493, "temporal_difference_h0p200_dt0p0003125_percent": 0.18888172026785752, - "temporal_difference_h0p200_dt0p000625_percent": 6.490506150704244 + "temporal_difference_h0p200_dt0p000625_percent": 2.4445468415236173 }, { "period_s": 3.5, "radius_m": 0.2, "force_h0p400_dt0p0003125_N": 52.3714018, "force_h0p200_dt0p0003125_N": 52.35406759999999, - "force_h0p100_dt0p0003125_N": 52.345151599999994, + "force_h0p100_dt0p0003125_N": 52.342603399999994, "force_h0p200_dt0p00015625_N": 52.3533266, - "force_h0p200_dt0p000625_N": 53.9582166, - "spatial_difference_h0p400_dt0p0003125_percent": 0.0501482930083001, - "spatial_difference_h0p200_dt0p0003125_percent": 0.01703309614638552, + "force_h0p200_dt0p000625_N": 53.2401192, + "spatial_difference_h0p400_dt0p0003125_percent": 0.05501904400881702, + "spatial_difference_h0p200_dt0p0003125_percent": 0.021902234996585834, "temporal_difference_h0p200_dt0p0003125_percent": 0.0014153828383290867, - "temporal_difference_h0p200_dt0p000625_percent": 3.0654976564564618 + "temporal_difference_h0p200_dt0p000625_percent": 1.6938610353749701 } ] } From 065df73bde46ddb8bdccd6386974b5727cded69b Mon Sep 17 00:00:00 2001 From: Jae Hoon Seo Date: Tue, 20 Oct 2026 09:07:57 +0900 Subject: [PATCH 20/31] feat(control): active tension of finite-EI cables; committed lengths under the force blend (#26) Active line tensioning (CONTROL, driven by a ServoDyn cable-control channel) now works for finite-EI cables in OpenFAST runs: the fairlead-side segment changes length and rate as in MoorDyn-F, the committed force is kept across the update, and restarts and correction steps are bit-identical. For EI = 0 lines a length update entered the committed side of the generalised-alpha blend, so ramps lagged MoorDyn-F by up to 4.1 % (pay- out) and 6.3 % (haul-in) at the fairleads. The line now keeps the lengths and rates its committed state was reached with: under the force-blended step every step-start quantity uses them, end-of-step quantities the new ones, inertia the blended ones, and with ei0_substeps auto a pending change is spread over the sub-steps. A command outside MoorDyn-F's bounds stops the run by name. Coupled A/B against stock MoorDyn: ramp differences 0.13 % (fairlead) / 0.39 % (anchor) for EI = 0 lines and 0.21 % / 0.86 % for a finite-EI cable; a constant-rate pay-out matches its closed form to 1.8e-3 N. Runs without CONTROL are bit-identical. Signed-off-by: Jae Hoon Seo --- CHANGELOG.md | 73 ++ CMakeLists.txt | 11 + VALIDATION.md | 3 +- doc/capabilities.rst | 9 +- doc/coupling.rst | 6 +- doc/coupling_boundary.md | 2 +- doc/driver_format.md | 61 +- doc/migrating.rst | 10 +- doc/openfast.rst | 12 +- doc/theory.rst | 118 ++- doc/troubleshooting.rst | 24 +- python/tests/test_deck_file.py | 13 + src/CableDyn_DeckDriver.f90 | 381 ++++++-- src/CableDyn_Dynamic.f90 | 196 +++- src/CableDyn_HermiteCableDynamic.f90 | 680 ++++++++++++- src/CableDyn_Model.f90 | 794 +++++++++++++--- src/CableDyn_OpenFAST_Aggregate.f90 | 210 ++++- src/CableDyn_OpenFAST_HermiteFMF.f90 | 34 +- src/CableDyn_System.f90 | 93 +- src/openfast/CableDyn_OF.f90 | 35 +- tests/data/activetension_ab_reference.csv | 24 +- tests/test_core_release_regressions.f90 | 166 +++- tests/test_ei0_slack_dynamics.f90 | 432 ++++++++- tests/test_hermite_axial_damping.f90 | 94 +- tests/test_hermite_cable_control.f90 | 688 ++++++++++++++ tests/test_model.f90 | 332 ++++++- tests/test_openfast_aggregate.f90 | 891 +++++++++++++++++- validation/scripts/activetension/README.md | 10 +- .../scripts/openfast_activetension_ab.py | 46 +- 29 files changed, 4968 insertions(+), 480 deletions(-) create mode 100644 tests/test_hermite_cable_control.f90 diff --git a/CHANGELOG.md b/CHANGELOG.md index 4cd9946e..d1b295a8 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -168,6 +168,21 @@ All notable changes to CableDyn are recorded in this file. The format follows moorings, and quote their results for the enlarged grid. With the `MD_Shared` grid, the line-1 fairlead tension standard deviation of the tutorial was 18 % too high. See the manual's OpenFAST page (SeaState grid). +- Active tensioning of finite-EI cables in OpenFAST (`CompMooring = 5`). A `CONTROL` row may + now name a finite-EI (cubic-Hermite) cable, alone or in a deck with `EI = 0` lines. Before + each mooring step, ServoDyn's `CableDeltaL` and `CableDeltaLdot` scale every cable element of + the line's fairlead-side deck segment by (S + `DeltaL`)/S, with the matching rate, so the + segment becomes S + `DeltaL` long. The cable's mass, attachment masses, tributary lengths and + seabed contact coefficients follow the new lengths, and the axial damping acts on the rate of + the strain the elastic force uses, so a segment paid out at constant strain carries no damping + force. The force-blended generalised-α step takes its committed force at the lengths of the + preceding step, so a pay-out ramp follows the quasi-static tension at any `rhoInf`; a deck + that controls a finite-EI cable under `False alpha_force_blend` fails at initialisation with + a message that names the line, as that blend has no such treatment. A command outside + MoorDyn-F's bounds stops the run as for `EI = 0` lines (see Changed), and FAST.Farm decks + still reject `CONTROL`. A zero command, with a `DeltaLdot` of either sign, leaves the run + bit-identical to an uncontrolled one, and a checkpoint restart continues bit-identically. See + the manual's deck format page (CONTROL). ### Changed @@ -318,6 +333,16 @@ All notable changes to CableDyn are recorded in this file. The format follows 0.63 m against 0.64 m converged, where the linear interpolation gave 0.23 m. On the `EI = 0` chain of `examples/chain_range_tdp.dat` the largest step falls from 2.59 m to 1.33 m. The TDP now lies on the contact-onset height, and `TDPGrd` uses the same location. +- Active tensioning (`CONTROL`) of an `EI = 0` line now stops the run when a command leaves + MoorDyn-F's bounds, as MoorDyn-F does: with `UnstrLen` the line's unstretched length and N its + number of segments, a `DeltaL` above `UnstrLen`/N or below −0.5 `UnstrLen`/N, the comparisons + MoorDyn-F makes, so a command MoorDyn-F accepts is accepted (on a line of one section + `UnstrLen`/N is the controlled segment's initial length). The message names the channel, the + line, the command and the bound. A command beyond these bounds had printed a one-time warning + and been applied. A command within the bounds that would make the controlled segment of a + line of several sections non-positive also stops the run. Finite-EI cables take the same + bounds. Every row is checked before any line changes, and a row that still fails takes back + the lines the command had already changed, so a refused command changes nothing. - Faster wave kinematics of directional and multi-train seas (`wavetrain` rows, spectral `waves` rows, `WaveSpreading`). Each component's phase cosine is now computed once for the surface elevation and the kinematics, and its depth profile with one exponential instead of @@ -520,6 +545,54 @@ All notable changes to CableDyn are recorded in this file. The format follows than a factor four, as the manual states; it had kept the first tangent for the whole step, which a slow linear contraction could exhaust (30 iterations at the start of the 5 m heave cells of the L2-2 parity test with the force blend). +- Active tensioning (`CONTROL`) of an `EI = 0` line now changes the segment at the line's + fairlead-side end, the end on a host-driven point (`Coupled`, `Vessel`, `Turbine`, + `Body` or a `Coupled`/`Vessel` rod end), and the segment at the `NodeB` written in the + deck when both or neither ends are host-driven, as MoorDyn-F does for a deck in its own order. + It had always changed the segment at CableDyn's End A, the `NodeA` of a line that the + automatic anchor-first swap leaves in deck order. Two kinds of line change: a line kept in + deck order whose only host-driven end is its `NodeB`, such as a stock-order + `Connect`-to-`Vessel` clump leg or a line from a `Fixed` anchor to a coupled rod end, now + controls the segment at the host-driven end instead of the one at its `NodeA`; and a line + with both or no host-driven ends that the swap leaves in deck order, such as a + `Connect`-to-`Fixed` or `Connect`-to-`Connect` line, a `Fixed` hang-off above a + `Free`/`Connect` point, or a line between two vessel points, now controls the segment at its + `NodeB`. Lines from a `Fixed` anchor to a `Coupled`, `Vessel` or `Body` point, + written in either order, and lines written fairlead first from a host-driven `NodeA` control + the same segment as before. +- Active tensioning (`CONTROL`) of `EI = 0` lines no longer lags behind the commanded length + on a pay-out or haul-in ramp. A length update had re-derived the committed acceleration + under the new length, and the next generalised-α step evaluated its blended configuration + with the new length only, so the force of each length change entered the committed side of + the blend. The committed state now keeps its acceleration and the lengths and rates it was + reached with, and each share of the step after a change takes the lengths of its own time + level. With the force-blended step (the default), the step-start force is evaluated at the + committed lengths and rates: the internal force, every dynamic load, every step-start + quantity of the release cap (stretch, tension, secant and law stiffness, dashpot tension, and + the one-step dissipation budget of a dashpot slack at the step start), + and the distributed external load and seabed coefficients those lengths give; the cap's + end-state quantities take the new lengths; the end-of-step force takes the new lengths, and the inertia (the + structural and added mass, which the force blend keeps at the α level) the blended ones. + Under `False alpha_force_blend` the step blends the old and new lengths with the + configuration. An acceleration re-derived between a command and the next step, as a host + state update does, is solved at the committed lengths, as the step evaluates its committed + side, and leaves them committed. On a taut line paid out at a tension change of 1 N per step, + the tension follows the closed form to 1.8 mN at `rhoInf` 0.4 and 0 alike (the start-up + transient), where a step-start force at the new lengths lags by 2.6 N. In + the coupled OpenFAST comparison with stock MoorDyn (`validation/scripts/activetension/`), the + controlled fairlead tensions had run up to 97 kN (4.1 %) above MoorDyn during the pay-out and + 148 kN (6.3 %) below it during the haul-in, at `rhoInf` 0.4 and still 58 kN and 89 kN at + `rhoInf` 0; they now stay within 3 kN (0.13 %). The hold tensions, which the published + comparison scores, move by less than 0.01 %, and the scorer now also gates the ramps. + This change leaves runs without `CONTROL`, and a zero command, bit-identical. A checkpoint restart + re-applies the restored command as the committed state's, so a restart during a ramp + continues bit-identically. A step that `ei0_substeps auto` solves in sub-steps spreads the + length change over them: the committed lengths are part of the state each pass starts from, + each sub-step ends at the lengths and rates interpolated linearly in time (the last at the + new ones), and the trigger takes the step-start tensions at the committed lengths. On a line + turning by 2.3° per step and paid out at 0.05 m/s, the sub-stepped march equals one taken as + given at a quarter of the step to 3e-8 N; applying the whole change in the first sub-step + departs from it by 22 N. - The development environment (`environment.yml`) excludes OpenBLAS 0.3.34, which caused the access violation in the modal analysis tests listed under Known issues for 0.1.1. On AMD Zen 4 and Zen 5 CPUs that expose AVX-512, OpenBLAS 0.3.34 enlarges the GEMM blocking, diff --git a/CMakeLists.txt b/CMakeLists.txt index b57cb64e..20a5e70a 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -653,6 +653,14 @@ target_link_libraries(test_hermite_axial_damping PRIVATE cabledyn_core) add_test(NAME hermite_axial_damping COMMAND test_hermite_axial_damping) set_tests_properties(hermite_axial_damping PROPERTIES LABELS "fortran;unit;dynamic;damping") +# Active line control of a finite-EI cable: the length update rebuilds the caches a fresh +# build carries (bit for bit), is atomic and rewinds exactly; hanging, taut and paid-out +# vertical cables meet their closed forms; a slow ramp ends at the static equilibrium. +add_executable(test_hermite_cable_control tests/test_hermite_cable_control.f90) +target_link_libraries(test_hermite_cable_control PRIVATE cabledyn_core) +add_test(NAME hermite_cable_control COMMAND test_hermite_cable_control) +set_tests_properties(hermite_cable_control PROPERTIES LABELS "fortran;unit;dynamic;hermite") + add_executable(test_hermite_added_mass tests/test_hermite_added_mass.f90) target_link_libraries(test_hermite_added_mass PRIVATE cabledyn_core) add_test(NAME hermite_added_mass COMMAND test_hermite_added_mass) @@ -2347,6 +2355,7 @@ if(CMAKE_Fortran_COMPILER_ID STREQUAL "GNU") test_hermite_cable test_hermite_drag_dynamics test_hermite_axial_damping + test_hermite_cable_control test_endconn_spring) target_compile_options(${_cabledyn_exact_real_test} PRIVATE -Wno-compare-reals) endforeach() @@ -2355,6 +2364,7 @@ if(CMAKE_Fortran_COMPILER_ID STREQUAL "GNU") -Wno-uninitialized -Wno-maybe-uninitialized) target_compile_options(test_torsion_deck PRIVATE -Wno-uninitialized -Wno-maybe-uninitialized) + target_compile_options(test_hermite_cable_control PRIVATE -Wno-uninitialized -Wno-maybe-uninitialized) endif() if(CABLEDYN_ENABLE_COVERAGE) @@ -2403,6 +2413,7 @@ if(CABLEDYN_ENABLE_COVERAGE) test_hermite_cable_dynamic test_hermite_drag_dynamics test_hermite_axial_damping + test_hermite_cable_control test_hermite_added_mass test_hermite_wave_forcing test_lazywave_dynamics diff --git a/VALIDATION.md b/VALIDATION.md index 3626f377..78cee30d 100644 --- a/VALIDATION.md +++ b/VALIDATION.md @@ -757,7 +757,8 @@ stop with a named error. | Farm + restart / Farm + linearisation | Not applicable | FAST.Farm has no restart and does not call module linearisation; the same applies to stock MoorDyn | | Line failures (`FAILURE` table) | Pass verified | MoorDyn semantics on both paths (reserve-point pre-allocation, time or tension trigger, detach onto a massless Free point); standalone (point systems and free Rigid6 bodies), coupled, and checkpoint-replay tests | | Viscoelastic stiffness (`ElasticMod > 1`; [Hall et al., 2023](https://cabledyn.readthedocs.io/en/latest/references.html#ref-hall2023)) | Pass verified | both MoorDyn forms as per-element two-branch series-Kelvin laws eliminated implicitly in the generalised-α step; the standard linear solid is recovered only when the fast-branch dashpot `BA_D` is zero; `md_viscoelastic` r-test 0.007–0.97% at 5× dt; the coupled module carries `dl_1` in the checkpoint state | -| Active tension (`CtrlChan`) | Pass verified | CONTROL parsing, last-segment length/rate modulation, and exact unit tests; coupled A/B in which a ServoDyn cable-control DLL drives the same pay-out/haul-in `DeltaL` schedule into `=5` (CableDyn) and `=3` (stock MoorDyn) in one binary: hold tensions agree to <0.03% and the tension responses to <0.6% (controlled fairleads) / <0.7% (anchors) ([`validation/scripts/activetension/`](https://github.com/SMI-Lab-Inha/CableDyn/tree/main/validation/scripts/activetension), [`validation/scripts/openfast_activetension_ab.py`](https://github.com/SMI-Lab-Inha/CableDyn/blob/main/validation/scripts/openfast_activetension_ab.py)) | +| Active tension (`CtrlChan`) | Pass verified | CONTROL parsing, last-segment length/rate modulation, and exact unit tests; coupled A/B in which a ServoDyn cable-control DLL drives the same pay-out/haul-in `DeltaL` schedule into `=5` (CableDyn) and `=3` (stock MoorDyn) in one binary: hold tensions agree to <0.03% and the tension responses to <0.6% (controlled fairleads) / <0.7% (anchors); during the pay-out and haul-in ramps the tensions differ by at most 0.13% (controlled fairleads) / 0.39% (anchors) of the baseline tension, with the force-blended step evaluating its step-start force at the committed lengths (the fairleads had differed by up to 4.1% and 6.3% before the length update kept the committed lengths in the generalised-alpha step; the holds were unaffected) ([`validation/scripts/activetension/`](https://github.com/SMI-Lab-Inha/CableDyn/tree/main/validation/scripts/activetension), [`validation/scripts/openfast_activetension_ab.py`](https://github.com/SMI-Lab-Inha/CableDyn/blob/main/validation/scripts/openfast_activetension_ab.py)) | +| Active tension of finite-EI cables (no MoorDyn-F counterpart) | Pass scoped | coupled A/B with the active-tension model above, line 1 a finite-EI cable of small bending stiffness (EI = 1e5 N m², 50 elements) against stock MoorDyn's chain: during the ramps its tensions differ by at most 0.21% (fairlead) / 0.86% (anchor) of the baseline at `rhoInf` 0.4, and its hold responses by 1.9–2.3% (against the `EI = 0` twin of the same deck this hold difference falls from about 2% at 50 to 0.3% at 100 segments); a restart mid-ramp and `NumCrctn = 1` are bit-identical. Aggregate and model tests: closed forms on axial vertical cables (top reaction w(L + ΔL) to 2e-7, taut top tension EA(H − L′)/L′ + wL′/2 to 1e-12, Kelvin–Voigt pay-out lag BA·H·L̇/L′² to 1e-5 of the lag), slow-ramp end state equal to the static solve of the edited lengths to 2e-6 of the displacement, damping Jacobian with the length rate against finite differences, caches equal to a fresh build and snapshot/restore bit for bit, bit-identical zero command and checkpoint restart (`test_hermite_cable_control`, `test_hermite_axial_damping`, `case_aggregate_cable_control`, `case_restart_cable_control`) | | Coupled `Rigid6` bodies + `Point3` buoys | Pass verified | 6-DOF `Rigid6` motion with hydrostatic (`C33`/`C44`/`C55`) restoring, checkpoint state (bit-identical `openfast -restart` of a 13.9 MN-swinging tethered body), and SeaState drag / Froude–Krylov / added mass. `Point3` buoys take buoyancy and drag/added-mass/FK; a submerged volume-only buoy takes FK. Tests: `case_coupled_rigid6`/`_mirror`/`_fluid`, `case_coupled_point3_buoy`/`_fluid` | | Coupled rigid rods | Pass verified | host-driven `RodA/B` endpoints, correction rewind, bit-identical 24-scalar-per-rod checkpoint state, and two Gauss fluid nodes per rod with SeaState drag/Froude–Krylov/added mass; `case_coupled_rod`, `_mirror`, and `_fluid` pass, and the OpenFAST module compiles with rod decks enabled | | Coupled pinned rods (`Pinned`, `CoupledPinned`/`VesselPinned`) | Pass verified | `openfast_pinned_rod` on the aggregate: a dry rod (10 m, 500 kg) released at 30° swings with the elliptic-integral compound-pendulum period to 1.6e-4 at `dt = T/100`, End A on the pin to 0 m; a held `CoupledPinned` node reproduces the `Pinned` rod to round-off (1e-12), returns zero moment, and its force equals the analytic pin reaction to 2.0e-13 of `mg`; a pin accelerating at 2 m/s² gives the mean angle `atan(a/g)` to 1e-6 rad and the period of `sqrt(g² + a²)` to 1.6e-4; a harmonic pin motion follows the linear base-excitation solution to 1.5e-3 / 3.7e-4 of the amplitude at `T0/100` / `T0/200` (ratio 4.03); a 0.1 s step sub-cycled 7 times reproduces a run at the sub-step size to 1e-14 rad and 4e-10 N for a drifting pin; a 1 m `Pinned` rod that carries no line (dry and hanging, or buoyant and upright under water) at a 0.6 s step (`omega0 dt` 2.29 / 3.42, beyond the explicit limit 2) sub-cycles it 6 / 9 times from its own swing stiffness `|W d_g - B d_b|`, equals the run at the sub-step size bit for bit, stays within its release angle and keeps the elliptic-integral period to 6.0e-3 / 5.9e-3 (taken whole, the step turns the rod over); a `CoupledPinned` pin crossing the free surface within one step at constant velocity (a 1 kg/m rod lifted from submerged to dry in 0.1 s, `omega dt` 2.13 wet; a 33 kg/m rod lowered from dry to submerged in 0.6 s, 2.29 dry) takes at least 6 sub-steps from its step-start wetting (more from the waterplane near the surface) and ends within 5e-5 / 3e-4 rad of a run at a sixtieth of the step, where the end-of-step wetting alone gives one sub-step and an angle error of 0.20 / 0.69 rad; on a stiff seabed (`kBot` 1e7 N/m³) a `Pinned` rod whose far end rests on the bed (0.1 s step) and a `Free` rod lying on it (0.05 s step) sub-cycle their contact mode (34–36 and 26 sub-steps), stay at rest on the bed over 5 s (angle change 3.8e-3 / 4e-15 rad, the undamped static settlement) and end within 1.9e-6 / 8e-8 of a run at a tenth of the step, where the sub-steps of the lines and swing alone (1 and 4) throw them off the bed (4.2 rad, 0.8 m); an output probe returns `-m (I_c/I_p) a_p` within 1e-10 of `mg` (not `-m a_p`), and its pin force moves by 2e-11 N when the held end acceleration of the attached tethers changes their end load by 8 N; snapshot/restore, probe restore and restart overlay are bit-identical, the restored state's loads before the next step included; a step without the staged rods (the step-start pin carried by the rod) is bit-identical to the staged one; a `Free` or `Coupled` rod with an end without a line is refused by name; with `PtfmInit` the static start leaves 1.4e-8 N·m about the pin. OpenFAST (IEA-15 UMaine, JONSWAP Hs 6 m, 60 s, `dtM = DT = 0.025 s`) with line 1 hung from a 4 m `CoupledPinned` rod at its fairlead: `openfast -restart` at 30 s reproduces every later OpenFAST output row bit for bit (`NumCrctn` 0 and 1), `NumCrctn = 1` equals `NumCrctn = 0` bit for bit, and surge/heave/pitch statistics stay within 0.2 % / 0.4 % / 1.7 % (mean) of the deck with line 1 on a `Coupled` point | diff --git a/doc/capabilities.rst b/doc/capabilities.rst index df3a5864..e6fcac78 100644 --- a/doc/capabilities.rst +++ b/doc/capabilities.rst @@ -192,11 +192,10 @@ OpenFAST coverage The ``CompMooring = 5`` shell covers normal coupled time-domain stepping with its own ``dtM``, nonzero ``PtfmInit``, correction iterations, SeaState fields, checkpoint/restart, scoped -quasi-static ``dYdu`` linearisation, line failures, active-tension control for ``EI = 0`` lines, -and FAST.Farm shared moorings. Restart and linearisation do not arise under FAST.Farm, which -does not call those module operations. Active ServoDyn control of a finite-EI cable -remains rejected. See :doc:`openfast` for setup and :doc:`coupling_boundary` for the interface -contract. +quasi-static ``dYdu`` linearisation, line failures, active-tension control of ``EI = 0`` lines +and finite-EI cables, and FAST.Farm shared moorings. Restart and linearisation do not arise under +FAST.Farm, which does not call those module operations, and active-tension control is rejected +there. See :doc:`openfast` for setup and :doc:`coupling_boundary` for the interface contract. How to interpret this page -------------------------- diff --git a/doc/coupling.rst b/doc/coupling.rst index 12c84ab4..d66c8d64 100644 --- a/doc/coupling.rst +++ b/doc/coupling.rst @@ -48,8 +48,10 @@ solve is mathematically incorrect; changing ``NumCrctn`` does not change that de Outside that surface the module fails closed — a clear fatal error, never a silent wrong answer — on: - - active ServoDyn control (``CableDeltaL``) of a finite-EI cable, or any ``CONTROL`` section - in FAST.Farm (``EI = 0`` line control is supported in a single-turbine model), + - any ``CONTROL`` section in FAST.Farm (active ServoDyn control, ``CableDeltaL``, of + ``EI = 0`` lines and finite-EI cables is supported in a single-turbine model), a + command outside MoorDyn-F's bounds or one that would make a controlled segment + non-positive, and ``CONTROL`` of a finite-EI cable under ``False alpha_force_blend``, - coupled ``Rigid6`` bodies and rods in a FAST.Farm deck, - deck ``waves``/``wavetrain`` OPTIONS (the host SeaState supplies the waves), and a deck ``current`` except as a steady current on a single-turbine, pure ``EI = 0`` deck without diff --git a/doc/coupling_boundary.md b/doc/coupling_boundary.md index 15205cb8..5f4e36e4 100644 --- a/doc/coupling_boundary.md +++ b/doc/coupling_boundary.md @@ -128,7 +128,7 @@ point mesh. It supports: stored in the OpenFAST state record; - quasi-static linearisation; - FAST.Farm shared moorings; -- line failures and active tension control of `EI = 0` lines; +- line failures, and active tension control of `EI = 0` lines and finite-EI cables; - WaterKin files with independent selection of host wave and host current. SeaState's standard steady current is reconstructed on the same vertical nodes and weights SeaState uses, so it can be removed or kept exactly; a host field that cannot be separated is rejected. diff --git a/doc/driver_format.md b/doc/driver_format.md index 83c23521..e5240eef 100644 --- a/doc/driver_format.md +++ b/doc/driver_format.md @@ -386,7 +386,8 @@ row. On this route: field; - a finite-EI cable cannot share a coupled deck with Rigid6 bodies, rods, or `Connect`/`Free` points; -- CONTROL and FAILURE rows are rejected on decks that contain finite-EI cables; +- FAILURE rows are rejected on decks that contain finite-EI cables; CONTROL rows may name + finite-EI cables (see [CONTROL](#control-optional-openfast-line-control)); - `Coupled`/`Vessel` rods are platform-borne and need no `motionFile`: each is a node of the OpenFAST mesh at its End A, turns rigidly with the platform orientation (its deck coordinates, like those of `Coupled` points, are given at the undisplaced platform and moved by @@ -980,17 +981,53 @@ ChannelID Line(s) | `Line(s)` | one line id or a comma list without spaces (`1,2`) | Each line belongs to at most one channel. Before every advance, the channel's `DeltaL` sets the -unstretched length of each assigned line's **last (fairlead-side) segment** to its initial length -plus `DeltaL`; `DeltaLdot` supplies the matching rate. Axial damping on that segment acts on the -strain rate, as in MoorDyn-F, so a segment paid out at constant strain carries no damping tension. -A command that makes that segment length -zero or negative is rejected. A command above one initial segment length, or below minus half of -it, prints a one-time warning and is applied unclamped. The host input arrays are sized to the -highest channel id. - -CONTROL is supported only on the OpenFAST `CompMooring = 5` route, for pure `EI = 0`, -non-FAST.Farm decks, without OpenFAST linearisation. The standalone driver rejects a CONTROL -section, as does a coupled deck containing a finite-EI cable. +unstretched length of each assigned line's **fairlead-side segment** to its initial length plus +`DeltaL`; `DeltaLdot` supplies the matching rate. The fairlead-side segment is the one at the +line's end on a host-driven point: `Coupled`, `Vessel`, `Turbine`, `Body`, or an end of a +`Coupled` or `Vessel` rod. When both ends or neither end are on such points, it is the segment at +the `NodeB` written in the deck. A line written in the stock MoorDyn order, with its host-driven +end at `NodeB`, is therefore controlled where MoorDyn-F controls it, at its last segment N at +`AttachB`; so is a line with both or no host-driven ends. A line written fairlead first, with its +only host-driven end at `NodeA`, is controlled at that end. The length is held over the advance. +Axial damping on that segment acts on the strain rate, as in MoorDyn-F, so a segment paid out at +constant strain carries no damping tension. + +A command outside MoorDyn-F's bounds stops the run with a message that names the channel, the +line, the command and the bound, as MoorDyn-F stops there. With `UnstrLen` the line's unstretched +length and N its number of segments, both summed over its `SECTIONS` rows, MoorDyn-F refuses +`DeltaL` > `UnstrLen`/N and `DeltaL` < −0.5 `UnstrLen`/N; CableDyn makes the same comparisons, so +a command MoorDyn-F accepts is accepted. On a line of one section `UnstrLen`/N is the controlled +segment's initial length S, and the bounds read −S/2 ≤ `DeltaL` ≤ S. On a line of several +sections the controlled segment can be shorter or longer than `UnstrLen`/N; a command within the +bounds that would make it zero or negative (possible when it is shorter than half of +`UnstrLen`/N) also stops the run, with a message that names the line. + +- On an `EI = 0` line the segment is the end element on that side, of initial length S. The + step evaluates the committed side of its generalised-α blend at the lengths of the previous + advance (with the force blend, the default, the step-start force; under + `False alpha_force_blend`, lengths blended with the configuration), so a length ramp is + followed without lag at any `rhoInf`. +- On a finite-EI cable, which runs from a `Fixed` anchor to a host-driven fairlead, the segment + is the fairlead segment of the deck mesh (the length of the `SECTIONS` row at the fairlead over + its `NumSegs`). Where the static initialisation refined the mesh, it is the cable elements that + make up that segment. Each of them scales by (S + `DeltaL`)/S, S being the segment's initial + length, with rate `DeltaLdot` l/S for an element of initial length l, so the segment becomes + S + `DeltaL` long. The structural and attachment mass, the seabed contact coefficients and the + tributary lengths follow the new lengths; `BA` keeps its initial resolution. The step blends + the force of the committed state, taken at the lengths of the previous advance, with the force + at the new lengths, so a length ramp is followed without lag at any `rhoInf`. This needs the + force-blended generalised-α, the default: a deck that controls a finite-EI cable under + `False alpha_force_blend` fails at initialisation with a message that names the line. Within + the bounds above, a cable of one section scales each element within [0.5, 2] of its initial + length; on a cable of several sections the scaling can leave that range, beyond the + resolution its static mesh was built for, so keep large commands on a fairlead section whose + segments are at least `UnstrLen`/N long. A cable restrained in torsion cannot be controlled + (the coupled route rejects torsion stiffness in END CONNECTIONS). + +The host input arrays are sized to the highest channel id. + +CONTROL is supported only on the OpenFAST `CompMooring = 5` route, for non-FAST.Farm decks, +without OpenFAST linearisation. The standalone driver rejects a CONTROL section. ### OPTIONS (`value keyword` order, case-insensitive keyword) diff --git a/doc/migrating.rst b/doc/migrating.rst index e4723966..04748725 100644 --- a/doc/migrating.rst +++ b/doc/migrating.rst @@ -115,9 +115,13 @@ Keyword map * - ``WaterKin`` file (``CurrentMod 1``, ``WaveKinMod 1``) - same file; ``WaveKinMod 2`` and ``SEASTATE`` only when coupled to OpenFAST * - ``FAILURE``, ``CONTROL`` sections - - ``FAILURE`` on ``EI = 0`` decks, standalone and in OpenFAST; ``CONTROL`` on ``EI = 0`` - decks in OpenFAST (the standalone driver rejects it). A deck with a finite-EI cable - rejects both + - ``FAILURE`` on ``EI = 0`` decks, standalone and in OpenFAST (a deck with a finite-EI + cable rejects it); ``CONTROL`` on ``EI = 0`` lines and finite-EI cables in OpenFAST, not + in FAST.Farm (the standalone driver rejects it). The command changes the segment at the + line's host-driven end, or at the ``NodeB`` written in the deck when both or neither ends + are host-driven; a stock-order deck is controlled where MoorDyn-F controls it. A + command outside MoorDyn-F's bounds (−S/2 ≤ ``DeltaL`` ≤ S with S = ``UnstrLen``/N, the + same comparison) stops the run, as it stops MoorDyn-F * - ``FairTen``, ``AnchTen``, point/node channels - same names; tensions in N (:doc:`outputs`). On a line with no ``Fixed`` end the two end channels name the opposite ends from MoorDyn's (see above) diff --git a/doc/openfast.rst b/doc/openfast.rst index 941f7a94..09e82172 100644 --- a/doc/openfast.rst +++ b/doc/openfast.rst @@ -335,8 +335,16 @@ without an auxiliary process: turbines, otherwise initialisation fails. * **Line failures** detach a line end on a time or tension trigger and replay correctly after a restart. Verify the trigger and the post-failure topology in a dedicated case first. -* **Active tensioning** maps ServoDyn ``CableDeltaL`` control onto ``EI = 0`` lines; finite-EI - lines reject it. +* **Active tensioning** maps ServoDyn ``CableDeltaL``/``CableDeltaLdot`` control onto the + fairlead-side segment of ``EI = 0`` lines and finite-EI cables, the segment at the line's end + on a host-driven point, or at the ``NodeB`` written in the deck when both or neither ends are + (:doc:`driver_format`, CONTROL). On a finite-EI cable the command scales every cable element + of that segment, and needs the force-blended generalised-α (the default). On both kinds a + command outside MoorDyn-F's bounds, from minus half to plus one ``UnstrLen``/N of the line + (the controlled segment's initial length on a line of one section), stops the run with a + message that names the line, as it stops MoorDyn-F; so does a command that would make the + controlled segment of a line of several sections non-positive. FAST.Farm decks reject + CONTROL. * **Rigid6 bodies, Point3 bodies, and rigid rods** are translated at the deck boundary; their supported loads and restrictions in coupled runs are listed in :doc:`capabilities`. Free Rigid6 bodies, free rods and pinned rods start at their static equilibrium with the platform diff --git a/doc/theory.rst b/doc/theory.rst index eb199e87..5f9d41e8 100644 --- a/doc/theory.rst +++ b/doc/theory.rst @@ -1439,7 +1439,9 @@ dynamic load: axial damping, the viscoelastic and Syrope laws, seabed contact, d friction, Morison drag, Froude–Krylov and buoyancy loads. Added mass stays at :math:`(\mathbf{q}_\alpha, \mathbf{a}_{\alpha_m})`. :math:`\mathbf{r}_n` is evaluated afresh at the committed state of every step, with the viscoelastic and Syrope elements at their committed -internal state, so the scheme carries no extra state and a restart is exact; a re-solve of the +internal state (and, after a length change by active line control, at the lengths the committed +state was reached with; see Active line control), so the scheme carries no extra state and a +restart is exact; a re-solve of the same step from the same state (the junction coupling) reuses it. The fluid fields of an ``EI = 0`` line (current, wave velocity and acceleration, and the waterline) are held over the step: before the step the host (the standalone driver, or the coupling host) samples them for @@ -2239,11 +2241,115 @@ pre-allocated reserve free point that then moves with the attached line ends. On the bodies keep their staggered step with the remaining lines, and the reserve point is integrated on its line-end loads within the same line step. -**Active line control.** A ``CONTROL`` row assigns a control channel to an ``EI = 0`` line. The -commanded :math:`\Delta L` and :math:`\Delta\dot L` change the unstretched length and its rate -of the End-A element, :math:`L_0 = L_{0,\text{base}} + \Delta L`; the structural mass and the -point mass shares are updated consistently, while ``BA`` keeps its initial resolution. -Commands that would make the element length non-positive are rejected. +**Active line control.** A ``CONTROL`` row assigns a control channel to a line. The command +acts on the segment at the line's fairlead-side end, the end on a host-driven point (coupled, +vessel, turbine or body point, or an end of a coupled or vessel rod); when both or neither ends +are host-driven, it acts on the segment at the ``NodeB`` written in the deck (MoorDyn-F's +segment :math:`N` at ``AttachB``). On an ``EI = 0`` line the commanded :math:`\Delta L` and +:math:`\Delta\dot L` change the unstretched length and its rate of that end element, +:math:`L_0 = L_{0,\text{base}} + \Delta L`; the structural mass and the point mass shares are +updated consistently, while ``BA`` keeps its initial resolution. Commands outside MoorDyn-F's +bounds, :math:`-\bar L/2 \le \Delta L \le \bar L` with :math:`\bar L` the line's unstretched +length over its number of segments (``UnstrLen``/N, the base length of the controlled segment +on a line of one section), are rejected with the same comparisons MoorDyn-F makes, on both line +kinds; so is a command that would make the controlled segment non-positive, which only a line +of several sections allows. + +On an ``EI = 0`` line the length is applied before a step and held over it, and the +committed state keeps the lengths and rates it was reached with, :math:`L_{0,c}` and +:math:`\dot L_{0,c}`, together with its acceleration. Each share of the generalised-:math:`\alpha` +residual takes the lengths of its own time level, and the step commits the new lengths with the +new state. With the force blend (the default) the step-start force +:math:`\mathbf{r}(\mathbf{q}_n, \mathbf{v}_n)` is the committed state's: its internal force, axial +damping, viscoelastic and Syrope laws, seabed contact, damping and friction, Morison drag, +Froude–Krylov and buoyancy loads are evaluated with :math:`L_{0,c}` and :math:`\dot L_{0,c}`, with +the distributed external load and the nodal seabed coefficients those lengths give, and so is +every step-start quantity of the release cap: the stretch :math:`e_n = l_n - L_{0,c}`, the +tension :math:`T_n` (the elastic one, or that of the viscoelastic or Syrope law at the committed +state), :math:`W_n`, the secant :math:`T_n/e_n`, the law stiffness :math:`k_n` (:math:`EA_D/L_{0,c}`, +:math:`K_1/L_{0,c}`) and the dashpot tension :math:`T_{d,n}` (with :math:`\dot L_{0,c}`). +:math:`\mathbf{r}(\mathbf{q}_{n+1}, \mathbf{v}_{n+1})` and the cap's end-state quantities take the new +lengths and rates: the stretch :math:`e_{n+1} = l_{n+1} - L_0`, the estimate +:math:`\hat T_{n+1} = \min(T_n/e_n, k_n)\,e_{n+1}` and :math:`T_{d,n+1}`; the projections :math:`p` and +:math:`p_{n+1}` are geometric. The dashpot weight :math:`\phi` measures the end stretch against the new +length, so its band runs from :math:`L_0` to :math:`L_0 + c\,e_n`, the width set by the step-start +stretch as without a change. For an elastic element the secant estimate then differs from its end +tension :math:`EA\,e_{n+1}/L_0` by the factor :math:`L_0/L_{0,c}`, that is by the relative length change +of the step. A haul-in can make :math:`p_{n+1}` more negative than without a change; the +capped force is then bounded below by zero, and the cap's quick inactivity test uses the bound +:math:`N \ge W_n - (1-\alpha_f)\,T_n (l_n - L_0)^2/(4 e_n)`. The external load of the step, +constant over it, is :math:`(1-\alpha_f)\,\mathbf{f}_\text{ext}(L_0) + \alpha_f\,\mathbf{f}_\text{ext}(L_{0,c})`. +The inertia, which the force blend keeps at the :math:`\alpha` level (the structural mass applied +to :math:`\mathbf{a}_{n+1-\alpha_m}` and the added mass at :math:`\mathbf{q}_\alpha`), takes the +blended lengths :math:`(1-\alpha_f) L_0 + \alpha_f L_{0,c}` of the changed elements, as +:math:`\mathbf{q}_\alpha` blends the configuration. With the configuration blend +(``False alpha_force_blend``) the residual evaluates the internal force, the damping and the +hydrodynamic loads at the blended configuration :math:`\mathbf{q}_{n+1-\alpha_f}`; for an element +whose length changed it also blends the lengths, :math:`(1-\alpha_f) L_0 + \alpha_f L_{0,c}` (and +the rates likewise, the structural and added mass included), so that the configuration and the +lengths are blended consistently and the new length belongs to :math:`t_{n+1}`; the external load +and the seabed coefficients are then the new lengths'. Evaluating the committed side with the +new lengths (the step-start force, or a configuration blended without its lengths), or +re-deriving the committed acceleration under the new length, would add the force of the length +change to the committed side of the blend, weighted by :math:`\alpha_m` and :math:`\alpha_f`; on a +pay-out or haul-in ramp the tension would then lag the quasi-static value by a fixed fraction of +its change per step, at any :math:`\rho_\infty` (on a taut line paid out at a tension change of +1 N per step, 2.6 N with the step-start force at the new lengths, against 1.8 mN, the start-up +transient that :math:`\rho_\infty = 0` shows as well). An acceleration re-derived between the +command and the step (a host state update or a boundary commit) belongs to the committed state, +so it is solved with :math:`L_{0,c}` and :math:`\dot L_{0,c}`, which stay the committed lengths and +rates, and evaluated as the step evaluates its committed side: with the force blend at the +external load and seabed coefficients of :math:`L_{0,c}` as well, with the configuration blend at +the present ones. + +A step that the rotation- and snap-resolved sub-steps (``ei0_substeps auto``, above) solve +again spreads a pending length change over its sub-steps. The committed lengths and rates are +part of the state each pass starts from; sub-step :math:`k` of :math:`n` ends at the lengths and +rates interpolated linearly in time between :math:`L_{0,c}` and :math:`L_0` at :math:`k/n`, with +the external load and seabed coefficients rebuilt at them, and the last on the new ones bit for +bit. Each sub-step treats its start and end lengths as the step above treats :math:`L_{0,c}` and +:math:`L_0`, so the first starts at :math:`L_{0,c}`, and the trigger takes the step-start +tensions at :math:`L_{0,c}`. A constant command rate makes the interpolated lengths those the +rate integrates to: on a line turning by 2.3° per step whose end segment is paid out at +0.05 m/s, every step solved in four sub-steps, the march equals one taken as given at a quarter +of the step to 3e-8 N, where applying the whole change in the first sub-step departs from it by +22 N (2.2 times the tension change per step). A step recovered after a stall and the halves of a +line-system step halved after a failure, which take their sub-steps as given, apply the whole +change in their first part. + +On a finite-EI cable, whose fairlead is End A, the command acts on the cable elements that make +up the End-A segment of the deck mesh, of initial length :math:`S`. Each element scales by +:math:`\lambda = (S + \Delta L)/S`, :math:`L_{0,e} = \lambda L_{0,e,\text{base}}`, with rate +:math:`\dot L_{0,e} = \Delta\dot L\, L_{0,e,\text{base}}/S`. The length is applied before a +step and held over it. The +consistent mass, the attachment masses, the tributary lengths and the nodal seabed coefficients +are rebuilt from the new lengths in the order initialisation used, so the model is the one a +build with those lengths would give; the mass of the new lengths acts over the step and its rate +term :math:`\dot{\mathbf{M}}\mathbf{v}` is not modelled (as in MoorDyn), and the committed +acceleration is kept as the history of the preceding step. The committed state keeps the lengths +and rates it was reached with: in the force-blended residual the committed force +:math:`\mathbf{F}_n = \mathbf{R}(\mathbf{q}_n, \mathbf{v}_n, t_n)` is the force at those +lengths, and only :math:`\mathbf{R}(\mathbf{q}_{n+1}, \mathbf{v}_{n+1}, t_{n+1})` takes the new +ones; an acceleration re-derived between the command and the step (a boundary commit) is solved +at those lengths too, since it belongs to the committed state. The configuration-blended form +(``False alpha_force_blend``) has no such treatment and is refused for a controlled cable. Evaluating :math:`\mathbf{F}_n` at the new lengths would add the force of the length change +to the committed state, which the blend weighs by :math:`\alpha_f`; on a pay-out ramp the +tension would then lag the quasi-static value by a fixed fraction of its change per step. A step +that follows a change starts its Newton iteration from the Newmark predictor, not from the +constant-acceleration one, since the change is a step in the load. The axial damping acts on +the rate of the strain :math:`\varepsilon = |\mathbf{r}_{,\xi}|/L_0 - 1` along the motion and +the length change. The tangent terms of :math:`\mathbf{r}_{,\xi}` carry the +factor :math:`L_0` and cancel, so with :math:`\mathbf{p} = H'_1 \mathbf{r}_1 + H'_3 \mathbf{r}_2` +the end-position part, + +.. math:: + + \dot\varepsilon = \frac{\mathbf{t}\cdot\left(\mathbf{v}_{,\xi} + - (\dot L_0/L_0)\,\mathbf{p}\right)}{L_0}, + +and a segment paid out at constant strain carries no damping force. The position Jacobian of the +damping force gains :math:`-BA\, H'_a H'_b\, (\dot L_0/L_0^2)\, \mathbf{t}\mathbf{t}^\mathsf{T}` on +the end-position columns. Tension and coupled loads ------------------------- diff --git a/doc/troubleshooting.rst b/doc/troubleshooting.rst index bbe679ab..b7e0c42b 100644 --- a/doc/troubleshooting.rst +++ b/doc/troubleshooting.rst @@ -402,10 +402,25 @@ FAILURE and CONTROL sections bodies and their lines only; model a clump or buoy on the line as part of a body. * - ``this entry point does not support the CONTROL section`` - the standalone driver does not consume CONTROL. Line control is an OpenFAST - ``CompMooring = 5`` feature for ``EI = 0`` decks; remove the section for a standalone run. + ``CompMooring = 5`` feature; remove the section for a standalone run. * - ``CONTROL row has trailing content`` / ``line L is assigned to more than one CONTROL channel`` - write ``ChannelID Lines`` with a comma list without spaces, and assign each line once. + * - ``control channel C commands DeltaL = ... m on EI = 0 line L, outside MoorDyn-F's + bounds -S/2 <= DeltaL <= S (S = UnstrLen/N = ... m)`` (or ``on finite-EI line L``) + - the command lengthens the line's fairlead-side segment by more than ``UnstrLen``/N (the + line's unstretched length over its number of segments) or shortens it by more than half + of that, where MoorDyn-F also stops. Keep ``CableDeltaL`` within the bounds, or mesh the + line with fewer, longer segments so the command is a smaller fraction of one. + * - ``control channel C commands DeltaL = ... m on ... line L, which would make its controlled + segment (... m long) non-positive`` + - on a line of several sections the controlled segment is shorter than half of + ``UnstrLen``/N, so a haul-in within MoorDyn-F's bounds would consume it. Keep the + haul-in shorter than the segment, or make the fairlead-side section's segments longer. + * - ``CONTROL line L: active line control of a finite-EI line needs the force-blended + generalised-alpha (OPTION alpha_force_blend True)`` + - the configuration blend has no committed-length treatment, so a ramp would lag; remove + ``False alpha_force_blend`` from a deck that controls a finite-EI cable. .. _non-convergence: @@ -682,9 +697,10 @@ aborts with a CableDyn fatal error, check whether the deck uses one of these com * - Not supported on the coupled route - Use instead - * - active ServoDyn control (``CONTROL``) on a deck with a **finite-EI** cable, or in FAST.Farm - - ``EI = 0`` line control **is** supported in a single-turbine model; for a controlled cable, - use stock MoorDyn (``CompMooring = 3``) in the same binary + * - active ServoDyn control (``CONTROL``) in FAST.Farm + - line control of ``EI = 0`` lines and finite-EI cables **is** supported in a single-turbine + model; for controlled lines in a farm, use stock MoorDyn (``CompMooring = 3``) in the same + binary * - deck ``waves``/``wavetrain`` OPTIONS, and a deck ``current`` on a deck with finite-EI cables, Rigid6 bodies or rods, in FAST.Farm, or with a SeaState that carries waves or current diff --git a/python/tests/test_deck_file.py b/python/tests/test_deck_file.py index c8c783b6..62a65f6c 100644 --- a/python/tests/test_deck_file.py +++ b/python/tests/test_deck_file.py @@ -3437,6 +3437,19 @@ def test_control_rows_fail_closed(rows, message): DeckFile.from_text(_with_section(_STATIC, "CONTROL", "Channel Lines", *rows)) +def test_control_rows_may_name_finite_ei_cables_on_the_coupled_route(): + # native CD_Init_Deck_Aggregate controls the fairlead-side segment of a finite-EI cable + # too, alone or on one channel with EI = 0 lines (line 4 is the mixed deck's cable) + marker = "--------------------------- OPTIONS" + block = ( + "--------------------------- CONTROL -------------------------------------------\n" + "ChannelID Lines\n(-) (-)\n1 4\n2 1,3\n" + ) + text = (ROOT / "examples/iea15mw_umaine_mixed_cabledyn.dat").read_text(encoding="utf-8") + deck = DeckFile.from_text(text.replace(marker, block + marker, 1), caller_driven=True) + assert [row.tokens for row in deck._rows("CONTROL")] == [("1", "4"), ("2", "1,3")] + + # --------------------------------------------------------------------------- # Editing API error contract # --------------------------------------------------------------------------- diff --git a/src/CableDyn_DeckDriver.f90 b/src/CableDyn_DeckDriver.f90 index 497f5ffd..ed9ed449 100644 --- a/src/CableDyn_DeckDriver.f90 +++ b/src/CableDyn_DeckDriver.f90 @@ -103,6 +103,7 @@ MODULE CableDyn_DeckDriver CD_HermiteCable_Dyn_Set_ForceBlend, CD_HC_FORCE_BLEND_DEFAULT, & CD_HermiteCable_Dyn_Set_Friction_Anchors, & CD_HermiteCable_Dyn_Set_Friction_Axial, & + CD_HermiteCable_Dyn_Set_Control_Seabed, & CD_HermiteCable_Dyn_Max_Step_Rotation, CD_HermiteCable_Dyn_Energy, & CD_HermiteCable_Attachment_Drag, CD_HermiteCable_Dyn_Torsion_State USE CableDyn_HermiteTorsion, ONLY: CD_HermiteTorsionType, CD_HermiteTorsion_Compliance, CD_HTORS_MAX_STEP, & @@ -247,6 +248,8 @@ MODULE CableDyn_DeckDriver 'route, which supports torsion); set TorsStiffness Free in every END CONNECTIONS row' CHARACTER(*), PARAMETER :: TORSION_NEEDS_FORCE_BLEND = 'torsion in a dynamic run needs the force-blended '// & 'generalised-alpha (OPTION alpha_force_blend True)' + CHARACTER(*), PARAMETER :: CONTROL_NEEDS_FORCE_BLEND = 'active line control of a finite-EI line needs the '// & + 'force-blended generalised-alpha (OPTION alpha_force_blend True)' REAL(wp), PARAMETER :: QUARTER_PI = 0.785398163397448309616_wp ! pi/4 (displaced-area factor) ! rhoInf above which a dynamic run notes the missing numerical dissipation (run_deck_driver) REAL(wp), PARAMETER :: RHO_INF_NOTE = 0.95_wp @@ -436,6 +439,10 @@ MODULE CableDyn_DeckDriver REAL(wp) :: tors_nx(3, 2) = CD_ZERO REAL(wp) :: tors_pretwist(2) = CD_ZERO INTEGER :: deck_line = 0 ! deck file line of the row, for error messages + ! True when the anchor-first swap (normalize_stock_endpoint_order) exchanged the two ends: + ! the deck's written NodeB (MoorDyn's AttachB) is then End A, otherwise End B. Active line + ! control reads it for a line with no single host-driven end. + LOGICAL :: ends_swapped = .FALSE. ! ATTACHMENTS (finite-EI lines): one column per discrete attachment -- arc length from ! End A [m], mass [kg], displaced volume [m^3], drag area CdA [m^2], added-mass Ca [-], ! axial drag area CdAx [m^2] (rows 1-6). @@ -469,8 +476,9 @@ MODULE CableDyn_DeckDriver TYPE :: DeckControl !! One CONTROL row (MoorDyn cable control): ChannelID LineID[,LineID...]. - !! The host's DeltaL/DeltaLdot input for this channel modulates the LAST - !! (fairlead-side) segment's unstretched length of every listed line. + !! The host's DeltaL/DeltaLdot input for this channel modulates the unstretched length of + !! the fairlead-side segment of every listed line: the one at its end on a host-driven + !! point, or, when both or neither ends are, at the written NodeB (MoorDyn's AttachB). INTEGER :: channel = 0 INTEGER, ALLOCATABLE :: line_ids(:) END TYPE @@ -1013,13 +1021,31 @@ MODULE CableDyn_DeckDriver TYPE(DeckLine), ALLOCATABLE :: fail_lines(:) TYPE(DeckPoint), ALLOCATABLE :: fail_points(:) ! Active line control (CONTROL section), flattened per controlled line: the - ! host channel, the system line index, the LAST (fairlead-side) element, and - ! its base unstretched length -- l(N) = base + DeltaL(chan) each advance. + ! host channel and the deck line id. The controlled segment is the deck segment at + ! the line's fairlead-side end: the end on a host-driven point (Coupled, Vessel, + ! Turbine, Body, a Coupled/Vessel rod end), or, when both or neither ends are, + ! the written NodeB (MoorDyn's AttachB, its segment N); on a finite-EI line that is its + ! host-driven End A. + ! An EI = 0 row (ctrl_is_cable false) holds the system line index, that element and + ! its base unstretched length -- l = base + DeltaL(chan) each advance. A finite-EI row + ! holds the cable index, the first of the ctrl_nelem cable elements that make up that + ! segment, and the segment's base length S; their base lengths sit at + ! ctrl_span_l0(ctrl_span_off + 1:) and each scales by (S + DeltaL)/S. + ! ctrl_unstr_len and ctrl_nsegs are the deck line's unstretched length and segment + ! count (summed over its sections), MoorDyn-F's UnstrLen and N: its command bounds + ! -0.5 UnstrLen/N <= DeltaL <= UnstrLen/N. INTEGER :: n_ctrl_chans = 0 INTEGER, ALLOCATABLE :: ctrl_chan(:) INTEGER, ALLOCATABLE :: ctrl_line(:) INTEGER, ALLOCATABLE :: ctrl_elem(:) + INTEGER, ALLOCATABLE :: ctrl_nelem(:) REAL(wp), ALLOCATABLE :: ctrl_base_l0(:) + REAL(wp), ALLOCATABLE :: ctrl_unstr_len(:) + INTEGER, ALLOCATABLE :: ctrl_nsegs(:) + LOGICAL, ALLOCATABLE :: ctrl_is_cable(:) + INTEGER, ALLOCATABLE :: ctrl_line_id(:) + INTEGER, ALLOCATABLE :: ctrl_span_off(:) + REAL(wp), ALLOCATABLE :: ctrl_span_l0(:) ! Coupled Rigid6 bodies (pure EI=0 deck): the opaque runtime the facade marches over ! `sys` each mooring step. Populated only when the deck declares Rigid6 BODYs ! (has_rigid6); the facade MOVEs it onto its persistent module state. @@ -2928,6 +2954,12 @@ RECURSIVE SUBROUTINE build_one_hermite_cable(ln, sections, types, points, opts, IF (es /= CD_HFMF_OK) THEN CALL fail(ErrStat, ErrMsg, 'finite-EI Hermite contact wiring failed: '//TRIM(em)); RETURN END IF + ! The same kBot, diameters and cBot/kBot let active line control rebuild the nodal + ! coefficients when an unstretched length changes (the EI = 0 seabed recompute inputs). + CALL CD_HermiteCable_Dyn_Set_Control_Seabed(cable%line, opts%kbot, diam, opts%cbot/opts%kbot, es, em) + IF (es /= CD_HCDYN_OK) THEN + CALL fail(ErrStat, ErrMsg, 'finite-EI Hermite seabed recompute wiring failed: '//TRIM(em)); RETURN + END IF ! The static friction force of every node becomes the initial force of its ! elastic-plastic spring, so the march starts in the static equilibrium. IF (static_friction) THEN @@ -6040,7 +6072,7 @@ SUBROUTINE CD_Init_Deck_Aggregate(deck_path, dt, agg, ErrStat, ErrMsg, env_gravi TYPE(DeckFailure), ALLOCATABLE :: fails(:) TYPE(DeckControl), ALLOCATABLE :: ctrls(:) LOGICAL, ALLOCATABLE :: is_fin(:) - INTEGER :: i, c, n_fin, n_ei0, cn, es, j, k, nctrl_lines, ne_line + INTEGER :: i, c, n_fin, n_ei0, cn, es, j INTEGER :: n_rigid6, n_point3, n_rod, n_host_rod, n_host_body REAL(wp) :: fairlead_dcm(3, 3), host_dcm(3, 3) ! Preserve the complete multi-hierarchy finite-EI initialization diagnostic. @@ -6450,17 +6482,13 @@ SUBROUTINE CD_Init_Deck_Aggregate(deck_path, dt, agg, ErrStat, ErrMsg, env_gravi END IF END IF - ! CONTROL scope in the coupled aggregate: pure EI=0, non-farm decks (the - ! system wrapper drives the segment update; finite-EI cable control and farm - ! mode are not supported). + ! CONTROL scope in the coupled aggregate: non-farm decks. The system wrapper + ! drives the EI = 0 segment update and each finite-EI cable takes its own + ! (CD_HFMF_Set_SegmentLength); farm mode is not supported for either. IF (SIZE(ctrls) > 0) THEN IF (nturb > 0) THEN CALL fail(ErrStat, ErrMsg, 'CD_Init_Deck_Aggregate: CONTROL on a FAST.Farm deck is not supported'); RETURN END IF - IF (n_fin > 0) THEN - CALL fail(ErrStat, ErrMsg, 'CD_Init_Deck_Aggregate: CONTROL on a deck with finite-EI cables is '// & - 'not supported'); RETURN - END IF END IF ! FAILURE scope in the coupled aggregate: pure EI=0, non-farm, frictionless @@ -6569,65 +6597,6 @@ SUBROUTINE CD_Init_Deck_Aggregate(deck_path, dt, agg, ErrStat, ErrMsg, env_gravi agg%fail_lines = lines agg%fail_points = points END IF - ! CONTROL runtime table: flatten channel -> (system line, last element, base - ! length). The scope above guarantees a pure EI=0 deck, so deck line ids - ! resolve to system line indices by array position. - IF (SIZE(ctrls) > 0) THEN - nctrl_lines = 0 - DO i = 1, SIZE(ctrls) - nctrl_lines = nctrl_lines + SIZE(ctrls(i)%line_ids) - agg%n_ctrl_chans = MAX(agg%n_ctrl_chans, ctrls(i)%channel) - END DO - ALLOCATE (agg%ctrl_chan(nctrl_lines), agg%ctrl_line(nctrl_lines), agg%ctrl_elem(nctrl_lines), & - agg%ctrl_base_l0(nctrl_lines)) - c = 0 - DO i = 1, SIZE(ctrls) - DO k = 1, SIZE(ctrls(i)%line_ids) - c = c + 1 - agg%ctrl_chan(c) = ctrls(i)%channel - agg%ctrl_line(c) = 0 - DO j = 1, SIZE(lines) - IF (lines(j)%id == ctrls(i)%line_ids(k)) agg%ctrl_line(c) = j - END DO - IF (agg%ctrl_line(c) < 1) THEN - CALL fail(ErrStat, ErrMsg, 'CONTROL references a line the aggregate did not initialize') - CALL CD_End_Deck_Aggregate(agg); RETURN - END IF - ! Fairlead element + base length from the BUILT model, never re-derived - ! from the deck sections: the mesh builder reverses element order for - ! anchor_is_end_b lines, so on a composite line a sections-scan picks the - ! ANCHOR-side segment and a zero command would rewrite the fairlead - ! segment to the wrong length. The built l0 is the single truth. - ne_line = SIZE(agg%sys%lines(agg%ctrl_line(c))%l0) - IF (ne_line < 1) THEN - CALL fail(ErrStat, ErrMsg, 'CONTROL line has no elements') - CALL CD_End_Deck_Aggregate(agg); RETURN - END IF - agg%ctrl_elem(c) = ne_line - agg%ctrl_base_l0(c) = agg%sys%lines(agg%ctrl_line(c))%l0(ne_line) - ! Update capability is an INIT-time property: verify it here so the apply - ! loop can never fail for input reasons after its prevalidation (a mid-loop - ! failure would leave mixed lengths). The deck path always supplies the - ! seabed recompute inputs; this protects any future builder that does not. - IF (agg%sys%lines(agg%ctrl_line(c))%has_seabed .AND. & - .NOT. agg%sys%lines(agg%ctrl_line(c))%has_seabed_recompute) THEN - CALL fail(ErrStat, ErrMsg, 'CONTROL line was built without the seabed recompute inputs') - CALL CD_End_Deck_Aggregate(agg); RETURN - END IF - IF (agg%sys%lines(agg%ctrl_line(c))%has_viscoelastic) THEN - IF (agg%sys%lines(agg%ctrl_line(c))%ve_mode(ne_line) /= 0) THEN - ! same INIT-time rule: the runtime length update fails closed on a - ! viscoelastic element (the dl_1 state has no rescaling law), so a - ! deck composing CONTROL with a viscoelastic fairlead segment must - ! not start at all - CALL fail(ErrStat, ErrMsg, 'CONTROL targets a viscoelastic (ElasticMod 2) fairlead '// & - 'segment; active line control is not supported on the viscoelastic model') - CALL CD_End_Deck_Aggregate(agg); RETURN - END IF - END IF - END DO - END DO - END IF ! Build one coupled Hermite cable per finite-EI line (the production bending path). Each ! cable owns its own static-seeded dynamic model and its coupled fairlead node. @@ -6676,6 +6645,15 @@ SUBROUTINE CD_Init_Deck_Aggregate(deck_path, dt, agg, ErrStat, ErrMsg, env_gravi IF (opts%has_bathymetry_file) CALL CD_End_Bathymetry(bathymetry) END IF + ! CONTROL runtime table, from the built system lines and cables. + IF (SIZE(ctrls) > 0) THEN + CALL build_aggregate_control_table(ctrls, lines, points, rods, sections, types, is_fin, agg, & + ErrStat, ErrMsg) + IF (ErrStat /= CD_DECKDRV_OK) THEN + CALL CD_End_Deck_Aggregate(agg); RETURN + END IF + END IF + ! Retain the deck OUTPUTS channels and always build the deck-line-id -> object map. The ! map is also the authoritative line inventory for the coupled static profile, which is ! written even when the deck intentionally declares no time-history OUTPUTS channels. @@ -6748,6 +6726,213 @@ SUBROUTINE CD_Init_Deck_Aggregate(deck_path, dt, agg, ErrStat, ErrMsg, env_gravi END BLOCK END SUBROUTINE CD_Init_Deck_Aggregate + SUBROUTINE build_aggregate_control_table(ctrls, lines, points, rods, sections, types, is_fin, agg, ErrStat, ErrMsg) + !! CONTROL runtime table of the coupled aggregate: one row per controlled line, read + !! from the BUILT models, never re-derived from the deck sections (both mesh builders + !! reverse the deck's End A -> End B order). A deck line resolves to its object by its + !! rank among the lines of its kind in deck order -- the order in which the EI = 0 + !! system and the cables are built (build_line_object_map) -- so a deck mixing both + !! kinds addresses the right object. + !! The controlled segment is the one at the line's fairlead-side end: the end on a + !! host-driven point (Coupled, Vessel, Turbine, Body, or an end of a Coupled or + !! Vessel rod). When both ends or neither end are host-driven, it is the segment at + !! the NodeB the deck wrote (MoorDyn's AttachB, its segment N). The built models run + !! End B (node 1) -> End A (last node); the written NodeB is End A when the + !! anchor-first swap exchanged the ends and End B otherwise. + !! EI = 0 row: that end element of the system line and its base length. + !! Finite-EI row: the cable elements that make up the deck segment at that end, with + !! their base length S. The coupled cable builder runs a finite-EI line from its Fixed + !! anchor at End B to its Coupled/Vessel fairlead at End A, so the rule gives End A; a + !! finite-EI line whose End A is not its only host-driven end fails closed by name. + !! When the static solve refined the deck mesh, the span is the elements whose + !! reference-arc midpoint lies in that segment (the rule the property remap uses). + !! Each row also keeps the deck line's unstretched length and segment count (MoorDyn-F's + !! UnstrLen and N, summed over the line's sections), from which the apply takes + !! MoorDyn-F's command bounds. Every capability check runs here (a finite-EI line also + !! needs the force-blended generalised-alpha), so the apply loop cannot fail for input + !! reasons after its prevalidation. + TYPE(DeckControl), INTENT(IN) :: ctrls(:) + TYPE(DeckLine), INTENT(IN) :: lines(:) + TYPE(DeckPoint), INTENT(IN) :: points(:) + TYPE(DeckRod), INTENT(IN) :: rods(:) + TYPE(DeckSection), INTENT(IN) :: sections(:) + TYPE(DeckLineType), INTENT(IN) :: types(:) + LOGICAL, INTENT(IN) :: is_fin(:) + TYPE(CD_DeckAggregateType), INTENT(INOUT) :: agg + INTEGER, INTENT(OUT) :: ErrStat + CHARACTER(*), INTENT(OUT) :: ErrMsg + + INTEGER :: i, j, k, c, nrow, jline, obj, ne_line, first, e, es, parent_end + LOGICAL :: host_a, host_b + INTEGER, ALLOCATABLE :: conn(:, :), parent(:) + REAL(wp), ALLOCATABLE :: l0_deck(:), ea(:), mpl(:), diam(:), ei(:), gas(:), gj(:), i_rt(:), i_rn(:) + REAL(wp) :: span + CHARACTER(24) :: lid + CHARACTER(512) :: em + + ErrStat = CD_DECKDRV_OK + ErrMsg = '' + nrow = 0 + DO i = 1, SIZE(ctrls) + nrow = nrow + SIZE(ctrls(i)%line_ids) + agg%n_ctrl_chans = MAX(agg%n_ctrl_chans, ctrls(i)%channel) + END DO + ALLOCATE (agg%ctrl_chan(nrow), agg%ctrl_line(nrow), agg%ctrl_elem(nrow), agg%ctrl_nelem(nrow), & + agg%ctrl_base_l0(nrow), agg%ctrl_is_cable(nrow), agg%ctrl_line_id(nrow), agg%ctrl_span_off(nrow), & + agg%ctrl_span_l0(0), agg%ctrl_unstr_len(nrow), agg%ctrl_nsegs(nrow)) + c = 0 + DO i = 1, SIZE(ctrls) + DO k = 1, SIZE(ctrls(i)%line_ids) + c = c + 1 + agg%ctrl_chan(c) = ctrls(i)%channel + jline = 0 + DO j = 1, SIZE(lines) + IF (lines(j)%id == ctrls(i)%line_ids(k)) jline = j + END DO + IF (jline < 1) THEN + CALL fail(ErrStat, ErrMsg, 'CONTROL references a line the aggregate did not initialize'); RETURN + END IF + lid = int_to_str(lines(jline)%id) + obj = COUNT(is_fin(1:jline) .EQV. is_fin(jline)) + agg%ctrl_line(c) = obj + agg%ctrl_line_id(c) = lines(jline)%id + agg%ctrl_is_cable(c) = is_fin(jline) + agg%ctrl_span_off(c) = SIZE(agg%ctrl_span_l0) + agg%ctrl_nelem(c) = 1 + ! MoorDyn-F's UnstrLen and N of the line (the bounds of its command) + agg%ctrl_unstr_len(c) = CD_ZERO + agg%ctrl_nsegs(c) = 0 + DO j = 1, SIZE(sections) + IF (sections(j)%line_id /= lines(jline)%id) CYCLE + agg%ctrl_unstr_len(c) = agg%ctrl_unstr_len(c) + sections(j)%length + agg%ctrl_nsegs(c) = agg%ctrl_nsegs(c) + sections(j)%nsegs + END DO + IF (.NOT. (agg%ctrl_nsegs(c) > 0 .AND. agg%ctrl_unstr_len(c) > CD_ZERO)) THEN + CALL fail(ErrStat, ErrMsg, 'CONTROL line '//TRIM(lid)//' has no unstretched length and segment count'); RETURN + END IF + ! the fairlead-side end: the host-driven one, else the written NodeB + host_a = host_driven_point(lines(jline)%nodeA) + host_b = host_driven_point(lines(jline)%nodeB) + IF (.NOT. is_fin(jline)) THEN + IF (.NOT. agg%has_sys) THEN + CALL fail(ErrStat, ErrMsg, 'CONTROL line '//TRIM(lid)//' has no EI = 0 system line'); RETURN + END IF + IF (obj > SIZE(agg%sys%lines)) THEN + CALL fail(ErrStat, ErrMsg, 'CONTROL line '//TRIM(lid)//' has no EI = 0 system line'); RETURN + END IF + ne_line = SIZE(agg%sys%lines(obj)%l0) + IF (ne_line < 1) THEN + CALL fail(ErrStat, ErrMsg, 'CONTROL line has no elements'); RETURN + END IF + ! the fairlead-side element (End A is the last element, End B the first) + IF (host_a .NEQV. host_b) THEN + e = MERGE(ne_line, 1, host_a) + ELSE + e = MERGE(ne_line, 1, lines(jline)%ends_swapped) + END IF + agg%ctrl_elem(c) = e + agg%ctrl_base_l0(c) = agg%sys%lines(obj)%l0(e) + ! The deck path always supplies the seabed recompute inputs; this protects any + ! future builder that does not. + IF (agg%sys%lines(obj)%has_seabed .AND. .NOT. agg%sys%lines(obj)%has_seabed_recompute) THEN + CALL fail(ErrStat, ErrMsg, 'CONTROL line was built without the seabed recompute inputs'); RETURN + END IF + IF (agg%sys%lines(obj)%has_viscoelastic) THEN + IF (agg%sys%lines(obj)%ve_mode(e) /= 0) THEN + ! the runtime length update fails closed on a viscoelastic element (the + ! dl_1 state has no rescaling law), so a deck composing CONTROL with a + ! viscoelastic controlled segment must not start at all + CALL fail(ErrStat, ErrMsg, 'CONTROL targets a viscoelastic (ElasticMod 2) '// & + 'segment; active line control is not supported on the viscoelastic model'); RETURN + END IF + END IF + IF (agg%sys%lines(obj)%has_syrope) THEN + IF (agg%sys%lines(obj)%syrope_is(e)) THEN + ! the same rule for the Syrope working-curve states + CALL fail(ErrStat, ErrMsg, 'CONTROL line '//TRIM(lid)//' targets a Syrope segment; active '// & + 'line control is not supported on the Syrope model'); RETURN + END IF + END IF + ELSE + ! the coupled cable builder makes End A the host-driven fairlead and End B the + ! Fixed anchor; any other arrangement would control a segment that is not the + ! fairlead-side one, so it fails closed + IF (.NOT. (host_a .AND. .NOT. host_b)) THEN + CALL fail(ErrStat, ErrMsg, 'CONTROL line '//TRIM(lid)//': active line control of a finite-EI '// & + 'line needs its End A, the fairlead, to be its only host-driven end'); RETURN + END IF + IF (.NOT. ALLOCATED(agg%cables)) THEN + CALL fail(ErrStat, ErrMsg, 'CONTROL line '//TRIM(lid)//' has no finite-EI cable'); RETURN + END IF + IF (obj > SIZE(agg%cables)) THEN + CALL fail(ErrStat, ErrMsg, 'CONTROL line '//TRIM(lid)//' has no finite-EI cable'); RETURN + END IF + ASSOCIATE (cab => agg%cables(obj)%line) + IF (cab%torsion%active) THEN + CALL fail(ErrStat, ErrMsg, 'CONTROL line '//TRIM(lid)//': active line control of a finite-EI '// & + 'line restrained in torsion is not supported'); RETURN + END IF + IF (cab%has_contact .AND. .NOT. cab%has_seabed_recompute) THEN + CALL fail(ErrStat, ErrMsg, 'CONTROL line '//TRIM(lid)//' was built without the seabed '// & + 'recompute inputs'); RETURN + END IF + IF (.NOT. cab%force_blend) THEN + CALL fail(ErrStat, ErrMsg, 'CONTROL line '//TRIM(lid)//': '//CONTROL_NEEDS_FORCE_BLEND); RETURN + END IF + CALL build_finite_section_mesh(lines(jline), sections, types, conn, l0_deck, ea, mpl, diam, ei, & + gas, gj, i_rt, i_rn, es, em) + IF (es /= CD_DECKDRV_OK) THEN + CALL fail(ErrStat, ErrMsg, 'CONTROL line '//TRIM(lid)//': '//TRIM(em)); RETURN + END IF + CALL reference_arc_parents(l0_deck, cab%l0, parent) + ! the deck's End A segment (deck element SIZE(l0_deck)): the trailing span of + ! cable elements whose parent it is + parent_end = SIZE(l0_deck) + first = cab%ne + 1 + DO e = cab%ne, 1, -1 + IF (parent(e) /= parent_end) EXIT + first = e + END DO + span = CD_ZERO + DO e = first, cab%ne + span = span + cab%l0(e) + END DO + IF (first > cab%ne .OR. & + ABS(span - l0_deck(parent_end)) > 1.0e-9_wp*MAX(CD_ONE, l0_deck(parent_end))) THEN + CALL fail(ErrStat, ErrMsg, 'CONTROL line '//TRIM(lid)//': the controlled segment is not '// & + 'made up of whole cable elements'); RETURN + END IF + agg%ctrl_elem(c) = first + agg%ctrl_nelem(c) = cab%ne - first + 1 + agg%ctrl_base_l0(c) = span + agg%ctrl_span_l0 = [agg%ctrl_span_l0, cab%l0(first:cab%ne)] + END ASSOCIATE + END IF + END DO + END DO + + CONTAINS + + LOGICAL FUNCTION host_driven_point(id) RESULT(host) + !! True for a point the host drives: Coupled or Vessel (Turbine points are already + !! Coupled here), Body, or an end of a Coupled or Vessel rod. + INTEGER, INTENT(IN) :: id + INTEGER :: ip, ir, rod_id, end_id + host = .FALSE. + ip = find_point(points, id) + IF (ip < 1) RETURN + host = TRIM(points(ip)%ptype) == 'coupled' .OR. TRIM(points(ip)%ptype) == 'vessel' .OR. & + starts_with(TRIM(points(ip)%ptype), 'body') .OR. points(ip)%turbine_id > 0 + IF (host) RETURN + CALL parse_rod_point_type(points(ip)%ptype, rod_id, end_id) + IF (rod_id < 1 .OR. (end_id /= 1 .AND. end_id /= 2)) RETURN + DO ir = 1, SIZE(rods) + IF (rods(ir)%id == rod_id) host = TRIM(rods(ir)%rod_type) == 'coupled' .OR. & + TRIM(rods(ir)%rod_type) == 'vessel' + END DO + END FUNCTION host_driven_point + END SUBROUTINE build_aggregate_control_table + SUBROUTINE validate_aggregate_point_channels(channels, points, lines, is_fin, ErrStat, ErrMsg) CHARACTER(*), INTENT(IN) :: channels(:) TYPE(DeckPoint), INTENT(IN) :: points(:) @@ -7062,7 +7247,14 @@ SUBROUTINE CD_End_Deck_Aggregate(agg) IF (ALLOCATED(agg%ctrl_chan)) DEALLOCATE (agg%ctrl_chan) IF (ALLOCATED(agg%ctrl_line)) DEALLOCATE (agg%ctrl_line) IF (ALLOCATED(agg%ctrl_elem)) DEALLOCATE (agg%ctrl_elem) + IF (ALLOCATED(agg%ctrl_nelem)) DEALLOCATE (agg%ctrl_nelem) IF (ALLOCATED(agg%ctrl_base_l0)) DEALLOCATE (agg%ctrl_base_l0) + IF (ALLOCATED(agg%ctrl_unstr_len)) DEALLOCATE (agg%ctrl_unstr_len) + IF (ALLOCATED(agg%ctrl_nsegs)) DEALLOCATE (agg%ctrl_nsegs) + IF (ALLOCATED(agg%ctrl_is_cable)) DEALLOCATE (agg%ctrl_is_cable) + IF (ALLOCATED(agg%ctrl_line_id)) DEALLOCATE (agg%ctrl_line_id) + IF (ALLOCATED(agg%ctrl_span_off)) DEALLOCATE (agg%ctrl_span_off) + IF (ALLOCATED(agg%ctrl_span_l0)) DEALLOCATE (agg%ctrl_span_l0) ! Release the Rigid6 runtime and clear the flag: without this a REUSED bundle (or a ! failed re-init that routes through here) would keep a stale has_rigid6 = .TRUE. and the ! previous deck's body allocatables, so a later non-Rigid6 deck could march a stale body. @@ -8442,26 +8634,42 @@ SUBROUTINE remap_elem_by_reference_arc(a, l0_parent, l0_child) REAL(wp), ALLOCATABLE, INTENT(INOUT) :: a(:) REAL(wp), INTENT(IN) :: l0_parent(:), l0_child(:) REAL(wp), ALLOCATABLE :: b(:) - REAL(wp) :: s_mid, s_child, s_parent_end, tol_arc - INTEGER :: j, parent + INTEGER, ALLOCATABLE :: parent(:) IF (SIZE(l0_child) == SIZE(l0_parent)) RETURN - ALLOCATE (b(SIZE(l0_child))) - parent = 1 + CALL reference_arc_parents(l0_parent, l0_child, parent) + b = a(parent) + CALL MOVE_ALLOC(b, a) + END SUBROUTINE remap_elem_by_reference_arc + + SUBROUTINE reference_arc_parents(l0_parent, l0_child, parent) + !! The parent element of every child element of a nested child mesh: the parent whose + !! reference arc contains the child's midpoint (the rule of remap_elem_by_reference_arc). + !! Meshes of equal size map element to element. + REAL(wp), INTENT(IN) :: l0_parent(:), l0_child(:) + INTEGER, ALLOCATABLE, INTENT(OUT) :: parent(:) + REAL(wp) :: s_mid, s_child, s_parent_end, tol_arc + INTEGER :: j, p + + ALLOCATE (parent(SIZE(l0_child))) + IF (SIZE(l0_child) == SIZE(l0_parent)) THEN + parent = [(j, j=1, SIZE(l0_child))] + RETURN + END IF + p = 1 s_child = CD_ZERO s_parent_end = l0_parent(1) tol_arc = 64.0_wp*EPSILON(CD_ONE)*MAX(CD_ONE, SUM(l0_parent)) DO j = 1, SIZE(l0_child) s_mid = s_child + 0.5_wp*l0_child(j) - DO WHILE (parent < SIZE(l0_parent) .AND. s_mid > s_parent_end + tol_arc) - parent = parent + 1 - s_parent_end = s_parent_end + l0_parent(parent) + DO WHILE (p < SIZE(l0_parent) .AND. s_mid > s_parent_end + tol_arc) + p = p + 1 + s_parent_end = s_parent_end + l0_parent(p) END DO - b(j) = a(parent) + parent(j) = p s_child = s_child + l0_child(j) END DO - CALL MOVE_ALLOC(b, a) - END SUBROUTINE remap_elem_by_reference_arc + END SUBROUTINE reference_arc_parents SUBROUTINE deck_node_mesh_map(l0_deck, l0_mesh, map) !! The public node (End A = 1) of a finite-EI line's final mesh at each deck node, matched on @@ -13689,6 +13897,7 @@ SUBROUTINE normalize_stock_endpoint_order(points, lines, sections) tmp = lines(i)%nodeA lines(i)%nodeA = lines(i)%nodeB lines(i)%nodeB = tmp + lines(i)%ends_swapped = .TRUE. mode_tmp = lines(i)%endconn_mode(1) lines(i)%endconn_mode(1) = lines(i)%endconn_mode(2) lines(i)%endconn_mode(2) = mode_tmp @@ -32601,8 +32810,14 @@ REAL(wp) FUNCTION cable_axial_tension(cable, e, xi) RESULT(t) IF (cable%line%has_axial_damping) THEN vr(1:6) = cable%line%v(6*(e - 1) + 1:6*(e - 1) + 6) vr(7:12) = cable%line%v(6*e + 1:6*e + 6) - CALL CD_HermiteCable_Axial_Damping_Resultant(qr, vr, l0, cable%line%BA(e), xi, & - viscous, es, em) + IF (cable%line%has_ctrl) THEN + ! active line control: the strain rate includes the unstretched-length rate + CALL CD_HermiteCable_Axial_Damping_Resultant(qr, vr, l0, cable%line%BA(e), xi, & + viscous, es, em, l0_dot=cable%line%l0_dot(e)) + ELSE + CALL CD_HermiteCable_Axial_Damping_Resultant(qr, vr, l0, cable%line%BA(e), xi, & + viscous, es, em) + END IF IF (es /= 0) THEN t = CD_ZERO ELSE diff --git a/src/CableDyn_Dynamic.f90 b/src/CableDyn_Dynamic.f90 index 06274e55..03df8de5 100644 --- a/src/CableDyn_Dynamic.f90 +++ b/src/CableDyn_Dynamic.f90 @@ -627,7 +627,7 @@ SUBROUTINE CD_Cable_Gen_Alpha_Step(q, v, a, elem_conn, l0, ea, rho_a, tension_on load_band_proc, prescribed_q, prescribed_v, prescribed_a, structural_mass, & workspace, added_mass_band_proc, start_load, start_tension, & probe_q, probe_R, probe_K, start_stiffness, axial_damping, & - axial_l0_rate) + axial_l0_rate, start_l0, mass_l0, start_l0_rate) !! One generalized-alpha step: the constant load f_ext plus the optional load, !! banded-load, force-only and added-mass callbacks (hydrodynamics, damping, contact). !! On a singular effective tangent returns CD_DYN_SINGULAR; on a line-search @@ -708,6 +708,18 @@ SUBROUTINE CD_Cable_Gen_Alpha_Step(q, v, a, elem_conn, l0, ea, rho_a, tension_on !! are passed together; the state outputs are the t_n state, converged = .FALSE. REAL(wp), INTENT(IN), OPTIONAL :: probe_q(:) REAL(wp), INTENT(OUT), OPTIONAL :: probe_R(:), probe_K(:, :) + !! Unstretched lengths changed between t_n and t_{n+1} (active line control; n_elem each, + !! finite and positive). l0 is then the length at t_{n+1}, which r(q_{n+1}, v_{n+1}) and + !! the release cap's end stretch use. start_l0 (force blend only, ignored without it): the + !! lengths the step-start state was reached with, which the step-start internal force + !! r(q_n) and the release cap's step-start quantities use: e_n, T_n, W_n and the + !! step-start dashpot tension T_d,n (start_load, start_tension and start_stiffness must + !! then be those of these lengths). mass_l0: the lengths of the structural consistent mass + !! (ignored with structural_mass). Absent: l0. start_l0_rate (force blend with + !! axial_damping only): the unstretched-length rates the step-start state was reached + !! with, for T_d,n; axial_l0_rate stays the rate at t_{n+1}, for T_d,n+1. Absent: + !! axial_l0_rate. + REAL(wp), INTENT(IN), OPTIONAL :: start_l0(:), mass_l0(:), start_l0_rate(:) INTEGER :: n_dof, n_elem, n_free, bt, kl, ku, ldab INTEGER, POINTER :: free(:), fixed(:), ipiv(:) @@ -844,6 +856,36 @@ SUBROUTINE CD_Cable_Gen_Alpha_Step(q, v, a, elem_conn, l0, ea, rho_a, tension_on CALL check_config(cfg, ErrStat, ErrMsg) IF (ErrStat /= 0) RETURN n_elem = SIZE(elem_conn, 2) + IF (PRESENT(start_l0)) THEN + IF (SIZE(start_l0) /= n_elem) THEN + CALL fail(ErrStat, ErrMsg, 'start_l0 must have shape (n_elem)') + RETURN + END IF + IF (.NOT. CD_All_Finite(start_l0) .OR. ANY(start_l0 <= CD_ZERO)) THEN + CALL fail(ErrStat, ErrMsg, 'start_l0 must be finite and positive') + RETURN + END IF + END IF + IF (PRESENT(mass_l0)) THEN + IF (SIZE(mass_l0) /= n_elem) THEN + CALL fail(ErrStat, ErrMsg, 'mass_l0 must have shape (n_elem)') + RETURN + END IF + IF (.NOT. CD_All_Finite(mass_l0) .OR. ANY(mass_l0 <= CD_ZERO)) THEN + CALL fail(ErrStat, ErrMsg, 'mass_l0 must be finite and positive') + RETURN + END IF + END IF + IF (PRESENT(start_l0_rate)) THEN + IF (SIZE(start_l0_rate) /= n_elem) THEN + CALL fail(ErrStat, ErrMsg, 'start_l0_rate must have shape (n_elem)') + RETURN + END IF + IF (.NOT. CD_All_Finite(start_l0_rate)) THEN + CALL fail(ErrStat, ErrMsg, 'start_l0_rate must be finite') + RETURN + END IF + END IF IF (PRESENT(workspace)) THEN work => workspace ELSE @@ -907,7 +949,11 @@ SUBROUTINE CD_Cable_Gen_Alpha_Step(q, v, a, elem_conn, l0, ea, rho_a, tension_on END IF M = structural_mass ELSE IF (.NOT. use_element_mass_band) THEN - CALL CD_Assemble_Cable_Mass(elem_conn, l0, rho_a, M, es, em) + IF (PRESENT(mass_l0)) THEN + CALL CD_Assemble_Cable_Mass(elem_conn, mass_l0, rho_a, M, es, em) + ELSE + CALL CD_Assemble_Cable_Mass(elem_conn, l0, rho_a, M, es, em) + END IF IF (es /= 0) THEN CALL fail(ErrStat, ErrMsg, 'mass assembly failed: '//TRIM(em)) RETURN @@ -1050,16 +1096,26 @@ SUBROUTINE CD_Cable_Gen_Alpha_Step(q, v, a, elem_conn, l0, ea, rho_a, tension_on IF (use_element_mass_band) THEN ! The element mass band depends only on the connectivity, the free list, l0 and ! rho_a: a step with the inputs of the remembered band (bw_hit: same connectivity and - ! free list) reuses it, which is the band the assembly would build again. + ! free list) reuses it, which is the band the assembly would build again. Its lengths + ! are mass_l0 when present. mb_hit = .FALSE. - IF (bw_hit) mb_hit = mass_band_matches(work, l0, rho_a) - IF (.NOT. mb_hit) THEN - work%mb_valid = .FALSE. - CALL assemble_mass_band_free(elem_conn, l0, rho_a, work%dof_marker(1:n_dof), kl, ku, M_band, es, em) - IF (es == 0 .AND. work%bw_valid) CALL remember_mass_band(work, l0, rho_a) - ELSE IF (work%mb_hits < HUGE(work%mb_hits)) THEN - work%mb_hits = work%mb_hits + 1 + IF (PRESENT(mass_l0)) THEN + IF (bw_hit) mb_hit = mass_band_matches(work, mass_l0, rho_a) + IF (.NOT. mb_hit) THEN + work%mb_valid = .FALSE. + CALL assemble_mass_band_free(elem_conn, mass_l0, rho_a, work%dof_marker(1:n_dof), kl, ku, M_band, & + es, em) + IF (es == 0 .AND. work%bw_valid) CALL remember_mass_band(work, mass_l0, rho_a) + END IF + ELSE + IF (bw_hit) mb_hit = mass_band_matches(work, l0, rho_a) + IF (.NOT. mb_hit) THEN + work%mb_valid = .FALSE. + CALL assemble_mass_band_free(elem_conn, l0, rho_a, work%dof_marker(1:n_dof), kl, ku, M_band, es, em) + IF (es == 0 .AND. work%bw_valid) CALL remember_mass_band(work, l0, rho_a) + END IF END IF + IF (mb_hit .AND. work%mb_hits < HUGE(work%mb_hits)) work%mb_hits = work%mb_hits + 1 ELSE work%mb_valid = .FALSE. CALL pack_dense_free_band(M, free, kl, ku, CD_ONE, M_band, es, em) @@ -1508,14 +1564,21 @@ END SUBROUTINE end_junction_data SUBROUTINE start_forces(es_s, em_s) !! fint_n = f_int(q_n) and load_n = the dynamic load at (q_n, v_n): start_load when the - !! caller supplies it, else the force-only callback (or load_proc) evaluated there. + !! caller supplies it, else the force-only callback (or load_proc) evaluated there. The + !! internal force and the release-cap data take the lengths the step-start state was + !! reached with (start_l0 when present). INTEGER, INTENT(OUT) :: es_s CHARACTER(*), INTENT(OUT) :: em_s INTEGER :: i es_s = 0 em_s = '' - CALL CD_Assemble_Cable_Internal_Force(q_n_nodes, elem_conn, l0, ea, tension_only, fint_n, es_s, em_s, & - topology_validated=topo_ok) + IF (PRESENT(start_l0)) THEN + CALL CD_Assemble_Cable_Internal_Force(q_n_nodes, elem_conn, start_l0, ea, tension_only, fint_n, es_s, & + em_s, topology_validated=topo_ok) + ELSE + CALL CD_Assemble_Cable_Internal_Force(q_n_nodes, elem_conn, l0, ea, tension_only, fint_n, es_s, em_s, & + topology_validated=topo_ok) + END IF IF (es_s /= 0) THEN es_s = CD_DYN_BADINPUT em_s = 'step-start internal-force assembly failed: '//TRIM(em_s) @@ -1577,11 +1640,13 @@ SUBROUTINE start_forces(es_s, em_s) IF (release_cap) THEN DO i = 1, n_elem BLOCK - REAL(wp) :: d(3), ell + REAL(wp) :: d(3), ell, l0s d = q_n_nodes(:, elem_conn(2, i)) - q_n_nodes(:, elem_conn(1, i)) ell = NORM2(d) + l0s = l0(i) + IF (PRESENT(start_l0)) l0s = start_l0(i) chord_n(:, i) = d/ell - stretch_n(i) = ell - l0(i) + stretch_n(i) = ell - l0s tension_n(i) = CD_ZERO stiff_n(i) = HUGE(CD_ONE) dcoef_n(i) = CD_ZERO @@ -1589,16 +1654,34 @@ SUBROUTINE start_forces(es_s, em_s) damp_n(i) = CD_ZERO IF (ea(i) > CD_ZERO .AND. PRESENT(axial_damping)) THEN IF (axial_damping(i) > CD_ZERO) THEN - ! the dashpot tension the start load carries, as the callback evaluates it + ! the dashpot coefficient and payout rate of the end share (lengths at t_{n+1}) dcoef_n(i) = axial_damping(i)/l0(i) IF (PRESENT(axial_l0_rate)) rl0dot_n(i) = axial_l0_rate(i)/l0(i) - damp_n(i) = dcoef_n(i)*(DOT_PRODUCT(chord_n(:, i), v_n(3*elem_conn(2, i) - 2:3*elem_conn(2, i)) - & - v_n(3*elem_conn(1, i) - 2:3*elem_conn(1, i))) - ell*rl0dot_n(i)) + IF (PRESENT(start_l0) .OR. PRESENT(start_l0_rate)) THEN + ! after a length change the start load's dashpot has the step-start lengths + ! and rates + BLOCK + REAL(wp) :: dcs, rrs + dcs = axial_damping(i)/l0s + rrs = CD_ZERO + IF (PRESENT(start_l0_rate)) THEN + rrs = start_l0_rate(i)/l0s + ELSE IF (PRESENT(axial_l0_rate)) THEN + rrs = axial_l0_rate(i)/l0s + END IF + damp_n(i) = dcs*(DOT_PRODUCT(chord_n(:, i), v_n(3*elem_conn(2, i) - 2:3*elem_conn(2, i)) - & + v_n(3*elem_conn(1, i) - 2:3*elem_conn(1, i))) - ell*rrs) + END BLOCK + ELSE + ! the dashpot tension the start load carries, as the callback evaluates it + damp_n(i) = dcoef_n(i)*(DOT_PRODUCT(chord_n(:, i), v_n(3*elem_conn(2, i) - 2:3*elem_conn(2, i)) - & + v_n(3*elem_conn(1, i) - 2:3*elem_conn(1, i))) - ell*rl0dot_n(i)) + END IF END IF END IF IF (stretch_n(i) > CD_ZERO) THEN IF (ea(i) > CD_ZERO) THEN - tension_n(i) = ea(i)*(ell/l0(i) - CD_ONE) + tension_n(i) = ea(i)*(ell/l0s - CD_ONE) ELSE IF (PRESENT(start_tension)) THEN tension_n(i) = MAX(start_tension(i), CD_ZERO) IF (PRESENT(start_stiffness)) stiff_n(i) = start_stiffness(i) @@ -2026,13 +2109,13 @@ SUBROUTINE eval_dynamic(q_eval, Rout, es_e, em_e, effout, effbandout) ! (= structural_mass when supplied). Recomputing from elem_conn/l0/rho_a here ! would ignore a supplied structural_mass while the Jacobian honored it. IF (use_element_mass_band) THEN - CALL consistent_mass_matvec(elem_conn, l0, rho_a, a_alpha, Rout) + CALL structural_inertia(Rout) ELSE Rout = MATMUL(M, a_alpha) END IF Rout = Rout + M_add_a_eval + fint_eval - f_ext - load_eval ELSE IF (use_element_mass_band) THEN - CALL consistent_mass_matvec(elem_conn, l0, rho_a, a_alpha, Rout) + CALL structural_inertia(Rout) Rout = Rout + fint_eval - f_ext - load_eval ELSE Rout = MATMUL(M, a_alpha) + fint_eval - f_ext - load_eval @@ -2068,6 +2151,17 @@ SUBROUTINE eval_dynamic(q_eval, Rout, es_e, em_e, effout, effbandout) END IF END SUBROUTINE eval_dynamic + SUBROUTINE structural_inertia(Rout) + !! Rout = M a_alpha with the element consistent mass (of mass_l0 when present, the lengths + !! the mass band was built from). + REAL(wp), INTENT(OUT) :: Rout(:) + IF (PRESENT(mass_l0)) THEN + CALL consistent_mass_matvec(elem_conn, mass_l0, rho_a, a_alpha, Rout) + ELSE + CALL consistent_mass_matvec(elem_conn, l0, rho_a, a_alpha, Rout) + END IF + END SUBROUTINE structural_inertia + SUBROUTINE apply_release_cap(q_eval, Rout, effout, effbandout) !! Release cap of the force blend. A tension-only element taut at t_n (tension T_0, !! stretch e_0 = l_n - l0 > 0, chord d_0 = l_n t_0) carries alpha_f T_0 along its @@ -2133,12 +2227,24 @@ SUBROUTINE apply_release_cap(q_eval, Rout, effout, effbandout) !! T_d,0 |ldot_0| dt plus the end share's credit. The capped force grows without bound as !! p -> 0 (W_d > 0), so the force is continuous there; alpha_f |p| <= |ldot_0| dt is a !! sufficient test of an inactive cap. The same law covers a compressive T_d,0 (p < 0). + !! After a length change W_d and ldot_0 take the step-start lengths and rates (BA/l0_c, + !! l_n l0_dot_c/l0_c), as T_d,0 does, and the end share's T_d,1 the new ones. + !! After a length change (start_l0) every step-start quantity takes the lengths and rates + !! the step-start state was reached with: e_0 = l_n - l0_c, T_0, W_0, the secant T_0/e_0, + !! the law stiffness k_n and the dashpot tension T_d,0 (start_l0_rate); the end-state + !! quantities take those at t_{n+1}: e_1 = |d_1| - l0, T^_1 = k e_1, T_d,1 and the + !! dashpot weight phi, whose band runs from l0 to l0 + c e_0 (the end stretch against the + !! new length, the band width set by the step-start stretch, as without a change). p and + !! p_1 are the geometric projections above (l_n = l0_c + e_0). A haul-in (l0 < l0_c) can + !! make p_1 more negative, so N is bounded below by zero there too, and the inactive-cap + !! test uses the bound N >= W_0 - (1 - alpha_f) T_0 (l_n - l0)^2/(4 e_0), which is W_0/2 + !! without a change. REAL(wp), INTENT(IN) :: q_eval(:) REAL(wp), INTENT(INOUT) :: Rout(:) REAL(wp), INTENT(INOUT), OPTIONAL :: effout(:, :), effbandout(:, :) INTEGER :: e, na, nb, i, j, gi(6), fi, fj REAL(wp) :: d1(3), l1, e1, e0, t0, p, p1, num, ln, k0, ten1, cosang, dg, delta, t1(3), g(3), blk(3, 3), sgn - REAL(wp) :: band, phi, dphi, td1, dv(3), dp1(3), dtd1(3), kc, credit + REAL(wp) :: band, phi, dphi, td1, dv(3), dp1(3), dtd1(3), kc, credit, ls, nlb, dcs LOGICAL :: taut_end, damped, slack band = alpha_f/(CD_ONE - alpha_f) DO e = 1, n_elem @@ -2152,9 +2258,12 @@ SUBROUTINE apply_release_cap(q_eval, Rout, effout, effbandout) nb = elem_conn(2, e) d1 = q_eval(3*nb - 2:3*nb) - q_eval(3*na - 2:3*na) e0 = stretch_n(e) - ! projected shortening p = l_n - t_0 . d_1 (l_n = l0 + e_0); the common case, an element + ! the rest length of the step-start state (the committed one after a length change) + ls = l0(e) + IF (PRESENT(start_l0)) ls = start_l0(e) + ! projected shortening p = l_n - t_0 . d_1 (l_n = ls + e_0); the common case, an element ! that does not release, is decided here without a root - p = e0 + (l0(e) - (chord_n(1, e)*d1(1) + chord_n(2, e)*d1(2) + chord_n(3, e)*d1(3))) + p = e0 + (ls - (chord_n(1, e)*d1(1) + chord_n(2, e)*d1(2) + chord_n(3, e)*d1(3))) ! a damped element taut at t_n whose end state lies below the band edge l0 + band e_0 damped = .FALSE. IF (.NOT. slack) THEN @@ -2163,12 +2272,15 @@ SUBROUTINE apply_release_cap(q_eval, Rout, effout, effbandout) END IF IF (slack) THEN ! the kept dashpot share alpha_f T_d,0 returns work only when T_d,0 p > 0, and stays - ! within W_d = T_d,0^2 dt/(BA/l0) while alpha_f |p| <= |ldot_0| dt + ! within W_d = T_d,0^2 dt/(BA/l0) while alpha_f |p| <= |ldot_0| dt (BA/l0_c after a + ! length change: the dashpot coefficient T_d,0 was evaluated with) IF (.NOT. damp_n(e)*p > CD_ZERO) CYCLE - IF (alpha_f*ABS(p)*dcoef_n(e) <= ABS(damp_n(e))*dt) CYCLE + dcs = dcoef_n(e) + IF (PRESENT(start_l0)) dcs = axial_damping(e)/ls + IF (alpha_f*ABS(p)*dcs <= ABS(damp_n(e))*dt) CYCLE l1 = NORM2(d1) IF (.NOT. l1 > CD_ZERO) CYCLE - ln = l0(e) + e0 + ln = ls + e0 t1 = d1/l1 cosang = t1(1)*chord_n(1, e) + t1(2)*chord_n(2, e) + t1(3)*chord_n(3, e) p1 = (l1 - ln) + 0.5_wp*ln*((t1(1) - chord_n(1, e))**2 + (t1(2) - chord_n(2, e))**2 + & @@ -2176,7 +2288,7 @@ SUBROUTINE apply_release_cap(q_eval, Rout, effout, effbandout) dv = v_eval(3*nb - 2:3*nb) - v_eval(3*na - 2:3*na) td1 = dcoef_n(e)*(DOT_PRODUCT(t1, dv) - l1*rl0dot_n(e)) credit = (CD_ONE - alpha_f)*td1*p1 - num = damp_n(e)*damp_n(e)*dt/dcoef_n(e) + MAX(credit, CD_ZERO) + num = damp_n(e)*damp_n(e)*dt/dcs + MAX(credit, CD_ZERO) dg = num/p IF (ABS(dg) >= alpha_f*ABS(damp_n(e))) CYCLE delta = dg - alpha_f*damp_n(e) @@ -2196,11 +2308,13 @@ SUBROUTINE apply_release_cap(q_eval, Rout, effout, effbandout) l1 = NORM2(d1) IF (.NOT. l1 > CD_ZERO) CYCLE e1 = l1 - l0(e) - ln = l0(e) + e0 + ln = ls + e0 t1 = d1/l1 cosang = t1(1)*chord_n(1, e) + t1(2)*chord_n(2, e) + t1(3)*chord_n(3, e) p1 = (e1 - e0) + 0.5_wp*ln*((t1(1) - chord_n(1, e))**2 + (t1(2) - chord_n(2, e))**2 + & (t1(3) - chord_n(3, e))**2) + ! |d_1| - l_n = (e_1 - e_0) + (l0 - ls) after a length change + IF (PRESENT(start_l0)) p1 = p1 + (l0(e) - ls) k0 = MIN(t0/e0, stiff_n(e)) ten1 = k0*MAX(e1, CD_ZERO) ! the dashpot weight and its slope along t_1 (zero at and below l0) @@ -2233,7 +2347,14 @@ SUBROUTINE apply_release_cap(q_eval, Rout, effout, effbandout) IF (e1 > CD_ZERO) g = g + ((CD_ONE - alpha_f)/p)*k0*p1*t1 END IF ELSE - IF (.NOT. 4.0_wp*alpha_f*p > e0) CYCLE + IF (PRESENT(start_l0)) THEN + ! N >= W_0 - (1 - alpha_f) T_0 (l_n - l0)^2/(4 e_0), l_n - l0 = e_0 + ls - l0 + nlb = 0.5_wp*t0*e0 - (CD_ONE - alpha_f)*t0*MAX(e0 + (ls - l0(e)), CD_ZERO)**2/(4.0_wp*e0) + ! (p > 0 as well: the bound can be negative after a haul-in) + IF (.NOT. (p > CD_ZERO .AND. alpha_f*t0*p > nlb)) CYCLE + ELSE + IF (.NOT. 4.0_wp*alpha_f*p > e0) CYCLE + END IF num = 0.5_wp*t0*e0 taut_end = d1(1)*d1(1) + d1(2)*d1(2) + d1(3)*d1(3) > l0(e)*l0(e) l1 = CD_ZERO @@ -2247,7 +2368,7 @@ SUBROUTINE apply_release_cap(q_eval, Rout, effout, effbandout) taut_end = e1 > CD_ZERO END IF IF (taut_end) THEN - ln = l0(e) + e0 + ln = ls + e0 ! the secant stiffness, bounded for a law element by its step-start axial stiffness k0 = MIN(t0/e0, stiff_n(e)) ten1 = k0*e1 @@ -2255,9 +2376,11 @@ SUBROUTINE apply_release_cap(q_eval, Rout, effout, effbandout) cosang = t1(1)*chord_n(1, e) + t1(2)*chord_n(2, e) + t1(3)*chord_n(3, e) p1 = (e1 - e0) + 0.5_wp*ln*((t1(1) - chord_n(1, e))**2 + (t1(2) - chord_n(2, e))**2 + & (t1(3) - chord_n(3, e))**2) + IF (PRESENT(start_l0)) p1 = p1 + (l0(e) - ls) num = num + (CD_ONE - alpha_f)*ten1*p1 END IF - dg = num/p + ! num >= W_0/2 > 0 without a length change; a haul-in can drive it below zero + dg = MAX(num, CD_ZERO)/p IF (dg >= alpha_f*t0) CYCLE delta = dg - alpha_f*t0 Rout(3*na - 2:3*na) = Rout(3*na - 2:3*na) - delta*chord_n(:, e) @@ -2265,9 +2388,12 @@ SUBROUTINE apply_release_cap(q_eval, Rout, effout, effbandout) IF (.NOT. (PRESENT(effout) .OR. PRESENT(effbandout))) CYCLE ! d(delta)/d(x_b) = g, d(delta)/d(x_a) = -g, with dp/dd_1 = -t_0, ! dT_1/dd_1 = k0 t_1 and dp_1/dd_1 = t_1 - (l_n/|d_1|)(t_0 - (t_1 . t_0) t_1) - g = (num/(p*p))*chord_n(:, e) - IF (taut_end) g = g + ((CD_ONE - alpha_f)/p)*((k0*p1 + ten1)*t1 - & - ten1*(ln/l1)*(chord_n(:, e) - cosang*t1)) + g = CD_ZERO + IF (num > CD_ZERO) THEN + g = (num/(p*p))*chord_n(:, e) + IF (taut_end) g = g + ((CD_ONE - alpha_f)/p)*((k0*p1 + ten1)*t1 - & + ten1*(ln/l1)*(chord_n(:, e) - cosang*t1)) + END IF END IF DO j = 1, 3 DO i = 1, 3 diff --git a/src/CableDyn_HermiteCableDynamic.f90 b/src/CableDyn_HermiteCableDynamic.f90 index 43d8195d..02a635a3 100644 --- a/src/CableDyn_HermiteCableDynamic.f90 +++ b/src/CableDyn_HermiteCableDynamic.f90 @@ -72,6 +72,7 @@ MODULE CableDyn_HermiteCableDynamic USE CableDyn_Bathymetry, ONLY: CD_BathymetryType, CD_Bathymetry_Is_Initialized, & CD_Bathymetry_Floor_Gradient, CD_End_Bathymetry, CD_BATHY_OK, & CD_Bathymetry_Rotate_Curvature + USE CableDyn_Line, ONLY: CD_Nodal_Seabed_Stiffness, CD_LINE_OK USE CableDyn_HermiteTorsion, ONLY: CD_HermiteTorsionType, CD_HermiteTorsion_Line, CD_HermiteTorsion_Unwrap, & CD_HermiteTorsion_Compliance, CD_HermiteTorsion_Validate, CD_HTORS_OK, & CD_HTORS_MAX_STEP, CD_HermiteTorsionWorkType, CD_HermiteTorsion_Work_Init, & @@ -105,6 +106,9 @@ MODULE CableDyn_HermiteCableDynamic PUBLIC :: CD_HermiteCable_Dyn_Set_Attachments PUBLIC :: CD_HermiteCable_Attachment_Drag PUBLIC :: CD_HermiteCable_Dyn_Recompute_Acceleration + PUBLIC :: CD_HermiteCable_Dyn_Set_SegmentLength + PUBLIC :: CD_HermiteCableControlSaveType, CD_HermiteCable_Dyn_Save_Control, CD_HermiteCable_Dyn_Restore_Control + PUBLIC :: CD_HermiteCable_Dyn_Set_Control_Seabed PUBLIC :: CD_HermiteCable_Dyn_Set_Irregular_Waves PUBLIC :: CD_HermiteCable_Drag_Element PUBLIC :: CD_HermiteCable_Axial_Damping_Element @@ -192,6 +196,26 @@ MODULE CableDyn_HermiteCableDynamic ! axial quadrature as the elastic resultant. Off by default. LOGICAL :: has_axial_damping = .FALSE. REAL(wp), ALLOCATABLE :: BA(:) + ! Active line control (CD_HermiteCable_Dyn_Set_SegmentLength): a host changes the + ! unstretched lengths l0 of chosen elements between steps. has_ctrl is set by the first + ! change; from then on l0_dot(ne) holds the unstretched-length rate of every element + ! (zero outside the controlled span), which the axial damping subtracts from the strain + ! rate. A model that is never controlled leaves has_ctrl false and l0_dot unallocated, so + ! every evaluation is unchanged. BA keeps its initial resolution. + LOGICAL :: has_ctrl = .FALSE. + REAL(wp), ALLOCATABLE :: l0_dot(:) + ! The lengths and rates the committed state was reached with (allocated with l0_dot, set + ! at each commit): the force-blended committed force F_n = R(q_n, v_n, t_n) belongs to + ! them, so the first step after a length change blends F_n at these lengths with + ! R(q_{n+1}) at the new ones. ws_recovery_l0_c/ws_recovery_l0_dot_c are the step-start + ! copies of the recovering step. + REAL(wp), ALLOCATABLE :: l0_c(:), l0_dot_c(:), ws_recovery_l0_c(:), ws_recovery_l0_dot_c(:) + ! Seabed recompute inputs of a controlled contact model (CD_HermiteCable_Dyn_Set_Control_Seabed): + ! the per-area penalty kBot, the per-element contact diameter and cBot/kBot, so a length + ! change rebuilds contact_kn/contact_cn with the helper the deck used at initialisation. + LOGICAL :: has_seabed_recompute = .FALSE. + REAL(wp) :: seabed_kbot = CD_ZERO, seabed_cn_over_kn = CD_ZERO + REAL(wp), ALLOCATABLE :: seabed_diameter_elem(:) REAL(wp) :: seabed_z = CD_ZERO, kn = CD_ZERO REAL(wp), ALLOCATABLE :: trib(:) ! nodal tributary length ! Production standalone contact. contact_kn/contact_cn are nodal coefficients [N/m] @@ -311,6 +335,9 @@ MODULE CableDyn_HermiteCableDynamic LOGICAL :: a_restored = .FALSE. INTEGER, ALLOCATABLE :: att_node(:) REAL(wp), ALLOCATABLE :: att_w(:), att_b(:), att_fk(:), att_cda(:), att_cdax(:) + ! The two nodal mass terms each attachment adds to Mgb, the dry mass m and the added mass + ! Ca rho V, kept so that a length change rebuilds Mgb in the order initialisation used. + REAL(wp), ALLOCATABLE :: att_mass(:), att_madd(:) REAL(wp) :: att_rho = CD_ZERO ! Rollback copies of CD_HermiteCable_Dyn_Set_Held_Fluid, kept so a per-step field update ! allocates nothing: a (ndof), hf_u/hf_ud (3, nn), hf_wl (nn). @@ -324,6 +351,10 @@ MODULE CableDyn_HermiteCableDynamic ! leave partially advanced state. Buffers allocate on first Snapshot (amortised zero; ! never touched by Step itself). REAL(wp), ALLOCATABLE :: snap_q(:), snap_v(:), snap_a(:) + ! The unstretched lengths and their rates join the snapshot (active line control): a + ! restore that changes l0 rebuilds the length-dependent caches from the restored lengths. + REAL(wp), ALLOCATABLE :: snap_l0(:), snap_l0_dot(:), snap_l0_c(:), snap_l0_dot_c(:) + LOGICAL :: snap_has_ctrl = .FALSE. REAL(wp) :: snap_t = CD_ZERO REAL(wp) :: snap_endconn_d0(3, 2) = CD_ZERO ! Condensed torsion (CD_HermiteCable_Dyn_Set_Torsion): end frames, GJ, imposed twist Phi and @@ -439,6 +470,21 @@ MODULE CableDyn_HermiteCableDynamic LOGICAL :: initialized = .FALSE. END TYPE CD_HermiteCableDynType + TYPE :: CD_HermiteCableControlSaveType + !! What CD_HermiteCable_Dyn_Set_SegmentLength writes, as CD_HermiteCable_Dyn_Save_Control + !! found it (the length caches are rebuilt from the lengths on a restore). + LOGICAL :: valid = .FALSE., has_ctrl = .FALSE., tr_valid = .FALSE., rates = .FALSE. + REAL(wp), ALLOCATABLE :: l0(:), l0_dot(:), l0_c(:), l0_dot_c(:) + END TYPE CD_HermiteCableControlSaveType + + TYPE :: committed_lengths_aside + !! The present lengths, rates and length caches of a controlled model, set aside while + !! one evaluation of the committed state runs with the lengths and rates that state was + !! reached with (enter_committed_lengths / leave_committed_lengths). + LOGICAL :: lengths = .FALSE., rates = .FALSE. + REAL(wp), ALLOCATABLE :: l0(:), rate(:), mgb(:, :), trib(:), kn(:), cn(:), frk(:) + END TYPE committed_lengths_aside + CONTAINS LOGICAL FUNCTION CD_HermiteCable_Dyn_Profile_Enabled() RESULT(enabled) @@ -784,6 +830,8 @@ SUBROUTINE CD_HermiteCable_Dyn_Set_Contact(model, kn_node, cn_node, mu, ErrStat, model%a = old_a CALL fail_contact('initial acceleration refresh failed: '//TRIM(em)); RETURN END IF + ! New nodal coefficients supersede any seabed recompute inputs given for the old ones. + model%has_seabed_recompute = .FALSE. CONTAINS SUBROUTINE fail_contact(msg) @@ -950,7 +998,7 @@ SUBROUTINE CD_HermiteCable_Dyn_Set_Attachments(model, node, mass, volume, cda, c a_old = model%a 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_cdax(n), model%att_mass(n), model%att_madd(n)) model%att_node = node model%att_w = (mass - rho_w*volume)*gravity model%att_b = rho_w*gravity*volume @@ -958,16 +1006,19 @@ SUBROUTINE CD_HermiteCable_Dyn_Set_Attachments(model, node, mass, volume, cda, c model%att_cda = cda model%att_cdax = cdax model%att_rho = rho_w + model%att_mass = mass + model%att_madd = ca*rho_w*volume DO k = 1, n DO d = 1, 3 dof = 6*(node(k) - 1) + d - model%Mgb(KL_D + KU_D + 1, dof) = model%Mgb(KL_D + KU_D + 1, dof) + mass(k) + ca(k)*rho_w*volume(k) + model%Mgb(KL_D + KU_D + 1, dof) = model%Mgb(KL_D + KU_D + 1, dof) + model%att_mass(k) + model%att_madd(k) END DO END DO model%has_attach = .TRUE. 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) + 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%has_attach = .FALSE. model%Mgb = mgb_old model%a = a_old @@ -1090,7 +1141,11 @@ SUBROUTINE CD_HermiteCable_Dyn_Recompute_Acceleration(model, ErrStat, ErrMsg, pr !! free-DOF acceleration from the complete installed load set at the model's current !! q/v/t. Optional prescribed fixed-DOF accelerations enter the consistent-mass RHS, !! including their off-diagonal coupling to free DOFs. Failure is atomic with respect - !! to the previously committed acceleration. + !! to the previously committed acceleration. Under active line control the acceleration + !! is the committed state's: between a length change (CD_HermiteCable_Dyn_Set_SegmentLength) + !! and the next step it is solved with the lengths and rates that state was reached with + !! (l0_c, l0_dot_c), which stay the committed ones, so the step still blends the old and new + !! lengths. TYPE(CD_HermiteCableDynType), INTENT(INOUT) :: model INTEGER, INTENT(OUT) :: ErrStat CHARACTER(*), INTENT(OUT) :: ErrMsg @@ -1105,13 +1160,13 @@ SUBROUTINE CD_HermiteCable_Dyn_Recompute_Acceleration(model, ErrStat, ErrMsg, pr END IF a_old = model%a IF (PRESENT(pres_dofs) .AND. PRESENT(pres_a)) THEN - CALL solve_consistent_acceleration(model, ErrStat, ErrMsg, pres_dofs=pres_dofs, pres_a=pres_a) + CALL solve_committed_acceleration(model, ErrStat, ErrMsg, pres_dofs=pres_dofs, pres_a=pres_a) ELSE IF (PRESENT(pres_dofs) .OR. PRESENT(pres_a)) THEN ErrStat = CD_HCDYN_BADINPUT ErrMsg = 'CD_HermiteCable_Dyn_Recompute_Acceleration: pres_dofs and pres_a must be supplied together' RETURN ELSE - CALL solve_consistent_acceleration(model, ErrStat, ErrMsg) + CALL solve_committed_acceleration(model, ErrStat, ErrMsg) END IF IF (ErrStat /= CD_HCDYN_OK) THEN model%a = a_old @@ -1119,6 +1174,437 @@ SUBROUTINE CD_HermiteCable_Dyn_Recompute_Acceleration(model, ErrStat, ErrMsg, pr END IF END SUBROUTINE CD_HermiteCable_Dyn_Recompute_Acceleration + SUBROUTINE CD_HermiteCable_Dyn_Set_SegmentLength(model, elems, l0_new, l0_dot, ErrStat, ErrMsg, restored) + !! Active line control (the OpenFAST cable-control channel): set the unstretched length + !! and its rate of the listed elements, applied before a step and held over it. Every + !! term that reads l0 when it is evaluated (elastic force, weight, drag, Froude-Krylov + !! load, added mass, dry-part buoyancy, the tensile audit and the residual scale) follows + !! at once. The cached terms are rebuilt from the new lengths in the order initialisation + !! used, so the model carries what one built with them would: the constant mass Mgb with + !! the attachment masses, the nodal tributary lengths and, on a contact model, the nodal + !! seabed coefficients and the friction spring stiffness. The rate enters the axial + !! damping (CD_HermiteCable_Axial_Damping_Element). The step uses the mass of the new + !! lengths and leaves out the rate term dM/dt v, as MoorDyn does; the committed + !! acceleration is kept as the history of the preceding step, and BA keeps its initial + !! resolution. The committed state keeps the lengths it was reached with (l0_c, + !! l0_dot_c): the force-blended committed force F_n stays the force at those lengths + !! (cached or, after a cache loss, evaluated with them), and only the step's new force + !! R(q_{n+1}) takes the new ones, so a length ramp is not lagged by alpha_f times the + !! length change. The carried step factor is discarded, and the step after a change starts + !! from the Newmark predictor (the change is a load step). + !! A call that changes no length and no rate (bit for bit, a rate of -0 counting as +0) + !! returns at once, so a zero command of either sign on an uncontrolled model leaves it + !! untouched. The update is atomic: every check and rebuild runs before the model is + !! written. A line restrained in torsion is refused (its condensed torsional compliance + !! has no length-control law here), as is a contact model without the seabed recompute + !! inputs and a model on the configuration-blended generalised-alpha (force blend off, + !! CD_HermiteCable_Dyn_Set_ForceBlend), whose blended state has no committed-length + !! treatment, so a ramp would lag by alpha_f times the length change. restored = .TRUE. (a checkpoint + !! restart re-applying the command the committed state was reached with) makes the + !! lengths and rates the committed ones at once; a committed force reloaded with the + !! state belongs to them and stays valid. + TYPE(CD_HermiteCableDynType), INTENT(INOUT) :: model + INTEGER, INTENT(IN) :: elems(:) + REAL(wp), INTENT(IN) :: l0_new(:), l0_dot(:) + INTEGER, INTENT(OUT) :: ErrStat + CHARACTER(*), INTENT(OUT) :: ErrMsg + LOGICAL, INTENT(IN), OPTIONAL :: restored + INTEGER :: k, n, istat + LOGICAL :: lengths_changed, rates_changed + REAL(wp) :: rate_now + REAL(wp), ALLOCATABLE :: l0_trial(:), rate_new(:) + + ErrStat = CD_HCDYN_OK; ErrMsg = '' + IF (.NOT. model%initialized) THEN + CALL fail('model not initialised'); RETURN + END IF + n = SIZE(elems) + IF (n < 1 .OR. SIZE(l0_new) /= n .OR. SIZE(l0_dot) /= n) THEN + CALL fail('elems, l0_new and l0_dot must share one length >= 1'); RETURN + END IF + IF (ANY(elems < 1) .OR. ANY(elems > model%ne)) THEN + CALL fail('element index out of range'); RETURN + END IF + DO k = 2, n + IF (elems(k) <= elems(k - 1)) THEN + CALL fail('element indices must be strictly increasing'); RETURN + END IF + END DO + IF (.NOT. (CD_All_Finite(l0_new) .AND. CD_All_Finite(l0_dot))) THEN + CALL fail('l0 and l0_dot must be finite'); RETURN + END IF + IF (ANY(l0_new <= CD_ZERO)) THEN + CALL fail('l0 must be positive'); RETURN + END IF + IF (model%torsion%active) THEN + CALL fail('a line restrained in torsion is not supported (the condensed torsional compliance '// & + 'has no length-control law)'); RETURN + END IF + IF (model%has_contact .AND. .NOT. model%has_seabed_recompute) THEN + CALL fail('a seabed-contact model needs the seabed recompute inputs '// & + '(CD_HermiteCable_Dyn_Set_Control_Seabed)'); RETURN + END IF + IF (.NOT. model%force_blend) THEN + CALL fail('the configuration-blended generalised-alpha (force blend off) is not supported: '// & + 'enable the force blend (CD_HermiteCable_Dyn_Set_ForceBlend)'); RETURN + END IF + ! a rate of -0 is stored as +0, so a zero command of either sign is inert + rate_new = positive_zero(l0_dot) + lengths_changed = .FALSE. + rates_changed = .FALSE. + DO k = 1, n + IF (.NOT. bits_equal(model%l0(elems(k)), l0_new(k))) lengths_changed = .TRUE. + rate_now = CD_ZERO + IF (model%has_ctrl) rate_now = model%l0_dot(elems(k)) + IF (.NOT. bits_equal(rate_now, rate_new(k))) rates_changed = .TRUE. + END DO + IF (.NOT. (lengths_changed .OR. rates_changed)) THEN + CALL commit_restored() + RETURN + END IF + IF (.NOT. ALLOCATED(model%l0_dot)) THEN + ALLOCATE (model%l0_dot(model%ne), model%l0_c(model%ne), model%l0_dot_c(model%ne), & + model%ws_recovery_l0_c(model%ne), model%ws_recovery_l0_dot_c(model%ne), STAT=istat) + IF (istat /= 0) THEN + CALL fail('rate storage allocation failed'); RETURN + END IF + model%l0_dot = CD_ZERO + END IF + ! the first change: the committed state was reached with the present lengths, at rest + IF (.NOT. model%has_ctrl) THEN + model%l0_c = model%l0 + model%l0_dot_c = CD_ZERO + END IF + IF (lengths_changed) THEN + ALLOCATE (l0_trial(model%ne), STAT=istat) + IF (istat /= 0) THEN + CALL fail('length storage allocation failed'); RETURN + END IF + l0_trial = model%l0 + l0_trial(elems) = l0_new + CALL rebuild_length_caches(model, l0_trial, ErrStat, ErrMsg) + IF (ErrStat /= CD_HCDYN_OK) THEN + ErrMsg = 'CD_HermiteCable_Dyn_Set_SegmentLength: '//TRIM(ErrMsg); RETURN + END IF + END IF + IF (.NOT. model%has_ctrl) model%l0_dot = CD_ZERO + model%has_ctrl = .TRUE. + model%l0_dot(elems) = rate_new + ! the cached committed force stays valid (it is the force at l0_c); the carried factor + ! holds the tangent of the old lengths + model%tr_valid = .FALSE. + CALL commit_restored() + + CONTAINS + SUBROUTINE fail(msg) + CHARACTER(*), INTENT(IN) :: msg + ErrStat = CD_HCDYN_BADINPUT + ErrMsg = 'CD_HermiteCable_Dyn_Set_SegmentLength: '//msg + END SUBROUTINE fail + + SUBROUTINE commit_restored() + !! restored: the present lengths and rates are the committed state's. + IF (.NOT. PRESENT(restored)) RETURN + IF (.NOT. (restored .AND. model%has_ctrl)) RETURN + model%l0_c = model%l0 + model%l0_dot_c = model%l0_dot + END SUBROUTINE commit_restored + END SUBROUTINE CD_HermiteCable_Dyn_Set_SegmentLength + + SUBROUTINE CD_HermiteCable_Dyn_Save_Control(model, saved) + !! Save what CD_HermiteCable_Dyn_Set_SegmentLength writes (the lengths, rates, committed + !! lengths and rates, the control flag and the carried-factor flag), so that a caller + !! applying one command to several models can take back the ones it already changed + !! when a later one fails (CD_HermiteCable_Dyn_Restore_Control). + TYPE(CD_HermiteCableDynType), INTENT(IN) :: model + TYPE(CD_HermiteCableControlSaveType), INTENT(INOUT) :: saved + saved%valid = model%initialized + IF (.NOT. saved%valid) RETURN + saved%has_ctrl = model%has_ctrl + saved%tr_valid = model%tr_valid + saved%l0 = model%l0 + saved%rates = ALLOCATED(model%l0_dot) + IF (saved%rates) THEN + saved%l0_dot = model%l0_dot + saved%l0_c = model%l0_c + saved%l0_dot_c = model%l0_dot_c + END IF + END SUBROUTINE CD_HermiteCable_Dyn_Save_Control + + SUBROUTINE CD_HermiteCable_Dyn_Restore_Control(model, saved, ErrStat, ErrMsg) + !! Take the model back to what CD_HermiteCable_Dyn_Save_Control saved. Lengths changed + !! since get the caches built from the saved lengths, as CD_HermiteCable_Dyn_Restore + !! rebuilds them: the caches are a function of the lengths (built in the order + !! initialisation used), so the model is the saved one bit for bit. Fails closed, writing + !! nothing, when the save does not belong to the model or the rebuild fails. + TYPE(CD_HermiteCableDynType), INTENT(INOUT) :: model + TYPE(CD_HermiteCableControlSaveType), INTENT(IN) :: saved + INTEGER, INTENT(OUT) :: ErrStat + CHARACTER(*), INTENT(OUT) :: ErrMsg + REAL(wp), ALLOCATABLE :: l0_back(:) + + ErrStat = CD_HCDYN_OK; ErrMsg = '' + IF (.NOT. (model%initialized .AND. saved%valid)) THEN + ErrStat = CD_HCDYN_BADINPUT + ErrMsg = 'CD_HermiteCable_Dyn_Restore_Control: no saved control state'; RETURN + END IF + IF (SIZE(saved%l0) /= model%ne) THEN + ErrStat = CD_HCDYN_BADINPUT + ErrMsg = 'CD_HermiteCable_Dyn_Restore_Control: the saved state belongs to another model'; RETURN + END IF + IF (.NOT. ALL(bits_equal(model%l0, saved%l0))) THEN + l0_back = saved%l0 + CALL rebuild_length_caches(model, l0_back, ErrStat, ErrMsg) + IF (ErrStat /= CD_HCDYN_OK) THEN + ErrMsg = 'CD_HermiteCable_Dyn_Restore_Control: '//TRIM(ErrMsg); RETURN + END IF + END IF + IF (saved%rates) THEN + model%l0_dot = saved%l0_dot + model%l0_c = saved%l0_c + model%l0_dot_c = saved%l0_dot_c + IF (.NOT. ALLOCATED(model%ws_recovery_l0_c)) & + ALLOCATE (model%ws_recovery_l0_c(model%ne), model%ws_recovery_l0_dot_c(model%ne)) + ELSE IF (ALLOCATED(model%l0_dot)) THEN + DEALLOCATE (model%l0_dot, model%l0_c, model%l0_dot_c, model%ws_recovery_l0_c, model%ws_recovery_l0_dot_c) + END IF + model%has_ctrl = saved%has_ctrl + model%tr_valid = saved%tr_valid + END SUBROUTINE CD_HermiteCable_Dyn_Restore_Control + + SUBROUTINE CD_HermiteCable_Dyn_Set_Control_Seabed(model, kbot, diameter_elem, cn_over_kn, ErrStat, ErrMsg) + !! Store the seabed recompute inputs of a contact model for active line control: the + !! per-area penalty kbot [N/m^3], the per-element contact diameter [m] and the ratio + !! cn/kn, the inputs from which the deck built the installed nodal coefficients with + !! CD_Nodal_Seabed_Stiffness. Call after CD_HermiteCable_Dyn_Set_Contact. The inputs + !! must reproduce the installed contact_kn and contact_cn bit for bit at the present + !! lengths, so a length change rebuilds exactly the coefficients a model built with the + !! new lengths would carry; otherwise the call fails and changes nothing. + TYPE(CD_HermiteCableDynType), INTENT(INOUT) :: model + REAL(wp), INTENT(IN) :: kbot, diameter_elem(:), cn_over_kn + INTEGER, INTENT(OUT) :: ErrStat + CHARACTER(*), INTENT(OUT) :: ErrMsg + REAL(wp), ALLOCATABLE :: kn_check(:) + INTEGER :: es + CHARACTER(200) :: em + + ErrStat = CD_HCDYN_OK; ErrMsg = '' + IF (.NOT. model%initialized) THEN + CALL fail('model not initialised'); RETURN + END IF + IF (.NOT. (model%has_contact .AND. ALLOCATED(model%contact_kn) .AND. ALLOCATED(model%contact_cn))) THEN + CALL fail('seabed contact (CD_HermiteCable_Dyn_Set_Contact) is required'); RETURN + END IF + IF (SIZE(diameter_elem) /= model%ne) THEN + CALL fail('diameter_elem must have one entry per element'); RETURN + END IF + IF (.NOT. (CD_Is_Finite(cn_over_kn) .AND. cn_over_kn >= CD_ZERO)) THEN + CALL fail('cn_over_kn must be finite and non-negative'); RETURN + END IF + CALL CD_Nodal_Seabed_Stiffness(kbot, diameter_elem, model%l0, kn_check, es, em) + IF (es /= CD_LINE_OK) THEN + CALL fail(TRIM(em)); RETURN + END IF + IF (.NOT. ALL(bits_equal(kn_check, model%contact_kn))) THEN + CALL fail('the inputs do not reproduce the installed nodal contact stiffness'); RETURN + END IF + IF (.NOT. ALL(bits_equal(kn_check*cn_over_kn, model%contact_cn))) THEN + CALL fail('the inputs do not reproduce the installed nodal contact damping'); RETURN + END IF + model%seabed_kbot = kbot + model%seabed_diameter_elem = diameter_elem + model%seabed_cn_over_kn = cn_over_kn + model%has_seabed_recompute = .TRUE. + + CONTAINS + SUBROUTINE fail(msg) + CHARACTER(*), INTENT(IN) :: msg + ErrStat = CD_HCDYN_BADINPUT + ErrMsg = 'CD_HermiteCable_Dyn_Set_Control_Seabed: '//msg + END SUBROUTINE fail + END SUBROUTINE CD_HermiteCable_Dyn_Set_Control_Seabed + + SUBROUTINE rebuild_length_caches(model, l0_new, ErrStat, ErrMsg) + !! Install the unstretched lengths l0_new with every cache built from them, in the order + !! initialisation used, so the model matches one built with these lengths bit for bit: + !! the constant mass Mgb (element by element, then the attachment masses), the nodal + !! tributary lengths and, on a contact model, the nodal seabed coefficients + !! (CD_Nodal_Seabed_Stiffness, as the deck builds them) with the friction spring + !! stiffness that follows them. Everything is built first; the model is written only + !! when every build succeeded. + TYPE(CD_HermiteCableDynType), INTENT(INOUT) :: model + REAL(wp), INTENT(IN) :: l0_new(:) + INTEGER, INTENT(OUT) :: ErrStat + CHARACTER(*), INTENT(OUT) :: ErrMsg + REAL(wp), ALLOCATABLE :: mgb_new(:, :), trib_new(:), kn_new(:), cn_new(:) + REAL(wp) :: Me(12, 12) + INTEGER :: e, k, d, dof, es, istat + CHARACTER(200) :: em + + ErrStat = CD_HCDYN_OK; ErrMsg = '' + IF (SIZE(l0_new) /= model%ne) THEN + ErrStat = CD_HCDYN_BADINPUT; ErrMsg = 'length rebuild: l0 must have one entry per element'; RETURN + END IF + ALLOCATE (mgb_new(LDAB_D, model%ndof), trib_new(model%nn), STAT=istat) + IF (istat /= 0) THEN + ErrStat = CD_HCDYN_BADINPUT; ErrMsg = 'length rebuild: workspace allocation failed'; RETURN + END IF + mgb_new = CD_ZERO + DO e = 1, model%ne + CALL CD_HermiteCable_Mass(model%rho_a(e), l0_new(e), Me, es, em) + IF (es /= CD_HCABLE_OK) THEN + ErrStat = CD_HCDYN_BADINPUT; ErrMsg = 'length rebuild: mass assembly: '//TRIM(em); RETURN + END IF + CALL scatter12_band(mgb_new, Me, e) + END DO + IF (model%has_attach) THEN + DO k = 1, SIZE(model%att_node) + DO d = 1, 3 + dof = 6*(model%att_node(k) - 1) + d + mgb_new(KL_D + KU_D + 1, dof) = mgb_new(KL_D + KU_D + 1, dof) + model%att_mass(k) + model%att_madd(k) + END DO + END DO + END IF + trib_new = CD_ZERO + DO e = 1, model%ne + trib_new(e) = trib_new(e) + 0.5_wp*l0_new(e) + trib_new(e + 1) = trib_new(e + 1) + 0.5_wp*l0_new(e) + END DO + IF (model%has_contact) THEN + IF (.NOT. model%has_seabed_recompute) THEN + ErrStat = CD_HCDYN_BADINPUT + ErrMsg = 'length rebuild: the seabed-contact model has no seabed recompute inputs'; RETURN + END IF + CALL CD_Nodal_Seabed_Stiffness(model%seabed_kbot, model%seabed_diameter_elem, l0_new, kn_new, es, em) + IF (es /= CD_LINE_OK) THEN + ErrStat = CD_HCDYN_BADINPUT; ErrMsg = 'length rebuild: seabed stiffness: '//TRIM(em); RETURN + END IF + cn_new = kn_new*model%seabed_cn_over_kn + END IF + model%l0 = l0_new + CALL MOVE_ALLOC(mgb_new, model%Mgb) + CALL MOVE_ALLOC(trib_new, model%trib) + IF (model%has_contact) THEN + CALL MOVE_ALLOC(kn_new, model%contact_kn) + CALL MOVE_ALLOC(cn_new, model%contact_cn) + IF (model%fr_active) model%fr_k = model%contact_kn + END IF + END SUBROUTINE rebuild_length_caches + + SUBROUTINE enter_committed_lengths(model, aside, ErrStat, ErrMsg) + !! Install the lengths and rates the committed state was reached with (l0_c, l0_dot_c) for + !! one evaluation of the committed state, setting the present ones aside: after a length + !! change the length-dependent caches are rebuilt from l0_c, and leave_committed_lengths + !! moves the present ones back bit for bit. A model that is not under active line control, + !! or whose lengths and rates are the committed ones, is left as it is. On failure nothing + !! is written. + TYPE(CD_HermiteCableDynType), INTENT(INOUT) :: model + TYPE(committed_lengths_aside), INTENT(INOUT) :: aside + INTEGER, INTENT(OUT) :: ErrStat + CHARACTER(*), INTENT(OUT) :: ErrMsg + REAL(wp), ALLOCATABLE :: l0_old(:) + + ErrStat = CD_HCDYN_OK; ErrMsg = '' + aside%lengths = .FALSE. + aside%rates = .FALSE. + IF (.NOT. model%has_ctrl) RETURN + IF (ALL(bits_equal(model%l0, model%l0_c)) .AND. ALL(bits_equal(model%l0_dot, model%l0_dot_c))) RETURN + IF (.NOT. ALL(bits_equal(model%l0, model%l0_c))) THEN + aside%l0 = model%l0 + aside%mgb = model%Mgb + aside%trib = model%trib + IF (model%has_contact) THEN + aside%kn = model%contact_kn + aside%cn = model%contact_cn + IF (model%fr_active) aside%frk = model%fr_k + END IF + ! a copy, so no subobject of model is associated with a second dummy + l0_old = model%l0_c + CALL rebuild_length_caches(model, l0_old, ErrStat, ErrMsg) + IF (ErrStat /= CD_HCDYN_OK) RETURN + aside%lengths = .TRUE. + END IF + aside%rate = model%l0_dot + model%l0_dot = model%l0_dot_c + aside%rates = .TRUE. + END SUBROUTINE enter_committed_lengths + + SUBROUTINE leave_committed_lengths(model, aside) + !! Move back the present lengths, rates and caches enter_committed_lengths set aside. + TYPE(CD_HermiteCableDynType), INTENT(INOUT) :: model + TYPE(committed_lengths_aside), INTENT(INOUT) :: aside + IF (aside%lengths) THEN + model%l0 = aside%l0 + CALL MOVE_ALLOC(aside%mgb, model%Mgb) + CALL MOVE_ALLOC(aside%trib, model%trib) + IF (model%has_contact) THEN + CALL MOVE_ALLOC(aside%kn, model%contact_kn) + CALL MOVE_ALLOC(aside%cn, model%contact_cn) + IF (model%fr_active) CALL MOVE_ALLOC(aside%frk, model%fr_k) + END IF + END IF + IF (aside%rates) model%l0_dot = aside%rate + aside%lengths = .FALSE. + aside%rates = .FALSE. + END SUBROUTINE leave_committed_lengths + + SUBROUTINE assemble_committed_force(model, ErrStat, ErrMsg) + !! The committed force F_n = R(q_n, v_n, t_n) into ws_R, with the lengths and rates the + !! committed state was reached with (l0_c, l0_dot_c; enter_committed_lengths); without a + !! pending length or rate change this is the plain evaluation. + TYPE(CD_HermiteCableDynType), INTENT(INOUT) :: model + INTEGER, INTENT(OUT) :: ErrStat + CHARACTER(*), INTENT(OUT) :: ErrMsg + TYPE(committed_lengths_aside) :: aside + INTEGER :: es + CHARACTER(200) :: em + + CALL enter_committed_lengths(model, aside, es, em) + IF (es /= CD_HCDYN_OK) THEN + ErrStat = es; ErrMsg = 'committed force: '//TRIM(em); RETURN + END IF + CALL assemble_residual(model, model%q, model%v, model%t, .TRUE., .FALSE., ErrStat, ErrMsg) + CALL leave_committed_lengths(model, aside) + END SUBROUTINE assemble_committed_force + + SUBROUTINE solve_committed_acceleration(model, ErrStat, ErrMsg, pres_dofs, pres_a) + !! solve_consistent_acceleration for the committed state: the acceleration is the + !! committed state's, so under active line control it is solved with the lengths and rates + !! that state was reached with (l0_c, l0_dot_c; enter_committed_lengths), which stay the + !! committed ones. Without a pending length or rate change this is the plain solve. + TYPE(CD_HermiteCableDynType), INTENT(INOUT) :: model + INTEGER, INTENT(OUT) :: ErrStat + CHARACTER(*), INTENT(OUT) :: ErrMsg + INTEGER, INTENT(IN), OPTIONAL :: pres_dofs(:) + REAL(wp), INTENT(IN), OPTIONAL :: pres_a(:) + TYPE(committed_lengths_aside) :: aside + INTEGER :: es + CHARACTER(200) :: em + + CALL enter_committed_lengths(model, aside, es, em) + IF (es /= CD_HCDYN_OK) THEN + ErrStat = es; ErrMsg = 'committed acceleration: '//TRIM(em); RETURN + END IF + CALL solve_consistent_acceleration(model, ErrStat, ErrMsg, pres_dofs=pres_dofs, pres_a=pres_a) + CALL leave_committed_lengths(model, aside) + END SUBROUTINE solve_committed_acceleration + + ELEMENTAL LOGICAL FUNCTION bits_equal(a, b) RESULT(same) + !! Bitwise equality of two reals (so +0 and -0 differ). + REAL(wp), INTENT(IN) :: a, b + same = TRANSFER(a, 0_INT64) == TRANSFER(b, 0_INT64) + END FUNCTION bits_equal + + ELEMENTAL REAL(wp) FUNCTION positive_zero(x) RESULT(y) + !! x with a negative zero replaced by +0, on the bits (so no floating-point mode can keep + !! the sign); every other value is returned unchanged. + REAL(wp), INTENT(IN) :: x + INTEGER(INT64) :: bits + bits = TRANSFER(x, 0_INT64) + IF (bits == -HUGE(0_INT64) - 1_INT64) bits = 0_INT64 + y = TRANSFER(bits, y) + END FUNCTION positive_zero + SUBROUTINE CD_HermiteCable_Dyn_Set_ForceBlend(model, enabled, ErrStat, ErrMsg) !! Select the generalised-alpha blend. enabled = .TRUE. (the default): the residual !! blends the forces, G = M a_am + (1-af) r(q_{n+1}, v_{n+1}, t_{n+1}) + af r(q_n, v_n, t_n), @@ -1136,6 +1622,12 @@ SUBROUTINE CD_HermiteCable_Dyn_Set_ForceBlend(model, enabled, ErrStat, ErrMsg) ErrMsg = 'CD_HermiteCable_Dyn_Set_ForceBlend: model not initialised' RETURN END IF + IF (model%has_ctrl .AND. .NOT. enabled) THEN + ! active line control needs the committed-length treatment of the force blend + ErrStat = CD_HCDYN_BADINPUT + ErrMsg = 'CD_HermiteCable_Dyn_Set_ForceBlend: a model under active line control needs the force blend' + RETURN + END IF model%force_blend = enabled model%fc_valid = .FALSE. model%tr_valid = .FALSE. @@ -2333,14 +2825,15 @@ SUBROUTINE CD_HermiteCable_Dyn_Set_Held_Fluid(model, fluid_velocity, fluid_accel model%hf_wl = waterline_z model%has_held_field = .TRUE. IF (.NOT. had_field .AND. .NOT. model%a_restored) THEN - CALL solve_consistent_acceleration(model, ErrStat, ErrMsg) + CALL solve_committed_acceleration(model, ErrStat, ErrMsg) ELSE - CALL assemble_residual(model, model%q, model%v, model%t, .TRUE., .FALSE., es, em) + CALL assemble_committed_force(model, es, em) ErrStat = es ErrMsg = em IF (es == CD_HCDYN_OK .AND. model%force_blend) THEN ! This validation is the next step's committed force F_n = R(q_n, v_n, t_n) under the - ! new field, the evaluation the step would otherwise repeat: cache it, keyed as usual. + ! new field (at the committed lengths), the evaluation the step would otherwise repeat: + ! cache it, keyed as usual. model%fc_R = model%ws_R model%fc_q = model%q model%fc_v = model%v @@ -2767,9 +3260,10 @@ SUBROUTINE dyn_step_core(model, dt, max_iter, tol, ErrStat, ErrMsg, iters_out, r model%ws_an(pres_dofs(ip)) = model%a(pres_dofs(ip)) END DO END IF - ! Committed force F_n = R(q_n, v_n, t_n) with the current load configuration: reused - ! from the previous step's converged evaluation when its key matches the committed - ! state exactly, evaluated here otherwise (one residual assembly). + ! Committed force F_n = R(q_n, v_n, t_n) with the current load configuration and the + ! lengths the committed state was reached with (active line control: l0_c): reused from + ! the previous step's converged evaluation when its key matches the committed state + ! exactly, evaluated here otherwise (one residual assembly). fc_hit = .FALSE. IF (model%force_blend) fc_hit = force_cache_matches() ! Cross-step factor reuse needs the step to continue bitwise from the state the carried @@ -2781,7 +3275,7 @@ SUBROUTINE dyn_step_core(model, dt, max_iter, tol, ErrStat, ErrMsg, iters_out, r factor_ok = xs_active model%tr_valid = .FALSE. IF (model%force_blend .AND. .NOT. fc_hit) THEN - CALL assemble_residual(model, model%q, model%v, model%t, .TRUE., .FALSE., es, em2) + CALL assemble_committed_force(model, es, em2) IF (es /= CD_HCDYN_OK) THEN ErrStat = es; ErrMsg = 'CD_HermiteCable_Dyn_Step: '//TRIM(em2); RETURN END IF @@ -2823,6 +3317,11 @@ SUBROUTINE dyn_step_core(model, dt, max_iter, tol, ErrStat, ErrMsg, iters_out, r e_ma = e_ma + model%ws_inert(iv)**2 END DO use_ca = e_ma > CD_ZERO .AND. e_bal <= PRED_BALANCE**2*e_ma + ! Active line control: after a length or rate change the step's force departs from the + ! committed balance by the force of the change, a load step the constant-acceleration + ! guess does not anticipate; the step starts from the Newmark guess, which damps what + ! the change excites. + IF (use_ca .AND. model%has_ctrl) use_ca = lengths_committed() END IF ! The carried factor is used under the same smoothness test: through a transient it ! stops each step just inside the tolerance, and those states can lead the start-up of a @@ -3433,6 +3932,11 @@ SUBROUTINE dyn_step_core(model, dt, max_iter, tol, ErrStat, ErrMsg, iters_out, r model%fc_d0 = model%endconn_d0 model%fc_valid = .TRUE. END IF + ! The committed state was reached with the present lengths and rates. + IF (model%has_ctrl) THEN + model%l0_c = model%l0 + model%l0_dot_c = model%l0_dot + END IF ! Largest nodal tangent turn of the step (the time-step diagnostic). DO i = 1, model%nn model%max_step_rotation = MAX(model%max_step_rotation, & @@ -3482,6 +3986,19 @@ SUBROUTINE window_mean(slot, esx) win_done(slot) = .TRUE. END SUBROUTINE window_mean + LOGICAL FUNCTION lengths_committed() RESULT(ok) + !! The lengths and rates are those the committed state was reached with. + INTEGER :: ie + ok = .TRUE. + DO ie = 1, model%ne + IF (.NOT. (bits_equal(model%l0(ie), model%l0_c(ie)) .AND. & + bits_equal(model%l0_dot(ie), model%l0_dot_c(ie)))) THEN + ok = .FALSE. + RETURN + END IF + END DO + END FUNCTION lengths_committed + LOGICAL FUNCTION force_cache_matches() RESULT(ok) !! The cached F_n was evaluated at exactly the committed state and configuration. INTEGER :: ii @@ -3946,6 +4463,10 @@ SUBROUTINE CD_HermiteCable_Dyn_Step_Recovering(model, dt, max_iter, tol, ErrStat model%ws_recovery_v0 = model%v model%ws_recovery_a0 = model%a IF (model%fr_active) model%ws_recovery_fr = model%fr_anchor + IF (model%has_ctrl) THEN + model%ws_recovery_l0_c = model%l0_c + model%ws_recovery_l0_dot_c = model%l0_dot_c + END IF t_save = model%t na_steps_save = model%na_steps_done; na_sum_save = model%na_iter_sum; na_mn_save = model%na_mn_active tensile_events_save = model%tensile_event_count @@ -4033,6 +4554,8 @@ SUBROUTINE CD_HermiteCable_Dyn_Step_Recovering(model, dt, max_iter, tol, ErrStat model%q = q_save; model%v = v_save; model%a = a_save; model%t = t_save model%endconn_d0 = d0_save IF (model%fr_active) model%fr_anchor = model%ws_recovery_fr + IF (model%has_ctrl) model%l0_c = model%ws_recovery_l0_c + IF (model%has_ctrl) model%l0_dot_c = model%ws_recovery_l0_dot_c model%na_steps_done = na_steps_save; model%na_iter_sum = na_sum_save; model%na_mn_active = na_mn_save model%tensile_event_count = tensile_events_save model%tensile_worst_element = tensile_element_save @@ -4107,6 +4630,8 @@ SUBROUTINE CD_HermiteCable_Dyn_Step_Recovering(model, dt, max_iter, tol, ErrStat model%q = q_save; model%v = v_save; model%a = a_save; model%t = t_save model%endconn_d0 = d0_save IF (model%fr_active) model%fr_anchor = model%ws_recovery_fr + IF (model%has_ctrl) model%l0_c = model%ws_recovery_l0_c + IF (model%has_ctrl) model%l0_dot_c = model%ws_recovery_l0_dot_c model%na_steps_done = na_steps_save model%na_iter_sum = na_sum_save model%na_mn_active = na_mn_save @@ -4149,6 +4674,8 @@ SUBROUTINE CD_HermiteCable_Dyn_Step_Recovering(model, dt, max_iter, tol, ErrStat model%q = q_save; model%v = v_save; model%a = a_save; model%t = t_save model%endconn_d0 = d0_save IF (model%fr_active) model%fr_anchor = model%ws_recovery_fr + IF (model%has_ctrl) model%l0_c = model%ws_recovery_l0_c + IF (model%has_ctrl) model%l0_dot_c = model%ws_recovery_l0_dot_c model%na_steps_done = na_steps_save; model%na_iter_sum = na_sum_save; model%na_mn_active = na_mn_save model%tensile_event_count = tensile_events_save model%tensile_worst_element = tensile_element_save @@ -4617,8 +5144,14 @@ SUBROUTINE CD_HermiteCable_Dyn_End_Force(model, node, force, ErrStat, ErrMsg) END IF r3 = fe(i0 + 1:i0 + 3) IF (model%has_axial_damping) THEN - CALL CD_HermiteCable_Axial_Damping_Element(qe, ve, model%l0(e), model%BA(e), fdamp, ErrStat=es, ErrMsg=em2, & - quadrature_order=model%axial_quadrature_order) + IF (model%has_ctrl) THEN + CALL CD_HermiteCable_Axial_Damping_Element(qe, ve, model%l0(e), model%BA(e), fdamp, ErrStat=es, ErrMsg=em2, & + quadrature_order=model%axial_quadrature_order, & + l0_dot=model%l0_dot(e)) + ELSE + CALL CD_HermiteCable_Axial_Damping_Element(qe, ve, model%l0(e), model%BA(e), fdamp, ErrStat=es, ErrMsg=em2, & + quadrature_order=model%axial_quadrature_order) + END IF IF (es /= CD_HCDYN_OK) THEN ErrStat = CD_HCDYN_NOCONVERGE; ErrMsg = 'CD_HermiteCable_Dyn_End_Force: '//TRIM(em2); RETURN END IF @@ -5608,9 +6141,9 @@ SUBROUTINE torsion_cache_fill(model, ErrStat, ErrMsg) END SUBROUTINE torsion_cache_fill SUBROUTINE CD_HermiteCable_Dyn_Snapshot(model, ErrStat, ErrMsg) - !! Capture the committed step state (q, v, a, t) into the model-owned snapshot - !! buffers (see the type note: the aggregate stage-then-commit contract). Buffers - !! allocate on first use and are reused thereafter. + !! Capture the committed step state (q, v, a, t) and the unstretched lengths with their + !! rates into the model-owned snapshot buffers (see the type note: the aggregate + !! stage-then-commit contract). Buffers allocate on first use and are reused thereafter. TYPE(CD_HermiteCableDynType), INTENT(INOUT) :: model INTEGER, INTENT(OUT) :: ErrStat CHARACTER(*), INTENT(OUT) :: ErrMsg @@ -5622,11 +6155,24 @@ SUBROUTINE CD_HermiteCable_Dyn_Snapshot(model, ErrStat, ErrMsg) RETURN END IF IF (.NOT. ALLOCATED(model%snap_q)) THEN - ALLOCATE (model%snap_q(model%ndof), model%snap_v(model%ndof), model%snap_a(model%ndof)) + ALLOCATE (model%snap_q(model%ndof), model%snap_v(model%ndof), model%snap_a(model%ndof), & + model%snap_l0(model%ne), model%snap_l0_dot(model%ne), model%snap_l0_c(model%ne), & + model%snap_l0_dot_c(model%ne)) END IF model%snap_q = model%q model%snap_v = model%v model%snap_a = model%a + model%snap_l0 = model%l0 + model%snap_has_ctrl = model%has_ctrl + IF (model%has_ctrl) THEN + model%snap_l0_dot = model%l0_dot + model%snap_l0_c = model%l0_c + model%snap_l0_dot_c = model%l0_dot_c + ELSE + model%snap_l0_dot = CD_ZERO + model%snap_l0_c = model%l0 + model%snap_l0_dot_c = CD_ZERO + END IF model%snap_t = model%t model%snap_endconn_d0 = model%endconn_d0 model%snap_torsion_theta = model%torsion%theta @@ -5650,10 +6196,13 @@ END SUBROUTINE CD_HermiteCable_Dyn_Snapshot SUBROUTINE CD_HermiteCable_Dyn_Restore(model, ErrStat, ErrMsg) !! Restore the committed step state from the last Snapshot. Fails closed if no valid - !! snapshot exists (a restore must never silently run on stale or absent state). + !! snapshot exists (a restore must never silently run on stale or absent state). Lengths + !! changed by active line control since the snapshot come back with the caches built + !! from them, so no command need be re-applied. TYPE(CD_HermiteCableDynType), INTENT(INOUT) :: model INTEGER, INTENT(OUT) :: ErrStat CHARACTER(*), INTENT(OUT) :: ErrMsg + REAL(wp), ALLOCATABLE :: l0_restore(:) ErrStat = CD_HCDYN_OK ErrMsg = '' IF (.NOT. model%initialized) THEN @@ -5666,6 +6215,24 @@ SUBROUTINE CD_HermiteCable_Dyn_Restore(model, ErrStat, ErrMsg) ErrMsg = 'CD_HermiteCable_Dyn_Restore: no valid snapshot' RETURN END IF + ! Lengths first (active line control): when they moved since the snapshot, the + ! length-dependent caches are rebuilt from the snapshot lengths before any state is + ! written, so a failed rebuild leaves the model unchanged. + IF (.NOT. ALL(bits_equal(model%l0, model%snap_l0))) THEN + ! a copy, so no subobject of model is associated with a second dummy + l0_restore = model%snap_l0 + CALL rebuild_length_caches(model, l0_restore, ErrStat, ErrMsg) + IF (ErrStat /= CD_HCDYN_OK) THEN + ErrMsg = 'CD_HermiteCable_Dyn_Restore: '//TRIM(ErrMsg) + RETURN + END IF + END IF + model%has_ctrl = model%snap_has_ctrl + IF (model%has_ctrl) THEN + model%l0_dot = model%snap_l0_dot + model%l0_c = model%snap_l0_c + model%l0_dot_c = model%snap_l0_dot_c + END IF model%q = model%snap_q model%v = model%snap_v model%a = model%snap_a @@ -5700,7 +6267,17 @@ 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_mass)) DEALLOCATE (model%att_mass, model%att_madd) model%has_attach = .FALSE. + IF (ALLOCATED(model%l0_dot)) DEALLOCATE (model%l0_dot, model%l0_c, model%l0_dot_c, model%ws_recovery_l0_c, & + model%ws_recovery_l0_dot_c) + model%has_ctrl = .FALSE. + IF (ALLOCATED(model%seabed_diameter_elem)) DEALLOCATE (model%seabed_diameter_elem) + model%has_seabed_recompute = .FALSE. + model%seabed_kbot = CD_ZERO + model%seabed_cn_over_kn = CD_ZERO + IF (ALLOCATED(model%snap_l0)) DEALLOCATE (model%snap_l0, model%snap_l0_dot, model%snap_l0_c, model%snap_l0_dot_c) + model%snap_has_ctrl = .FALSE. IF (ALLOCATED(model%l0)) DEALLOCATE (model%l0) IF (ALLOCATED(model%EA)) DEALLOCATE (model%EA) IF (ALLOCATED(model%EI)) DEALLOCATE (model%EI) @@ -6035,10 +6612,19 @@ SUBROUTINE assemble_residual(model, q_cfg, v_cfg, t_eval, want_residual, want_ta qe(7:9) = q_cfg(6*e + 1:6*e + 3); qe(10:12) = q_cfg(6*e + 4:6*e + 6) ve(1:3) = v_cfg(6*(e - 1) + 1:6*(e - 1) + 3); ve(4:6) = v_cfg(6*(e - 1) + 4:6*(e - 1) + 6) ve(7:9) = v_cfg(6*e + 1:6*e + 3); ve(10:12) = v_cfg(6*e + 4:6*e + 6) - IF (want_tangent) THEN + IF (want_tangent .AND. model%has_ctrl) THEN + CALL CD_HermiteCable_Axial_Damping_Element(qe, ve, model%l0(e), model%BA(e), & + fdamp, kdq, kdv, es, em2, & + model%axial_quadrature_order, model%l0_dot(e)) + ELSE IF (want_tangent) THEN CALL CD_HermiteCable_Axial_Damping_Element(qe, ve, model%l0(e), model%BA(e), & fdamp, kdq, kdv, es, em2, & model%axial_quadrature_order) + ELSE IF (model%has_ctrl) THEN + CALL CD_HermiteCable_Axial_Damping_Element(qe, ve, model%l0(e), model%BA(e), & + fdamp, ErrStat=es, ErrMsg=em2, & + quadrature_order=model%axial_quadrature_order, & + l0_dot=model%l0_dot(e)) ELSE CALL CD_HermiteCable_Axial_Damping_Element(qe, ve, model%l0(e), model%BA(e), & fdamp, ErrStat=es, ErrMsg=em2, & @@ -6678,9 +7264,15 @@ SUBROUTINE evaluate_tangent_element(model, e, q_cfg, v_cfg, t_eval, Kstruct, Kdr END IF IF (model%has_axial_damping) THEN - CALL CD_HermiteCable_Axial_Damping_Element(qe, ve, model%l0(e), model%BA(e), & - fload, djq, djv, es, em, & - model%axial_quadrature_order) + IF (model%has_ctrl) THEN + CALL CD_HermiteCable_Axial_Damping_Element(qe, ve, model%l0(e), model%BA(e), & + fload, djq, djv, es, em, & + model%axial_quadrature_order, model%l0_dot(e)) + ELSE + CALL CD_HermiteCable_Axial_Damping_Element(qe, ve, model%l0(e), model%BA(e), & + fload, djq, djv, es, em, & + model%axial_quadrature_order) + END IF IF (es /= CD_HCDYN_OK) THEN ErrStat = CD_HCDYN_NOCONVERGE; ErrMsg = TRIM(em); RETURN END IF @@ -6756,13 +7348,15 @@ SUBROUTINE evaluate_tangent_element(model, e, q_cfg, v_cfg, t_eval, Kstruct, Kdr END IF END SUBROUTINE evaluate_tangent_element - SUBROUTINE CD_HermiteCable_Axial_Damping_Resultant(qe, ve, l0, BA, xi, resultant, ErrStat, ErrMsg) + SUBROUTINE CD_HermiteCable_Axial_Damping_Resultant(qe, ve, l0, BA, xi, resultant, ErrStat, ErrMsg, l0_dot) !! Signed viscous axial resultant N_v = BA*strain_rate at one material point. !! This is the damping share added to the elastic resultant for tension outputs. + !! l0_dot: the unstretched-length rate of a controlled element (see the element routine). REAL(wp), INTENT(IN) :: qe(12), ve(12), l0, BA, xi REAL(wp), INTENT(OUT) :: resultant INTEGER, INTENT(OUT) :: ErrStat CHARACTER(*), INTENT(OUT) :: ErrMsg + REAL(wp), INTENT(IN), OPTIONAL :: l0_dot REAL(wp) :: H(4), dH(4), r_xi(3), v_xi(3), speed INTEGER :: s @@ -6777,6 +7371,11 @@ SUBROUTINE CD_HermiteCable_Axial_Damping_Resultant(qe, ve, l0, BA, xi, resultant IF (.NOT. CD_All_Finite(qe) .OR. .NOT. CD_All_Finite(ve)) THEN CALL fail('qe and ve must be finite'); RETURN END IF + IF (PRESENT(l0_dot)) THEN + IF (.NOT. CD_Is_Finite(l0_dot)) THEN + CALL fail('l0_dot must be finite'); RETURN + END IF + END IF IF (.NOT. (BA > CD_ZERO)) RETURN CALL CD_HermiteCable_Shapes(xi, l0, H, dH) r_xi = CD_ZERO @@ -6789,6 +7388,7 @@ SUBROUTINE CD_HermiteCable_Axial_Damping_Resultant(qe, ve, l0, BA, xi, resultant IF (.NOT. CD_Is_Finite(speed) .OR. speed <= 1.0e-12_wp*MAX(CD_ONE, l0)) THEN CALL fail('collapsed or non-finite element tangent'); RETURN END IF + IF (PRESENT(l0_dot)) v_xi = v_xi - (l0_dot/l0)*(dH(1)*qe(1:3) + dH(3)*qe(7:9)) resultant = BA*DOT_PRODUCT(r_xi/speed, v_xi)/l0 IF (.NOT. CD_Is_Finite(resultant)) CALL fail('non-finite damping resultant') @@ -6802,7 +7402,7 @@ END SUBROUTINE fail END SUBROUTINE CD_HermiteCable_Axial_Damping_Resultant SUBROUTINE CD_HermiteCable_Axial_Damping_Element(qe, ve, l0, BA, fdamp, Kq, Kv, ErrStat, ErrMsg, & - quadrature_order) + quadrature_order, l0_dot) !! Consistent axial Kelvin-Voigt contribution for one cubic-Hermite element. !! The material coordinate is reference arc length s0 = l0*xi. With !! r_xi = dr/dxi, t = r_xi/|r_xi| and v_xi = dv/dxi, @@ -6812,16 +7412,30 @@ SUBROUTINE CD_HermiteCable_Axial_Damping_Element(qe, ve, l0, BA, fdamp, Kq, Kv, !! !! fdamp is an INTERNAL generalized force, so v dot fdamp is non-negative. !! Kq = d(fdamp)/dq and Kv = d(fdamp)/dv are exact analytical Jacobians. + !! + !! l0_dot (optional): the unstretched-length rate of an element under active line + !! control. The strain |r_xi|/l0 - 1 then also changes with l0: the material-tangent + !! terms of r_xi carry the factor l0 and cancel, so only the end-position part + !! p = dH_1 r_1 + dH_3 r_2 contributes, and the strain rate becomes + !! + !! strain_rate = t dot (v_xi - (l0_dot/l0) p) / l0, + !! + !! the rate of the strain the elastic resultant uses, so a segment paid out at constant + !! strain carries no damping force (the MoorDyn-F convention ldot - (l/L0) L0dot of the + !! EI = 0 lines, taken pointwise). Kq gains -BA dH_a dH_b (l0_dot/l0**2) t t^T on the + !! end-position columns b, and the transverse part of v_xi becomes that of the same + !! combination; Kv is unchanged. REAL(wp), INTENT(IN) :: qe(12), ve(12), l0, BA REAL(wp), INTENT(OUT) :: fdamp(12) REAL(wp), INTENT(OUT), OPTIONAL :: Kq(12, 12), Kv(12, 12) INTEGER, INTENT(OUT) :: ErrStat CHARACTER(*), INTENT(OUT) :: ErrMsg INTEGER, INTENT(IN), OPTIONAL :: quadrature_order + REAL(wp), INTENT(IN), OPTIONAL :: l0_dot REAL(wp) :: gp(6), gw(6), H(4), dH(4) REAL(wp) :: r_xi(3), v_xi(3), tangent(3), pperp(3), projector(3, 3) - REAL(wp) :: speed, strain_rate, scale_q, scale_v + REAL(wp) :: speed, strain_rate, scale_q, scale_v, rate_ratio INTEGER :: order, ig, s, sp, c, cp, ia, ib ErrStat = CD_HCDYN_OK @@ -6841,6 +7455,13 @@ SUBROUTINE CD_HermiteCable_Axial_Damping_Element(qe, ve, l0, BA, fdamp, Kq, Kv, IF (order < 1 .OR. order > 6) THEN CALL fail('quadrature_order must lie in [1,6]'); RETURN END IF + rate_ratio = CD_ZERO + IF (PRESENT(l0_dot)) THEN + IF (.NOT. CD_Is_Finite(l0_dot)) THEN + CALL fail('l0_dot must be finite'); RETURN + END IF + rate_ratio = l0_dot/l0 + END IF IF (.NOT. (BA > CD_ZERO)) RETURN CALL CD_HermiteCable_Gauss_Rule(order, gp, gw) @@ -6857,6 +7478,8 @@ SUBROUTINE CD_HermiteCable_Axial_Damping_Element(qe, ve, l0, BA, fdamp, Kq, Kv, CALL fail('collapsed or non-finite element tangent at a quadrature point'); RETURN END IF tangent = r_xi/speed + ! controlled element: the rate of the end-position part of r_xi at fixed q + IF (PRESENT(l0_dot)) v_xi = v_xi - rate_ratio*(dH(1)*qe(1:3) + dH(3)*qe(7:9)) strain_rate = DOT_PRODUCT(tangent, v_xi)/l0 projector = CD_ZERO DO c = 1, 3 @@ -6884,6 +7507,9 @@ SUBROUTINE CD_HermiteCable_Axial_Damping_Element(qe, ve, l0, BA, fdamp, Kq, Kv, scale_q = gw(ig)*BA*dH(s)*dH(sp)/speed Kq(ia, ib) = Kq(ia, ib) + scale_q*(strain_rate*projector(c, cp) + & tangent(c)*pperp(cp)/l0) + ! the length-rate term depends on the end positions (sp = 1, 3) only + IF (PRESENT(l0_dot) .AND. MOD(sp, 2) == 1) & + Kq(ia, ib) = Kq(ia, ib) - gw(ig)*BA*dH(s)*dH(sp)*(rate_ratio/l0)*tangent(c)*tangent(cp) END IF END DO END DO diff --git a/src/CableDyn_Model.f90 b/src/CableDyn_Model.f90 index a3198b82..631fc344 100644 --- a/src/CableDyn_Model.f90 +++ b/src/CableDyn_Model.f90 @@ -62,6 +62,7 @@ MODULE CableDyn_Model USE CableDyn_Linalg, ONLY: CD_Solve_Dense_As_Banded, CD_Solve_Dense_As_Banded_Multiple, CD_Factor_Banded, & CD_Solve_Factored_Banded_Multiple USE CableDyn_Profile, ONLY: CD_Profile_Count_Line_Step + USE, INTRINSIC :: ISO_FORTRAN_ENV, ONLY: INT64 IMPLICIT NONE PRIVATE @@ -97,6 +98,7 @@ MODULE CableDyn_Model PUBLIC :: CD_Set_Model_EndQuery PUBLIC :: CD_Get_Model_EndQuery PUBLIC :: CD_Update_Model_SegmentLength + PUBLIC :: CD_ModelControlSaveType, CD_Save_Model_Control, CD_Restore_Model_Control PUBLIC :: CD_Calc_Model_CoupledLoads PUBLIC :: CD_Calc_Model_CoupledKinematicDerivatives PUBLIC :: CD_Calc_Model_CoupledAccelDerivative, CD_Update_Model_CoupledAccelDerivative @@ -140,7 +142,7 @@ MODULE CableDyn_Model ! slots. commit_state_copy holds the one list of that state. TYPE :: CD_ModelCommitSlot REAL(wp), ALLOCATABLE :: q(:), v(:), a(:), ve_dl_1(:), syrope_slow(:), syrope_tmax(:) - REAL(wp), ALLOCATABLE :: fr_anchor(:, :) + REAL(wp), ALLOCATABLE :: fr_anchor(:, :), l0_c(:), l0_dot_c(:) END TYPE CD_ModelCommitSlot ! Diagnostics of the rotation- and snap-resolved sub-stepping (CD_Step_Model): calls counts @@ -155,6 +157,20 @@ MODULE CableDyn_Model INTEGER :: max_used = 1 END TYPE CD_SubstepStats + TYPE :: CD_ModelControlSaveType + !! What CD_Update_Model_SegmentLength writes, as CD_Save_Model_Control found it. + LOGICAL :: valid = .FALSE. + REAL(wp), ALLOCATABLE :: l0(:), l0_dot(:), l0_c(:), l0_dot_c(:), f_ext(:), seabed_kn(:), seabed_cn(:) + END TYPE CD_ModelControlSaveType + + TYPE :: model_lengths_aside + !! The present lengths and rates, and the external load and seabed coefficients that follow + !! the lengths, that enter_committed_lengths set aside (leave_committed_lengths moves them + !! back). + LOGICAL :: active = .FALSE. + REAL(wp), ALLOCATABLE :: l0(:), l0_dot(:), f_ext(:), kn(:), cn(:) + END TYPE model_lengths_aside + TYPE :: CD_ModelType !! Persistent positions-only EI=0 model state and immutable mesh/properties. LOGICAL :: initialized = .FALSE. @@ -170,6 +186,17 @@ MODULE CableDyn_Model ! until CD_Update_Model_SegmentLength sets it). Feeds the axial-damping ! effective stretch rate. REAL(wp), ALLOCATABLE :: l0_dot(:) + ! The unstretched lengths and rates the committed state was reached with (active line + ! control), so the committed state keeps its own lengths in the generalised-alpha blend of + ! the step that follows a length change (CD_Step_Model). With the force blend the step-start + ! force takes l0_c and l0_dot_c (with the external load and seabed coefficients of l0_c), + ! the end-of-step force the present lengths and rates, and only the inertia the blended + ! lengths (1 - alpha_f) l0 + alpha_f l0_c; under False alpha_force_blend every alpha-level + ! term takes the blended lengths and rates. Each successful step makes the present lengths + ! the committed ones. l0_c_rollback / recovery_l0_c are the copies of the system + ! stage-then-commit and of the recovering step. + REAL(wp), ALLOCATABLE :: l0_c(:), l0_dot_c(:) + REAL(wp), ALLOCATABLE :: l0_c_rollback(:), l0_dot_c_rollback(:), recovery_l0_c(:), recovery_l0_dot_c(:) ! Per-element distributed load per unit LENGTH (3, n_elem) plus the ! NON-distributed remainder of the init f_ext, stored when the caller supplies ! the per-length load: a segment-length update REASSEMBLES the distributed part @@ -362,13 +389,16 @@ MODULE CableDyn_Model ! parameter of the line, copied with the model). The other sub_* arrays are scratch: ! sub_slot(1) the committed state at the step start, sub_slot(2) the state the plain step ! reached, sub_t0 and sub_t1 the segment tensions at the step start and end, and - ! sub_pq/pv/pa the sub-step boundary motion. + ! sub_pq/pv/pa the sub-step boundary motion, sub_target the lengths, rates, external load + ! and seabed coefficients a pending length change (active line control) sets for the end of + ! the step (CD_Save_Model_Control). TYPE(CD_SubstepStats) :: sub_stats, sub_stats_rollback REAL(wp) :: sub_t_init = CD_ZERO ! audit_hmax at the last save of the system-rollback state (CableDyn_System) REAL(wp) :: audit_hmax_rollback = CD_ZERO TYPE(CD_ModelCommitSlot) :: sub_slot(2) REAL(wp), ALLOCATABLE :: sub_t0(:), sub_t1(:), sub_pq(:), sub_pv(:), sub_pa(:) + TYPE(CD_ModelControlSaveType) :: sub_target ! TEST-ONLY hooks of the sub-stepping, never set by a production caller: sub_test_fail > 0 ! makes sub-step number sub_test_fail of every sub-stepped pass report a failure, and ! sub_test_repeat solves the first sub-stepped pass twice (the second from the restored @@ -911,6 +941,8 @@ SUBROUTINE CD_Init_Model(model, q0, v0, elem_conn, l0, ea, rho_a, tension_only, model%cfg = cfg ALLOCATE (model%elem_conn(2, n_elem), model%fixed_dofs(SIZE(fixed_dofs)), & model%l0(n_elem), model%ea(n_elem), model%ea_dyn(n_elem), model%rho_a(n_elem), model%l0_dot(n_elem), & + model%l0_c(n_elem), model%l0_dot_c(n_elem), model%l0_c_rollback(n_elem), & + model%l0_dot_c_rollback(n_elem), model%recovery_l0_c(n_elem), model%recovery_l0_dot_c(n_elem), & model%f_ext(n_dof), & model%q(n_dof), model%v(n_dof), model%a(n_dof), & model%q_step(n_dof), model%v_step(n_dof), model%a_step(n_dof), & @@ -926,6 +958,12 @@ SUBROUTINE CD_Init_Model(model, q0, v0, elem_conn, l0, ea, rho_a, tension_only, model%fixed_dofs = fixed_dofs model%l0 = l0 model%l0_dot = CD_ZERO + model%l0_c = l0 + model%l0_dot_c = CD_ZERO + model%l0_c_rollback = l0 + model%l0_dot_c_rollback = CD_ZERO + model%recovery_l0_c = l0 + model%recovery_l0_dot_c = CD_ZERO model%ea = ea model%ea_dyn = ea model%rho_a = rho_a @@ -1948,6 +1986,19 @@ SUBROUTINE CD_Step_Model(model, dt, converged, stalled, n_iter, ErrStat, ErrMsg, !! needs the end reaction and tangent of the nominal step. as_given = .TRUE. takes the step !! as given as well: the stall recoveries of CD_Step_Model_Recovering and CD_Step_System, !! whose sub-steps are themselves part of a recovery, pass it. + !! + !! A pending length change (active line control: CD_Update_Model_SegmentLength set lengths + !! or rates that differ from those the committed state was reached with, l0_c and l0_dot_c) + !! is spread over the sub-steps. The committed lengths are part of the state each pass + !! starts from (commit_state_copy). Sub-step k of n ends at the lengths and rates + !! interpolated linearly in time between the committed ones and the new ones at k/n, with + !! the external load and seabed coefficients rebuilt at those lengths as + !! CD_Update_Model_SegmentLength builds them, and the last sub-step ends at the new lengths, + !! rates, external load and seabed coefficients bit for bit. Each sub-step treats its own + !! start and end lengths as the plain step treats the committed and new ones, so the first + !! starts at the committed lengths. (A constant pay-out rate, the usual command, makes the + !! interpolated lengths those its rate integrates to.) The trigger takes the step-start + !! tensions and slack classification at the committed lengths. TYPE(CD_ModelType), INTENT(INOUT) :: model REAL(wp), INTENT(IN) :: dt LOGICAL, INTENT(OUT) :: converged, stalled @@ -1956,9 +2007,10 @@ SUBROUTINE CD_Step_Model(model, dt, converged, stalled, n_iter, ErrStat, ErrMsg, REAL(wp), INTENT(IN), OPTIONAL :: prescribed_q(:), prescribed_v(:), prescribed_a(:) LOGICAL, INTENT(IN), OPTIONAL :: as_given INTEGER :: nsub, nsub2, iter_trial - LOGICAL :: has_pres, resolve, capped, capped2, ok + LOGICAL :: has_pres, resolve, capped, capped2, ok, pending has_pres = PRESENT(prescribed_q) .AND. PRESENT(prescribed_v) .AND. PRESENT(prescribed_a) + pending = .FALSE. resolve = model%initialized .AND. model%cfg%ei0_substeps == CD_EI0_SUBSTEPS_AUTO .AND. & .NOT. model%dynamic_workspace%end_request IF (resolve .AND. PRESENT(as_given)) resolve = .NOT. as_given @@ -1969,8 +2021,23 @@ SUBROUTINE CD_Step_Model(model, dt, converged, stalled, n_iter, ErrStat, ErrMsg, resolve = sub_alloc(model, has_pres) IF (resolve) THEN CALL sub_store(model, 1) - ! the segment tensions at the step start, for the trigger (sub_count) - CALL sub_tensions_scratch(model, 0) + ! the segment tensions at the step start, for the trigger (sub_count), at the lengths + ! the committed state was reached with + pending = .NOT. model_lengths_committed(model) + IF (pending) THEN + CALL CD_Save_Model_Control(model, model%sub_target) + BLOCK + TYPE(model_lengths_aside) :: aside + INTEGER :: es_c + CHARACTER(160) :: em_c + ! without the loads nothing is rebuilt, so this cannot fail + CALL enter_committed_lengths(model, aside, .FALSE., es_c, em_c) + CALL sub_tensions_scratch(model, 0) + CALL leave_committed_lengths(model, aside) + END BLOCK + ELSE + CALL sub_tensions_scratch(model, 0) + END IF END IF END IF IF (.NOT. resolve) THEN @@ -2029,6 +2096,7 @@ SUBROUTINE CD_Step_Model(model, dt, converged, stalled, n_iter, ErrStat, ErrMsg, END IF ! a sub-step failed: return the plain step's own (converged) result CALL sub_load(model, 2) + IF (pending) CALL sub_lengths_target(model) converged = .TRUE. stalled = .FALSE. n_iter = iter_trial @@ -2052,6 +2120,19 @@ SUBROUTINE run_substeps(n, ok_run) h = dt/REAL(n, wp) ok_run = .TRUE. DO k = 1, n + ! a pending length change: the lengths at the sub-step end (the new ones at the last) + IF (pending) THEN + IF (k == n) THEN + CALL sub_lengths_target(model) + ELSE + CALL sub_lengths_at(model, REAL(k, wp)/REAL(n, wp), es_k) + IF (es_k /= CD_MODEL_OK) THEN + CALL sub_lengths_target(model) + ok_run = .FALSE. + RETURN + END IF + END IF + END IF IF (has_pres) THEN IF (k == n) THEN model%sub_pq = prescribed_q @@ -2069,6 +2150,7 @@ SUBROUTINE run_substeps(n, ok_run) END IF IF (k == model%sub_test_fail) conv_k = .FALSE. IF (es_k /= CD_MODEL_OK .OR. .NOT. conv_k) THEN + IF (pending) CALL sub_lengths_target(model) ok_run = .FALSE. RETURN END IF @@ -2093,6 +2175,11 @@ LOGICAL FUNCTION sub_alloc(model, has_pres) RESULT(ok) ALLOCATE (s%q(model%n_dof), s%v(model%n_dof), s%a(model%n_dof), STAT=istat) IF (istat /= 0) RETURN END IF + IF (.NOT. sized(s%l0_c, model%n_elem)) THEN + IF (ALLOCATED(s%l0_c)) DEALLOCATE (s%l0_c, s%l0_dot_c) + ALLOCATE (s%l0_c(model%n_elem), s%l0_dot_c(model%n_elem), STAT=istat) + IF (istat /= 0) RETURN + END IF IF (model%has_viscoelastic) THEN IF (.NOT. sized(s%ve_dl_1, SIZE(model%ve_dl_1))) THEN IF (ALLOCATED(s%ve_dl_1)) DEALLOCATE (s%ve_dl_1) @@ -2146,14 +2233,16 @@ LOGICAL FUNCTION sized(x, n) RESULT(yes) END FUNCTION sized END FUNCTION sub_alloc - SUBROUTINE commit_state_copy(model, to_model, q, v, a, ve_dl_1, syrope_slow, syrope_tmax, fr_anchor) + SUBROUTINE commit_state_copy(model, to_model, q, v, a, ve_dl_1, syrope_slow, syrope_tmax, fr_anchor, & + l0_c, l0_dot_c) !! The one list of the state a line step commits: the kinematics, the viscoelastic dl_1, the - !! Syrope slow strain and running maximum tension, and the friction anchors. to_model = + !! Syrope slow strain and running maximum tension, the friction anchors, and the unstretched + !! lengths and rates the committed state was reached with (l0_c, l0_dot_c, active line + !! control). to_model = !! .FALSE. saves the model's state into the arrays given, .TRUE. returns the model to them. !! Every snapshot of the committed state in this module goes through here (the sub-step !! slots of CD_Step_Model, save_recovery_state and restore_recovery_state). A state a step - !! comes to commit (such as the segment length of a line under active tension control) is - !! added here, as an optional array its snapshots pass; the rollback of the line system + !! comes to commit is added here, as an optional array its snapshots pass; the rollback of the line system !! (CableDyn_System: save_line_states, restore_line_states, CD_System_Snapshot and the !! frame snapshot of CD_Step_System) lists the same state and must follow. An optional array !! is passed as an allocatable that is allocated with the state it holds, so it is absent @@ -2162,6 +2251,7 @@ SUBROUTINE commit_state_copy(model, to_model, q, v, a, ve_dl_1, syrope_slow, syr LOGICAL, INTENT(IN) :: to_model REAL(wp), INTENT(INOUT) :: q(:), v(:), a(:) REAL(wp), INTENT(INOUT), OPTIONAL :: ve_dl_1(:), syrope_slow(:), syrope_tmax(:), fr_anchor(:, :) + REAL(wp), INTENT(INOUT), OPTIONAL :: l0_c(:), l0_dot_c(:) IF (to_model) THEN model%q = q model%v = v @@ -2172,6 +2262,10 @@ SUBROUTINE commit_state_copy(model, to_model, q, v, a, ve_dl_1, syrope_slow, syr model%syrope_tmax = syrope_tmax END IF IF (model%has_seabed_friction .AND. PRESENT(fr_anchor)) model%fr_anchor = fr_anchor + IF (PRESENT(l0_c) .AND. PRESENT(l0_dot_c)) THEN + model%l0_c = l0_c + model%l0_dot_c = l0_dot_c + END IF ELSE q = model%q v = model%v @@ -2182,6 +2276,10 @@ SUBROUTINE commit_state_copy(model, to_model, q, v, a, ve_dl_1, syrope_slow, syr syrope_tmax = model%syrope_tmax END IF IF (model%has_seabed_friction .AND. PRESENT(fr_anchor)) fr_anchor = model%fr_anchor + IF (PRESENT(l0_c) .AND. PRESENT(l0_dot_c)) THEN + l0_c = model%l0_c + l0_dot_c = model%l0_dot_c + END IF END IF END SUBROUTINE commit_state_copy @@ -2191,7 +2289,8 @@ SUBROUTINE sub_store(model, slot) INTEGER, INTENT(IN) :: slot CALL commit_state_copy(model, .FALSE., model%sub_slot(slot)%q, model%sub_slot(slot)%v, model%sub_slot(slot)%a, & model%sub_slot(slot)%ve_dl_1, model%sub_slot(slot)%syrope_slow, & - model%sub_slot(slot)%syrope_tmax, model%sub_slot(slot)%fr_anchor) + model%sub_slot(slot)%syrope_tmax, model%sub_slot(slot)%fr_anchor, & + model%sub_slot(slot)%l0_c, model%sub_slot(slot)%l0_dot_c) END SUBROUTINE sub_store SUBROUTINE sub_load(model, slot) @@ -2200,9 +2299,83 @@ SUBROUTINE sub_load(model, slot) INTEGER, INTENT(IN) :: slot CALL commit_state_copy(model, .TRUE., model%sub_slot(slot)%q, model%sub_slot(slot)%v, model%sub_slot(slot)%a, & model%sub_slot(slot)%ve_dl_1, model%sub_slot(slot)%syrope_slow, & - model%sub_slot(slot)%syrope_tmax, model%sub_slot(slot)%fr_anchor) + model%sub_slot(slot)%syrope_tmax, model%sub_slot(slot)%fr_anchor, & + model%sub_slot(slot)%l0_c, model%sub_slot(slot)%l0_dot_c) END SUBROUTINE sub_load + SUBROUTINE sub_lengths_target(model) + !! Put back the lengths, rates, external load and seabed coefficients a pending length + !! change set for the end of the step (sub_target, saved by CD_Step_Model), bit for bit; the + !! committed lengths are left as they are. + TYPE(CD_ModelType), INTENT(INOUT) :: model + model%l0 = model%sub_target%l0 + model%l0_dot = model%sub_target%l0_dot + model%f_ext = model%sub_target%f_ext + IF (ALLOCATED(model%sub_target%seabed_kn)) model%seabed_kn = model%sub_target%seabed_kn + IF (ALLOCATED(model%sub_target%seabed_cn)) model%seabed_cn = model%sub_target%seabed_cn + END SUBROUTINE sub_lengths_target + + SUBROUTINE sub_lengths_at(model, frac, ErrStat) + !! The lengths and rates at the fraction frac of a sub-stepped interval with a pending length + !! change: interpolated linearly in time between those of the committed state at the + !! interval start (sub_slot(1)) and the new ones (sub_target), an element whose length or + !! rate does not change keeping it bit for bit; the external load and the seabed + !! coefficients that follow the lengths are rebuilt at them with the helpers + !! CD_Update_Model_SegmentLength uses (those of the new lengths when no length changes). + !! On failure the model is left as it was. + TYPE(CD_ModelType), INTENT(INOUT) :: model + REAL(wp), INTENT(IN) :: frac + INTEGER, INTENT(OUT) :: ErrStat + REAL(wp) :: l0_k(model%n_elem), l0_dot_k(model%n_elem), f_dist(model%n_dof) + REAL(wp), ALLOCATABLE :: kn_k(:) + REAL(wp) :: a, b + INTEGER :: e, es + LOGICAL :: moved + CHARACTER(160) :: em + ErrStat = CD_MODEL_OK + moved = .FALSE. + DO e = 1, model%n_elem + a = model%sub_slot(1)%l0_c(e) + b = model%sub_target%l0(e) + l0_k(e) = b + IF (.NOT. bits_equal(a, b)) THEN + l0_k(e) = a + frac*(b - a) + moved = .TRUE. + END IF + a = model%sub_slot(1)%l0_dot_c(e) + b = model%sub_target%l0_dot(e) + l0_dot_k(e) = b + IF (.NOT. bits_equal(a, b)) l0_dot_k(e) = positive_zero(a + frac*(b - a)) + END DO + IF (moved .AND. ALLOCATED(model%dist_load)) THEN + CALL CD_Assemble_Distributed_Load(model%elem_conn, l0_k, model%dist_load, f_dist, es, em) + IF (es /= 0) THEN + ErrStat = CD_MODEL_BADINPUT + RETURN + END IF + f_dist = model%f_ext_dist_base + f_dist + IF (.NOT. CD_All_Finite(f_dist)) THEN + ErrStat = CD_MODEL_BADINPUT + RETURN + END IF + END IF + IF (moved .AND. model%has_seabed .AND. model%has_seabed_recompute) THEN + CALL CD_Nodal_Seabed_Stiffness(model%seabed_kbot, model%seabed_diameter_elem, l0_k, kn_k, es, em) + IF (es /= 0) THEN + ErrStat = CD_MODEL_BADINPUT + RETURN + END IF + END IF + CALL sub_lengths_target(model) + model%l0 = l0_k + model%l0_dot = l0_dot_k + IF (moved .AND. ALLOCATED(model%dist_load)) model%f_ext = f_dist + IF (ALLOCATED(kn_k)) THEN + CALL MOVE_ALLOC(kn_k, model%seabed_kn) + IF (ALLOCATED(model%seabed_cn)) model%seabed_cn = model%seabed_kn*model%seabed_cn_over_kn + END IF + END SUBROUTINE sub_lengths_at + SUBROUTINE sub_tensions(model, tension) !! The segment tensions at the model's committed state as the run audit takes them !! (CD_Audit_Model_Step): the dynamic EA times the strain of an elastic segment, the law's @@ -2291,9 +2464,9 @@ SUBROUTINE sub_count(model, dt, nsub, capped) !! scale (the largest step-start tension, at least SUB_TAUT_FRACTION of sub_t_init); at least !! SUB_SNAP_STEPS when a segment slack at the start ends above SUB_SNAP_FRACTION of the scale !! and its axial wave crosses it more than once in dt. The tensions are those of - !! sub_tensions. The strains use model%l0, the lengths the step itself uses - !! (CD_Update_Model_SegmentLength sets them before the step); a length that changes within - !! the step would need its step-start value for the start state here. + !! sub_tensions. The end state takes the present lengths model%l0, the start state the + !! lengths it was reached with (slot 1's l0_c; the same bits unless a length change is + !! pending, see CD_Step_Model). TYPE(CD_ModelType), INTENT(INOUT) :: model REAL(wp), INTENT(IN) :: dt INTEGER, INTENT(OUT) :: nsub @@ -2318,7 +2491,7 @@ SUBROUTINE sub_count(model, dt, nsub, capped) te = model%sub_t1(e) d0 = model%sub_slot(1)%q(3*nb - 2:3*nb) - model%sub_slot(1)%q(3*na - 2:3*na) l_s = NORM2(d0) - IF (.NOT. snap .AND. l_s <= model%l0(e) .AND. te > SUB_SNAP_FRACTION*scale) THEN + IF (.NOT. snap .AND. l_s <= model%sub_slot(1)%l0_c(e) .AND. te > SUB_SNAP_FRACTION*scale) THEN courant = dt*SQRT(segment_wave_stiffness(model, e, te)/model%rho_a(e))/model%l0(e) IF (courant > CD_ONE) snap = .TRUE. END IF @@ -2366,9 +2539,13 @@ SUBROUTINE step_model_plain(model, dt, converged, stalled, n_iter, ErrStat, ErrM CHARACTER(*), INTENT(OUT) :: ErrMsg REAL(wp), INTENT(IN), OPTIONAL :: prescribed_q(:), prescribed_v(:), prescribed_a(:) - INTEGER :: es + INTEGER :: es, e CHARACTER(160) :: em - LOGICAL :: has_load + LOGICAL :: has_load, blend, force_lengths + REAL(wp) :: af + REAL(wp), ALLOCATABLE :: l0_new(:), l0_dot_new(:), l0_start(:), l0_mass(:), f_ext_new(:), f_ext_c(:) + REAL(wp), ALLOCATABLE :: l0_dot_start(:) + TYPE(model_lengths_aside) :: aside converged = .FALSE. stalled = .FALSE. @@ -2405,70 +2582,70 @@ SUBROUTINE step_model_plain(model, dt, converged, stalled, n_iter, ErrStat, ErrM ! whose tension (tension_start_work) the release cap of the step bounds like the elastic ! tension. A warm re-solve of the same step (the junction coupling re-steps the line from ! the same committed state with moved ends) reuses the load of the previous call. - IF (.NOT. (has_load .AND. model%cfg%force_blend)) THEN - model%load_start_valid = .FALSE. - ELSE IF (.NOT. (model%dynamic_workspace%guess_armed .AND. model%load_start_valid)) THEN - model%load_start_valid = .FALSE. - IF (ALLOCATED(model%load_start_work)) THEN - IF (SIZE(model%load_start_work) /= model%n_dof) DEALLOCATE (model%load_start_work) - END IF - IF (.NOT. ALLOCATED(model%load_start_work)) THEN - ALLOCATE (model%load_start_work(model%n_dof), STAT=es) - IF (es /= 0) THEN - ErrStat = CD_MODEL_ALLOCFAIL - ErrMsg = 'CableDyn_Model: step-start load workspace allocation failed' - RETURN - END IF - END IF - ! tension_start_work stays unallocated without a viscoelastic or Syrope element, and the - ! step then sees start_tension absent - IF (ALLOCATED(model%tension_start_work)) THEN - IF (SIZE(model%tension_start_work) /= model%n_elem .OR. & - .NOT. (model%has_viscoelastic .OR. model%has_syrope)) DEALLOCATE (model%tension_start_work) - END IF - IF ((model%has_viscoelastic .OR. model%has_syrope) .AND. .NOT. ALLOCATED(model%tension_start_work)) THEN - ALLOCATE (model%tension_start_work(model%n_elem), STAT=es) - IF (es /= 0) THEN - ErrStat = CD_MODEL_ALLOCFAIL - ErrMsg = 'CableDyn_Model: step-start tension workspace allocation failed' - RETURN - END IF - END IF - IF (ALLOCATED(model%stiffness_start_work)) THEN - IF (.NOT. ALLOCATED(model%tension_start_work)) THEN - DEALLOCATE (model%stiffness_start_work) - ELSE IF (SIZE(model%stiffness_start_work) /= model%n_elem) THEN - DEALLOCATE (model%stiffness_start_work) - END IF - END IF - IF (ALLOCATED(model%tension_start_work) .AND. .NOT. ALLOCATED(model%stiffness_start_work)) THEN - ALLOCATE (model%stiffness_start_work(model%n_elem), STAT=es) - IF (es /= 0) THEN - ErrStat = CD_MODEL_ALLOCFAIL - ErrMsg = 'CableDyn_Model: step-start stiffness workspace allocation failed' - RETURN - END IF - END IF - model%ve_dt = CD_ZERO - IF (ALLOCATED(model%tension_start_work)) THEN - CALL model_contributor_force(model, model%q, model%v, model%load_start_work, es, em, & - law_tension=model%tension_start_work, & - law_stiffness=model%stiffness_start_work) - ELSE - CALL model_contributor_force(model, model%q, model%v, model%load_start_work, es, em) - END IF + ! + ! Active line control: after a length or rate change the committed state keeps the lengths + ! and rates it was reached with (l0_c, l0_dot_c), and the step that follows treats them as + ! the generalised-alpha form requires. With the force blend, r(q_{n+1}, v_{n+1}) takes the + ! present lengths, rates, external load and seabed coefficients, and r(q_n, v_n) those of + ! the committed state: its load (here) and its internal force and release-cap data (the + ! step's start_l0) are evaluated at l0_c and l0_dot_c, with the distributed load and the + ! recomputed seabed coefficients rebuilt at l0_c (enter_committed_lengths), and the + ! constant external load of the step blends the two, (1 - alpha_f) f_ext + alpha_f f_ext_c. + ! The inertia, which the force blend keeps at the alpha level (M a_alpha, the added mass + ! at q_alpha), takes the blended lengths (1 - alpha_f) l0 + alpha_f l0_c. Under + ! False alpha_force_blend every alpha-level term (internal force, damping, hydrodynamic + ! loads, the structural and added mass) takes the blended lengths and rates, with the + ! present external load and seabed coefficients. Either way the lengths are blended element + ! by element and only where they differ, the new lengths come back with the state at + ! t_{n+1}, and an unchanged model takes the plain path. + blend = .NOT. model_lengths_committed(model) + force_lengths = blend .AND. model%cfg%force_blend + af = model%cfg%rho_inf/(model%cfg%rho_inf + CD_ONE) + IF (force_lengths) THEN + CALL enter_committed_lengths(model, aside, .TRUE., es, em) IF (es /= CD_MODEL_OK) THEN ErrStat = es - ErrMsg = 'CableDyn_Model: step-start load failed: '//TRIM(em) + ErrMsg = 'CableDyn_Model: step-start lengths: '//TRIM(em) RETURN END IF - model%load_start_valid = .TRUE. + IF (ALLOCATED(aside%f_ext)) f_ext_c = model%f_ext END IF + CALL step_start_load(ErrStat, ErrMsg) + IF (force_lengths) CALL leave_committed_lengths(model, aside) + IF (ErrStat /= CD_MODEL_OK) RETURN ! arm the viscoelastic contributors with the step size: in-step load ! evaluations use the backward-Euler-eliminated dl_1(q, v); it is reset to ! the instantaneous limit (0) on EVERY exit below so committed-state queries ! (coupled loads, tension) never see a stale step size model%ve_dt = dt + IF (force_lengths) THEN + ! the release cap's step-start dashpot takes the committed rates (start_l0_rate) + l0_dot_start = model%l0_dot_c + IF (.NOT. ALL(bits_equal(model%l0, model%l0_c))) THEN + l0_start = model%l0_c + l0_mass = model%l0 + DO e = 1, model%n_elem + IF (.NOT. bits_equal(model%l0(e), model%l0_c(e))) & + l0_mass(e) = (CD_ONE - af)*model%l0(e) + af*model%l0_c(e) + END DO + END IF + IF (ALLOCATED(f_ext_c)) THEN + f_ext_new = model%f_ext + DO e = 1, model%n_dof + IF (.NOT. bits_equal(f_ext_new(e), f_ext_c(e))) & + model%f_ext(e) = (CD_ONE - af)*f_ext_new(e) + af*f_ext_c(e) + END DO + END IF + ELSE IF (blend) THEN + l0_new = model%l0 + l0_dot_new = model%l0_dot + DO e = 1, model%n_elem + IF (.NOT. bits_equal(l0_new(e), model%l0_c(e))) & + model%l0(e) = (CD_ONE - af)*l0_new(e) + af*model%l0_c(e) + IF (.NOT. bits_equal(l0_dot_new(e), model%l0_dot_c(e))) & + model%l0_dot(e) = (CD_ONE - af)*l0_dot_new(e) + af*model%l0_dot_c(e) + END DO + END IF IF (PRESENT(prescribed_q) .AND. has_load .AND. model%has_added_mass) THEN CALL CD_Cable_Gen_Alpha_Step(model%q, model%v, model%a, model%elem_conn, model%l0, model%ea_dyn, & model%rho_a, model%tension_only, model%f_ext, model%fixed_dofs, & @@ -2480,7 +2657,8 @@ SUBROUTINE step_model_plain(model, dt, converged, stalled, n_iter, ErrStat, ErrM workspace=model%dynamic_workspace, start_load=model%load_start_work, & start_tension=model%tension_start_work, & start_stiffness=model%stiffness_start_work, & - axial_damping=model%ba_dyn, axial_l0_rate=model%l0_dot) + axial_damping=model%ba_dyn, axial_l0_rate=model%l0_dot, & + start_l0=l0_start, mass_l0=l0_mass, start_l0_rate=l0_dot_start) ELSE IF (PRESENT(prescribed_q) .AND. has_load) THEN CALL CD_Cable_Gen_Alpha_Step(model%q, model%v, model%a, model%elem_conn, model%l0, model%ea_dyn, & model%rho_a, model%tension_only, model%f_ext, model%fixed_dofs, & @@ -2491,7 +2669,8 @@ SUBROUTINE step_model_plain(model, dt, converged, stalled, n_iter, ErrStat, ErrM prescribed_a=prescribed_a, workspace=model%dynamic_workspace, & start_load=model%load_start_work, start_tension=model%tension_start_work, & start_stiffness=model%stiffness_start_work, & - axial_damping=model%ba_dyn, axial_l0_rate=model%l0_dot) + axial_damping=model%ba_dyn, axial_l0_rate=model%l0_dot, & + start_l0=l0_start, mass_l0=l0_mass, start_l0_rate=l0_dot_start) ELSE IF (PRESENT(prescribed_q) .AND. model%has_added_mass) THEN CALL CD_Cable_Gen_Alpha_Step(model%q, model%v, model%a, model%elem_conn, model%l0, model%ea_dyn, & model%rho_a, model%tension_only, model%f_ext, model%fixed_dofs, & @@ -2499,14 +2678,16 @@ SUBROUTINE step_model_plain(model, dt, converged, stalled, n_iter, ErrStat, ErrM n_iter, & es, em, added_mass_band_proc=model_added_mass_band, prescribed_q=prescribed_q, & prescribed_v=prescribed_v, prescribed_a=prescribed_a, & - workspace=model%dynamic_workspace) + workspace=model%dynamic_workspace, & + start_l0=l0_start, mass_l0=l0_mass) ELSE IF (PRESENT(prescribed_q)) THEN CALL CD_Cable_Gen_Alpha_Step(model%q, model%v, model%a, model%elem_conn, model%l0, model%ea_dyn, & model%rho_a, model%tension_only, model%f_ext, model%fixed_dofs, & dt, model%cfg, model%q_step, model%v_step, model%a_step, converged, stalled, & n_iter, & es, em, prescribed_q=prescribed_q, prescribed_v=prescribed_v, & - prescribed_a=prescribed_a, workspace=model%dynamic_workspace) + prescribed_a=prescribed_a, workspace=model%dynamic_workspace, & + start_l0=l0_start, mass_l0=l0_mass) ELSE IF (has_load .AND. model%has_added_mass) THEN CALL CD_Cable_Gen_Alpha_Step(model%q, model%v, model%a, model%elem_conn, model%l0, model%ea_dyn, & model%rho_a, model%tension_only, model%f_ext, model%fixed_dofs, & @@ -2516,7 +2697,8 @@ SUBROUTINE step_model_plain(model, dt, converged, stalled, n_iter, ErrStat, ErrM added_mass_band_proc=model_added_mass_band, workspace=model%dynamic_workspace, & start_load=model%load_start_work, start_tension=model%tension_start_work, & start_stiffness=model%stiffness_start_work, & - axial_damping=model%ba_dyn, axial_l0_rate=model%l0_dot) + axial_damping=model%ba_dyn, axial_l0_rate=model%l0_dot, & + start_l0=l0_start, mass_l0=l0_mass, start_l0_rate=l0_dot_start) ELSE IF (has_load) THEN CALL CD_Cable_Gen_Alpha_Step(model%q, model%v, model%a, model%elem_conn, model%l0, model%ea_dyn, & model%rho_a, model%tension_only, model%f_ext, model%fixed_dofs, & @@ -2526,19 +2708,25 @@ SUBROUTINE step_model_plain(model, dt, converged, stalled, n_iter, ErrStat, ErrM workspace=model%dynamic_workspace, start_load=model%load_start_work, & start_tension=model%tension_start_work, & start_stiffness=model%stiffness_start_work, & - axial_damping=model%ba_dyn, axial_l0_rate=model%l0_dot) + axial_damping=model%ba_dyn, axial_l0_rate=model%l0_dot, & + start_l0=l0_start, mass_l0=l0_mass, start_l0_rate=l0_dot_start) ELSE IF (model%has_added_mass) THEN CALL CD_Cable_Gen_Alpha_Step(model%q, model%v, model%a, model%elem_conn, model%l0, model%ea_dyn, & model%rho_a, model%tension_only, model%f_ext, model%fixed_dofs, & dt, model%cfg, model%q_step, model%v_step, model%a_step, converged, stalled, & n_iter, es, em, & - added_mass_band_proc=model_added_mass_band, workspace=model%dynamic_workspace) + added_mass_band_proc=model_added_mass_band, workspace=model%dynamic_workspace, & + start_l0=l0_start, mass_l0=l0_mass) ELSE CALL CD_Cable_Gen_Alpha_Step(model%q, model%v, model%a, model%elem_conn, model%l0, model%ea_dyn, & model%rho_a, model%tension_only, model%f_ext, model%fixed_dofs, & dt, model%cfg, model%q_step, model%v_step, model%a_step, converged, stalled, & - n_iter, es, em, workspace=model%dynamic_workspace) + n_iter, es, em, workspace=model%dynamic_workspace, & + start_l0=l0_start, mass_l0=l0_mass) END IF + IF (ALLOCATED(l0_new)) model%l0 = l0_new + IF (ALLOCATED(l0_dot_new)) model%l0_dot = l0_dot_new + IF (ALLOCATED(f_ext_new)) model%f_ext = f_ext_new model%ve_dt = CD_ZERO CALL CD_Profile_Count_Line_Step(n_iter) IF (es /= CD_DYN_OK) THEN @@ -2665,12 +2853,90 @@ SUBROUTINE step_model_plain(model, dt, converged, stalled, n_iter, ErrStat, ErrM model%q = model%q_step model%v = model%v_step model%a = model%a_step + ! the committed state is now the one of the present lengths and rates + IF (blend) THEN + model%l0_c = model%l0 + model%l0_dot_c = model%l0_dot + END IF ! The mapping repeats the queries validated above, so it cannot fail here. IF (model%has_seabed_friction) & CALL mapped_friction_anchors(model, model%q, model%v, .TRUE., ErrStat, ErrMsg) CONTAINS + SUBROUTINE step_start_load(es_s, em_s) + !! The force blend's load at the committed state (q_n, v_n) into load_start_work (with the + !! law tensions and axial stiffnesses of the viscoelastic and Syrope elements in + !! tension_start_work and stiffness_start_work), unless a + !! warm re-solve of the same step reuses the previous call's; without the force blend or a + !! load contributor there is none. Evaluated with the model as the caller left it (the + !! committed lengths entered after a length change). + INTEGER, INTENT(OUT) :: es_s + CHARACTER(*), INTENT(OUT) :: em_s + CHARACTER(160) :: em_c + es_s = CD_MODEL_OK + em_s = '' + IF (.NOT. (has_load .AND. model%cfg%force_blend)) THEN + model%load_start_valid = .FALSE. + RETURN + END IF + IF (model%dynamic_workspace%guess_armed .AND. model%load_start_valid) RETURN + model%load_start_valid = .FALSE. + IF (ALLOCATED(model%load_start_work)) THEN + IF (SIZE(model%load_start_work) /= model%n_dof) DEALLOCATE (model%load_start_work) + END IF + IF (.NOT. ALLOCATED(model%load_start_work)) THEN + ALLOCATE (model%load_start_work(model%n_dof), STAT=es_s) + IF (es_s /= 0) THEN + es_s = CD_MODEL_ALLOCFAIL + em_s = 'CableDyn_Model: step-start load workspace allocation failed' + RETURN + END IF + END IF + ! tension_start_work stays unallocated without a viscoelastic or Syrope element, and the + ! step then sees start_tension absent + IF (ALLOCATED(model%tension_start_work)) THEN + IF (SIZE(model%tension_start_work) /= model%n_elem .OR. & + .NOT. (model%has_viscoelastic .OR. model%has_syrope)) DEALLOCATE (model%tension_start_work) + END IF + IF ((model%has_viscoelastic .OR. model%has_syrope) .AND. .NOT. ALLOCATED(model%tension_start_work)) THEN + ALLOCATE (model%tension_start_work(model%n_elem), STAT=es_s) + IF (es_s /= 0) THEN + es_s = CD_MODEL_ALLOCFAIL + em_s = 'CableDyn_Model: step-start tension workspace allocation failed' + RETURN + END IF + END IF + IF (ALLOCATED(model%stiffness_start_work)) THEN + IF (.NOT. ALLOCATED(model%tension_start_work)) THEN + DEALLOCATE (model%stiffness_start_work) + ELSE IF (SIZE(model%stiffness_start_work) /= model%n_elem) THEN + DEALLOCATE (model%stiffness_start_work) + END IF + END IF + IF (ALLOCATED(model%tension_start_work) .AND. .NOT. ALLOCATED(model%stiffness_start_work)) THEN + ALLOCATE (model%stiffness_start_work(model%n_elem), STAT=es_s) + IF (es_s /= 0) THEN + es_s = CD_MODEL_ALLOCFAIL + em_s = 'CableDyn_Model: step-start stiffness workspace allocation failed' + RETURN + END IF + END IF + model%ve_dt = CD_ZERO + IF (ALLOCATED(model%tension_start_work)) THEN + CALL model_contributor_force(model, model%q, model%v, model%load_start_work, es_s, em_c, & + law_tension=model%tension_start_work, & + law_stiffness=model%stiffness_start_work) + ELSE + CALL model_contributor_force(model, model%q, model%v, model%load_start_work, es_s, em_c) + END IF + IF (es_s /= CD_MODEL_OK) THEN + em_s = 'CableDyn_Model: step-start load failed: '//TRIM(em_c) + RETURN + END IF + model%load_start_valid = .TRUE. + END SUBROUTINE step_start_load + SUBROUTINE model_force(q, v, force, ErrStat, ErrMsg) REAL(wp), INTENT(IN) :: q(:), v(:) REAL(wp), INTENT(OUT) :: force(:) @@ -2692,6 +2958,8 @@ END SUBROUTINE model_load_band SUBROUTINE model_added_mass_band(q, accel, free, kl, ku, M_add_a, M_add_band, dMa_a_dq_band, ErrStat, ErrMsg, & need_tangent) + !! The added mass at q_alpha; after a length change under the force blend with the + !! blended lengths of the inertia (l0_mass, unallocated and so absent otherwise). REAL(wp), INTENT(IN) :: q(:), accel(:) INTEGER, INTENT(IN) :: free(:), kl, ku REAL(wp), INTENT(OUT) :: M_add_a(:), M_add_band(:, :), dMa_a_dq_band(:, :) @@ -2699,7 +2967,7 @@ SUBROUTINE model_added_mass_band(q, accel, free, kl, ku, M_add_a, M_add_band, dM CHARACTER(*), INTENT(OUT) :: ErrMsg LOGICAL, INTENT(IN), OPTIONAL :: need_tangent CALL model_added_mass_banded(model, q, accel, free, kl, ku, M_add_a, M_add_band, dMa_a_dq_band, & - ErrStat, ErrMsg, need_tangent=need_tangent) + ErrStat, ErrMsg, need_tangent=need_tangent, l0_elem=l0_mass) ErrStat = as_dyn_callback_status(ErrStat) END SUBROUTINE model_added_mass_band END SUBROUTINE step_model_plain @@ -2879,12 +3147,123 @@ SUBROUTINE CD_Step_Model_Recovering(model, dt, converged, stalled, n_iter, ErrSt END BLOCK END SUBROUTINE CD_Step_Model_Recovering + LOGICAL FUNCTION model_lengths_committed(model) RESULT(same) + !! The unstretched lengths and rates are those the committed state was reached with (bit + !! for bit). A model without the committed copies counts as committed. + TYPE(CD_ModelType), INTENT(IN) :: model + INTEGER :: e + same = .TRUE. + IF (.NOT. (ALLOCATED(model%l0_c) .AND. ALLOCATED(model%l0_dot_c))) RETURN + DO e = 1, SIZE(model%l0) + IF (.NOT. (bits_equal(model%l0(e), model%l0_c(e)) .AND. bits_equal(model%l0_dot(e), model%l0_dot_c(e)))) THEN + same = .FALSE. + RETURN + END IF + END DO + END FUNCTION model_lengths_committed + + ELEMENTAL LOGICAL FUNCTION bits_equal(x, y) RESULT(same) + !! Bitwise equality of two reals (so +0 and -0 differ). + REAL(wp), INTENT(IN) :: x, y + same = TRANSFER(x, 0_INT64) == TRANSFER(y, 0_INT64) + END FUNCTION bits_equal + + ELEMENTAL REAL(wp) FUNCTION positive_zero(x) RESULT(y) + !! x with a negative zero replaced by +0, on the bits (so no floating-point mode can keep + !! the sign); every other value is returned unchanged. + REAL(wp), INTENT(IN) :: x + INTEGER(INT64) :: bits + bits = TRANSFER(x, 0_INT64) + IF (bits == -HUGE(0_INT64) - 1_INT64) bits = 0_INT64 + y = TRANSFER(bits, y) + END FUNCTION positive_zero + + SUBROUTINE enter_committed_lengths(model, aside, loads, ErrStat, ErrMsg) + !! Install the lengths and rates the committed state was reached with (l0_c, l0_dot_c) for + !! an evaluation of the committed state, setting the present ones aside; + !! leave_committed_lengths moves them back bit for bit. With loads, the external load and + !! the seabed coefficients that follow the lengths (the distributed load, and the seabed + !! stiffness and damping of a model that recomputes them) are rebuilt at l0_c as well, with + !! the helpers and in the order CD_Update_Model_SegmentLength uses, so they are those of the + !! committed lengths; they are rebuilt only when a length differs (a rate change alone + !! leaves them as they are). A model whose lengths and rates are the committed ones is left + !! as it is. On failure nothing is written. + TYPE(CD_ModelType), INTENT(INOUT) :: model + TYPE(model_lengths_aside), INTENT(INOUT) :: aside + LOGICAL, INTENT(IN) :: loads + INTEGER, INTENT(OUT) :: ErrStat + CHARACTER(*), INTENT(OUT) :: ErrMsg + REAL(wp), ALLOCATABLE :: f_c(:), kn_c(:) + LOGICAL :: rebuild + INTEGER :: es + CHARACTER(160) :: em + + ErrStat = CD_MODEL_OK + ErrMsg = '' + aside%active = .FALSE. + IF (.NOT. model%initialized) RETURN + IF (model_lengths_committed(model)) RETURN + rebuild = loads + IF (rebuild) rebuild = .NOT. ALL(bits_equal(model%l0, model%l0_c)) + IF (rebuild .AND. ALLOCATED(model%dist_load)) THEN + ALLOCATE (f_c(SIZE(model%f_ext)), STAT=es) + IF (es /= 0) THEN + ErrStat = CD_MODEL_ALLOCFAIL + ErrMsg = 'committed lengths: external-load workspace allocation failed' + RETURN + END IF + CALL CD_Assemble_Distributed_Load(model%elem_conn, model%l0_c, model%dist_load, f_c, es, em) + IF (es /= 0) THEN + CALL fail(ErrStat, ErrMsg, 'committed lengths: distributed-load assembly failed: '//TRIM(em)) + RETURN + END IF + f_c = model%f_ext_dist_base + f_c + END IF + IF (rebuild .AND. model%has_seabed .AND. model%has_seabed_recompute) THEN + CALL CD_Nodal_Seabed_Stiffness(model%seabed_kbot, model%seabed_diameter_elem, model%l0_c, kn_c, es, em) + IF (es /= 0) THEN + CALL fail(ErrStat, ErrMsg, 'committed lengths: seabed stiffness recompute failed: '//TRIM(em)) + RETURN + END IF + END IF + aside%l0 = model%l0 + aside%l0_dot = model%l0_dot + model%l0 = model%l0_c + model%l0_dot = model%l0_dot_c + IF (ALLOCATED(f_c)) THEN + CALL MOVE_ALLOC(model%f_ext, aside%f_ext) + CALL MOVE_ALLOC(f_c, model%f_ext) + END IF + IF (ALLOCATED(kn_c)) THEN + CALL MOVE_ALLOC(model%seabed_kn, aside%kn) + CALL MOVE_ALLOC(kn_c, model%seabed_kn) + IF (ALLOCATED(model%seabed_cn)) THEN + CALL MOVE_ALLOC(model%seabed_cn, aside%cn) + model%seabed_cn = model%seabed_kn*model%seabed_cn_over_kn + END IF + END IF + aside%active = .TRUE. + END SUBROUTINE enter_committed_lengths + + SUBROUTINE leave_committed_lengths(model, aside) + !! Move back what enter_committed_lengths set aside. + TYPE(CD_ModelType), INTENT(INOUT) :: model + TYPE(model_lengths_aside), INTENT(INOUT) :: aside + IF (.NOT. aside%active) RETURN + model%l0 = aside%l0 + model%l0_dot = aside%l0_dot + IF (ALLOCATED(aside%f_ext)) CALL MOVE_ALLOC(aside%f_ext, model%f_ext) + IF (ALLOCATED(aside%kn)) CALL MOVE_ALLOC(aside%kn, model%seabed_kn) + IF (ALLOCATED(aside%cn)) CALL MOVE_ALLOC(aside%cn, model%seabed_cn) + aside%active = .FALSE. + END SUBROUTINE leave_committed_lengths + SUBROUTINE save_recovery_state(model) !! Save the committed state into the recovery snapshot (commit_state_copy). TYPE(CD_ModelType), INTENT(INOUT) :: model CALL commit_state_copy(model, .FALSE., model%recovery_q0, model%recovery_v0, model%recovery_a0, & model%recovery_ve_dl_1, model%recovery_syrope_slow, model%recovery_syrope_tmax, & - model%recovery_fr_anchor) + model%recovery_fr_anchor, model%recovery_l0_c, model%recovery_l0_dot_c) END SUBROUTINE save_recovery_state SUBROUTINE restore_recovery_state(model) @@ -2892,7 +3271,7 @@ SUBROUTINE restore_recovery_state(model) TYPE(CD_ModelType), INTENT(INOUT) :: model CALL commit_state_copy(model, .TRUE., model%recovery_q0, model%recovery_v0, model%recovery_a0, & model%recovery_ve_dl_1, model%recovery_syrope_slow, model%recovery_syrope_tmax, & - model%recovery_fr_anchor) + model%recovery_fr_anchor, model%recovery_l0_c, model%recovery_l0_dot_c) model%ve_dt = CD_ZERO END SUBROUTINE restore_recovery_state @@ -4049,7 +4428,7 @@ SUBROUTINE CD_Calc_Model_CoupledEndMass(model, m_cc, ErrStat, ErrMsg) END DO END SUBROUTINE CD_Calc_Model_CoupledEndMass - SUBROUTINE CD_Update_Model_SegmentLength(model, elem, l0_new, l0_dot, ErrStat, ErrMsg) + SUBROUTINE CD_Update_Model_SegmentLength(model, elem, l0_new, l0_dot, ErrStat, ErrMsg, restored) !! Active line control (the MoorDyn CtrlChan mechanism): set one element's !! unstretched length and its rate. The elastic tension and the per-step mass !! assembly read model%l0 directly, so the dynamics track the new length from @@ -4058,15 +4437,27 @@ SUBROUTINE CD_Update_Model_SegmentLength(model, elem, l0_new, l0_dot, ErrStat, E !! frozen at its init resolution (MoorDyn's convention -- BA derives from the !! INITIAL UnstrLen). Callers owning point bindings (the system) must recompute !! any end-node mass-diagonal shares after this call. + !! The committed state keeps its acceleration and the lengths it was reached with + !! (l0_c, l0_dot_c). With the force blend the next step (CD_Step_Model) evaluates its + !! step-start force at l0_c and l0_dot_c, its end-of-step force at the new lengths and + !! rates, and only its inertia at the blended lengths (1 - alpha_f) l0 + alpha_f l0_c; + !! under False alpha_force_blend it blends the lengths and rates into every alpha-level + !! term. restored = .TRUE. (a checkpoint restart re-applying the command of + !! the committed state) makes the new length and rate the committed ones as well. A rate + !! of -0 is stored as +0, so a zero command of either sign leaves an uncontrolled model + !! bit-identical (the committed-length test compares bits). TYPE(CD_ModelType), INTENT(INOUT) :: model INTEGER, INTENT(IN) :: elem REAL(wp), INTENT(IN) :: l0_new, l0_dot INTEGER, INTENT(OUT) :: ErrStat CHARACTER(*), INTENT(OUT) :: ErrMsg + LOGICAL, INTENT(IN), OPTIONAL :: restored INTEGER :: es + REAL(wp) :: rate CHARACTER(160) :: em ErrStat = CD_MODEL_OK ErrMsg = '' + rate = positive_zero(l0_dot) IF (.NOT. model%initialized) THEN ErrStat = CD_MODEL_NOT_INITIALIZED ErrMsg = 'CableDyn_Model: model is not initialized' @@ -4107,11 +4498,10 @@ SUBROUTINE CD_Update_Model_SegmentLength(model, elem, l0_new, l0_dot, ErrStat, E END IF ! The update is atomic: every length-dependent quantity is built from a trial ! length vector first, and the committed fields are mutated only once all builds - ! succeeded. A failed acceleration recompute restores the entry state whole. + ! succeeded. BLOCK - REAL(wp) :: l0_trial(SIZE(model%l0)), f_dist(SIZE(model%f_ext)), f_ext_entry(SIZE(model%f_ext)) - REAL(wp) :: l0_entry, l0_dot_entry - REAL(wp), ALLOCATABLE :: kn_new(:), kn_entry(:), cn_entry(:) + REAL(wp) :: l0_trial(SIZE(model%l0)), f_dist(SIZE(model%f_ext)) + REAL(wp), ALLOCATABLE :: kn_new(:) l0_trial = model%l0 l0_trial(elem) = l0_new ! Distributed external load tracks the length: REASSEMBLE the distributed part @@ -4124,6 +4514,12 @@ SUBROUTINE CD_Update_Model_SegmentLength(model, elem, l0_new, l0_dot, ErrStat, E CALL fail(ErrStat, ErrMsg, 'segment-length update: distributed-load reassembly failed: '//TRIM(em)) RETURN END IF + ! the external load the new length gives must be finite (an overflowing length + ! fails here, before anything is written) + IF (.NOT. CD_All_Finite(model%f_ext_dist_base + f_dist)) THEN + CALL fail(ErrStat, ErrMsg, 'segment-length update: the external load at the new length is not finite') + RETURN + END IF END IF ! Seabed nodal coefficients track the tributary lengths: rebuild through the ! SAME helper the deck used, so a fresh build at the new length matches @@ -4135,44 +4531,86 @@ SUBROUTINE CD_Update_Model_SegmentLength(model, elem, l0_new, l0_dot, ErrStat, E CALL fail(ErrStat, ErrMsg, 'segment-length update: seabed stiffness recompute failed: '//TRIM(em)) RETURN END IF + IF (.NOT. CD_All_Finite(kn_new*model%seabed_cn_over_kn)) THEN + CALL fail(ErrStat, ErrMsg, 'segment-length update: the seabed coefficients at the new length are not finite') + RETURN + END IF END IF ! Commit. The consistent mass follows l0 implicitly (it is applied element by - ! element from the committed lengths, and the step rebuilds its mass band when they change). - l0_entry = model%l0(elem) - l0_dot_entry = model%l0_dot(elem) - f_ext_entry = model%f_ext + ! element from the present lengths, and the step rebuilds its mass band when they change). model%l0(elem) = l0_new - model%l0_dot(elem) = l0_dot + model%l0_dot(elem) = rate IF (ALLOCATED(model%dist_load)) model%f_ext = model%f_ext_dist_base + f_dist IF (model%has_seabed .AND. model%has_seabed_recompute) THEN - CALL MOVE_ALLOC(model%seabed_kn, kn_entry) CALL MOVE_ALLOC(kn_new, model%seabed_kn) - IF (ALLOCATED(model%seabed_cn)) THEN - cn_entry = model%seabed_cn - model%seabed_cn = model%seabed_kn*model%seabed_cn_over_kn - END IF - END IF - ! The committed acceleration satisfied the OLD length's equation of motion; - ! recompute it at the current q/v under the new length so the model is - ! indistinguishable from one built with it (load exchanges and the next - ! gen-alpha step start from a consistent state). A FULLY COUPLED model (no - ! free DOFs -- every line in a point-connected system) carries only - ! caller-prescribed accelerations, so there is nothing to recompute. - IF (SIZE(model%fixed_dofs) < model%n_dof) THEN - CALL CD_Recompute_Model_Acceleration(model, es, em) - IF (es /= CD_MODEL_OK) THEN - ! The recompute restored the acceleration; restore every other field. - model%l0(elem) = l0_entry - model%l0_dot(elem) = l0_dot_entry - model%f_ext = f_ext_entry - IF (ALLOCATED(kn_entry)) CALL MOVE_ALLOC(kn_entry, model%seabed_kn) - IF (ALLOCATED(cn_entry)) model%seabed_cn = cn_entry - CALL fail(ErrStat, ErrMsg, 'segment-length update: acceleration recompute failed: '//TRIM(em)) + IF (ALLOCATED(model%seabed_cn)) model%seabed_cn = model%seabed_kn*model%seabed_cn_over_kn + END IF + ! The committed acceleration is kept: it is the history of the step that reached the + ! committed state, at the lengths of that step (re-deriving it under the new length + ! would carry the force of the length change into the next step's alpha_m blend). + IF (PRESENT(restored)) THEN + IF (restored) THEN + model%l0_c(elem) = l0_new + model%l0_dot_c(elem) = rate END IF END IF END BLOCK END SUBROUTINE CD_Update_Model_SegmentLength + SUBROUTINE CD_Save_Model_Control(model, saved) + !! Save what CD_Update_Model_SegmentLength writes (the lengths and rates, the committed + !! lengths and rates, the external load and the seabed coefficients), so that a caller + !! applying one command to several lines can take back the ones it already changed when + !! a later one fails (CD_Restore_Model_Control). + TYPE(CD_ModelType), INTENT(IN) :: model + TYPE(CD_ModelControlSaveType), INTENT(INOUT) :: saved + saved%valid = model%initialized + IF (.NOT. saved%valid) RETURN + saved%l0 = model%l0 + saved%l0_dot = model%l0_dot + saved%l0_c = model%l0_c + saved%l0_dot_c = model%l0_dot_c + saved%f_ext = model%f_ext + IF (ALLOCATED(model%seabed_kn)) THEN + saved%seabed_kn = model%seabed_kn + ELSE IF (ALLOCATED(saved%seabed_kn)) THEN + DEALLOCATE (saved%seabed_kn) + END IF + IF (ALLOCATED(model%seabed_cn)) THEN + saved%seabed_cn = model%seabed_cn + ELSE IF (ALLOCATED(saved%seabed_cn)) THEN + DEALLOCATE (saved%seabed_cn) + END IF + END SUBROUTINE CD_Save_Model_Control + + SUBROUTINE CD_Restore_Model_Control(model, saved, ErrStat, ErrMsg) + !! Put back, bit for bit, what CD_Save_Model_Control saved. Fails closed, writing nothing, + !! when the save does not belong to the model. + TYPE(CD_ModelType), INTENT(INOUT) :: model + TYPE(CD_ModelControlSaveType), INTENT(IN) :: saved + INTEGER, INTENT(OUT) :: ErrStat + CHARACTER(*), INTENT(OUT) :: ErrMsg + ErrStat = CD_MODEL_OK + ErrMsg = '' + IF (.NOT. (model%initialized .AND. saved%valid)) THEN + CALL fail(ErrStat, ErrMsg, 'control restore: no saved control state') + RETURN + END IF + IF (SIZE(saved%l0) /= SIZE(model%l0) .OR. SIZE(saved%f_ext) /= SIZE(model%f_ext) .OR. & + (ALLOCATED(saved%seabed_kn) .NEQV. ALLOCATED(model%seabed_kn)) .OR. & + (ALLOCATED(saved%seabed_cn) .NEQV. ALLOCATED(model%seabed_cn))) THEN + CALL fail(ErrStat, ErrMsg, 'control restore: the saved state belongs to another model') + RETURN + END IF + model%l0 = saved%l0 + model%l0_dot = saved%l0_dot + model%l0_c = saved%l0_c + model%l0_dot_c = saved%l0_dot_c + model%f_ext = saved%f_ext + IF (ALLOCATED(saved%seabed_kn)) model%seabed_kn = saved%seabed_kn + IF (ALLOCATED(saved%seabed_cn)) model%seabed_cn = saved%seabed_cn + END SUBROUTINE CD_Restore_Model_Control + SUBROUTINE CD_Get_Model_EndNodeMassDiag(model, coupled_slot, mass_diag, ErrStat, ErrMsg) !! The coupled end node's OWN diagonal share of the consistent structural mass: !! sum over elements attached to that node of rho_a*l0/3 (the 2m/6 block diagonal @@ -4892,35 +5330,37 @@ SUBROUTINE CD_Update_Model_External_Loads(model, f_ext, ErrStat, ErrMsg) CALL fail(ErrStat, ErrMsg, 'external-load update requires initialized rollback workspace') RETURN END IF - model%f_ext_rollback = model%f_ext - model%a_rollback = model%a - model%f_ext = f_ext - CALL CD_Recompute_Model_Acceleration(model, ErrStat, ErrMsg) - IF (ErrStat /= CD_MODEL_OK) THEN - model%f_ext = model%f_ext_rollback - model%a = model%a_rollback - RETURN - END IF - ! Maintain the distributed-load invariant f_ext = remainder + assemble(dist, l0): - ! a later segment-length update RECONSTRUCTS f_ext from the remainder, so a - ! runtime external-load update that skipped this would be silently WIPED by the - ! next control command. Recomputed only on success (the rollback path above - ! restores the committed pair untouched). - IF (ALLOCATED(model%dist_load)) THEN - BLOCK - REAL(wp) :: f_dist(SIZE(model%f_ext)) - INTEGER :: es2 - CHARACTER(160) :: em2 + ! Maintain the distributed-load invariant f_ext = remainder + assemble(dist, l0): a later + ! segment-length update RECONSTRUCTS f_ext from the remainder, so a runtime external-load + ! update that skipped this would be silently WIPED by the next control command. The + ! remainder is stored BEFORE the acceleration recompute, which under the force blend after + ! a pending length change rebuilds the committed external load from it + ! (enter_committed_lengths); a failed recompute restores f_ext, the remainder and a. + BLOCK + REAL(wp) :: f_dist(SIZE(model%f_ext)) + REAL(wp), ALLOCATABLE :: base_entry(:) + INTEGER :: es2 + CHARACTER(160) :: em2 + IF (ALLOCATED(model%dist_load)) THEN CALL CD_Assemble_Distributed_Load(model%elem_conn, model%l0, model%dist_load, f_dist, es2, em2) IF (es2 /= 0) THEN - model%f_ext = model%f_ext_rollback - model%a = model%a_rollback CALL fail(ErrStat, ErrMsg, 'external-load update: distributed-load remainder failed: '//TRIM(em2)) RETURN END IF - model%f_ext_dist_base = model%f_ext - f_dist - END BLOCK - END IF + base_entry = model%f_ext_dist_base + END IF + model%f_ext_rollback = model%f_ext + model%a_rollback = model%a + model%f_ext = f_ext + IF (ALLOCATED(model%dist_load)) model%f_ext_dist_base = model%f_ext - f_dist + CALL CD_Recompute_Model_Acceleration(model, ErrStat, ErrMsg) + IF (ErrStat /= CD_MODEL_OK) THEN + model%f_ext = model%f_ext_rollback + model%a = model%a_rollback + IF (ALLOCATED(base_entry)) model%f_ext_dist_base = base_entry + RETURN + END IF + END BLOCK END SUBROUTINE CD_Update_Model_External_Loads SUBROUTINE CD_Update_Model_CoupledMotion(model, q_coupled, v_coupled, a_coupled, ErrStat, ErrMsg) @@ -5018,6 +5458,32 @@ SUBROUTINE CD_Recompute_Model_Acceleration(model, ErrStat, ErrMsg) !! external loads, environmental loads, added mass, and fixed/coupled DOF map. !! Use this after runtime updates when the caller needs a consistent !! acceleration before a load exchange or diagnostic query. + !! Under active line control the acceleration is the committed state's: between a length + !! change (CD_Update_Model_SegmentLength) and the next step it is solved with the lengths + !! and rates that state was reached with (l0_c, l0_dot_c), which stay the committed ones, + !! so the step still treats the old and new lengths as it should. The state is evaluated as + !! the step evaluates its committed side: with the force blend (the step-start force r_n) + !! the external load and the seabed coefficients that follow the lengths are rebuilt at + !! the committed lengths too (enter_committed_lengths); under False alpha_force_blend, as + !! in that step's blend, only the element lengths and rates take the committed values and + !! the external load and the seabed coefficients are the present ones. The present values + !! are put back bit for bit on every exit. + TYPE(CD_ModelType), INTENT(INOUT) :: model + INTEGER, INTENT(OUT) :: ErrStat + CHARACTER(*), INTENT(OUT) :: ErrMsg + TYPE(model_lengths_aside) :: aside + + CALL enter_committed_lengths(model, aside, model%cfg%force_blend, ErrStat, ErrMsg) + IF (ErrStat /= CD_MODEL_OK) THEN + ErrMsg = 'CableDyn_Model: acceleration recompute: '//TRIM(ErrMsg) + RETURN + END IF + CALL recompute_model_acceleration_now(model, ErrStat, ErrMsg) + CALL leave_committed_lengths(model, aside) + END SUBROUTINE CD_Recompute_Model_Acceleration + + SUBROUTINE recompute_model_acceleration_now(model, ErrStat, ErrMsg) + !! CD_Recompute_Model_Acceleration with the lengths and rates in place. TYPE(CD_ModelType), INTENT(INOUT) :: model INTEGER, INTENT(OUT) :: ErrStat CHARACTER(*), INTENT(OUT) :: ErrMsg @@ -5289,7 +5755,7 @@ SUBROUTINE model_added_mass_band(q, accel, free, kl, ku, M_add_a, M_add_band, dM ErrStat, ErrMsg, need_tangent=need_tangent) ErrStat = as_dyn_callback_status(ErrStat) END SUBROUTINE model_added_mass_band - END SUBROUTINE CD_Recompute_Model_Acceleration + END SUBROUTINE recompute_model_acceleration_now SUBROUTINE CD_Audit_Model_Step(model, time, dt, new_spike) !! Audit one committed host step of an EI=0 line (called by the standalone driver on the @@ -5484,6 +5950,12 @@ SUBROUTINE CD_End_Model(model, ErrStat, ErrMsg) IF (ALLOCATED(model%rho_a)) DEALLOCATE (model%rho_a) IF (ALLOCATED(model%f_ext)) DEALLOCATE (model%f_ext) IF (ALLOCATED(model%l0_dot)) DEALLOCATE (model%l0_dot) + IF (ALLOCATED(model%l0_c)) DEALLOCATE (model%l0_c) + IF (ALLOCATED(model%l0_dot_c)) DEALLOCATE (model%l0_dot_c) + IF (ALLOCATED(model%l0_c_rollback)) DEALLOCATE (model%l0_c_rollback) + IF (ALLOCATED(model%l0_dot_c_rollback)) DEALLOCATE (model%l0_dot_c_rollback) + IF (ALLOCATED(model%recovery_l0_c)) DEALLOCATE (model%recovery_l0_c) + IF (ALLOCATED(model%recovery_l0_dot_c)) DEALLOCATE (model%recovery_l0_dot_c) IF (ALLOCATED(model%dist_load)) DEALLOCATE (model%dist_load) IF (ALLOCATED(model%f_ext_dist_base)) DEALLOCATE (model%f_ext_dist_base) IF (ALLOCATED(model%seabed_diameter_elem)) DEALLOCATE (model%seabed_diameter_elem) @@ -5508,6 +5980,7 @@ SUBROUTINE CD_End_Model(model, ErrStat, ErrMsg) IF (ALLOCATED(model%recovery_q0)) DEALLOCATE (model%recovery_q0) model%sub_slot(1) = CD_ModelCommitSlot() model%sub_slot(2) = CD_ModelCommitSlot() + model%sub_target = CD_ModelControlSaveType() IF (ALLOCATED(model%sub_t0)) DEALLOCATE (model%sub_t0) IF (ALLOCATED(model%sub_t1)) DEALLOCATE (model%sub_t1) IF (ALLOCATED(model%sub_pq)) DEALLOCATE (model%sub_pq) @@ -5681,6 +6154,18 @@ SUBROUTINE CD_Copy_Model(src, dst, ErrStat, ErrMsg) IF (ErrStat /= CD_MODEL_OK) RETURN CALL copy_real1(src%l0_dot, work%l0_dot, 'l0_dot', ErrStat, ErrMsg) IF (ErrStat /= CD_MODEL_OK) RETURN + CALL copy_real1(src%l0_c, work%l0_c, 'l0_c', ErrStat, ErrMsg) + IF (ErrStat /= CD_MODEL_OK) RETURN + CALL copy_real1(src%l0_dot_c, work%l0_dot_c, 'l0_dot_c', ErrStat, ErrMsg) + IF (ErrStat /= CD_MODEL_OK) RETURN + CALL copy_real1(src%l0_c_rollback, work%l0_c_rollback, 'l0_c_rollback', ErrStat, ErrMsg) + IF (ErrStat /= CD_MODEL_OK) RETURN + CALL copy_real1(src%l0_dot_c_rollback, work%l0_dot_c_rollback, 'l0_dot_c_rollback', ErrStat, ErrMsg) + IF (ErrStat /= CD_MODEL_OK) RETURN + CALL copy_real1(src%recovery_l0_c, work%recovery_l0_c, 'recovery_l0_c', ErrStat, ErrMsg) + IF (ErrStat /= CD_MODEL_OK) RETURN + CALL copy_real1(src%recovery_l0_dot_c, work%recovery_l0_dot_c, 'recovery_l0_dot_c', ErrStat, ErrMsg) + IF (ErrStat /= CD_MODEL_OK) RETURN CALL copy_real2(src%dist_load, work%dist_load, 'dist_load', ErrStat, ErrMsg) IF (ErrStat /= CD_MODEL_OK) RETURN CALL copy_real1(src%f_ext_dist_base, work%f_ext_dist_base, 'f_ext_dist_base', ErrStat, ErrMsg) @@ -5889,6 +6374,12 @@ SUBROUTINE commit_model_copy(from, to) CALL MOVE_ALLOC(from%ea, to%ea) CALL MOVE_ALLOC(from%rho_a, to%rho_a) CALL MOVE_ALLOC(from%l0_dot, to%l0_dot) + CALL MOVE_ALLOC(from%l0_c, to%l0_c) + CALL MOVE_ALLOC(from%l0_dot_c, to%l0_dot_c) + CALL MOVE_ALLOC(from%l0_c_rollback, to%l0_c_rollback) + CALL MOVE_ALLOC(from%l0_dot_c_rollback, to%l0_dot_c_rollback) + CALL MOVE_ALLOC(from%recovery_l0_c, to%recovery_l0_c) + CALL MOVE_ALLOC(from%recovery_l0_dot_c, to%recovery_l0_dot_c) CALL MOVE_ALLOC(from%dist_load, to%dist_load) CALL MOVE_ALLOC(from%f_ext_dist_base, to%f_ext_dist_base) CALL MOVE_ALLOC(from%f_ext, to%f_ext) @@ -7628,7 +8119,9 @@ SUBROUTINE model_added_mass_full(model, q, accel, M_add, dMa_a_dq, ErrStat, ErrM END SUBROUTINE model_added_mass_full SUBROUTINE model_added_mass_banded(model, q, accel, free, kl, ku, M_add_a, M_add_band, dMa_a_dq_band, & - ErrStat, ErrMsg, need_tangent) + ErrStat, ErrMsg, need_tangent, l0_elem) + !! l0_elem (n_elem, finite and positive): the element lengths to use instead of model%l0 + !! (the blended lengths of a step after a length change). TYPE(CD_ModelType), INTENT(INOUT) :: model REAL(wp), INTENT(IN) :: q(:), accel(:) INTEGER, INTENT(IN) :: free(:), kl, ku @@ -7636,9 +8129,10 @@ SUBROUTINE model_added_mass_banded(model, q, accel, free, kl, ku, M_add_a, M_add INTEGER, INTENT(OUT) :: ErrStat CHARACTER(*), INTENT(OUT) :: ErrMsg LOGICAL, INTENT(IN), OPTIONAL :: need_tangent + REAL(wp), INTENT(IN), OPTIONAL :: l0_elem(:) INTEGER :: e, i, n, ldab, idx(6) - REAL(wp) :: q2(6), a2(6), wl2(2), m2(6, 6), dm2(6, 6), ma2(6) + REAL(wp) :: q2(6), a2(6), wl2(2), m2(6, 6), dm2(6, 6), ma2(6), le LOGICAL :: want_tangent, zero_accel, free_map_ready ErrStat = CD_MODEL_OK @@ -7673,6 +8167,16 @@ SUBROUTINE model_added_mass_banded(model, q, accel, free, kl, ku, M_add_a, M_add CALL fail(ErrStat, ErrMsg, 'banded added mass q/accel must be finite') RETURN END IF + IF (PRESENT(l0_elem)) THEN + IF (SIZE(l0_elem) /= model%n_elem) THEN + CALL fail(ErrStat, ErrMsg, 'banded added mass lengths must have shape (n_elem)') + RETURN + END IF + IF (.NOT. CD_All_Finite(l0_elem) .OR. ANY(l0_elem <= CD_ZERO)) THEN + CALL fail(ErrStat, ErrMsg, 'banded added mass lengths must be finite and positive') + RETURN + END IF + END IF IF (want_tangent) THEN model%free_map_work(1:n) = 0 @@ -7693,16 +8197,18 @@ SUBROUTINE model_added_mass_banded(model, q, accel, free, kl, ku, M_add_a, M_add DO e = 1, model%n_elem CALL extract_element_state(model, e, q, accel, idx, q2, a2) CALL extract_nodal_scalar(model%added_mass_waterline_z, model, e, wl2) + le = model%l0(e) + IF (PRESENT(l0_elem)) le = l0_elem(e) IF (want_tangent) THEN IF (zero_accel) THEN - CALL CD_Added_Mass_Element_Matrix(q2(1:3), q2(4:6), model%l0(e), wl2(1), wl2(2), & + CALL CD_Added_Mass_Element_Matrix(q2(1:3), q2(4:6), le, wl2(1), wl2(2), & model%added_mass_rho, model%added_mass_diameter_elem(e), & model%added_mass_can_elem(e), model%added_mass_cat_elem(e), & m2, ErrStat, ErrMsg, inputs_validated=.TRUE.) IF (ErrStat /= 0) RETURN ma2 = CD_ZERO ELSE - CALL CD_Added_Mass_Element(q2(1:3), q2(4:6), a2(1:3), a2(4:6), model%l0(e), wl2(1), wl2(2), & + CALL CD_Added_Mass_Element(q2(1:3), q2(4:6), a2(1:3), a2(4:6), le, wl2(1), wl2(2), & model%added_mass_rho, model%added_mass_diameter_elem(e), & model%added_mass_can_elem(e), model%added_mass_cat_elem(e), & m2, dm2, ErrStat, ErrMsg, inputs_validated=.TRUE.) @@ -7710,7 +8216,7 @@ SUBROUTINE model_added_mass_banded(model, q, accel, free, kl, ku, M_add_a, M_add ma2 = MATMUL(m2, a2) END IF ELSE - CALL CD_Added_Mass_Element_Force(q2(1:3), q2(4:6), a2(1:3), a2(4:6), model%l0(e), wl2(1), wl2(2), & + CALL CD_Added_Mass_Element_Force(q2(1:3), q2(4:6), a2(1:3), a2(4:6), le, wl2(1), wl2(2), & model%added_mass_rho, model%added_mass_diameter_elem(e), & model%added_mass_can_elem(e), model%added_mass_cat_elem(e), & ma2, ErrStat, ErrMsg, inputs_validated=.TRUE.) diff --git a/src/CableDyn_OpenFAST_Aggregate.f90 b/src/CableDyn_OpenFAST_Aggregate.f90 index 2abb1d4f..1b06e130 100644 --- a/src/CableDyn_OpenFAST_Aggregate.f90 +++ b/src/CableDyn_OpenFAST_Aggregate.f90 @@ -53,8 +53,12 @@ MODULE CableDyn_OpenFAST_Aggregate CD_HFMF_SetCoupledKinematics, CD_HFMF_GetCoupledKinematics, & CD_HFMF_End, CD_HFMF_OK, CD_HFMF_BADINPUT, & CD_HFMF_Snapshot, CD_HFMF_Restore, & - CD_HFMF_Set_Held_Fluid, CD_HFMF_NNodes, CD_HFMF_GetNodePositions - USE CableDyn_HermiteCableDynamic, ONLY: CD_HermiteCable_Dyn_Profile_Enabled + CD_HFMF_Set_Held_Fluid, CD_HFMF_NNodes, CD_HFMF_GetNodePositions, & + CD_HFMF_Set_SegmentLength + USE CableDyn_HermiteCableDynamic, ONLY: CD_HermiteCable_Dyn_Profile_Enabled, CD_HermiteCableControlSaveType, & + CD_HermiteCable_Dyn_Save_Control, CD_HermiteCable_Dyn_Restore_Control, & + CD_HCDYN_OK + USE CableDyn_Model, ONLY: CD_ModelControlSaveType USE CableDyn_DeckDriver, ONLY: CD_DeckAggregateType, CD_Init_Deck_Aggregate, CD_End_Deck_Aggregate, & CD_DECKDRV_OK, CD_DECKDRV_BADINPUT, CD_Eval_Aggregate_Channel, & CD_Cable_Deck_Node, & @@ -78,7 +82,8 @@ MODULE CableDyn_OpenFAST_Aggregate USE CableDyn_RangeOutput, ONLY: CD_RangeSet, CD_Range_End USE CableDyn_System, ONLY: CD_Get_System_Substep_Counts, CD_System_NLines, CD_System_Line_NDOF, & CD_Get_System_Line_State, & - CD_Update_System_Line_SegmentLength, & + CD_Update_System_Line_SegmentLength, CD_Save_System_Line_Control, & + CD_Restore_System_Line_Control, & CD_Update_System_Line_Hydro_Fields, CD_SYSTEM_OK, & CD_System_NHydroPoints, CD_Get_System_HydroPoint_Positions, & CD_Set_System_HydroPoint_Fluid @@ -190,13 +195,23 @@ MODULE CableDyn_OpenFAST_Aggregate TYPE(DeckLine), ALLOCATABLE :: fail_lines(:) TYPE(DeckPoint), ALLOCATABLE :: fail_points(:) TYPE(DeckFailure), ALLOCATABLE :: snap_failures(:) - ! Active line control (CONTROL section): flattened channel -> (line, last - ! element, base length) table; ctrl_warned suppresses the MoorDyn bound - ! warnings after the first exceedance per row. + ! Active line control (CONTROL section): flattened channel -> (line, controlled + ! element, base length) table. The controlled segment is the deck segment at the line's + ! fairlead-side end (see CD_DeckAggregateType). A finite-EI row (ctrl_is_cable) holds + ! the cable index, the first of the ctrl_nelem cable elements of that segment and its + ! base length S; their base lengths sit at ctrl_span_l0(ctrl_span_off + 1:). INTEGER :: n_ctrl_chans = 0 - INTEGER, ALLOCATABLE :: ctrl_chan(:), ctrl_line(:), ctrl_elem(:) + INTEGER, ALLOCATABLE :: ctrl_chan(:), ctrl_line(:), ctrl_elem(:), ctrl_nelem(:) REAL(wp), ALLOCATABLE :: ctrl_base_l0(:) - LOGICAL, ALLOCATABLE :: ctrl_warned(:) + ! the deck line's unstretched length and segment count, MoorDyn-F's UnstrLen and N + REAL(wp), ALLOCATABLE :: ctrl_unstr_len(:) + INTEGER, ALLOCATABLE :: ctrl_nsegs(:) + ! per row, the object it changes as it was before the change (CD_AGG_Apply_LineControl) + TYPE(CD_HermiteCableControlSaveType), ALLOCATABLE :: ctrl_cable_saved(:) + TYPE(CD_ModelControlSaveType), ALLOCATABLE :: ctrl_line_saved(:) + LOGICAL, ALLOCATABLE :: ctrl_is_cable(:) + INTEGER, ALLOCATABLE :: ctrl_line_id(:), ctrl_span_off(:) + REAL(wp), ALLOCATABLE :: ctrl_span_l0(:) ! Coupled Rigid6 bodies (pure EI=0 deck): the opaque runtime the facade marches over the ! EI=0 system each mooring step, in place of the plain moving step. has_rigid6 selects the ! body-march branch; the runtime's own snapshot buffer joins the aggregate snapshot/restore. @@ -345,9 +360,14 @@ SUBROUTINE CD_AGG_Init_From_Deck(self, deck_path, dt, ErrStat, ErrMsg, env_gravi CALL MOVE_ALLOC(parts%ctrl_chan, candidate%ctrl_chan) CALL MOVE_ALLOC(parts%ctrl_line, candidate%ctrl_line) CALL MOVE_ALLOC(parts%ctrl_elem, candidate%ctrl_elem) + CALL MOVE_ALLOC(parts%ctrl_nelem, candidate%ctrl_nelem) CALL MOVE_ALLOC(parts%ctrl_base_l0, candidate%ctrl_base_l0) - ALLOCATE (candidate%ctrl_warned(SIZE(candidate%ctrl_chan))) - candidate%ctrl_warned = .FALSE. + CALL MOVE_ALLOC(parts%ctrl_unstr_len, candidate%ctrl_unstr_len) + CALL MOVE_ALLOC(parts%ctrl_nsegs, candidate%ctrl_nsegs) + CALL MOVE_ALLOC(parts%ctrl_is_cable, candidate%ctrl_is_cable) + CALL MOVE_ALLOC(parts%ctrl_line_id, candidate%ctrl_line_id) + CALL MOVE_ALLOC(parts%ctrl_span_off, candidate%ctrl_span_off) + CALL MOVE_ALLOC(parts%ctrl_span_l0, candidate%ctrl_span_l0) END IF ! Coupled Rigid6 decks: take over the opaque body runtime (deep-copied by the intrinsic ! assignment; the deck bundle is released in CD_End_Deck_Aggregate below). @@ -1700,30 +1720,45 @@ INTEGER FUNCTION CD_AGG_NCtrlChans(self) RESULT(n) n = self%n_ctrl_chans END FUNCTION CD_AGG_NCtrlChans - SUBROUTINE CD_AGG_Apply_LineControl(self, delta_l, delta_l_dot, ErrStat, ErrMsg) - !! Apply the host's cable-control command BEFORE an advance: for every - !! controlled line, the LAST (fairlead-side) segment's unstretched length - !! becomes base + delta_l(chan) with rate delta_l_dot(chan) -- the MoorDyn - !! convention, applied unclamped with the MoorDyn warning bounds (an increase - !! beyond one base segment length or a reduction past half of it warns once - !! per row and proceeds). + SUBROUTINE CD_AGG_Apply_LineControl(self, delta_l, delta_l_dot, ErrStat, ErrMsg, restored) + !! Apply the host's cable-control command BEFORE an advance to the deck segment at the + !! fairlead-side end of each controlled line: the end on a host-driven point, else the + !! written NodeB (MoorDyn's AttachB, its segment N). On an EI = 0 line that element's + !! unstretched length becomes base + delta_l(chan) with rate delta_l_dot(chan) -- the + !! MoorDyn convention. On a finite-EI cable every cable element of that segment (base + !! length S) scales by (S + delta_l)/S, with rate delta_l_dot*l_e/S, so the segment takes + !! the same length and rate. + !! A command outside MoorDyn-F's bounds fails closed by channel and line, as MoorDyn-F + !! stops the run there (ErrID_Fatal): with UnstrLen and N the deck line's unstretched + !! length and segment count (summed over its sections), MoorDyn-F refuses + !! DeltaL > UnstrLen/N and DeltaL < -0.5*UnstrLen/N (MoorDyn.f90, the active-tension + !! bounds check), the same comparisons in the same precision, so a command MoorDyn-F + !! accepts is accepted here. On a uniform line UnstrLen/N is the controlled segment's + !! base length S. On a line of several sections the controlled segment can be shorter + !! than UnstrLen/N/2, so a command within the bounds can still make it non-positive; + !! that fails closed as well. + !! Every row is checked before any line changes, and the objects the loop already + !! changed are put back, bit for bit, if a later row fails after all (a capability the + !! initialisation could not verify, an allocation): a refused command writes nothing. + !! On both kinds the committed state keeps the lengths it was reached with until the + !! next advance commits the new ones. restored = .TRUE. is the checkpoint-restart + !! re-application of the command the committed state was reached with: the lengths + !! become the committed ones at once. TYPE(CD_AGG_ModuleType), INTENT(INOUT) :: self REAL(wp), INTENT(IN) :: delta_l(:), delta_l_dot(:) INTEGER, INTENT(OUT) :: ErrStat CHARACTER(*), INTENT(OUT) :: ErrMsg + LOGICAL, INTENT(IN), OPTIONAL :: restored - INTEGER :: c, ch, es + INTEGER :: c, ch, es, nspan, k, nrow + REAL(wp) :: lambda, mean_seg CHARACTER(512) :: em + CHARACTER(16) :: line_kind ErrStat = CD_AGG_OK ErrMsg = '' IF (.NOT. require_initialized(self, ErrStat, ErrMsg)) RETURN IF (.NOT. ALLOCATED(self%ctrl_chan)) RETURN - IF (.NOT. self%has_sys) THEN - ErrStat = CD_AGG_BADINPUT - ErrMsg = 'CableDyn_OpenFAST_Aggregate: line control requires the EI=0 system' - RETURN - END IF IF (SIZE(delta_l) < self%n_ctrl_chans .OR. SIZE(delta_l_dot) < self%n_ctrl_chans) THEN ErrStat = CD_AGG_BADINPUT ErrMsg = 'CableDyn_OpenFAST_Aggregate: the control command must cover every declared channel' @@ -1734,33 +1769,114 @@ SUBROUTINE CD_AGG_Apply_LineControl(self, delta_l, delta_l_dot, ErrStat, ErrMsg) ErrMsg = 'CableDyn_OpenFAST_Aggregate: the control command must be finite' RETURN END IF - ! PREVALIDATE every row before mutating any line: a bad later row must not - ! leave the aggregate at mixed lengths (the caller may treat BADINPUT as - ! recoverable). - DO c = 1, SIZE(self%ctrl_chan) - IF (delta_l(self%ctrl_chan(c)) <= -self%ctrl_base_l0(c)) THEN + nrow = SIZE(self%ctrl_chan) + ! PREVALIDATE every row before mutating any line + DO c = 1, nrow + ch = self%ctrl_chan(c) + IF (self%ctrl_is_cable(c)) THEN + line_kind = 'finite-EI' + IF (self%ctrl_line(c) < 1 .OR. self%ctrl_line(c) > self%ncable) THEN + ErrStat = CD_AGG_BADINPUT + ErrMsg = 'CableDyn_OpenFAST_Aggregate: line control addresses a cable the aggregate does not own' + RETURN + END IF + ELSE + line_kind = 'EI = 0' + IF (.NOT. self%has_sys) THEN + ErrStat = CD_AGG_BADINPUT + ErrMsg = 'CableDyn_OpenFAST_Aggregate: line control requires the EI=0 system' + RETURN + END IF + END IF + ! MoorDyn-F's bounds, written as MoorDyn-F evaluates them + mean_seg = self%ctrl_unstr_len(c)/REAL(self%ctrl_nsegs(c), wp) + IF (delta_l(ch) > self%ctrl_unstr_len(c)/REAL(self%ctrl_nsegs(c), wp) .OR. & + delta_l(ch) < -0.5_wp*self%ctrl_unstr_len(c)/REAL(self%ctrl_nsegs(c), wp)) THEN + ErrStat = CD_AGG_BADINPUT + WRITE (em, '(A,I0,A,ES12.5,A,I0,A,ES12.5,A)') 'CableDyn_OpenFAST_Aggregate: control channel ', ch, & + ' commands DeltaL = ', delta_l(ch), ' m on '//TRIM(line_kind)//' line ', self%ctrl_line_id(c), & + ', outside MoorDyn-F''s bounds -S/2 <= DeltaL <= S (S = UnstrLen/N = ', mean_seg, ' m)' + ErrMsg = TRIM(em) + RETURN + END IF + IF (.NOT. (self%ctrl_base_l0(c) + delta_l(ch) > CD_ZERO)) THEN ErrStat = CD_AGG_BADINPUT - ErrMsg = 'CableDyn_OpenFAST_Aggregate: DeltaL reduces a controlled segment to a non-positive length' + WRITE (em, '(A,I0,A,ES12.5,A,I0,A,ES12.5,A)') 'CableDyn_OpenFAST_Aggregate: control channel ', ch, & + ' commands DeltaL = ', delta_l(ch), ' m on '//TRIM(line_kind)//' line ', self%ctrl_line_id(c), & + ', which would make its controlled segment (', self%ctrl_base_l0(c), ' m long) non-positive' + ErrMsg = TRIM(em) RETURN END IF END DO - DO c = 1, SIZE(self%ctrl_chan) + ! The objects each row changes, as they are before its change (kept from step to step, + ! so the saves allocate once) + IF (ALLOCATED(self%ctrl_cable_saved)) THEN + IF (SIZE(self%ctrl_cable_saved) /= nrow) DEALLOCATE (self%ctrl_cable_saved, self%ctrl_line_saved) + END IF + IF (.NOT. ALLOCATED(self%ctrl_cable_saved)) ALLOCATE (self%ctrl_cable_saved(nrow), self%ctrl_line_saved(nrow)) + DO c = 1, nrow ch = self%ctrl_chan(c) - IF (.NOT. self%ctrl_warned(c)) THEN - IF (delta_l(ch) > self%ctrl_base_l0(c) .OR. delta_l(ch) < -0.5_wp*self%ctrl_base_l0(c)) THEN - WRITE (*, '(A,I0,A)') 'CableDyn: WARNING -- control channel ', ch, & - ' DeltaL exceeds the MoorDyn advisory bounds (+1/-0.5 segment lengths); applying unclamped' - self%ctrl_warned(c) = .TRUE. + IF (self%ctrl_is_cable(c)) THEN + CALL CD_HermiteCable_Dyn_Save_Control(self%cables(self%ctrl_line(c))%line, self%ctrl_cable_saved(c)) + nspan = self%ctrl_nelem(c) + BLOCK + INTEGER :: elems(nspan) + REAL(wp) :: l0_new(nspan), l0_rate(nspan), base + lambda = (self%ctrl_base_l0(c) + delta_l(ch))/self%ctrl_base_l0(c) + DO k = 1, nspan + base = self%ctrl_span_l0(self%ctrl_span_off(c) + k) + elems(k) = self%ctrl_elem(c) + k - 1 + l0_new(k) = base*lambda + l0_rate(k) = delta_l_dot(ch)*base/self%ctrl_base_l0(c) + END DO + CALL CD_HFMF_Set_SegmentLength(self%cables(self%ctrl_line(c)), elems, l0_new, l0_rate, es, em, & + restored=restored) + END BLOCK + IF (es /= CD_HFMF_OK) THEN + CALL take_back(c - 1, 'CableDyn_OpenFAST_Aggregate: line-control update failed: '//TRIM(em)) + RETURN + END IF + ELSE + CALL CD_Save_System_Line_Control(self%sys%fast%system, self%ctrl_line(c), self%ctrl_line_saved(c), es, em) + IF (es == CD_SYSTEM_OK) & + CALL CD_Update_System_Line_SegmentLength(self%sys%fast%system, self%ctrl_line(c), self%ctrl_elem(c), & + self%ctrl_base_l0(c) + delta_l(ch), delta_l_dot(ch), es, em, & + restored=restored) + IF (es /= CD_SYSTEM_OK) THEN + CALL take_back(c - 1, 'CableDyn_OpenFAST_Aggregate: line-control update failed: '//TRIM(em)) + RETURN END IF - END IF - CALL CD_Update_System_Line_SegmentLength(self%sys%fast%system, self%ctrl_line(c), self%ctrl_elem(c), & - self%ctrl_base_l0(c) + delta_l(ch), delta_l_dot(ch), es, em) - IF (es /= CD_SYSTEM_OK) THEN - ErrStat = CD_AGG_BADINPUT - ErrMsg = 'CableDyn_OpenFAST_Aggregate: line-control update failed: '//TRIM(em) - RETURN END IF END DO + + CONTAINS + + SUBROUTINE take_back(last, msg) + !! A row failed after the rows 1..last were applied: put their objects back, the latest + !! first (a line named in two rows ends at its state before the first), and report msg. + INTEGER, INTENT(IN) :: last + CHARACTER(*), INTENT(IN) :: msg + INTEGER :: r, es2 + CHARACTER(512) :: em2, em_undo + em_undo = '' + DO r = last, 1, -1 + IF (self%ctrl_is_cable(r)) THEN + CALL CD_HermiteCable_Dyn_Restore_Control(self%cables(self%ctrl_line(r))%line, self%ctrl_cable_saved(r), & + es2, em2) + IF (es2 /= CD_HCDYN_OK) em_undo = em2 + ELSE + CALL CD_Restore_System_Line_Control(self%sys%fast%system, self%ctrl_line(r), self%ctrl_line_saved(r), & + es2, em2) + IF (es2 /= CD_SYSTEM_OK) em_undo = em2 + END IF + END DO + ErrStat = CD_AGG_BADINPUT + IF (LEN_TRIM(em_undo) == 0) THEN + ErrMsg = msg + ELSE + ErrMsg = msg//'; the lines it had already changed could not all be put back: '//TRIM(em_undo) + END IF + END SUBROUTINE take_back END SUBROUTINE CD_AGG_Apply_LineControl INTEGER FUNCTION CD_AGG_NFailures(self) RESULT(n) @@ -1851,8 +1967,16 @@ SUBROUTINE CD_AGG_End(self, ErrStat, ErrMsg) IF (ALLOCATED(self%ctrl_chan)) DEALLOCATE (self%ctrl_chan) IF (ALLOCATED(self%ctrl_line)) DEALLOCATE (self%ctrl_line) IF (ALLOCATED(self%ctrl_elem)) DEALLOCATE (self%ctrl_elem) + IF (ALLOCATED(self%ctrl_nelem)) DEALLOCATE (self%ctrl_nelem) IF (ALLOCATED(self%ctrl_base_l0)) DEALLOCATE (self%ctrl_base_l0) - IF (ALLOCATED(self%ctrl_warned)) DEALLOCATE (self%ctrl_warned) + IF (ALLOCATED(self%ctrl_unstr_len)) DEALLOCATE (self%ctrl_unstr_len) + IF (ALLOCATED(self%ctrl_nsegs)) DEALLOCATE (self%ctrl_nsegs) + IF (ALLOCATED(self%ctrl_cable_saved)) DEALLOCATE (self%ctrl_cable_saved) + IF (ALLOCATED(self%ctrl_line_saved)) DEALLOCATE (self%ctrl_line_saved) + IF (ALLOCATED(self%ctrl_is_cable)) DEALLOCATE (self%ctrl_is_cable) + IF (ALLOCATED(self%ctrl_line_id)) DEALLOCATE (self%ctrl_line_id) + IF (ALLOCATED(self%ctrl_span_off)) DEALLOCATE (self%ctrl_span_off) + IF (ALLOCATED(self%ctrl_span_l0)) DEALLOCATE (self%ctrl_span_l0) CALL CD_Rigid6_End(self%rigid6) self%has_rigid6 = .FALSE. CALL CD_Rod_End(self%rod) diff --git a/src/CableDyn_OpenFAST_HermiteFMF.f90 b/src/CableDyn_OpenFAST_HermiteFMF.f90 index 66f14b96..01853ea9 100644 --- a/src/CableDyn_OpenFAST_HermiteFMF.f90 +++ b/src/CableDyn_OpenFAST_HermiteFMF.f90 @@ -41,7 +41,8 @@ MODULE CableDyn_OpenFAST_HermiteFMF CD_HermiteCable_Dyn_Snapshot, CD_HermiteCable_Dyn_Restore, & CD_HermiteCable_Dyn_End, CD_HCDYN_OK, & CD_HermiteCable_Dyn_Set_Torsion, CD_HermiteCable_Dyn_Set_Torsion_Drive, & - CD_HermiteCable_Dyn_Set_Torsion_Frames + CD_HermiteCable_Dyn_Set_Torsion_Frames, & + CD_HermiteCable_Dyn_Set_SegmentLength USE CableDyn_HermiteTorsion, ONLY: CD_HermiteTorsionType, CD_HermiteTorsion_Compliance, CD_HermiteTorsion_Line, & CD_HermiteTorsion_Unwrap, CD_HTORS_OK, CD_HTORS_MAX_STEP USE CableDyn_HermiteCable, ONLY: CD_HermiteCable_Shapes @@ -65,6 +66,7 @@ MODULE CableDyn_OpenFAST_HermiteFMF PUBLIC :: CD_HFMF_Set_Waves PUBLIC :: CD_HFMF_Set_Held_Fluid PUBLIC :: CD_HFMF_Set_Contact + PUBLIC :: CD_HFMF_Set_SegmentLength PUBLIC :: CD_HFMF_Set_Attachments PUBLIC :: CD_HFMF_Set_EndConnection PUBLIC :: CD_HFMF_Set_Torsion @@ -1194,6 +1196,29 @@ SUBROUTINE CD_HFMF_Set_Contact(self, kn_node, cn_node, mu, ErrStat, ErrMsg, bath END IF END SUBROUTINE CD_HFMF_Set_Contact + SUBROUTINE CD_HFMF_Set_SegmentLength(self, elems, l0_new, l0_dot, ErrStat, ErrMsg, restored) + !! Active line control through the FMF owner: set the unstretched lengths and their rates + !! of the listed elements before the next UpdateStates (CD_HermiteCable_Dyn_Set_SegmentLength). + !! Lengths do not depend on the frame, so the cable heading plays no part. + TYPE(CD_HFMF_ModuleType), INTENT(INOUT) :: self + INTEGER, INTENT(IN) :: elems(:) + REAL(wp), INTENT(IN) :: l0_new(:), l0_dot(:) + LOGICAL, INTENT(IN), OPTIONAL :: restored + INTEGER, INTENT(OUT) :: ErrStat + CHARACTER(*), INTENT(OUT) :: ErrMsg + INTEGER :: es + CHARACTER(300) :: em + + ErrStat = CD_HFMF_OK; ErrMsg = '' + IF (.NOT. self%initialized) THEN + ErrStat = CD_HFMF_BADINPUT; ErrMsg = 'CD_HFMF_Set_SegmentLength: module not initialised'; RETURN + END IF + CALL CD_HermiteCable_Dyn_Set_SegmentLength(self%line, elems, l0_new, l0_dot, es, em, restored=restored) + IF (es /= CD_HCDYN_OK) THEN + ErrStat = CD_HFMF_BADINPUT; ErrMsg = 'CD_HFMF_Set_SegmentLength: '//TRIM(em) + END IF + END SUBROUTINE CD_HFMF_Set_SegmentLength + SUBROUTINE CD_HFMF_Refresh_Acceleration(self, ErrStat, ErrMsg) !! Recompute free-node acceleration after a direct-feedthrough boundary commit. !! The caller-prescribed coupled acceleration participates in the consistent-mass @@ -1660,6 +1685,13 @@ SUBROUTINE CD_HFMF_UnpackMirror(self, buf, t, ErrStat, ErrMsg) ! The reloaded acceleration is committed history: a first held fluid field after the ! reload (the host re-sampling its field on the restored state) must keep it. self%line%a_restored = .TRUE. + ! Active line control: the reloaded state is committed with the lengths and rates in + ! place now, so the caller re-applies the command of the checkpointed step BEFORE the + ! reload (the committed force F_n belongs to those lengths). + IF (self%line%has_ctrl) THEN + self%line%l0_c = self%line%l0 + self%line%l0_dot_c = self%line%l0_dot + END IF ! the force-blend committed force reloads with the state it was evaluated at self%line%fc_valid = .FALSE. IF (self%line%force_blend) THEN diff --git a/src/CableDyn_System.f90 b/src/CableDyn_System.f90 index 34dcc24a..bf5b025f 100644 --- a/src/CableDyn_System.f90 +++ b/src/CableDyn_System.f90 @@ -20,7 +20,8 @@ MODULE CableDyn_System CD_Model_Has_Friction, CD_Get_Model_Friction_Anchors, CD_Set_Model_Friction_Anchors, & CD_Get_Model_EndNodeMassDiag, CD_Get_Model_EndNodeAddedMass, & CD_Get_Model_EndNodeTangent, CD_Set_Model_EndQuery, CD_Get_Model_EndQuery, & - CD_Update_Model_SegmentLength, & + CD_Update_Model_SegmentLength, CD_ModelControlSaveType, CD_Save_Model_Control, & + CD_Restore_Model_Control, & CD_Update_Model_CoupledMotion, CD_Update_Model_Interior_State, CD_Step_Model, & CD_Get_Model_Substep_Counts, CD_SubstepStats, & CD_Calc_Model_CoupledLoads, CD_Recompute_Model_Acceleration, & @@ -98,6 +99,7 @@ MODULE CableDyn_System PUBLIC :: CD_System_Point_Environment PUBLIC :: CD_Detach_System_LineEnds PUBLIC :: CD_Update_System_Line_SegmentLength + PUBLIC :: CD_Save_System_Line_Control, CD_Restore_System_Line_Control PUBLIC :: CD_System_Is_Initialized PUBLIC :: CD_System_Has_DynamicPoints @@ -210,7 +212,7 @@ MODULE CableDyn_System ! init helpers (bitwise-deterministic), and the distributed-load remainder ! restores with f_ext -- the documented bit-identical restore must hold ! WITHOUT the caller re-applying its command. - REAL(wp), ALLOCATABLE :: snap_l0(:), snap_l0_dot(:), snap_fbase(:) + REAL(wp), ALLOCATABLE :: snap_l0(:), snap_l0_dot(:), snap_fbase(:), snap_l0_c(:), snap_l0_dot_c(:) ! Viscoelastic dl_1 joins the snapshot (per-element, concatenated like ! snap_l0): the state advances with every committed line step, so the ! aggregate stage-then-commit restore must rewind it with q/v/a. @@ -455,6 +457,7 @@ SUBROUTINE CD_End_System(system, ErrStat, ErrMsg) IF (ALLOCATED(system%snap_bindings)) DEALLOCATE (system%snap_bindings) IF (ALLOCATED(system%snap_map)) DEALLOCATE (system%snap_map) IF (ALLOCATED(system%snap_l0)) DEALLOCATE (system%snap_l0, system%snap_l0_dot) + IF (ALLOCATED(system%snap_l0_c)) DEALLOCATE (system%snap_l0_c, system%snap_l0_dot_c) IF (ALLOCATED(system%snap_fbase)) DEALLOCATE (system%snap_fbase) IF (ALLOCATED(system%snap_ve_dl_1)) DEALLOCATE (system%snap_ve_dl_1) IF (ALLOCATED(system%snap_syrope_slow)) DEALLOCATE (system%snap_syrope_slow, system%snap_syrope_tmax) @@ -1254,11 +1257,11 @@ RECURSIVE SUBROUTINE CD_Step_System(system, dt, q_coupled, v_coupled, a_coupled, INTEGER, PARAMETER :: MAX_SUBDIV = 6 ! floor dt/64: resolves any benign line-search stall INTEGER :: i, j, lo, hi, nc, es, line_dof, sys_dof, depth, iter2, ntot, nve, nsy, lo_ve, lo_sy, ne, nfr, lo_fr - INTEGER :: n_team + INTEGER :: n_team, nel, lo_el LOGICAL :: conv2, stall2 CHARACTER(160) :: em REAL(wp), ALLOCATABLE :: q0(:), v0(:), a0(:), qm(:), vm(:), am(:), qs(:), vs(:), as(:) - REAL(wp), ALLOCATABLE :: dl1s(:), slows(:), tmaxs(:), frs(:, :), hmaxs(:) + REAL(wp), ALLOCATABLE :: dl1s(:), slows(:), tmaxs(:), frs(:, :), hmaxs(:), l0cs(:), l0dcs(:) TYPE(CD_SubstepStats), ALLOCATABLE :: subs(:) converged = .FALSE. @@ -1380,24 +1383,29 @@ RECURSIVE SUBROUTINE CD_Step_System(system, dt, q_coupled, v_coupled, a_coupled, lo = lo + nc END DO CALL restore_line_states(system) - ! The frame snapshot covers every state a line step commits: the kinematics and the - ! viscoelastic / Syrope history variables. + ! The frame snapshot covers every state a line step commits: the kinematics, the + ! viscoelastic / Syrope history variables and the lengths and rates the committed state + ! was reached with (active line control: a converged first half commits the new + ! lengths, so a restore without them would re-run the full step unblended). ntot = 0 nve = 0 nsy = 0 nfr = 0 + nel = 0 DO i = 1, system%n_lines ntot = ntot + SIZE(system%lines(i)%q) + nel = nel + SIZE(system%lines(i)%l0_c) IF (system%lines(i)%has_viscoelastic) nve = nve + SIZE(system%lines(i)%ve_dl_1) IF (system%lines(i)%has_syrope) nsy = nsy + SIZE(system%lines(i)%syrope_slow) IF (CD_Model_Has_Friction(system%lines(i))) nfr = nfr + SIZE(system%lines(i)%fr_anchor, 2) END DO ALLOCATE (qs(ntot), vs(ntot), as(ntot), dl1s(nve), slows(nsy), tmaxs(nsy), frs(2, nfr), & - hmaxs(system%n_lines), subs(system%n_lines)) + hmaxs(system%n_lines), subs(system%n_lines), l0cs(nel), l0dcs(nel)) lo = 1 lo_ve = 1 lo_sy = 1 lo_fr = 1 + lo_el = 1 DO i = 1, system%n_lines hi = lo + SIZE(system%lines(i)%q) - 1 qs(lo:hi) = system%lines(i)%q @@ -1408,6 +1416,10 @@ RECURSIVE SUBROUTINE CD_Step_System(system, dt, q_coupled, v_coupled, a_coupled, hmaxs(i) = system%lines(i)%audit_hmax subs(i) = system%lines(i)%sub_stats lo = hi + 1 + ne = SIZE(system%lines(i)%l0_c) + l0cs(lo_el:lo_el + ne - 1) = system%lines(i)%l0_c + l0dcs(lo_el:lo_el + ne - 1) = system%lines(i)%l0_dot_c + lo_el = lo_el + ne IF (CD_Model_Has_Friction(system%lines(i))) THEN ne = SIZE(system%lines(i)%fr_anchor, 2) frs(:, lo_fr:lo_fr + ne - 1) = system%lines(i)%fr_anchor @@ -1444,6 +1456,7 @@ RECURSIVE SUBROUTINE CD_Step_System(system, dt, q_coupled, v_coupled, a_coupled, lo_ve = 1 lo_sy = 1 lo_fr = 1 + lo_el = 1 DO i = 1, system%n_lines hi = lo + SIZE(system%lines(i)%q) - 1 system%lines(i)%q = qs(lo:hi) @@ -1452,6 +1465,10 @@ RECURSIVE SUBROUTINE CD_Step_System(system, dt, q_coupled, v_coupled, a_coupled, system%lines(i)%audit_hmax = hmaxs(i) system%lines(i)%sub_stats = subs(i) lo = hi + 1 + ne = SIZE(system%lines(i)%l0_c) + system%lines(i)%l0_c = l0cs(lo_el:lo_el + ne - 1) + system%lines(i)%l0_dot_c = l0dcs(lo_el:lo_el + ne - 1) + lo_el = lo_el + ne IF (CD_Model_Has_Friction(system%lines(i))) THEN ne = SIZE(system%lines(i)%fr_anchor, 2) system%lines(i)%fr_anchor = frs(:, lo_fr:lo_fr + ne - 1) @@ -1893,18 +1910,21 @@ PURE SUBROUTINE solve_spd3(A, b, x, ok) IF (.NOT. ok) x = CD_ZERO END SUBROUTINE solve_spd3 - SUBROUTINE CD_Update_System_Line_SegmentLength(system, line_index, elem, l0_new, l0_dot, ErrStat, ErrMsg) + SUBROUTINE CD_Update_System_Line_SegmentLength(system, line_index, elem, l0_new, l0_dot, ErrStat, ErrMsg, & + restored) !! Active line control at the system level: update one element's unstretched !! length/rate on a contained line (CD_Update_Model_SegmentLength does the model !! work) and RECOMPUTE the end-node consistent-mass diagonal shares of every !! point bound to that line -- the implicit share a Free/Connect point carries !! (see the massless-point step) reads rho_a*l0/3, so a length change on an end - !! element moves it. + !! element moves it. restored = .TRUE. marks the length and rate as the committed + !! state's (a checkpoint restart re-applying the restored command). TYPE(CD_SystemType), INTENT(INOUT) :: system INTEGER, INTENT(IN) :: line_index, elem REAL(wp), INTENT(IN) :: l0_new, l0_dot INTEGER, INTENT(OUT) :: ErrStat CHARACTER(*), INTENT(OUT) :: ErrMsg + LOGICAL, INTENT(IN), OPTIONAL :: restored INTEGER :: k, i, kb, es REAL(wp) :: md @@ -1934,7 +1954,7 @@ SUBROUTINE CD_Update_System_Line_SegmentLength(system, line_index, elem, l0_new, END DO END DO END IF - CALL CD_Update_Model_SegmentLength(system%lines(line_index), elem, l0_new, l0_dot, es, em) + CALL CD_Update_Model_SegmentLength(system%lines(line_index), elem, l0_new, l0_dot, es, em, restored=restored) IF (es /= CD_MODEL_OK) THEN CALL fail(ErrStat, ErrMsg, 'segment-length update failed: '//TRIM(em)) RETURN @@ -1951,6 +1971,49 @@ SUBROUTINE CD_Update_System_Line_SegmentLength(system, line_index, elem, l0_new, END DO END SUBROUTINE CD_Update_System_Line_SegmentLength + SUBROUTINE CD_Save_System_Line_Control(system, line_index, saved, ErrStat, ErrMsg) + !! Save what CD_Update_System_Line_SegmentLength writes on one contained line + !! (CD_Save_Model_Control), for CD_Restore_System_Line_Control. + TYPE(CD_SystemType), INTENT(IN) :: system + INTEGER, INTENT(IN) :: line_index + TYPE(CD_ModelControlSaveType), INTENT(INOUT) :: saved + INTEGER, INTENT(OUT) :: ErrStat + CHARACTER(*), INTENT(OUT) :: ErrMsg + CALL validate_line_index(system, line_index, ErrStat, ErrMsg) + IF (ErrStat /= CD_SYSTEM_OK) RETURN + CALL CD_Save_Model_Control(system%lines(line_index), saved) + END SUBROUTINE CD_Save_System_Line_Control + + SUBROUTINE CD_Restore_System_Line_Control(system, line_index, saved, ErrStat, ErrMsg) + !! Take one contained line back to what CD_Save_System_Line_Control saved, bit for bit, + !! and re-accumulate the end-node mass-diagonal shares of the Free/Connect points bound to + !! it from the restored lengths (the accumulation the update and initialisation perform). + TYPE(CD_SystemType), INTENT(INOUT) :: system + INTEGER, INTENT(IN) :: line_index + TYPE(CD_ModelControlSaveType), INTENT(IN) :: saved + INTEGER, INTENT(OUT) :: ErrStat + CHARACTER(*), INTENT(OUT) :: ErrMsg + INTEGER :: k, i, es + CHARACTER(240) :: em + CALL validate_line_index(system, line_index, ErrStat, ErrMsg) + IF (ErrStat /= CD_SYSTEM_OK) RETURN + CALL CD_Restore_Model_Control(system%lines(line_index), saved, es, em) + IF (es /= CD_MODEL_OK) THEN + CALL fail(ErrStat, ErrMsg, TRIM(em)) + RETURN + END IF + IF (.NOT. (ALLOCATED(system%points) .AND. ALLOCATED(system%bindings))) RETURN + DO k = 1, SIZE(system%bindings) + IF (system%bindings(k)%line_index /= line_index) CYCLE + i = find_point_index(system%points, system%bindings(k)%point_id) + IF (i < 1) CYCLE + IF (system%points(i)%point_type /= CD_POINT_FREE .AND. & + system%points(i)%point_type /= CD_POINT_CONNECT) CYCLE + CALL recompute_point_line_mass_diag(system, i, ErrStat, ErrMsg) + IF (ErrStat /= CD_SYSTEM_OK) RETURN + END DO + END SUBROUTINE CD_Restore_System_Line_Control + SUBROUTINE recompute_point_line_mass_diag(system, point_index, ErrStat, ErrMsg) !! Re-accumulate one point's attached end-node consistent-mass diagonal share !! from its CURRENT bindings (the same accumulation init performs). @@ -2978,6 +3041,9 @@ SUBROUTINE save_line_states(system, ErrStat, ErrMsg) system%lines(i)%audit_hmax_rollback = system%lines(i)%audit_hmax ! the sub-stepping diagnostics likewise: a rolled-back step is not counted system%lines(i)%sub_stats_rollback = system%lines(i)%sub_stats + ! the committed lengths and rates (active line control) advance with a step too + system%lines(i)%l0_c_rollback = system%lines(i)%l0_c + system%lines(i)%l0_dot_c_rollback = system%lines(i)%l0_dot_c ! the viscoelastic dl_1 state advances with every committed line step, so ! it must roll back with q/v/a (a line that stepped can be rolled back ! when a sibling line or the coupled point solve fails) @@ -3007,6 +3073,8 @@ SUBROUTINE restore_line_states(system) system%lines(i)%a = system%lines(i)%a_rollback system%lines(i)%audit_hmax = system%lines(i)%audit_hmax_rollback system%lines(i)%sub_stats = system%lines(i)%sub_stats_rollback + system%lines(i)%l0_c = system%lines(i)%l0_c_rollback + system%lines(i)%l0_dot_c = system%lines(i)%l0_dot_c_rollback IF (system%lines(i)%has_viscoelastic) & system%lines(i)%ve_dl_1 = system%lines(i)%ve_dl_1_rollback IF (system%lines(i)%has_syrope) THEN @@ -3115,6 +3183,7 @@ SUBROUTINE CD_System_Snapshot(system, ErrStat, ErrMsg) netot = netot + SIZE(system%lines(i)%l0) END DO ALLOCATE (system%snap_l0(netot), system%snap_l0_dot(netot), system%snap_fbase(ntot), & + system%snap_l0_c(netot), system%snap_l0_dot_c(netot), & system%snap_ve_dl_1(netot), system%snap_syrope_slow(netot), & system%snap_syrope_tmax(netot), system%snap_fr_anchor(ntot)) END BLOCK @@ -3152,6 +3221,8 @@ SUBROUTINE CD_System_Snapshot(system, ErrStat, ErrMsg) he = le + ne_i - 1 system%snap_l0(le:he) = system%lines(i)%l0 system%snap_l0_dot(le:he) = system%lines(i)%l0_dot + system%snap_l0_c(le:he) = system%lines(i)%l0_c + system%snap_l0_dot_c(le:he) = system%lines(i)%l0_dot_c IF (system%lines(i)%has_viscoelastic) & system%snap_ve_dl_1(le:he) = system%lines(i)%ve_dl_1 IF (system%lines(i)%has_syrope) THEN @@ -3224,6 +3295,8 @@ SUBROUTINE CD_System_Restore(system, ErrStat, ErrMsg) he = le + ne_i - 1 hi = lo + SIZE(system%lines(i)%q) - 1 system%lines(i)%l0_dot = system%snap_l0_dot(le:he) + system%lines(i)%l0_c = system%snap_l0_c(le:he) + system%lines(i)%l0_dot_c = system%snap_l0_dot_c(le:he) IF (system%lines(i)%has_viscoelastic) & system%lines(i)%ve_dl_1 = system%snap_ve_dl_1(le:he) IF (system%lines(i)%has_syrope) THEN diff --git a/src/openfast/CableDyn_OF.f90 b/src/openfast/CableDyn_OF.f90 index f280770e..07a32f3d 100644 --- a/src/openfast/CableDyn_OF.f90 +++ b/src/openfast/CableDyn_OF.f90 @@ -1418,6 +1418,24 @@ SUBROUTINE rebuild_from_checkpoint( t, u1, p, x, other, m, ErrStat, ErrMsg ) ErrStat, ErrMsg, RoutineName ) RETURN END IF + ! Active line control: the rebuild re-initialized at the BASE segment lengths; + ! apply the restored command HERE, on the rebuild transition itself, so every + ! entry that can trigger a rebuild (UpdateStates -- including its supercycle + ! early-return substeps -- and CalcOutput) resumes at the checkpointed lengths. + ! The restored command is the one the committed state was reached with, so the + ! lengths are re-applied as committed (the next advance blends them into its + ! generalised-alpha terms exactly as the uninterrupted run does). It runs before the + ! line interiors and cable mirrors reload below, which bring back the committed state + ! of the uninterrupted run, a cable's committed force included. + IF (ALLOCATED(u1%DeltaL)) THEN + CALL CD_AGG_Apply_LineControl( Inst(id)%agg, REAL(u1%DeltaL, wp), REAL(u1%DeltaLdot, wp), es, em, & + restored=.TRUE. ) + IF (es /= CD_AGG_OK) THEN + CALL SetErrStat( ErrID_Fatal, 'CableDyn mooring module: line-control apply after the '// & + 'checkpoint rebuild failed: '//TRIM(em), ErrStat, ErrMsg, RoutineName ) + RETURN + END IF + END IF ! ...line interiors + cable free-DOF mirrors, exactly (committed accelerations ! reload from the mirror -- shared helper with the state-const CalcOutput) CALL reload_interiors_ary( Inst(id), m, x%states, REAL(t, wp), ErrStat2, ErrMsg2 ) @@ -1438,20 +1456,6 @@ SUBROUTINE rebuild_from_checkpoint( t, u1, p, x, other, m, ErrStat, ErrMsg ) RETURN END IF END IF - - ! Active line control: the rebuild re-initialized at the BASE segment lengths; - ! apply the restored command HERE, on the rebuild transition itself, so every - ! entry that can trigger a rebuild (UpdateStates -- including its supercycle - ! early-return substeps -- and CalcOutput) resumes at the checkpointed lengths. - IF (ALLOCATED(u1%DeltaL)) THEN - CALL CD_AGG_Apply_LineControl( Inst(id)%agg, REAL(u1%DeltaL, wp), REAL(u1%DeltaLdot, wp), es, em ) - IF (es /= CD_AGG_OK) THEN - CALL SetErrStat( ErrID_Fatal, 'CableDyn mooring module: line-control apply after the '// & - 'checkpoint rebuild failed: '//TRIM(em), ErrStat, ErrMsg, RoutineName ) - CALL release_instance( id ) - RETURN - END IF - END IF ! A fresh-process restart first passes through CD_Init, whose provisional instance ! owns the output stream of the same root; the checkpointed m%CDInst need not be ! that slot. Find it so its stream is released and the slot freed with old_id. @@ -1637,7 +1641,8 @@ SUBROUTINE CD_UpdateStates( t, n, u, t_array, p, x, xd, z, other, m, ErrStat, Er IF (ErrStat >= AbortErrLev) RETURN END IF ! Active line control: apply the interpolated DeltaL/DeltaLdot command to - ! the controlled segments BEFORE the advance (the MoorDyn placement). + ! the controlled segments (EI=0 line segments and finite-EI cable spans) + ! BEFORE the advance (the MoorDyn placement). ! Runs AFTER the snapshot so a correction re-entry restores the ! step-start lengths and re-applies the corrected command. IF (ALLOCATED(Inst(id)%u_interp%DeltaL)) THEN diff --git a/tests/data/activetension_ab_reference.csv b/tests/data/activetension_ab_reference.csv index 487180db..29a366c2 100644 --- a/tests/data/activetension_ab_reference.csv +++ b/tests/data/activetension_ab_reference.csv @@ -3,20 +3,20 @@ # Tensions in N; hold windows have DeltaLdot=0. Reproduce: validation/scripts/activetension/ + validation/scripts/openfast_activetension_ab.py. channel,hold,cabledyn_N,moordyn_N,pct FairTen1,baseline,2.353e+06,2.35299e+06,+0.000 -FairTen1,payout_hold,2.272e+06,2.27203e+06,-0.046 -FairTen1,haulin_hold,2.39815e+06,2.39819e+06,-0.112 +FairTen1,payout_hold,2.27203e+06,2.27203e+06,-0.013 +FairTen1,haulin_hold,2.39818e+06,2.39819e+06,-0.040 FairTen2,baseline,2.429e+06,2.42922e+06,-0.009 -FairTen2,payout_hold,2.339e+06,2.33916e+06,+0.080 -FairTen2,haulin_hold,2.47692e+06,2.47691e+06,+0.508 +FairTen2,payout_hold,2.33901e+06,2.33916e+06,+0.084 +FairTen2,haulin_hold,2.4769e+06,2.47691e+06,+0.461 FairTen3,baseline,2.429e+06,2.42922e+06,-0.009 -FairTen3,payout_hold,2.339e+06,2.33916e+06,+0.080 -FairTen3,haulin_hold,2.47692e+06,2.47691e+06,+0.508 +FairTen3,payout_hold,2.33901e+06,2.33916e+06,+0.084 +FairTen3,haulin_hold,2.4769e+06,2.47691e+06,+0.461 AnchTen1,baseline,1.274e+06,1.27428e+06,-0.022 -AnchTen1,payout_hold,1.19297e+06,1.19292e+06,+0.396 -AnchTen1,haulin_hold,1.31936e+06,1.31935e+06,+0.632 +AnchTen1,payout_hold,1.19295e+06,1.19292e+06,+0.367 +AnchTen1,haulin_hold,1.31937e+06,1.31935e+06,+0.665 AnchTen2,baseline,1.35e+06,1.35005e+06,-0.004 -AnchTen2,payout_hold,1.2601e+06,1.26032e+06,-0.190 -AnchTen2,haulin_hold,1.39775e+06,1.39772e+06,+0.169 +AnchTen2,payout_hold,1.26017e+06,1.26032e+06,-0.107 +AnchTen2,haulin_hold,1.39774e+06,1.39772e+06,+0.145 AnchTen3,baseline,1.35e+06,1.35005e+06,-0.004 -AnchTen3,payout_hold,1.2601e+06,1.26032e+06,-0.190 -AnchTen3,haulin_hold,1.39775e+06,1.39772e+06,+0.169 +AnchTen3,payout_hold,1.26017e+06,1.26032e+06,-0.107 +AnchTen3,haulin_hold,1.39774e+06,1.39772e+06,+0.145 diff --git a/tests/test_core_release_regressions.f90 b/tests/test_core_release_regressions.f90 index a692c8f1..9193d831 100644 --- a/tests/test_core_release_regressions.f90 +++ b/tests/test_core_release_regressions.f90 @@ -5,7 +5,12 @@ PROGRAM test_core_release_regressions !! Failure-path contracts of the numerical core: !! 1. The system subdivision fallback restores the complete committed line state !! (kinematics AND viscoelastic / Syrope history) when it cannot complete an - !! interval, so its best-effort result equals one plain full-dt step. + !! interval, so its best-effort result equals one plain full-dt step; after an + !! active-line-control length change that includes the committed lengths. + !! 1b. A re-derived acceleration between a length change and the next step (the + !! model's recompute, and the system update the OpenFAST shell performs) belongs to + !! the committed state: it is solved at the committed lengths, which stay committed, so + !! the step still blends the old and new lengths. !! 2. A segment-length update whose acceleration recompute fails leaves the model !! exactly as it was (lengths, rates, loads, mass, acceleration). !! 3. An ElasticMod 3 rope whose alphaMBL does not exceed the static EA fails at @@ -23,11 +28,13 @@ PROGRAM test_core_release_regressions USE CableDyn_Model, ONLY: CD_ModelType, CD_Init_Model, CD_Step_Model, CD_Step_Model_Recovering, & CD_End_Model, CD_Get_Model_State, CD_Get_Model_VE_Dl1, & CD_Get_Model_Syrope_State, CD_Update_Model_SegmentLength, & - CD_MODEL_OK, CD_MODEL_BADINPUT + CD_Recompute_Model_Acceleration, CD_MODEL_OK, CD_MODEL_BADINPUT USE CableDyn_System, ONLY: CD_SystemType, CD_Init_System_From_Models, CD_End_System, CD_Step_System, & CD_Get_System_CoupledMotion, CD_System_NCoupledDOF, CD_Get_System_Line_State, & CD_Get_System_Line_VE_Dl1, CD_Get_System_Line_Syrope_State, & - CD_System_Fallback_Count, CD_System_Fallback_Reset, CD_SYSTEM_OK + CD_System_Fallback_Count, CD_System_Fallback_Reset, CD_SYSTEM_OK, & + CD_Update_System_Line_SegmentLength, CD_Update_System_CoupledMotion, & + CD_Recompute_System_Acceleration USE CableDyn_Hydro, ONLY: CD_Airy_Wave_Kinematics_Precomputed, CD_HYDRO_OK, CD_HYDRO_BADINPUT USE CableDyn_HermiteCableStatic, ONLY: CD_HermiteCable_Static_Solve, CD_HermiteCable_Static_Solve_AutoMesh, & CD_HermiteCable_Trivial_Seed, CD_HermiteResolutionType, & @@ -58,6 +65,8 @@ PROGRAM test_core_release_regressions nfail = 0 CALL case_fallback_restores_constitutive_state() + CALL case_fallback_restores_committed_lengths() + CALL case_recompute_keeps_committed_lengths() CALL case_segment_length_update_is_atomic() CALL case_mode3_premise_over_slack_range() CALL case_short_error_buffers() @@ -209,6 +218,157 @@ SUBROUTINE case_fallback_restores_constitutive_state() CALL CD_Syrope_End(td) END SUBROUTINE case_fallback_restores_constitutive_state + SUBROUTINE case_fallback_restores_committed_lengths() + !! Active line control: a length and rate change, then a step that stalls at every + !! subdivision level. The first half-step commits the new lengths as those of the + !! committed state, so the fallback's restore must bring back the committed lengths of + !! the entry state as well: the plain full-dt re-run then blends the old and new lengths + !! and equals one plain step of the same line bit for bit. + REAL(wp), PARAMETER :: DT = 0.02_wp + TYPE(CD_ModelType) :: models(1), ref + TYPE(CD_SystemType) :: system + TYPE(GenAlphaConfig) :: cfg + INTEGER :: conn(2, 2), fixed(6), es, n_iter, nc, j + REAL(wp) :: l0(2), q0(9), v0(9), f_ext(9), eav(2), rho_a(2) + REAL(wp), ALLOCATABLE :: qc(:), vc(:), ac(:) + REAL(wp) :: qs(9), vs(9), as(9), qr(9), vr(9), ar(9), pq(9), pv(9), pa(9) + LOGICAL :: conv, stalled + CHARACTER(240) :: em + + cfg%max_iter = 1 + cfg%rel_tol = 1.0e-15_wp + cfg%abs_tol = 1.0e-300_wp + v0 = 0.0_wp + f_ext = 0.0_wp + f_ext(6) = -2.0e3_wp + rho_a = 22.42_wp + eav = 1.0e8_wp + CALL two_element_chain(1.01_wp, conn, l0, q0, fixed) + CALL CD_Init_Model(models(1), q0, v0, conn, l0, eav, rho_a, .FALSE., f_ext, fixed, cfg, es, em) + CALL require(es == CD_MODEL_OK, 'fallback-lengths:init '//TRIM(em)) + CALL CD_Init_Model(ref, q0, v0, conn, l0, eav, rho_a, .FALSE., f_ext, fixed, cfg, es, em) + CALL require(es == CD_MODEL_OK, 'fallback-lengths:reference-init '//TRIM(em)) + CALL CD_Init_System_From_Models(system, models, es, em) + CALL require(es == CD_SYSTEM_OK, 'fallback-lengths:system-init '//TRIM(em)) + ! pay out the second element: a new length and rate the committed state was not reached with + CALL CD_Update_System_Line_SegmentLength(system, 1, 2, 1.004_wp, 0.2_wp, es, em) + CALL require(es == CD_SYSTEM_OK, 'fallback-lengths:system-update '//TRIM(em)) + CALL CD_Update_Model_SegmentLength(ref, 2, 1.004_wp, 0.2_wp, es, em) + CALL require(es == CD_MODEL_OK, 'fallback-lengths:reference-update '//TRIM(em)) + nc = CD_System_NCoupledDOF(system, es, em) + CALL require(es == CD_SYSTEM_OK .AND. nc == 6, 'fallback-lengths:coupled-dof-count') + ALLOCATE (qc(nc), vc(nc), ac(nc)) + CALL CD_Get_System_CoupledMotion(system, qc, vc, ac, es, em) + CALL require(es == CD_SYSTEM_OK, 'fallback-lengths:coupled-motion') + qc(4) = qc(4) + 0.004_wp + vc(4) = 0.2_wp + ac = 0.0_wp + + CALL CD_System_Fallback_Reset() + CALL CD_Step_System(system, DT, qc, vc, ac, conv, stalled, n_iter, es, em) + CALL require(es == CD_SYSTEM_OK, 'fallback-lengths:system-step '//TRIM(em)) + CALL require(.NOT. conv, 'fallback-lengths:step-stalls-at-every-depth') + CALL require(CD_System_Fallback_Count() > 0, 'fallback-lengths:subdivision-entered') + CALL CD_System_Fallback_Reset() + + CALL CD_Get_Model_State(ref, pq, pv, pa, es, em) + DO j = 1, 6 + pq(fixed(j)) = qc(j) + pv(fixed(j)) = vc(j) + pa(fixed(j)) = ac(j) + END DO + CALL CD_Step_Model(ref, DT, conv, stalled, n_iter, es, em, prescribed_q=pq, prescribed_v=pv, prescribed_a=pa) + CALL require(es == CD_MODEL_OK, 'fallback-lengths:reference-step') + CALL CD_Get_System_Line_State(system, 1, qs, vs, as, es, em) + CALL CD_Get_Model_State(ref, qr, vr, ar, es, em) + CALL require(same(qs, qr) .AND. same(vs, vr) .AND. same(as, ar), & + 'fallback-lengths:kinematics-equal-one-blended-plain-step') + CALL require(same(system%lines(1)%l0_c, ref%l0_c) .AND. same(system%lines(1)%l0_dot_c, ref%l0_dot_c), & + 'fallback-lengths:committed-lengths-advanced-once') + + CALL CD_End_System(system, es, em) + CALL CD_End_Model(models(1), es, em) + CALL CD_End_Model(ref, es, em) + END SUBROUTINE case_fallback_restores_committed_lengths + + SUBROUTINE case_recompute_keeps_committed_lengths() + !! Active line control on an EI = 0 line: after a length and rate change, re-deriving the + !! acceleration (a boundary commit, or the OpenFAST shell's state update) solves it at the + !! lengths and rates the committed state was reached with. It equals the acceleration of + !! a line that was never commanded, the committed lengths stay, the new ones stay in + !! place, and the step that follows is the blended step of a model whose acceleration was + !! not re-derived. The same holds through the system update (coupled motion + recompute). + REAL(wp), PARAMETER :: DT = 0.02_wp + TYPE(CD_ModelType) :: a, b, twin, lines(1) + TYPE(CD_SystemType) :: system + TYPE(GenAlphaConfig) :: cfg + INTEGER :: conn(2, 2), fixed(6), es, n_iter, nc, j + REAL(wp) :: l0(2), q0(9), v0(9), f_ext(9), eav(2), rho_a(2), pq(9), pv(9), pa(9) + REAL(wp) :: qs(9), vs(9), as(9) + REAL(wp), ALLOCATABLE :: qc(:), vc(:), ac(:) + LOGICAL :: conv, stalled + CHARACTER(240) :: em + + v0 = 0.0_wp + f_ext = 0.0_wp + f_ext(6) = -2.0e3_wp + rho_a = 22.42_wp + eav = 1.0e8_wp + CALL two_element_chain(1.01_wp, conn, l0, q0, fixed) + CALL CD_Init_Model(a, q0, v0, conn, l0, eav, rho_a, .FALSE., f_ext, fixed, cfg, es, em) + CALL require(es == CD_MODEL_OK, 'recompute-lengths:init '//TRIM(em)) + CALL CD_Init_Model(twin, q0, v0, conn, l0, eav, rho_a, .FALSE., f_ext, fixed, cfg, es, em) + CALL require(es == CD_MODEL_OK, 'recompute-lengths:twin-init '//TRIM(em)) + lines(1) = a + CALL CD_Update_Model_SegmentLength(a, 2, 1.004_wp, 0.2_wp, es, em) + CALL require(es == CD_MODEL_OK, 'recompute-lengths:update '//TRIM(em)) + b = a + CALL CD_Recompute_Model_Acceleration(a, es, em) + CALL require(es == CD_MODEL_OK, 'recompute-lengths:recompute '//TRIM(em)) + CALL CD_Recompute_Model_Acceleration(twin, es, em) + CALL require(es == CD_MODEL_OK, 'recompute-lengths:twin-recompute '//TRIM(em)) + CALL require(same(a%a, twin%a), 'recompute-lengths:acceleration-of-the-committed-lengths') + CALL require(same(a%l0_c, l0) .AND. same(a%l0_dot_c, [0.0_wp, 0.0_wp]) .AND. & + a%l0(2) == 1.004_wp .AND. a%l0_dot(2) == 0.2_wp .AND. same(a%l0, b%l0) .AND. & + same(a%l0_dot, b%l0_dot), 'recompute-lengths:committed-and-present-lengths-kept') + ! the step after it is the blended step (of a model with the same acceleration) + b%a = a%a + CALL CD_Get_Model_State(a, pq, pv, pa, es, em) + pq(7) = pq(7) + 0.004_wp + pv(7) = 0.2_wp + CALL CD_Step_Model(a, DT, conv, stalled, n_iter, es, em, prescribed_q=pq, prescribed_v=pv, prescribed_a=pa) + CALL require(es == CD_MODEL_OK .AND. conv, 'recompute-lengths:step '//TRIM(em)) + CALL CD_Step_Model(b, DT, conv, stalled, n_iter, es, em, prescribed_q=pq, prescribed_v=pv, prescribed_a=pa) + CALL require(es == CD_MODEL_OK .AND. conv, 'recompute-lengths:reference-step '//TRIM(em)) + CALL require(same(a%q, b%q) .AND. same(a%v, b%v) .AND. same(a%a, b%a) .AND. same(a%l0_c, a%l0), & + 'recompute-lengths:the-step-still-blends-the-lengths') + + ! the system update the OpenFAST shell performs between the command and the step + CALL CD_Init_System_From_Models(system, lines, es, em) + CALL require(es == CD_SYSTEM_OK, 'recompute-lengths:system-init '//TRIM(em)) + CALL CD_Update_System_Line_SegmentLength(system, 1, 2, 1.004_wp, 0.2_wp, es, em) + CALL require(es == CD_SYSTEM_OK, 'recompute-lengths:system-update '//TRIM(em)) + nc = CD_System_NCoupledDOF(system, es, em) + ALLOCATE (qc(nc), vc(nc), ac(nc)) + CALL CD_Get_System_CoupledMotion(system, qc, vc, ac, es, em) + CALL CD_Update_System_CoupledMotion(system, qc, vc, ac, es, em) + CALL require(es == CD_SYSTEM_OK, 'recompute-lengths:system-motion '//TRIM(em)) + CALL CD_Recompute_System_Acceleration(system, es, em) + CALL require(es == CD_SYSTEM_OK, 'recompute-lengths:system-recompute '//TRIM(em)) + CALL CD_Get_System_Line_State(system, 1, qs, vs, as, es, em) + CALL require(same(as, twin%a) .AND. same(system%lines(1)%l0_c, l0) .AND. system%lines(1)%l0(2) == 1.004_wp, & + 'recompute-lengths:the-system-update-keeps-the-committed-lengths') + DO j = 1, 2 + CALL require(system%lines(1)%l0_dot_c(j) == 0.0_wp, 'recompute-lengths:system-committed-rates') + END DO + + CALL CD_End_System(system, es, em) + CALL CD_End_Model(a, es, em) + CALL CD_End_Model(b, es, em) + CALL CD_End_Model(twin, es, em) + CALL CD_End_Model(lines(1), es, em) + END SUBROUTINE case_recompute_keeps_committed_lengths + SUBROUTINE case_segment_length_update_is_atomic() !! A length so large that the reassembled distributed load overflows makes the !! acceleration recompute fail after the length-dependent fields were rebuilt. diff --git a/tests/test_ei0_slack_dynamics.f90 b/tests/test_ei0_slack_dynamics.f90 index 195ef517..5cefc951 100644 --- a/tests/test_ei0_slack_dynamics.f90 +++ b/tests/test_ei0_slack_dynamics.f90 @@ -63,6 +63,14 @@ PROGRAM test_ei0_slack_dynamics !! share's credit (it returned many times that before the cap covered slack starts), a !! slack segment with no step-start dashpot force keeps the plain blend, and the tangent !! of a capped row matches the finite difference on the banded and the dense path. + !! 11. A length change over the step (active line control) on the chain of case 5: the + !! step-start force and the release cap's step-start data at the lengths the step-start + !! state was reached with (start_l0), the inertia at the blended lengths (mass_l0); the + !! residual against the closed form and the tangent against the finite difference, also + !! for turning releases (the projected cap) and a haul-in whose end share alone returns more + !! than W_n; and, on the chain with a callback load, the dashpot share and the law bound of + !! the cap and the kept dashpot share of a segment slack at the step-start length (case 10) + !! under a length and rate change, against their closed forms. USE CableDyn_Precision, ONLY: wp USE CableDyn_DeckDriver, ONLY: CD_Run_Deck_Driver, CD_DECKDRV_OK USE CableDyn_Dynamic, ONLY: GenAlphaConfig, CD_CableGenAlphaWorkspace, CD_Cable_Gen_Alpha_Step, CD_DYN_OK @@ -85,6 +93,8 @@ PROGRAM test_ei0_slack_dynamics ! a two-sided axial dashpot (BA cb_ba_dash, force cb_ba_dash (dl/dt)/l0 along the chord, as the ! line model's axial damping) on segment cb_dash_elem (0: none) of rest length cb_l0_dash REAL(wp) :: cb_ba_dash = 0.0_wp, cb_l0_dash = 1.0_wp + ! the dashpot's unstretched-length rate (its force is then (BA/l0) (t . w - (l/l0) l0_dot) t) + REAL(wp) :: cb_l0dot_dash = 0.0_wp INTEGER :: cb_dash_elem = 0 REAL(wp) :: cb_q0(12) = 0.0_wp INTEGER :: cb_law_elem = 0 @@ -94,6 +104,8 @@ PROGRAM test_ei0_slack_dynamics IF (COMMAND_ARGUMENT_COUNT() >= 1) CALL GET_COMMAND_ARGUMENT(1, driver) CALL case_tangent_consistency() CALL case_release_energy() + CALL case_length_change_step() + CALL case_length_change_cap_terms() CALL case_law_release_cap() CALL case_law_damped_release() CALL case_damped_elastic_release() @@ -379,41 +391,54 @@ SUBROUTINE chain_nodes(dirs, strain, l0, q) END DO END SUBROUTINE chain_nodes - SUBROUTINE blended_force(qn, q1, l0, ea, alpha_f, capped, f) + SUBROUTINE blended_force(qn, q1, l0, ea, alpha_f, capped, f, l0s) !! Closed form of the blended internal force (1 - alpha_f) f(q1) + alpha_f f(qn) of the !! tension-only chain, with the release cap (capped) or without it: the retained share !! alpha_f T_n along the step-start chord t_n is at most - !! (W_n + (1 - alpha_f) T_1 p_1)/p, W_n = T_n e_n/2, with the projected shortening - !! p = |d_n| - t_n . d_1 and p_1 = |d_1| - t_1 . d_n, so that the blend returns at most W_n. + !! (W_n + (1 - alpha_f) T^_1 p_1)/p, W_n = T_n e_n/2, with the projected shortening + !! p = |d_n| - t_n . d_1 and p_1 = |d_1| - t_1 . d_n, so that the blend returns at most W_n + !! (T^_1 = T_1 without a length change). l0s: the lengths of the step-start state (f(qn), + !! T_n and e_n) when they differ from the lengths l0 at t_{n+1}; the cap's end-tension + !! estimate is then the step-start secant times the end stretch, T^_1 = (T_n/e_n) e_1, + !! and N is bounded below by zero. REAL(wp), INTENT(IN) :: qn(12), q1(12), l0(3), ea(3), alpha_f LOGICAL, INTENT(IN) :: capped REAL(wp), INTENT(OUT) :: f(12) + REAL(wp), INTENT(IN), OPTIONAL :: l0s(3) INTEGER :: e - REAL(wp) :: dn(3), d1(3), ln, l1, t0, t1, e0, dg, p, p1, share(3) + REAL(wp) :: dn(3), d1(3), ln, l1, t0, t1, t1h, e0, e1, dg, p, p1, share(3), ls(3) + ls = l0 + IF (PRESENT(l0s)) ls = l0s f = 0.0_wp DO e = 1, 3 dn = qn(3*e + 1:3*e + 3) - qn(3*e - 2:3*e) d1 = q1(3*e + 1:3*e + 3) - q1(3*e - 2:3*e) ln = NORM2(dn) l1 = NORM2(d1) - t0 = MAX(0.0_wp, ea(e)*(ln/l0(e) - 1.0_wp)) + t0 = MAX(0.0_wp, ea(e)*(ln/ls(e) - 1.0_wp)) t1 = MAX(0.0_wp, ea(e)*(l1/l0(e) - 1.0_wp)) - e0 = ln - l0(e) + e0 = ln - ls(e) + e1 = l1 - l0(e) dg = alpha_f*t0 p = ln - DOT_PRODUCT(dn/ln, d1) p1 = l1 - DOT_PRODUCT(d1/l1, dn) - IF (capped .AND. t0 > 0.0_wp .AND. p > 0.0_wp) dg = MIN(dg, (0.5_wp*t0*e0 + (1.0_wp - alpha_f)*t1*p1)/p) + t1h = t1 + IF (PRESENT(l0s) .AND. e0 > 0.0_wp) t1h = t0/e0*MAX(e1, 0.0_wp) + IF (capped .AND. t0 > 0.0_wp .AND. p > 0.0_wp) & + dg = MIN(dg, MAX(0.5_wp*t0*e0 + (1.0_wp - alpha_f)*t1h*p1, 0.0_wp)/p) share = (1.0_wp - alpha_f)*t1*d1/l1 + dg*dn/ln f(3*e - 2:3*e) = f(3*e - 2:3*e) - share f(3*e + 1:3*e + 3) = f(3*e + 1:3*e + 3) + share END DO END SUBROUTINE blended_force - SUBROUTINE probe_step(qn, vn, an, q1, l0, ea, rho_a, dense, R, K) - !! Residual and effective tangent of the force-blended step at q1 (the probe_q hook). + SUBROUTINE probe_step(qn, vn, an, q1, l0, ea, rho_a, dense, R, K, start_l0, mass_l0) + !! Residual and effective tangent of the force-blended step at q1 (the probe_q hook); + !! start_l0 and mass_l0 are passed on to the step (a length change over the step). REAL(wp), INTENT(IN) :: qn(12), vn(12), an(12), q1(12), l0(3), ea(3), rho_a(3) LOGICAL, INTENT(IN) :: dense REAL(wp), INTENT(OUT) :: R(12), K(9, 9) + REAL(wp), INTENT(IN), OPTIONAL :: start_l0(3), mass_l0(3) INTEGER :: conn(2, 3), n_iter, es REAL(wp) :: qo(12), vo(12), ao(12) LOGICAL :: converged, stalled @@ -425,11 +450,13 @@ SUBROUTINE probe_step(qn, vn, an, q1, l0, ea, rho_a, dense, R, K) IF (dense) THEN CALL CD_Cable_Gen_Alpha_Step(qn, vn, an, conn, l0, ea, rho_a, .TRUE., 0.0_wp*qn, [1, 2, 3], 0.05_wp, cfg, & qo, vo, ao, converged, stalled, n_iter, es, em, load_proc=zero_load, & - workspace=work, probe_q=q1, probe_R=R, probe_K=K) + workspace=work, probe_q=q1, probe_R=R, probe_K=K, start_l0=start_l0, & + mass_l0=mass_l0) ELSE CALL CD_Cable_Gen_Alpha_Step(qn, vn, an, conn, l0, ea, rho_a, .TRUE., 0.0_wp*qn, [1, 2, 3], 0.05_wp, cfg, & qo, vo, ao, converged, stalled, n_iter, es, em, & - workspace=work, probe_q=q1, probe_R=R, probe_K=K) + workspace=work, probe_q=q1, probe_R=R, probe_K=K, start_l0=start_l0, & + mass_l0=mass_l0) END IF IF (es /= CD_DYN_OK) THEN WRITE (*, '(A)') 'MISMATCH [tangent:probe '//TRIM(em)//']' @@ -588,6 +615,113 @@ SUBROUTINE case_release_energy() CALL require(ratio < 1.0e-6_wp, 'release-energy:continuous-at-rest-length') END SUBROUTINE case_release_energy + SUBROUTINE case_length_change_step() + !! A length change over the step (active line control): segment 1 paid out (0.97 to 1.0 m), + !! segment 3 hauled in (0.83 to 0.8 m). The step-start force and the release cap's + !! step-start tension and stretch take the lengths the step-start state was reached with + !! (start_l0), the force at t_{n+1} and the cap's end stretch the new ones (l0), and the + !! structural inertia the blended ones (mass_l0): residual against the closed form (force + !! and inertia) and tangent against the central difference of the residual, with all + !! segments taut, segment 1 released deeply (cap active), segment 1 turning by 45 degrees + !! as it ends just slack (projected cap), the hauled-in segment 3 turning by about 50 + !! degrees and ending taut (capped with the end share at the secant estimate + !! T^_1 = (T_n/e_n) e_1), and segment 3 shortening along its chord while it stretches + !! against its new length (the end share alone returns more than W_n: kept force zero), on + !! both paths. + REAL(wp), PARAMETER :: L0(3) = [1.0_wp, 1.2_wp, 0.8_wp], L0S(3) = [0.97_wp, 1.2_wp, 0.83_wp] + REAL(wp), PARAMETER :: EA(3) = [1.0e6_wp, 1.5e6_wp, 0.8e6_wp], RHO_A(3) = [2.0_wp, 3.0_wp, 1.5_wp] + REAL(wp), PARAMETER :: DIRS_N(3, 3) = RESHAPE([1.0_wp, 0.2_wp, 0.1_wp, 0.3_wp, 1.0_wp, -0.2_wp, & + -0.2_wp, 0.4_wp, 1.0_wp], [3, 3]) + REAL(wp), PARAMETER :: DIRS_1(3, 3) = RESHAPE([1.0_wp, 0.27_wp, 0.04_wp, 0.36_wp, 1.0_wp, -0.12_wp, & + -0.12_wp, 0.46_wp, 1.0_wp], [3, 3]) + REAL(wp), PARAMETER :: H = 1.0e-6_wp, RHO = 0.4_wp, DT = 0.05_wp + REAL(wp), PARAMETER :: ALPHA_F = RHO/(RHO + 1.0_wp), ALPHA_M = (2.0_wp*RHO - 1.0_wp)/(RHO + 1.0_wp) + REAL(wp), PARAMETER :: BETA = 0.25_wp*(1.0_wp - ALPHA_M + ALPHA_F)**2 + REAL(wp), PARAMETER :: DIRS_T1(3, 3) = RESHAPE([0.6_wp, 0.9_wp, 0.1_wp, 0.36_wp, 1.0_wp, -0.12_wp, & + -0.12_wp, 0.46_wp, 1.0_wp], [3, 3]) + REAL(wp), PARAMETER :: DIRS_T3(3, 3) = RESHAPE([1.0_wp, 0.27_wp, 0.04_wp, 0.36_wp, 1.0_wp, -0.12_wp, & + 0.6_wp, 1.2_wp, 0.4_wp], [3, 3]) + REAL(wp) :: dirs(3, 3, 5), strain_1(3, 5), qn(12), vn(12), an(12), q1(12), qp(12), lm(3), R(12), Rp(12), Rm(12) + REAL(wp) :: K(9, 9), Kfd(9, 9), Kdump(9, 9), f_cap(12), f_new(12), f_raw(12), acc(12), inertia(12), m + REAL(wp) :: scale, err + INTEGER :: c, p, j, i, e, free(9) + LOGICAL :: dense + CHARACTER(16) :: label + free = [(i + 3, i=1, 9)] + lm = L0 + lm(1) = (1.0_wp - ALPHA_F)*L0(1) + ALPHA_F*L0S(1) + lm(3) = (1.0_wp - ALPHA_F)*L0(3) + ALPHA_F*L0S(3) + strain_1(:, 1) = [0.020_wp, 0.015_wp, 0.020_wp] + strain_1(:, 2) = [-0.050_wp, 0.015_wp, 0.020_wp] + strain_1(:, 3) = [-0.0005_wp, 0.015_wp, 0.020_wp] + strain_1(:, 4) = [0.020_wp, 0.015_wp, 0.0002_wp] + strain_1(:, 5) = [0.020_wp, 0.015_wp, 0.025_wp] + dirs(:, :, 1) = DIRS_1 + dirs(:, :, 2) = DIRS_1 + dirs(:, :, 3) = DIRS_T1 + dirs(:, :, 4) = DIRS_T3 + dirs(:, :, 5) = DIRS_N + vn = 0.0_wp + an = 0.0_wp + DO i = 4, 12 + vn(i) = 0.01_wp*SIN(1.7_wp*REAL(i, wp)) + an(i) = 0.02_wp*COS(2.3_wp*REAL(i, wp)) + END DO + CALL chain_nodes(DIRS_N, [0.010_wp, 0.020_wp, 0.010_wp], L0S, qn) + DO c = 1, 5 + SELECT CASE (c) + CASE (1) + label = 'taut-taut' + CASE (2) + label = 'release-cap' + CASE (3) + label = 'turning-release' + CASE (4) + label = 'haul-in-turning' + CASE DEFAULT + label = 'haul-in-negative' + END SELECT + CALL chain_nodes(dirs(:, :, c), strain_1(:, c), L0, q1) + CALL blended_force(qn, q1, L0, EA, ALPHA_F, .TRUE., f_cap, l0s=L0S) + CALL blended_force(qn, q1, L0, EA, ALPHA_F, .FALSE., f_raw, l0s=L0S) + ! the same with the step-start force at the new lengths: what start_l0 must avoid + CALL blended_force(qn, q1, L0, EA, ALPHA_F, .TRUE., f_new) + scale = MAXVAL(ABS(f_raw)) + CALL require(MAXVAL(ABS(f_new - f_cap)) > 1.0e-2_wp*scale, 'lengths:'//TRIM(label)//':start-lengths-matter') + IF (c >= 2) CALL require(MAXVAL(ABS(f_cap - f_raw)) > 1.0e-3_wp*scale, 'lengths:'//TRIM(label)//':cap-active') + ! inertia M(mass_l0) a_alpha of the generalised-alpha relations, the fixed node held + acc = 0.0_wp + DO i = 4, 12 + acc(i) = (1.0_wp - ALPHA_M)*(q1(i) - qn(i) - DT*vn(i) - DT*DT*(0.5_wp - BETA)*an(i))/(BETA*DT*DT) + & + ALPHA_M*an(i) + END DO + inertia = 0.0_wp + DO e = 1, 3 + m = RHO_A(e)*lm(e)/6.0_wp + inertia(3*e - 2:3*e) = inertia(3*e - 2:3*e) + m*(2.0_wp*acc(3*e - 2:3*e) + acc(3*e + 1:3*e + 3)) + inertia(3*e + 1:3*e + 3) = inertia(3*e + 1:3*e + 3) + m*(acc(3*e - 2:3*e) + 2.0_wp*acc(3*e + 1:3*e + 3)) + END DO + DO p = 1, 2 + dense = p == 2 + CALL probe_step(qn, vn, an, q1, L0, EA, RHO_A, dense, R, K, start_l0=L0S, mass_l0=lm) + err = MAXVAL(ABS(R(4:12) - f_cap(4:12) - inertia(4:12)))/MAX(scale, MAXVAL(ABS(inertia))) + WRITE (*, '(A,A,A,L1,A,ES9.2)') ' lengths ', TRIM(label), ' dense=', dense, ': residual vs closed form ', err + CALL require(err < 1.0e-9_wp, 'lengths:'//TRIM(label)//TRIM(MERGE(':dense ', ':banded', dense))//':residual') + DO j = 1, 9 + qp = q1 + qp(free(j)) = q1(free(j)) + H + CALL probe_step(qn, vn, an, qp, L0, EA, RHO_A, dense, Rp, Kdump, start_l0=L0S, mass_l0=lm) + qp(free(j)) = q1(free(j)) - H + CALL probe_step(qn, vn, an, qp, L0, EA, RHO_A, dense, Rm, Kdump, start_l0=L0S, mass_l0=lm) + Kfd(:, j) = (Rp(4:12) - Rm(4:12))/(2.0_wp*H) + END DO + err = MAXVAL(ABS(K - Kfd))/MAXVAL(ABS(K)) + WRITE (*, '(A,A,A,L1,A,ES9.2)') ' lengths ', TRIM(label), ' dense=', dense, ': max |K - K_fd|/max|K| = ', err + CALL require(err < 1.0e-6_wp, 'lengths:'//TRIM(label)//TRIM(MERGE(':dense ', ':banded', dense))//':fd-tangent') + END DO + END DO + END SUBROUTINE case_length_change_step + SUBROUTINE case_light_cable_coarse_step() LOGICAL :: conv INTEGER :: es @@ -791,10 +925,11 @@ SUBROUTINE chain_load(q, v, force, jac_q, jac_v) ell = NORM2(c) t = c/ell w = v(3*b - 2:3*b) - v(3*a - 2:3*a) - ten = cb_ba_dash*DOT_PRODUCT(t, w)/cb_l0_dash + ten = cb_ba_dash*(DOT_PRODUCT(t, w) - ell*cb_l0dot_dash/cb_l0_dash)/cb_l0_dash force(3*a - 2:3*a) = force(3*a - 2:3*a) + ten*t force(3*b - 2:3*b) = force(3*b - 2:3*b) - ten*t - kb = ten*(eye - outer3(t, t))/ell + (cb_ba_dash/cb_l0_dash)*outer3(t, MATMUL(eye - outer3(t, t), w)/ell) + kb = ten*(eye - outer3(t, t))/ell + (cb_ba_dash/cb_l0_dash)*outer3(t, MATMUL(eye - outer3(t, t), w)/ell) - & + (cb_ba_dash*cb_l0dot_dash/cb_l0_dash**2)*outer3(t, t) kv = (cb_ba_dash/cb_l0_dash)*outer3(t, t) jac_q(3*a - 2:3*a, 3*a - 2:3*a) = jac_q(3*a - 2:3*a, 3*a - 2:3*a) + kb jac_q(3*a - 2:3*a, 3*b - 2:3*b) = jac_q(3*a - 2:3*a, 3*b - 2:3*b) - kb @@ -871,7 +1006,7 @@ SUBROUTINE cb_added_mass(q, accel, M_add, dMa_a_dq, ErrStat, ErrMsg) END SUBROUTINE cb_added_mass SUBROUTINE probe_chain(qn, vn, an, q1, l0, ea, rho_a, banded, R, K, start_tension, start_stiffness, & - axial_damping) + axial_damping, start_load, start_l0, axial_l0_rate, start_l0_rate) !! Residual and effective tangent at q1 of the force-blended step of the chain with the !! callback load: banded (load_band_proc + load_force_proc) or dense (load_proc, with the !! added mass when cb_madd > 0). @@ -879,6 +1014,9 @@ SUBROUTINE probe_chain(qn, vn, an, q1, l0, ea, rho_a, banded, R, K, start_tensio LOGICAL, INTENT(IN) :: banded REAL(wp), INTENT(OUT) :: R(12), K(9, 9) REAL(wp), INTENT(IN), OPTIONAL :: start_tension(:), start_stiffness(:), axial_damping(:) + !! a length change over the step: the step-start load, lengths and rates, and the rates at + !! t_{n+1} (passed on to the step) + REAL(wp), INTENT(IN), OPTIONAL :: start_load(:), start_l0(:), axial_l0_rate(:), start_l0_rate(:) INTEGER :: conn(2, 3), n_iter, es REAL(wp) :: qo(12), vo(12), ao(12) LOGICAL :: converged, stalled @@ -892,19 +1030,22 @@ SUBROUTINE probe_chain(qn, vn, an, q1, l0, ea, rho_a, banded, R, K, start_tensio qo, vo, ao, converged, stalled, n_iter, es, em, load_band_proc=cb_load_band, & load_force_proc=cb_force, workspace=work, start_tension=start_tension, & start_stiffness=start_stiffness, axial_damping=axial_damping, & - probe_q=q1, probe_R=R, probe_K=K) + start_load=start_load, start_l0=start_l0, axial_l0_rate=axial_l0_rate, & + start_l0_rate=start_l0_rate, probe_q=q1, probe_R=R, probe_K=K) ELSE IF (cb_madd > 0.0_wp) THEN CALL CD_Cable_Gen_Alpha_Step(qn, vn, an, conn, l0, ea, rho_a, .TRUE., 0.0_wp*qn, [1, 2, 3], 0.05_wp, cfg, & qo, vo, ao, converged, stalled, n_iter, es, em, load_proc=cb_load, & added_mass_proc=cb_added_mass, workspace=work, start_tension=start_tension, & start_stiffness=start_stiffness, axial_damping=axial_damping, & - probe_q=q1, probe_R=R, probe_K=K) + start_load=start_load, start_l0=start_l0, axial_l0_rate=axial_l0_rate, & + start_l0_rate=start_l0_rate, probe_q=q1, probe_R=R, probe_K=K) ELSE CALL CD_Cable_Gen_Alpha_Step(qn, vn, an, conn, l0, ea, rho_a, .TRUE., 0.0_wp*qn, [1, 2, 3], 0.05_wp, cfg, & qo, vo, ao, converged, stalled, n_iter, es, em, load_proc=cb_load, & workspace=work, start_tension=start_tension, & start_stiffness=start_stiffness, axial_damping=axial_damping, & - probe_q=q1, probe_R=R, probe_K=K) + start_load=start_load, start_l0=start_l0, axial_l0_rate=axial_l0_rate, & + start_l0_rate=start_l0_rate, probe_q=q1, probe_R=R, probe_K=K) END IF IF (es /= CD_DYN_OK) THEN WRITE (*, '(A)') 'MISMATCH [chain:probe '//TRIM(em)//']' @@ -915,24 +1056,26 @@ SUBROUTINE probe_chain(qn, vn, an, q1, l0, ea, rho_a, banded, R, K, start_tensio END SUBROUTINE probe_chain SUBROUTINE fd_tangent_check(label, qn, vn, an, q1, l0, ea, rho_a, banded, start_tension, start_stiffness, & - axial_damping) + axial_damping, start_load, start_l0, axial_l0_rate, start_l0_rate) !! The step's tangent against the central difference of its residual. CHARACTER(*), INTENT(IN) :: label REAL(wp), INTENT(IN) :: qn(12), vn(12), an(12), q1(12), l0(3), ea(3), rho_a(3) LOGICAL, INTENT(IN) :: banded REAL(wp), INTENT(IN), OPTIONAL :: start_tension(:), start_stiffness(:), axial_damping(:) + REAL(wp), INTENT(IN), OPTIONAL :: start_load(:), start_l0(:), axial_l0_rate(:), start_l0_rate(:) REAL(wp), PARAMETER :: H = 1.0e-6_wp INTEGER :: j REAL(wp) :: qp(12), R(12), Rp(12), Rm(12), K(9, 9), Kfd(9, 9), Kdump(9, 9), err - CALL probe_chain(qn, vn, an, q1, l0, ea, rho_a, banded, R, K, start_tension, start_stiffness, axial_damping) + CALL probe_chain(qn, vn, an, q1, l0, ea, rho_a, banded, R, K, start_tension, start_stiffness, axial_damping, & + start_load, start_l0, axial_l0_rate, start_l0_rate) DO j = 1, 9 qp = q1 qp(3 + j) = q1(3 + j) + H CALL probe_chain(qn, vn, an, qp, l0, ea, rho_a, banded, Rp, Kdump, start_tension, start_stiffness, & - axial_damping) + axial_damping, start_load, start_l0, axial_l0_rate, start_l0_rate) qp(3 + j) = q1(3 + j) - H CALL probe_chain(qn, vn, an, qp, l0, ea, rho_a, banded, Rm, Kdump, start_tension, start_stiffness, & - axial_damping) + axial_damping, start_load, start_l0, axial_l0_rate, start_l0_rate) Kfd(:, j) = (Rp(4:12) - Rm(4:12))/(2.0_wp*H) END DO err = MAXVAL(ABS(K - Kfd))/MAXVAL(ABS(K)) @@ -976,6 +1119,7 @@ SUBROUTINE reset_chain_load() cb_ba_law = 0.0_wp cb_ba_dash = 0.0_wp cb_l0_dash = 1.0_wp + cb_l0dot_dash = 0.0_wp cb_dash_elem = 0 END SUBROUTINE reset_chain_load @@ -1199,6 +1343,252 @@ SUBROUTINE case_damped_elastic_release() CALL reset_chain_load() END SUBROUTINE case_damped_elastic_release + SUBROUTINE case_length_change_cap_terms() + !! The release cap under a length change of the end segment (active line control), hauled + !! in (0.82 to 0.8 m) and paid out (0.78 to 0.8 m), its rate changing too. Its step-start + !! quantities take the step-start length and rate (start_l0, start_l0_rate): e_n, T_n, W_n, + !! the secant T_n/e_n, the law stiffness k_n and the dashpot tension T_d,n; its end-state + !! quantities the new ones: e_{n+1}, T^_{n+1} = min(T_n/e_n, k_n) e_{n+1}, T_d,n+1 and the + !! dashpot weight phi (band l0 to l0 + c e_n). (a) An elastic segment with a two-sided + !! dashpot turning by 5 and 45 degrees and ending slack, in the band or above it: the change + !! the dashpot share makes to the cap against the closed form. (b) A damped law segment + !! (ea = 0) with a damping-dominated start: the cap against the closed form with the + !! bounded secant. (c) The elastic segment with a dashpot slack at the step-start length + !! (e_n = -2 mm against l0_c; on the haul-in pass taut against the new length), extending at + !! 0.5 m/s and turning by 5 to 135 degrees: the kept dashpot share against the closed form + !! (W_d + N_d)/p, W_d = T_d,n^2 dt l0_c/BA with T_d,n at l0_c and l0_dot_c, N_d from + !! T_d,n+1 at the new length and rate. The tangent against the finite difference on both + !! paths. + REAL(wp), PARAMETER :: L0(3) = [1.0_wp, 1.2_wp, 0.8_wp], EA(3) = [1.0e6_wp, 1.5e6_wp, 0.8e6_wp] + REAL(wp), PARAMETER :: DIRS(3, 3) = RESHAPE([1.0_wp, 0.2_wp, 0.1_wp, 0.3_wp, 1.0_wp, -0.2_wp, & + -0.2_wp, 0.4_wp, 1.0_wp], [3, 3]) + REAL(wp), PARAMETER :: THETA(2) = [5.0_wp, 45.0_wp] + REAL(wp), PARAMETER :: S1(6) = [-1.0e-3_wp, -1.0e-5_wp, 2.0e-4_wp, 6.0e-4_wp, 1.5e-3_wp, 3.0e-3_wp] + REAL(wp), PARAMETER :: DT = 0.05_wp, RHO = 0.4_wp, BA = 2.0e4_wp, EA_LAW = 0.8e6_wp, BA_LAW = 2.0e5_wp + REAL(wp), PARAMETER :: RHO_TINY(3) = [1.0e-12_wp, 1.0e-12_wp, 1.0e-12_wp] + REAL(wp) :: ls3, rs, rn, ls(3), qn(12), vn(12), z(12), q1(12), v1(12), sl(12), jq(12, 12), jv(12, 12) + REAL(wp) :: Ra(12), Rb(12), K(9, 9), tn(3), u(3), dir(3), d0(3), d1(3), t1(3), ln, l1, e0, e1, t0, w0 + REAL(wp) :: p, p1, k0, that, td0, td1, phi, kc, num, dg, du, dd, am, af, beta, gamma, band, err, worst + REAL(wp) :: kn, wd, nd, best, qbest(12) + REAL(wp), PARAMETER :: THETA_S(4) = [5.0_wp, 45.0_wp, 90.0_wp, 135.0_wp] + REAL(wp), PARAMETER :: OFS_S(7) = [-0.02_wp, -0.003_wp, 0.0_wp, 0.003_wp, 0.02_wp, 0.1_wp, 0.3_wp] + INTEGER :: ip, i, j, nact + LOGICAL :: damped + am = (2.0_wp*RHO - 1.0_wp)/(RHO + 1.0_wp) + af = RHO/(RHO + 1.0_wp) + beta = 0.25_wp*(1.0_wp - am + af)**2 + gamma = 0.5_wp - am + af + band = af/(1.0_wp - af) + z = 0.0_wp + DO ip = 1, 2 + ! pass 1 hauls in, pass 2 pays out + ls3 = MERGE(0.82_wp, 0.78_wp, ip == 1) + rs = MERGE(-0.02_wp, 0.02_wp, ip == 1) + rn = MERGE(-0.03_wp, 0.03_wp, ip == 1) + ls = [L0(1), L0(2), ls3] + ! (a) the elastic segment with a dashpot + CALL reset_chain_load() + cb_dash_elem = 3 + cb_ba_dash = BA + CALL chain_nodes(DIRS, [0.010_wp, 0.020_wp, 0.001_wp], ls, qn) + d0 = qn(10:12) - qn(7:9) + ln = NORM2(d0) + tn = d0/ln + u = [tn(2), -tn(1), 0.0_wp] + u = u/NORM2(u) + vn = 0.0_wp + vn(10:12) = 0.5_wp*tn + ! the step-start load at the step-start length and rate, then the dashpot at the new ones + cb_l0_dash = ls3 + cb_l0dot_dash = rs + CALL chain_load(qn, vn, sl, jq, jv) + cb_l0_dash = L0(3) + cb_l0dot_dash = rn + e0 = ln - ls3 + t0 = EA(3)*(ln/ls3 - 1.0_wp) + w0 = 0.5_wp*t0*e0 + td0 = BA*(DOT_PRODUCT(tn, vn(10:12) - vn(7:9)) - ln*rs/ls3)/ls3 + worst = 0.0_wp + nact = 0 + DO i = 1, SIZE(THETA) + DO j = 1, SIZE(S1) + dir = COS(THETA(i)*PI/180.0_wp)*tn + SIN(THETA(i)*PI/180.0_wp)*u + q1 = qn + q1(10:12) = qn(7:9) + L0(3)*(1.0_wp + S1(j))*dir + CALL probe_chain(qn, vn, z, q1, L0, EA, RHO_TINY, .TRUE., Ra, K, axial_damping=[0.0_wp, 0.0_wp, BA], & + start_load=sl, start_l0=ls, axial_l0_rate=[0.0_wp, 0.0_wp, rn], & + start_l0_rate=[0.0_wp, 0.0_wp, rs]) + CALL probe_chain(qn, vn, z, q1, L0, EA, RHO_TINY, .TRUE., Rb, K, start_load=sl, start_l0=ls) + ! the closed form of the two caps on the end segment + v1 = gamma/(beta*DT)*(q1 - qn) + (1.0_wp - gamma/beta)*vn + v1(1:3) = 0.0_wp + d1 = q1(10:12) - q1(7:9) + l1 = NORM2(d1) + t1 = d1/l1 + e1 = l1 - L0(3) + p = ln - DOT_PRODUCT(tn, d1) + p1 = l1 - DOT_PRODUCT(t1, d0) + k0 = t0/e0 + that = k0*MAX(e1, 0.0_wp) + du = 0.0_wp + IF (p > 0.0_wp) du = MIN(MAX(w0 + (1.0_wp - af)*that*p1, 0.0_wp)/p - af*t0, 0.0_wp) + dd = du + damped = l1 < L0(3) + band*e0 + IF (damped) THEN + dd = 0.0_wp + IF (p > 0.0_wp) THEN + phi = MIN(1.0_wp, MAX(0.0_wp, 1.0_wp - e1/(band*e0))) + td1 = BA*(DOT_PRODUCT(t1, v1(10:12) - v1(7:9)) - l1*rn/L0(3))/L0(3) + num = w0 + (1.0_wp - af)*(that + phi*td1)*p1 + kc = t0 + phi*td0 + dg = MAX(num, 0.0_wp)/p + dd = MIN(dg - af*kc, 0.0_wp) + END IF + END IF + IF (ABS(dd - du) > 1.0e-6_wp*t0) nact = nact + 1 + err = MAX(MAXVAL(ABS(Ra(10:12) - Rb(10:12) - (dd - du)*tn)), MAXVAL(ABS(Ra(7:9) - Rb(7:9) + (dd - du)*tn))) + worst = MAX(worst, err/(t0 + ABS(td0))) + END DO + END DO + WRITE (*, '(A,I0,A,I0,A,ES10.3)') ' length change, pass ', ip, ': dashpot share of the cap active at ', nact, & + ' states; largest deviation from the closed form / (T_n + |T_d,n|) ', worst + CALL require(nact >= 2, 'lengths-cap:dashpot-share-active') + CALL require(worst < 1.0e-9_wp, 'lengths-cap:dashpot-closed-form') + dir = COS(THETA(1)*PI/180.0_wp)*tn + SIN(THETA(1)*PI/180.0_wp)*u + q1 = qn + q1(10:12) = qn(7:9) + L0(3)*(1.0_wp + 2.0e-4_wp)*dir + DO i = 1, 2 + CALL fd_tangent_check('lengths-cap-dashpot', qn, vn, z, q1, L0, EA, [2.0_wp, 3.0_wp, 1.5_wp], i == 1, & + axial_damping=[0.0_wp, 0.0_wp, BA], start_load=sl, start_l0=ls, & + axial_l0_rate=[0.0_wp, 0.0_wp, rn], start_l0_rate=[0.0_wp, 0.0_wp, rs]) + END DO + ! (c) the dashpot segment slack at the step-start length + CALL reset_chain_load() + cb_dash_elem = 3 + cb_ba_dash = BA + CALL chain_nodes(DIRS, [0.010_wp, 0.020_wp, -2.0e-3_wp/ls3], ls, qn) + d0 = qn(10:12) - qn(7:9) + ln = NORM2(d0) + tn = d0/ln + u = [tn(2), -tn(1), 0.0_wp] + u = u/NORM2(u) + vn = 0.0_wp + vn(10:12) = 0.5_wp*tn + cb_l0_dash = ls3 + cb_l0dot_dash = rs + CALL chain_load(qn, vn, sl, jq, jv) + cb_l0_dash = L0(3) + cb_l0dot_dash = rn + CALL require(ln < ls3, 'lengths-cap:slack-start') + td0 = BA*(DOT_PRODUCT(tn, vn(10:12) - vn(7:9)) - ln*rs/ls3)/ls3 + wd = td0*td0*DT*ls3/BA + worst = 0.0_wp + nact = 0 + best = 0.0_wp + qbest = qn + DO i = 1, SIZE(THETA_S) + DO j = 1, SIZE(OFS_S) + dir = COS(THETA_S(i)*PI/180.0_wp)*tn + SIN(THETA_S(i)*PI/180.0_wp)*u + q1 = qn + q1(10:12) = qn(7:9) + MAX(ln*COS(THETA_S(i)*PI/180.0_wp) + OFS_S(j), 0.05_wp*L0(3))*dir + CALL probe_chain(qn, vn, z, q1, L0, EA, RHO_TINY, .TRUE., Ra, K, axial_damping=[0.0_wp, 0.0_wp, BA], & + start_load=sl, start_l0=ls, axial_l0_rate=[0.0_wp, 0.0_wp, rn], & + start_l0_rate=[0.0_wp, 0.0_wp, rs]) + CALL probe_chain(qn, vn, z, q1, L0, EA, RHO_TINY, .TRUE., Rb, K, start_load=sl, start_l0=ls) + v1 = gamma/(beta*DT)*(q1 - qn) + (1.0_wp - gamma/beta)*vn + v1(1:3) = 0.0_wp + d1 = q1(10:12) - q1(7:9) + l1 = NORM2(d1) + t1 = d1/l1 + p = ln - DOT_PRODUCT(tn, d1) + p1 = l1 - DOT_PRODUCT(t1, d0) + td1 = BA*(DOT_PRODUCT(t1, v1(10:12) - v1(7:9)) - l1*rn/L0(3))/L0(3) + nd = MAX((1.0_wp - af)*td1*p1, 0.0_wp) + dd = 0.0_wp + dg = 0.0_wp + IF (td0*p > 0.0_wp) THEN + dg = (wd + nd)/p + IF (ABS(dg) < af*ABS(td0)) dd = dg - af*td0 + END IF + IF (ABS(dd) > 1.0e-6_wp*ABS(td0)) nact = nact + 1 + IF (ABS(dd) > best .AND. ABS(dg) < 0.5_wp*af*ABS(td0) .AND. & + ABS((1.0_wp - af)*td1*p1) > 0.1_wp*wd) THEN + best = ABS(dd) + qbest = q1 + END IF + err = MAX(MAXVAL(ABS(Ra(10:12) - Rb(10:12) - dd*tn)), MAXVAL(ABS(Ra(7:9) - Rb(7:9) + dd*tn))) + worst = MAX(worst, err/ABS(td0)) + END DO + END DO + WRITE (*, '(A,I0,A,I0,A,I0,A,ES10.3)') ' length change, pass ', ip, ': slack-start dashpot cap active at ', & + nact, ' of ', SIZE(THETA_S)*SIZE(OFS_S), ' states; largest deviation from the closed form / |T_d,n| ', worst + CALL require(nact >= 4 .AND. best > 0.0_wp, 'lengths-cap:slack-dashpot-active') + CALL require(worst < 1.0e-9_wp, 'lengths-cap:slack-dashpot-closed-form') + DO i = 1, 2 + CALL fd_tangent_check('lengths-cap-slack-dashpot', qn, vn, z, qbest, L0, EA, [2.0_wp, 3.0_wp, 1.5_wp], & + i == 1, axial_damping=[0.0_wp, 0.0_wp, BA], start_load=sl, start_l0=ls, & + axial_l0_rate=[0.0_wp, 0.0_wp, rn], start_l0_rate=[0.0_wp, 0.0_wp, rs]) + END DO + ! (b) the damped law segment (ea = 0): T_n mostly damping at e_n = 1 um + CALL reset_chain_load() + cb_law_elem = 3 + cb_ea_law = EA_LAW + cb_ba_law = BA_LAW + CALL chain_nodes(DIRS, [0.010_wp, 0.020_wp, 1.0e-6_wp/ls3], ls, qn) + d0 = qn(10:12) - qn(7:9) + ln = NORM2(d0) + tn = d0/ln + u = [tn(2), -tn(1), 0.0_wp] + u = u/NORM2(u) + vn = 0.0_wp + vn(10:12) = 0.05_wp*tn + cb_l0_law = ls3 + CALL chain_load(qn, vn, sl, jq, jv) + cb_l0_law = L0(3) + t0 = DOT_PRODUCT(sl(7:9), tn) + e0 = ln - ls3 + w0 = 0.5_wp*t0*e0 + kn = EA_LAW/ls3 + k0 = MIN(t0/e0, kn) + CALL require(t0/e0 > 1.0e3_wp*kn, 'lengths-cap:law-damping-dominated-start') + worst = 0.0_wp + nact = 0 + dir = COS(PI/4.0_wp)*tn + SIN(PI/4.0_wp)*u + DO j = 1, SIZE(S1) + q1 = qn + q1(10:12) = qn(7:9) + L0(3)*(1.0_wp + S1(j))*dir + CALL probe_chain(qn, vn, z, q1, L0, [EA(1), EA(2), 0.0_wp], RHO_TINY, .TRUE., Ra, K, & + start_tension=[0.0_wp, 0.0_wp, t0], start_stiffness=[0.0_wp, 0.0_wp, kn], start_load=sl, & + start_l0=ls) + CALL probe_chain(qn, vn, z, q1, L0, [EA(1), EA(2), 0.0_wp], RHO_TINY, .TRUE., Rb, K, start_load=sl, start_l0=ls) + d1 = q1(10:12) - q1(7:9) + l1 = NORM2(d1) + t1 = d1/l1 + e1 = l1 - L0(3) + p = ln - DOT_PRODUCT(tn, d1) + p1 = l1 - DOT_PRODUCT(t1, d0) + that = k0*MAX(e1, 0.0_wp) + dd = 0.0_wp + IF (p > 0.0_wp) dd = MIN(MAX(w0 + (1.0_wp - af)*that*p1, 0.0_wp)/p - af*t0, 0.0_wp) + IF (ABS(dd) > 1.0e-6_wp*t0) nact = nact + 1 + err = MAX(MAXVAL(ABS(Ra(10:12) - Rb(10:12) - dd*tn)), MAXVAL(ABS(Ra(7:9) - Rb(7:9) + dd*tn))) + worst = MAX(worst, err/t0) + END DO + WRITE (*, '(A,I0,A,I0,A,ES10.3)') ' length change, pass ', ip, ': law cap active at ', nact, & + ' states; largest deviation from the closed form / T_n ', worst + CALL require(nact >= 4, 'lengths-cap:law-active') + CALL require(worst < 1.0e-9_wp, 'lengths-cap:law-closed-form') + q1 = qn + q1(10:12) = qn(7:9) + L0(3)*(1.0_wp + 6.0e-4_wp)*dir + DO i = 1, 2 + CALL fd_tangent_check('lengths-cap-law', qn, vn, z, q1, L0, [EA(1), EA(2), 0.0_wp], [2.0_wp, 3.0_wp, 1.5_wp], & + i == 1, start_tension=[0.0_wp, 0.0_wp, t0], start_stiffness=[0.0_wp, 0.0_wp, kn], & + start_load=sl, start_l0=ls) + END DO + END DO + CALL reset_chain_load() + END SUBROUTINE case_length_change_cap_terms + SUBROUTINE damped_tangent_case(label, qn, vn, q1, l0, ea, ad, t0) !! The damped chain of case_damped_elastic_release at one trial state where the cap acts: !! the cap is active, and the tangent matches the finite difference on both paths. diff --git a/tests/test_hermite_axial_damping.f90 b/tests/test_hermite_axial_damping.f90 index e78e4fce..fc33ca19 100644 --- a/tests/test_hermite_axial_damping.f90 +++ b/tests/test_hermite_axial_damping.f90 @@ -4,8 +4,10 @@ PROGRAM test_hermite_axial_damping !! Axial Kelvin-Voigt damping on the finite-EI Hermite cable. The gates cover the !! analytical straight-element limit, rigid-body invariance, positive dissipation, - !! exact position/velocity Jacobians, and the transactional model setter. + !! exact position/velocity Jacobians, the unstretched-length rate of active line + !! control, and the transactional model setter. USE CableDyn_Precision, ONLY: wp + USE CableDyn_HermiteCable, ONLY: CD_HermiteCable_Axial_Resultant USE CableDyn_HermiteCableDynamic, ONLY: CD_HermiteCableDynType, CD_HermiteCable_Dyn_End_Force, & CD_HermiteCable_Axial_Damping_Element, & CD_HermiteCable_Axial_Damping_Resultant, & @@ -23,6 +25,7 @@ PROGRAM test_hermite_axial_damping nfail = 0 CALL check_straight_limit() CALL check_jacobians_and_dissipation() + CALL check_length_rate() CALL check_setter_lifecycle() IF (nfail > 0) THEN WRITE (*, '(A,I0,A)') 'FAIL: ', nfail, ' assertion(s) failed' @@ -120,6 +123,95 @@ SUBROUTINE check_jacobians_and_dissipation() 'velocity Jacobian is symmetric') END SUBROUTINE check_jacobians_and_dissipation + SUBROUTINE check_length_rate() + !! Active line control: with an unstretched-length rate l0_dot the damped strain rate is + !! the time derivative of the strain |r_xi|/l0 - 1 the elastic resultant uses, along + !! q + v t and l0 + l0_dot t. Gates: a straight element paid out at constant strain + !! carries no damping force; the viscous resultant matches the central difference of that + !! strain; a zero rate reproduces the uncontrolled element; and the position and velocity + !! Jacobians with a rate match central differences. + REAL(wp), PARAMETER :: l0 = 2.2_wp, ba = 3.7e4_wp, ldot = 0.37_wp, stretch = 1.004_wp + REAL(wp), PARAMETER :: xs(3) = [0.0_wp, 0.31_wp, 0.83_wp] + REAL(wp) :: qe(12), ve(12), qp(12), qm(12), vp(12), vm(12) + REAL(wp) :: f(12), f0(12), fp(12), fm(12), kq(12, 12), kv(12, 12), kq0(12, 12), kv0(12, 12) + REAL(wp) :: kqfd(12, 12), kvfd(12, 12) + REAL(wp) :: td, sp, sm, h, errq, errv, scaleq, scalev, rate_fd + INTEGER :: es, j, k + CHARACTER(300) :: em + + ! (a) constant-strain pay-out: r_2 moves with the growing reference at the element's + ! stretch and the tangents keep it, so the strain does not change anywhere + qe = [0.0_wp, 0.0_wp, 0.0_wp, stretch, 0.0_wp, 0.0_wp, & + stretch*l0, 0.0_wp, 0.0_wp, stretch, 0.0_wp, 0.0_wp] + ve = 0.0_wp + ve(7) = stretch*ldot + CALL CD_HermiteCable_Axial_Damping_Element(qe, ve, l0, ba, f, kq, kv, es, em, l0_dot=ldot) + CALL require(es == CD_HCDYN_OK, 'pay-out element accepted: '//TRIM(em)) + CALL require(nan_max_abs(f) <= 1.0e-12_wp*ba*ldot/l0, & + 'a straight element paid out at constant strain carries no damping force') + DO k = 1, SIZE(xs) + CALL CD_HermiteCable_Axial_Damping_Resultant(qe, ve, l0, ba, xs(k), td, es, em, l0_dot=ldot) + CALL require(es == CD_HCDYN_OK .AND. ABS(td) <= 1.0e-12_wp*ba*ldot/l0, & + 'constant-strain pay-out has no viscous resultant') + END DO + ! without the rate the end velocity reads as stretch: strain rate dH_3 stretch ldot/l0, + ! so f_r2 = BA stretch ldot/l0 times the integral of dH_3**2 = 36 x**2 (1 - x)**2, 6/5 + CALL CD_HermiteCable_Axial_Damping_Element(qe, ve, l0, ba, f, ErrStat=es, ErrMsg=em) + CALL require(ABS(f(7) - 1.2_wp*ba*stretch*ldot/l0) <= 1.0e-12_wp*ba*ldot/l0, & + 'without the rate the same motion reads as a stretching dashpot') + + ! (b) the resultant is BA times the time derivative of the strain along the motion + qe = [0.10_wp, -0.20_wp, 0.30_wp, 0.90_wp, 0.20_wp, 0.15_wp, & + 2.30_wp, 0.50_wp, 0.80_wp, 0.70_wp, -0.10_wp, 0.25_wp] + ve = [0.12_wp, -0.04_wp, 0.03_wp, 0.02_wp, 0.01_wp, -0.03_wp, & + -0.06_wp, 0.08_wp, 0.05_wp, -0.01_wp, 0.04_wp, 0.02_wp] + h = 1.0e-6_wp + DO k = 1, SIZE(xs) + CALL CD_HermiteCable_Axial_Resultant(qe + h*ve, l0 + h*ldot, 1.0_wp, xs(k), sp, es, em) + CALL CD_HermiteCable_Axial_Resultant(qe - h*ve, l0 - h*ldot, 1.0_wp, xs(k), sm, es, em) + rate_fd = (sp - sm)/(2.0_wp*h) + CALL CD_HermiteCable_Axial_Damping_Resultant(qe, ve, l0, ba, xs(k), td, es, em, l0_dot=ldot) + CALL require(es == CD_HCDYN_OK .AND. ABS(td - ba*rate_fd) <= 1.0e-7_wp*ba*MAX(ABS(rate_fd), 1.0e-3_wp), & + 'the controlled viscous resultant is BA times the strain rate along q(t), l0(t)') + END DO + + ! (c) a zero rate is the uncontrolled element + CALL CD_HermiteCable_Axial_Damping_Element(qe, ve, l0, ba, f0, kq0, kv0, es, em, 6) + CALL CD_HermiteCable_Axial_Damping_Element(qe, ve, l0, ba, f, kq, kv, es, em, 6, 0.0_wp) + CALL require(nan_max_abs(f - f0) <= 0.0_wp .AND. nan_max_abs(kq - kq0) <= 0.0_wp .AND. & + nan_max_abs(kv - kv0) <= 0.0_wp, 'a zero length rate reproduces the uncontrolled element') + + ! (d) Jacobians with a rate against central differences + CALL CD_HermiteCable_Axial_Damping_Element(qe, ve, l0, ba, f, kq, kv, es, em, 6, ldot) + CALL require(es == CD_HCDYN_OK, 'controlled curved element accepted: '//TRIM(em)) + CALL require(nan_max_abs(kq - kq0) > 1.0e-3_wp*nan_max_abs(kq0), 'the length rate enters the position Jacobian') + DO j = 1, 12 + h = 2.0e-7_wp*MAX(1.0_wp, ABS(qe(j))) + qp = qe; qm = qe + qp(j) = qp(j) + h; qm(j) = qm(j) - h + CALL CD_HermiteCable_Axial_Damping_Element(qp, ve, l0, ba, fp, ErrStat=es, ErrMsg=em, & + quadrature_order=6, l0_dot=ldot) + CALL CD_HermiteCable_Axial_Damping_Element(qm, ve, l0, ba, fm, ErrStat=es, ErrMsg=em, & + quadrature_order=6, l0_dot=ldot) + kqfd(:, j) = (fp - fm)/(2.0_wp*h) + h = 2.0e-7_wp*MAX(1.0_wp, ABS(ve(j))) + vp = ve; vm = ve + vp(j) = vp(j) + h; vm(j) = vm(j) - h + CALL CD_HermiteCable_Axial_Damping_Element(qe, vp, l0, ba, fp, ErrStat=es, ErrMsg=em, & + quadrature_order=6, l0_dot=ldot) + CALL CD_HermiteCable_Axial_Damping_Element(qe, vm, l0, ba, fm, ErrStat=es, ErrMsg=em, & + quadrature_order=6, l0_dot=ldot) + kvfd(:, j) = (fp - fm)/(2.0_wp*h) + END DO + scaleq = MAX(1.0_wp, nan_max_abs(kqfd)) + scalev = MAX(1.0_wp, nan_max_abs(kvfd)) + errq = nan_max_abs(kq - kqfd)/scaleq + errv = nan_max_abs(kv - kvfd)/scalev + WRITE (*, '(A,ES10.3,A,ES10.3)') ' controlled damping Jacobian relative errors: q=', errq, ' v=', errv + CALL require(errq < 2.0e-7_wp, 'controlled position Jacobian matches central differences') + CALL require(errv < 2.0e-8_wp, 'controlled velocity Jacobian matches central differences') + END SUBROUTINE check_length_rate + SUBROUTINE check_setter_lifecycle() TYPE(CD_HermiteCableDynType) :: model TYPE(CD_HFMF_ModuleType), ALLOCATABLE :: cables(:) diff --git a/tests/test_hermite_cable_control.f90 b/tests/test_hermite_cable_control.f90 new file mode 100644 index 00000000..8de7669a --- /dev/null +++ b/tests/test_hermite_cable_control.f90 @@ -0,0 +1,688 @@ +! File: tests/test_hermite_cable_control.f90 +! SPDX-License-Identifier: Apache-2.0 +! Copyright (c) 2026 Jae Hoon Seo, SMI Lab, Inha University +PROGRAM test_hermite_cable_control + !! Active line control of a finite-EI (cubic-Hermite) cable, + !! CD_HermiteCable_Dyn_Set_SegmentLength: + !! A the update is inert when nothing changes (a rate of -0 included), rebuilds every + !! length-dependent cache to what a model built with the new lengths carries (bit for + !! bit), leaves the committed lengths to a re-derived acceleration, is atomic on + !! failure, refuses a torsion line, a contact line without the seabed recompute inputs + !! and the configuration blend, is taken back exactly by a saved control state, and + !! joins the snapshot/restore contract exactly; + !! B a hanging vertical cable whose top span is paid out settles to the top reaction + !! w (L + DeltaL) and the stretched length L' + w L'**2/(2 EA); + !! C a taut vertical cable whose top span is hauled in settles to the top tension + !! EA (H - L')/L' + w L'/2; + !! D a weightless taut cable paid out at a constant rate Ldot carries the Kelvin-Voigt + !! tension EA (H/L' - 1) - BA H Ldot/L'**2 (without the length rate it does not); + !! E a slack cable whose top span is ramped slowly ends at the static equilibrium of the + !! edited lengths; + !! F the cable of D paid out at a constant rate under the force-blended generalised-alpha + !! with alpha_f > 0 carries the same tension as with alpha_f = 0, the closed form of D, + !! also when the committed force is evaluated afresh each step rather than reused: the + !! committed force of each step belongs to the lengths it was reached with. + !! The axial cases B-D and F hold every transverse DOF, so the closed forms are exact for the + !! cubic-Hermite element (linear tension, quadratic displacement); the transient is damped + !! by BA. A, D and E run at rho_inf = 0; B and C at rho_inf = 0 and 0.4, C also comparing the + !! two through the ramp (the lag check of a line with weight). + USE CableDyn_Precision, ONLY: wp + USE CableDyn_HermiteCableDynamic, ONLY: CD_HermiteCableDynType, CD_HermiteCable_Dyn_Init, & + CD_HermiteCable_Dyn_Step, CD_HermiteCable_Dyn_Reaction, & + CD_HermiteCable_Dyn_Set_SegmentLength, & + CD_HermiteCable_Dyn_Set_Control_Seabed, & + CD_HermiteCable_Dyn_Set_Contact, CD_HermiteCable_Dyn_Set_Attachments, & + CD_HermiteCable_Dyn_Set_Axial_Damping, CD_HermiteCable_Dyn_Set_Drag, & + CD_HermiteCable_Dyn_Recompute_Acceleration, & + CD_HermiteCable_Dyn_Snapshot, CD_HermiteCable_Dyn_Restore, & + CD_HermiteCable_Dyn_Set_ForceBlend, CD_HermiteCableControlSaveType, & + CD_HermiteCable_Dyn_Save_Control, CD_HermiteCable_Dyn_Restore_Control, & + CD_HermiteCable_Dyn_End, CD_HCDYN_OK + USE CableDyn_HermiteCableStatic, ONLY: CD_HermiteCable_Static_Solve, CD_HCSTAT_OK + USE CableDyn_Line, ONLY: CD_Nodal_Seabed_Stiffness, CD_LINE_OK + USE, INTRINSIC :: ISO_FORTRAN_ENV, ONLY: INT64 + IMPLICIT NONE + + REAL(wp), PARAMETER :: PI = 3.14159265358979323846_wp + INTEGER :: nfail + + nfail = 0 + CALL check_model_contract() + CALL check_hanging_payout() + CALL check_taut_haul_in() + CALL check_payout_rate_lag() + CALL check_slow_ramp_static() + CALL check_payout_alpha_f() + IF (nfail > 0) THEN + WRITE (*, '(A,I0,A)') 'FAIL: ', nfail, ' assertion(s) failed' + ERROR STOP 1 + END IF + WRITE (*, '(A)') 'PASS: finite-EI active line control (caches, rewind, closed forms, static end state)' + +CONTAINS + + INCLUDE 'nan_max_abs.inc' + + ! ------------------------------------------------------------------------------------------ + SUBROUTINE check_model_contract() + !! A: a seabed cable with friction, attachments and axial damping. + INTEGER, PARAMETER :: NE = 8, NN = NE + 1, NDOF = 6*NN + REAL(wp), PARAMETER :: L = 1.5_wp, KBOT = 1.0e5_wp, CBOT = 1.0e4_wp, ZBED = -20.0_wp, DT = 0.01_wp + TYPE(CD_HermiteCableDynType) :: a, b, ref, twin + REAL(wp) :: l0(NE), l0b(NE), q(NDOF), diam(NE), lam + INTEGER, PARAMETER :: SPAN(2) = [7, 8] + INTEGER :: i, es, k + CHARACTER(300) :: em + + l0 = L + diam = 0.1_wp + q = 0.0_wp + DO i = 1, NN + q(6*(i - 1) + 1) = REAL(i - 1, wp)*L + q(6*(i - 1) + 3) = ZBED + q(6*(i - 1) + 4) = 1.0_wp + END DO + CALL build_bed_model(a, l0, q, diam, KBOT, CBOT, ZBED, es, em) + CALL require(es == CD_HCDYN_OK, 'A: seabed model: '//TRIM(em)) + IF (es /= CD_HCDYN_OK) RETURN + + ! inert: a command that changes nothing leaves the model untouched and uncontrolled + twin = a + CALL CD_HermiteCable_Dyn_Set_SegmentLength(a, SPAN, a%l0(SPAN), [0.0_wp, 0.0_wp], es, em) + CALL require(es == CD_HCDYN_OK .AND. .NOT. a%has_ctrl .AND. .NOT. ALLOCATED(a%l0_dot), & + 'A: an unchanged length and zero rate leave the model uncontrolled') + CALL require(same_bits2(a%Mgb, twin%Mgb) .AND. same_bits(a%l0, twin%l0) .AND. & + (a%fc_valid .EQV. twin%fc_valid), 'A: the inert call writes nothing') + DO k = 1, 3 + CALL CD_HermiteCable_Dyn_Step(a, DT, 50, 1.0e-10_wp, es, em) + CALL require(es == CD_HCDYN_OK, 'A: inert step: '//TRIM(em)) + CALL CD_HermiteCable_Dyn_Step(twin, DT, 50, 1.0e-10_wp, es, em) + END DO + CALL require(same_bits(a%q, twin%q) .AND. same_bits(a%v, twin%v) .AND. same_bits(a%a, twin%a), & + 'A: steps after the inert call are bit-identical to a never-controlled twin') + ! a rate of -0 (a host's negated zero) counts as +0: still inert + CALL CD_HermiteCable_Dyn_Set_SegmentLength(a, SPAN, a%l0(SPAN), [SIGN(0.0_wp, -1.0_wp), SIGN(0.0_wp, -1.0_wp)], & + es, em) + CALL require(es == CD_HCDYN_OK .AND. .NOT. a%has_ctrl .AND. .NOT. ALLOCATED(a%l0_dot), & + 'A: a rate of -0 leaves the model uncontrolled') + ! the configuration blend has no committed-length treatment: refused by name + CALL CD_HermiteCable_Dyn_Set_ForceBlend(twin, .FALSE., es, em) + CALL require(es == CD_HCDYN_OK, 'A: twin on the configuration blend') + CALL CD_HermiteCable_Dyn_Set_SegmentLength(twin, SPAN, 1.1_wp*twin%l0(SPAN), [0.0_wp, 0.0_wp], es, em) + CALL require(es /= CD_HCDYN_OK .AND. INDEX(em, 'force blend') > 0 .AND. .NOT. twin%has_ctrl, & + 'A: the configuration blend fails closed by name') + CALL CD_HermiteCable_Dyn_End(twin) + + ! rebuild = fresh init: lengthen the trailing span, then build a model with those lengths + CALL CD_HermiteCable_Dyn_End(a) + CALL build_bed_model(a, l0, q, diam, KBOT, CBOT, ZBED, es, em) + lam = 1.3_wp + CALL CD_HermiteCable_Dyn_Set_SegmentLength(a, SPAN, lam*l0(SPAN), [0.0_wp, 0.0_wp], es, em) + CALL require(es == CD_HCDYN_OK .AND. a%has_ctrl, 'A: span lengthened: '//TRIM(em)) + CALL require(.NOT. a%tr_valid .AND. same_bits(a%l0_c, l0) .AND. ALL(a%l0_dot_c == 0.0_wp), & + 'A: a length change drops the carried factor; the committed state keeps its lengths') + l0b = l0 + l0b(SPAN) = lam*l0(SPAN) + CALL build_bed_model(b, l0b, q, diam, KBOT, CBOT, ZBED, es, em) + CALL require(es == CD_HCDYN_OK, 'A: fresh model at the new lengths: '//TRIM(em)) + CALL require(same_bits(a%l0, b%l0), 'A: lengths equal a fresh build') + CALL require(same_bits2(a%Mgb, b%Mgb), 'A: constant mass with attachments equals a fresh build bit for bit') + CALL require(same_bits(a%trib, b%trib), 'A: tributary lengths equal a fresh build bit for bit') + CALL require(same_bits(a%contact_kn, b%contact_kn) .AND. same_bits(a%contact_cn, b%contact_cn), & + 'A: nodal seabed coefficients equal a fresh build bit for bit') + CALL require(same_bits(a%fr_k, b%fr_k), 'A: friction spring stiffness equals a fresh build bit for bit') + ! a non-stepping re-derivation of the committed acceleration between the command and the + ! step belongs to the committed state: it is solved at the lengths that state was reached + ! with, which stay the committed ones, so it equals the acceleration of a model that was + ! never commanded, the committed force cache survives, and the new lengths stay in place + twin = a + CALL build_bed_model(ref, l0, q, diam, KBOT, CBOT, ZBED, es, em) + CALL CD_HermiteCable_Dyn_Recompute_Acceleration(ref, es, em) + CALL CD_HermiteCable_Dyn_Recompute_Acceleration(a, es, em) + CALL require(es == CD_HCDYN_OK .AND. same_bits(a%a, ref%a) .AND. same_bits(a%l0_c, l0) .AND. & + ALL(a%l0_dot_c == 0.0_wp) .AND. (a%fc_valid .EQV. twin%fc_valid) .AND. unchanged(a, twin), & + 'A: a re-derived acceleration belongs to the committed lengths, which stay committed') + CALL CD_HermiteCable_Dyn_End(ref) + CALL CD_HermiteCable_Dyn_End(twin) + ! once the new lengths are committed (restored = .TRUE., as a checkpoint restart does), + ! the re-derived acceleration is the fresh model's and the two models step identically + CALL CD_HermiteCable_Dyn_Set_SegmentLength(a, SPAN, lam*l0(SPAN), [0.0_wp, 0.0_wp], es, em, restored=.TRUE.) + CALL require(es == CD_HCDYN_OK .AND. same_bits(a%l0_c, a%l0), 'A: restored = .TRUE. commits the lengths') + CALL CD_HermiteCable_Dyn_Recompute_Acceleration(a, es, em) + CALL require(es == CD_HCDYN_OK .AND. nan_max_abs(a%a - b%a) <= 0.0_wp, & + 'A: at committed new lengths the re-derived acceleration equals the fresh model''s') + DO k = 1, 3 + CALL CD_HermiteCable_Dyn_Step(a, DT, 50, 1.0e-10_wp, es, em) + CALL require(es == CD_HCDYN_OK, 'A: controlled step: '//TRIM(em)) + CALL CD_HermiteCable_Dyn_Step(b, DT, 50, 1.0e-10_wp, es, em) + CALL require(es == CD_HCDYN_OK, 'A: fresh-model step: '//TRIM(em)) + END DO + CALL require(nan_max_abs(a%q - b%q) <= 0.0_wp .AND. nan_max_abs(a%v - b%v) <= 0.0_wp, & + 'A: the controlled model marches exactly as one built with the new lengths') + CALL CD_HermiteCable_Dyn_End(b) + + ! a rate-only change rebuilds nothing and keeps the committed force (it belongs to the + ! committed rates, which stay) + ref = a + CALL CD_HermiteCable_Dyn_Set_SegmentLength(a, SPAN, a%l0(SPAN), [0.05_wp, 0.05_wp], es, em) + CALL require(es == CD_HCDYN_OK .AND. same_bits2(a%Mgb, ref%Mgb) .AND. same_bits(a%l0, ref%l0) .AND. & + a%fc_valid .AND. same_bits(a%fc_R, ref%fc_R) .AND. ALL(a%l0_dot_c == 0.0_wp) .AND. & + ALL(a%l0_dot(SPAN) == 0.05_wp) .AND. ALL(a%l0_dot(1:6) == 0.0_wp), & + 'A: a rate-only change keeps the caches and records the rate on the span') + + ! a controlled model keeps the force blend + CALL CD_HermiteCable_Dyn_Set_ForceBlend(a, .FALSE., es, em) + CALL require(es /= CD_HCDYN_OK .AND. a%force_blend, 'A: the force blend of a controlled model stays on') + + ! a saved control state takes a command back bit for bit, the carried-factor flag included + BLOCK + TYPE(CD_HermiteCableControlSaveType) :: saved + LOGICAL :: tr_before + ref = a + tr_before = a%tr_valid + CALL CD_HermiteCable_Dyn_Save_Control(a, saved) + CALL CD_HermiteCable_Dyn_Set_SegmentLength(a, SPAN, 0.7_wp*a%l0(SPAN), [-0.3_wp, -0.3_wp], es, em, & + restored=.TRUE.) + CALL require(es == CD_HCDYN_OK .AND. .NOT. unchanged(a, ref), 'A: a command to take back') + CALL CD_HermiteCable_Dyn_Restore_Control(a, saved, es, em) + CALL require(es == CD_HCDYN_OK .AND. unchanged(a, ref) .AND. same_bits(a%l0_c, ref%l0_c) .AND. & + same_bits(a%l0_dot_c, ref%l0_dot_c) .AND. (a%tr_valid .EQV. tr_before), & + 'A: the saved control state takes the command back bit for bit') + ! on a model that was never controlled, the restore drops the control storage again + CALL build_bed_model(twin, l0, q, diam, KBOT, CBOT, ZBED, es, em) + ref = twin + CALL CD_HermiteCable_Dyn_Save_Control(twin, saved) + CALL CD_HermiteCable_Dyn_Set_SegmentLength(twin, SPAN, 1.2_wp*l0(SPAN), [0.1_wp, 0.1_wp], es, em) + CALL CD_HermiteCable_Dyn_Restore_Control(twin, saved, es, em) + CALL require(es == CD_HCDYN_OK .AND. unchanged(twin, ref) .AND. .NOT. ALLOCATED(twin%l0_dot), & + 'A: taking back the first command restores the uncontrolled model') + CALL CD_HermiteCable_Dyn_End(twin) + CALL CD_HermiteCable_Dyn_End(ref) + END BLOCK + + ! atomic failure: nothing is written + ref = a + CALL CD_HermiteCable_Dyn_Set_SegmentLength(a, [7, 9], [1.0_wp, 1.0_wp], [0.0_wp, 0.0_wp], es, em) + CALL require(es /= CD_HCDYN_OK .AND. unchanged(a, ref), 'A: an out-of-range element fails and writes nothing') + CALL CD_HermiteCable_Dyn_Set_SegmentLength(a, [8, 7], [1.0_wp, 1.0_wp], [0.0_wp, 0.0_wp], es, em) + CALL require(es /= CD_HCDYN_OK .AND. unchanged(a, ref), 'A: unordered elements fail and write nothing') + CALL CD_HermiteCable_Dyn_Set_SegmentLength(a, SPAN, [1.0_wp, -1.0_wp], [0.0_wp, 0.0_wp], es, em) + CALL require(es /= CD_HCDYN_OK .AND. unchanged(a, ref), 'A: a non-positive length fails and writes nothing') + twin = a + twin%torsion%active = .TRUE. + CALL CD_HermiteCable_Dyn_Set_SegmentLength(twin, SPAN, [1.0_wp, 1.0_wp], [0.0_wp, 0.0_wp], es, em) + CALL require(es /= CD_HCDYN_OK .AND. INDEX(em, 'torsion') > 0, 'A: a line restrained in torsion fails closed') + twin%torsion%active = .FALSE. + twin%has_seabed_recompute = .FALSE. + CALL CD_HermiteCable_Dyn_Set_SegmentLength(twin, SPAN, [1.0_wp, 1.0_wp], [0.0_wp, 0.0_wp], es, em) + CALL require(es /= CD_HCDYN_OK .AND. INDEX(em, 'seabed recompute') > 0, & + 'A: a contact line without the seabed recompute inputs fails closed') + CALL CD_HermiteCable_Dyn_End(twin) + CALL CD_HermiteCable_Dyn_Set_Control_Seabed(a, 2.0_wp*KBOT, diam, CBOT/KBOT, es, em) + CALL require(es /= CD_HCDYN_OK .AND. INDEX(em, 'do not reproduce') > 0 .AND. a%seabed_kbot == KBOT, & + 'A: seabed recompute inputs that do not reproduce the installed coefficients fail') + + ! snapshot/restore: a later command and step roll back exactly, caches included + ref = a + CALL CD_HermiteCable_Dyn_Snapshot(a, es, em) + CALL require(es == CD_HCDYN_OK, 'A: snapshot: '//TRIM(em)) + CALL CD_HermiteCable_Dyn_Set_SegmentLength(a, SPAN, 0.8_wp*a%l0(SPAN), [-0.1_wp, -0.1_wp], es, em) + CALL require(es == CD_HCDYN_OK, 'A: command after the snapshot: '//TRIM(em)) + CALL CD_HermiteCable_Dyn_Step(a, DT, 50, 1.0e-10_wp, es, em) + CALL require(es == CD_HCDYN_OK, 'A: step after the command: '//TRIM(em)) + CALL CD_HermiteCable_Dyn_Restore(a, es, em) + CALL require(es == CD_HCDYN_OK, 'A: restore: '//TRIM(em)) + CALL require(unchanged(a, ref) .AND. same_bits(a%l0_dot, ref%l0_dot) .AND. same_bits(a%q, ref%q) .AND. & + same_bits(a%v, ref%v) .AND. same_bits(a%a, ref%a) .AND. same_bits2(a%fr_anchor, ref%fr_anchor), & + 'A: restore brings back the lengths, rates, caches and state bit for bit') + DO k = 1, 3 + CALL CD_HermiteCable_Dyn_Step(a, DT, 50, 1.0e-10_wp, es, em) + CALL CD_HermiteCable_Dyn_Step(ref, DT, 50, 1.0e-10_wp, es, em) + END DO + CALL require(es == CD_HCDYN_OK .AND. same_bits(a%q, ref%q) .AND. same_bits(a%v, ref%v), & + 'A: the restored model marches bit-identically to an untouched copy') + CALL CD_HermiteCable_Dyn_End(ref) + CALL CD_HermiteCable_Dyn_End(a) + + ! a snapshot taken before any command restores the uncontrolled model + CALL build_bed_model(a, l0, q, diam, KBOT, CBOT, ZBED, es, em) + ref = a + CALL CD_HermiteCable_Dyn_Snapshot(a, es, em) + CALL CD_HermiteCable_Dyn_Set_SegmentLength(a, SPAN, 1.5_wp*l0(SPAN), [0.2_wp, 0.2_wp], es, em) + CALL CD_HermiteCable_Dyn_Restore(a, es, em) + CALL require(es == CD_HCDYN_OK .AND. .NOT. a%has_ctrl .AND. unchanged(a, ref), & + 'A: restoring a pre-control snapshot gives back the uncontrolled model') + CALL CD_HermiteCable_Dyn_End(ref) + CALL CD_HermiteCable_Dyn_End(a) + END SUBROUTINE check_model_contract + + SUBROUTINE build_bed_model(model, l0, q, diam, kbot, cbot, zbed, ErrStat, ErrMsg) + !! A cable laid on a flat bed: nodal contact with friction, axial damping and two + !! attachments, set up in the order of the deck builder. + TYPE(CD_HermiteCableDynType), INTENT(OUT) :: model + REAL(wp), INTENT(IN) :: l0(:), q(:), diam(:), kbot, cbot, zbed + INTEGER, INTENT(OUT) :: ErrStat + CHARACTER(*), INTENT(OUT) :: ErrMsg + REAL(wp), ALLOCATABLE :: kn(:), cn(:) + INTEGER :: ne, ndof, k + ne = SIZE(l0) + ndof = 6*(ne + 1) + CALL CD_HermiteCable_Dyn_Init(model, l0, [(1.0e6_wp, k=1, ne)], [(100.0_wp, k=1, ne)], [(5.0_wp, k=1, ne)], & + [(30.0_wp, k=1, ne)], q, [1, 2, 3, ndof - 5, ndof - 4, ndof - 3], zbed, 0.0_wp, & + 0.5_wp, ErrStat, ErrMsg) + IF (ErrStat /= CD_HCDYN_OK) RETURN + CALL CD_HermiteCable_Dyn_Set_Axial_Damping(model, [(2.0e4_wp, k=1, ne)], ErrStat, ErrMsg) + IF (ErrStat /= CD_HCDYN_OK) RETURN + CALL CD_Nodal_Seabed_Stiffness(kbot, diam, l0, kn, ErrStat, ErrMsg) + IF (ErrStat /= CD_LINE_OK) RETURN + cn = kn*(cbot/kbot) + CALL CD_HermiteCable_Dyn_Set_Contact(model, kn, cn, 0.3_wp, ErrStat, ErrMsg) + IF (ErrStat /= CD_HCDYN_OK) RETURN + CALL CD_HermiteCable_Dyn_Set_Control_Seabed(model, kbot, diam, cbot/kbot, ErrStat, ErrMsg) + IF (ErrStat /= CD_HCDYN_OK) RETURN + CALL CD_HermiteCable_Dyn_Set_Attachments(model, [3, ne], [50.0_wp, 20.0_wp], [0.01_wp, 0.02_wp], & + [0.1_wp, 0.0_wp], [0.05_wp, 0.0_wp], [1.0_wp, 0.5_wp], & + 1025.0_wp, 9.80665_wp, ErrStat, ErrMsg) + END SUBROUTINE build_bed_model + + LOGICAL FUNCTION unchanged(m, r) RESULT(same) + !! Every length-dependent field of m equals that of r bit for bit. + TYPE(CD_HermiteCableDynType), INTENT(IN) :: m, r + same = same_bits(m%l0, r%l0) .AND. same_bits2(m%Mgb, r%Mgb) .AND. same_bits(m%trib, r%trib) .AND. & + same_bits(m%contact_kn, r%contact_kn) .AND. same_bits(m%contact_cn, r%contact_cn) .AND. & + same_bits(m%fr_k, r%fr_k) .AND. (m%has_ctrl .EQV. r%has_ctrl) + IF (same .AND. m%has_ctrl) same = same_bits(m%l0_dot, r%l0_dot) + END FUNCTION unchanged + + ! ------------------------------------------------------------------------------------------ + SUBROUTINE check_hanging_payout() + !! B: a vertical cable hangs from a fixed top node; its two top elements (S = 2 m) are paid + !! out by 0.5 m on a smooth ramp. At rest the top carries the whole submerged weight + !! w (L + DeltaL), and the free end hangs L' + w L'**2/(2 EA) below the top. Marched at + !! rho_inf = 0 (alpha_f = 0) and rho_inf = 0.4 (alpha_f = 2/7, where the committed force + !! carries weight in the blend): both reach the closed form. (The free end rings axially + !! through the ramp, and the two spectral radii damp that differently by more than a lag + !! would shift the tension, so the lag is checked on the taut lines of C and F.) + INTEGER, PARAMETER :: NE = 10 + REAL(wp), PARAMETER :: L = 10.0_wp, EA = 1.0e5_wp, W = 50.0_wp, RHOA = 10.0_wp, BA = 2000.0_wp + REAL(wp), PARAMETER :: DL = 0.5_wp, TR = 2.0_wp, TEND = 8.0_wp, DT = 0.01_wp + TYPE(CD_HermiteCableDynType) :: m + REAL(wp) :: s, z(NE + 1), mz(NE + 1), t_top, lp, z_end, expect + INTEGER :: i, es, pass + CHARACTER(300) :: em + + DO pass = 1, 2 + DO i = 1, NE + 1 + s = REAL(i - 1, wp)*L/REAL(NE, wp) + z(i) = -(L - s) - W*(L*L - s*s)/(2.0_wp*EA) + mz(i) = 1.0_wp + W*s/EA + END DO + CALL vertical_model(m, L/REAL(NE, wp), EA, W, RHOA, BA, z, mz, .FALSE., es, em, & + rho_inf=MERGE(0.0_wp, 0.4_wp, pass == 1)) + CALL require(es == CD_HCDYN_OK, 'B: init: '//TRIM(em)) + IF (es /= CD_HCDYN_OK) RETURN + t_top = top_tension(m) + CALL require(ABS(t_top - W*L) <= 1.0e-9_wp*W*L, 'B: the seed carries the weight w L') + CALL march_ramp(m, [NE - 1, NE], DL, 0.0_wp, TR, TEND, DT, .TRUE., es, em) + CALL require(es == CD_HCDYN_OK, 'B: march: '//TRIM(em)) + IF (es /= CD_HCDYN_OK) RETURN + lp = L + DL + expect = W*lp + t_top = top_tension(m) + z_end = m%q(3) + WRITE (*, '(A,I0,A,ES12.5,A,ES12.5)') ' B (pass ', pass, '): top reaction rel. error ', & + ABS(t_top - expect)/expect, ' free-end position error [m] ', ABS(z_end + lp + W*lp*lp/(2.0_wp*EA)) + CALL require(ABS(t_top - expect) <= 1.0e-6_wp*expect, 'B: top reaction is w (L + DeltaL)') + CALL require(ABS(z_end + lp + W*lp*lp/(2.0_wp*EA)) <= 1.0e-6_wp, & + 'B: the free end hangs L'' + w L''**2/(2 EA) below the top') + CALL require(ALL(ABS(m%l0(NE - 1:NE) - 1.25_wp) <= 2.0_wp*EPSILON(1.0_wp)), & + 'B: the span elements scaled by (S + DeltaL)/S') + CALL CD_HermiteCable_Dyn_End(m) + END DO + END SUBROUTINE check_hanging_payout + + SUBROUTINE check_taut_haul_in() + !! C: a vertical cable between fixed ends H = 10.1 m apart; its two top elements are + !! hauled in by 0.2 m. At rest the top tension is EA (H - L')/L' + w L'/2. Marched at + !! rho_inf = 0 and 0.4, as B: both reach the closed form, and through the ramp the top + !! tension of the two follows the same path, to a few per cent of the per-step tension + !! change (a committed force taken at the new lengths would lag the alpha_f > 0 run by + !! alpha_f = 2/7 of it). + INTEGER, PARAMETER :: NE = 10 + REAL(wp), PARAMETER :: L = 10.0_wp, H = 10.1_wp, EA = 1.0e5_wp, W = 50.0_wp, RHOA = 10.0_wp + REAL(wp), PARAMETER :: BA = 2000.0_wp, DL = -0.2_wp, TR = 2.0_wp, TEND = 8.0_wp, DT = 0.01_wp + TYPE(CD_HermiteCableDynType) :: m + REAL(wp) :: s, z(NE + 1), mz(NE + 1), tb, t_top, lp, expect, hist(NINT(TEND/DT), 2), d_step, diff + INTEGER :: i, es, pass + CHARACTER(300) :: em + + DO pass = 1, 2 + tb = EA*(H - L)/L - W*L/2.0_wp + DO i = 1, NE + 1 + s = REAL(i - 1, wp)*L/REAL(NE, wp) + z(i) = s + (tb*s + W*s*s/2.0_wp)/EA + mz(i) = 1.0_wp + (tb + W*s)/EA + END DO + CALL vertical_model(m, L/REAL(NE, wp), EA, W, RHOA, BA, z, mz, .TRUE., es, em, & + rho_inf=MERGE(0.0_wp, 0.4_wp, pass == 1)) + CALL require(es == CD_HCDYN_OK, 'C: init: '//TRIM(em)) + IF (es /= CD_HCDYN_OK) RETURN + t_top = top_tension(m) + expect = EA*(H - L)/L + W*L/2.0_wp + CALL require(ABS(t_top - expect) <= 1.0e-9_wp*expect, 'C: the seed carries EA (H - L)/L + w L/2') + CALL march_ramp(m, [NE - 1, NE], DL, 0.0_wp, TR, TEND, DT, .TRUE., es, em, hist(:, pass)) + CALL require(es == CD_HCDYN_OK, 'C: march: '//TRIM(em)) + IF (es /= CD_HCDYN_OK) RETURN + lp = L + DL + expect = EA*(H - lp)/lp + W*lp/2.0_wp + t_top = top_tension(m) + WRITE (*, '(A,I0,A,ES12.5)') ' C (pass ', pass, '): top tension rel. error ', ABS(t_top - expect)/expect + CALL require(ABS(t_top - expect) <= 1.0e-6_wp*expect, 'C: top tension is EA (H - L'')/L'' + w L''/2') + CALL CD_HermiteCable_Dyn_End(m) + END DO + ! the largest per-step change of the quasi-static tension EA H/L'(t), at the shortest L' + lp = L + DL + d_step = EA*H*ABS(DL)*0.5_wp*(PI/TR)*DT/(lp*lp) + diff = MAXVAL(ABS(hist(:, 2) - hist(:, 1))) + WRITE (*, '(A,ES10.3,A,ES12.5)') ' C: per-step tension change ', d_step, & + ' N; max difference between rho_inf = 0.4 and 0 ', diff + CALL require(diff <= 5.0e-2_wp*d_step, 'C: the alpha_f > 0 ramp follows the alpha_f = 0 one (no lag)') + END SUBROUTINE check_taut_haul_in + + SUBROUTINE check_payout_rate_lag() + !! D: a weightless cable between fixed ends H = 10.1 m apart (initial strain 1 %); its two + !! top elements are paid out at Ldot = 0.01 m/s from t = 0. The strain stays uniform, + !! eps = H/L' - 1, so the Kelvin-Voigt tension is EA eps + BA d(eps)/dt + !! = EA (H/L' - 1) - BA H Ldot/L'**2: the damping lag. Withholding the length rate puts a + !! spurious stretch rate on the span and misses it. + INTEGER, PARAMETER :: NE = 10 + REAL(wp), PARAMETER :: L = 10.0_wp, H = 10.1_wp, EA = 1.0e5_wp, RHOA = 1.0_wp, BA = 1.0e5_wp + REAL(wp), PARAMETER :: LDOT = 0.01_wp, TEND = 4.0_wp, DT = 0.01_wp + TYPE(CD_HermiteCableDynType) :: m + REAL(wp) :: s, z(NE + 1), mz(NE + 1), err_rate, err_norate, lag + INTEGER :: i, es, pass + CHARACTER(300) :: em + + lag = BA*H*LDOT/(L + LDOT*TEND)**2 + DO pass = 1, 2 + DO i = 1, NE + 1 + s = REAL(i - 1, wp)*L/REAL(NE, wp) + z(i) = s*H/L + mz(i) = H/L + END DO + CALL vertical_model(m, L/REAL(NE, wp), EA, 0.0_wp, RHOA, BA, z, mz, .TRUE., es, em) + CALL require(es == CD_HCDYN_OK, 'D: init: '//TRIM(em)) + IF (es /= CD_HCDYN_OK) RETURN + IF (pass == 1) THEN + CALL march_rate(m, [NE - 1, NE], LDOT, .TRUE., TEND, DT, H, EA, BA, err_rate, es, em) + CALL require(es == CD_HCDYN_OK, 'D: march: '//TRIM(em)) + ELSE + CALL march_rate(m, [NE - 1, NE], LDOT, .FALSE., TEND, DT, H, EA, BA, err_norate, es, em) + CALL require(es == CD_HCDYN_OK, 'D: march without the rate: '//TRIM(em)) + END IF + CALL CD_HermiteCable_Dyn_End(m) + END DO + WRITE (*, '(A,ES10.3,A,ES12.5,A,ES12.5)') ' D: damping lag ', lag, ' N; max tension error with the rate ', & + err_rate, ' N, without ', err_norate + CALL require(err_rate <= 1.0e-2_wp*lag, 'D: tension follows EA (H/L'' - 1) - BA H Ldot/L''**2') + CALL require(err_norate > 0.2_wp*lag, 'D: without the length rate the damping tension is wrong') + END SUBROUTINE check_payout_rate_lag + + SUBROUTINE check_slow_ramp_static() + !! E: a slack planar cable (10.4 m between ends 10 m apart, EI > 0) sagging under its + !! weight; its three top elements are hauled in by 0.2 m on a slow ramp and the line + !! settles. The end state is the static equilibrium of the edited lengths + !! (CD_HermiteCable_Static_Solve, seeded from the initial equilibrium). + INTEGER, PARAMETER :: NE = 12, NN = NE + 1, NDOF = 6*NN + REAL(wp), PARAMETER :: LTOT = 10.4_wp, EA = 1.0e6_wp, EI = 50.0_wp, W = 20.0_wp, RHOA = 2.0_wp + REAL(wp), PARAMETER :: BA = 1.0e4_wp, SAG = 1.3_wp, DL = -0.2_wp, TR = 10.0_wp, TEND = 60.0_wp, DT = 0.05_wp + TYPE(CD_HermiteCableDynType) :: m + REAL(wp) :: l0(NE), seed(NDOF), q_static(NDOF), q_edit(NDOF), curv(NN), res, t, dx(3), dist, err + INTEGER, ALLOCATABLE :: fixed(:) + INTEGER :: i, es, iters, k + CHARACTER(300) :: em + + l0 = LTOT/REAL(NE, wp) + ! end translations, then the out-of-plane DOFs (m_y everywhere, r_y in the interior) + fixed = [1, 2, 3, NDOF - 5, NDOF - 4, NDOF - 3, (6*(i - 1) + 5, i=1, NN), (6*(i - 1) + 2, i=2, NN - 1)] + ! parabolic sag below the chord from (0, 0, 0) to (8, 0, 6) + DO i = 1, NN + t = REAL(i - 1, wp)/REAL(NE, wp) + seed(6*(i - 1) + 1:6*(i - 1) + 3) = [8.0_wp*t, 0.0_wp, 6.0_wp*t - 4.0_wp*SAG*t*(1.0_wp - t)] + dx = [8.0_wp, 0.0_wp, 6.0_wp - 4.0_wp*SAG*(1.0_wp - 2.0_wp*t)] + seed(6*(i - 1) + 4:6*(i - 1) + 6) = dx/NORM2(dx) + END DO + CALL CD_HermiteCable_Static_Solve(l0, [(EA, k=1, NE)], [(EI, k=1, NE)], [(W, k=1, NE)], seed, fixed, & + -1.0e3_wp, 0.0_wp, 4, 200, 1.0e-10_wp, 1.0_wp, q_static, curv, res, iters, & + es, em) + CALL require(es == CD_HCSTAT_OK, 'E: initial static solve: '//TRIM(em)) + IF (es /= CD_HCSTAT_OK) RETURN + CALL require(q_static(6*(NE/2) + 3) < 3.0_wp - 0.5_wp, 'E: the initial equilibrium sags below the chord') + CALL CD_HermiteCable_Dyn_Init(m, l0, [(EA, k=1, NE)], [(EI, k=1, NE)], [(RHOA, k=1, NE)], [(W, k=1, NE)], & + q_static, fixed, -1.0e3_wp, 0.0_wp, 0.0_wp, es, em) + CALL require(es == CD_HCDYN_OK, 'E: init: '//TRIM(em)) + IF (es /= CD_HCDYN_OK) RETURN + CALL CD_HermiteCable_Dyn_Set_Axial_Damping(m, [(BA, k=1, NE)], es, em) + CALL CD_HermiteCable_Dyn_Set_Drag(m, 1025.0_wp, [(0.2_wp, k=1, NE)], [(2.0_wp, k=1, NE)], & + [(0.5_wp, k=1, NE)], 100.0_wp, [0.0_wp, 0.0_wp, 0.0_wp], es, em) + CALL require(es == CD_HCDYN_OK, 'E: drag: '//TRIM(em)) + CALL march_ramp(m, [NE - 2, NE - 1, NE], DL, 0.0_wp, TR, TEND, DT, .TRUE., es, em) + CALL require(es == CD_HCDYN_OK, 'E: march: '//TRIM(em)) + IF (es /= CD_HCDYN_OK) RETURN + l0(NE - 2:NE) = l0(NE - 2:NE)*((3.0_wp*l0(NE) + DL)/(3.0_wp*l0(NE))) + CALL CD_HermiteCable_Static_Solve(l0, [(EA, k=1, NE)], [(EI, k=1, NE)], [(W, k=1, NE)], q_static, fixed, & + -1.0e3_wp, 0.0_wp, 1, 200, 1.0e-10_wp, 1.0_wp, q_edit, curv, res, iters, & + es, em) + CALL require(es == CD_HCSTAT_OK, 'E: static solve at the edited lengths: '//TRIM(em)) + IF (es /= CD_HCSTAT_OK) RETURN + err = 0.0_wp + dist = 0.0_wp + DO i = 1, NN + err = MAX(err, NORM2(m%q(6*(i - 1) + 1:6*(i - 1) + 3) - q_edit(6*(i - 1) + 1:6*(i - 1) + 3))) + dist = MAX(dist, NORM2(q_static(6*(i - 1) + 1:6*(i - 1) + 3) - q_edit(6*(i - 1) + 1:6*(i - 1) + 3))) + END DO + WRITE (*, '(A,ES12.5,A,ES12.5,A)') ' E: end state vs static solve ', err, ' m (the haul-in moves nodes up to ', & + dist, ' m)' + CALL require(dist > 0.1_wp, 'E: the haul-in moves the line') + CALL require(err <= 1.0e-5_wp*dist, 'E: the settled end state is the static equilibrium of the edited lengths') + CALL CD_HermiteCable_Dyn_End(m) + END SUBROUTINE check_slow_ramp_static + + SUBROUTINE check_payout_alpha_f() + !! F: the cable of D paid out at Ldot = 0.01 m/s, marched with rho_inf = 0.4 + !! (alpha_f = 2/7) and with rho_inf = 0 (alpha_f = 0). The force-blended residual weighs + !! the committed force F_n by alpha_f; F_n is the force at the lengths of the step that + !! reached the committed state, so the blend tracks the quasi-static tension + !! EA (H/L' - 1) - BA H Ldot/L'**2 at either alpha_f. Evaluating F_n with the new lengths + !! instead lags the tension by a fixed fraction of the per-step change + !! dT = EA H Ldot dt/L'**2 (the pay-out ramp artifact this check guards against). + INTEGER, PARAMETER :: NE = 10 + REAL(wp), PARAMETER :: L = 10.0_wp, H = 10.1_wp, EA = 1.0e5_wp, RHOA = 1.0_wp, BA = 1.0e5_wp + REAL(wp), PARAMETER :: LDOT = 0.01_wp, TEND = 4.0_wp, DT = 0.01_wp + TYPE(CD_HermiteCableDynType) :: m + REAL(wp) :: s, z(NE + 1), mz(NE + 1), err(3), t_hist(NINT(TEND/DT), 3), d_step, diff + INTEGER :: i, es, pass + CHARACTER(300) :: em + + d_step = EA*H*LDOT*DT/(L + LDOT*TEND)**2 + DO pass = 1, 3 + DO i = 1, NE + 1 + s = REAL(i - 1, wp)*L/REAL(NE, wp) + z(i) = s*H/L + mz(i) = H/L + END DO + CALL vertical_model(m, L/REAL(NE, wp), EA, 0.0_wp, RHOA, BA, z, mz, .TRUE., es, em, & + rho_inf=MERGE(0.0_wp, 0.4_wp, pass == 2)) + CALL require(es == CD_HCDYN_OK, 'F: init: '//TRIM(em)) + IF (es /= CD_HCDYN_OK) RETURN + ! pass 3 drops the committed force reused from the preceding step before every step, so + ! each step evaluates it afresh at the committed lengths + CALL march_rate(m, [NE - 1, NE], LDOT, .TRUE., TEND, DT, H, EA, BA, err(pass), es, em, t_hist(:, pass), & + fresh_force=pass == 3) + CALL require(es == CD_HCDYN_OK, 'F: march: '//TRIM(em)) + CALL CD_HermiteCable_Dyn_End(m) + IF (es /= CD_HCDYN_OK) RETURN + END DO + diff = MAXVAL(ABS(t_hist(NINT(1.0_wp/DT):, 1) - t_hist(NINT(1.0_wp/DT):, 2))) + WRITE (*, '(A,ES10.3,A,ES12.5,A,ES12.5,A,ES12.5)') ' F: per-step tension change ', d_step, & + ' N; max error vs the closed form at alpha_f = 2/7 ', err(1), ' N, at alpha_f = 0 ', err(2), & + ' N; max difference ', diff + CALL require(err(1) <= 2.0e-2_wp*d_step, 'F: at alpha_f > 0 the tension follows the quasi-static closed form') + CALL require(err(2) <= 2.0e-2_wp*d_step, 'F: at alpha_f = 0 the tension follows the quasi-static closed form') + WRITE (*, '(A,ES12.5,A)') ' F: with the committed force evaluated afresh each step, max error ', err(3), ' N' + CALL require(err(3) <= 2.0e-2_wp*d_step, & + 'F: a committed force evaluated afresh (not reused) is taken at the committed lengths') + CALL require(diff <= 2.0e-2_wp*d_step, 'F: the tension at alpha_f > 0 equals the one at alpha_f = 0') + END SUBROUTINE check_payout_alpha_f + + ! ------------------------------------------------------------------------------------------ + SUBROUTINE vertical_model(model, l, ea, w, rhoa, ba, z, mz, fix_bottom, ErrStat, ErrMsg, rho_inf) + !! A vertical cable along z (node 1 at the bottom, the last node at the fixed top) held in + !! every transverse DOF, so only r_z and m_z move: an axial bar under weight w. rho_inf + !! (default 0) is the generalised-alpha spectral radius. + TYPE(CD_HermiteCableDynType), INTENT(OUT) :: model + REAL(wp), INTENT(IN) :: l, ea, w, rhoa, ba, z(:), mz(:) + LOGICAL, INTENT(IN) :: fix_bottom + INTEGER, INTENT(OUT) :: ErrStat + CHARACTER(*), INTENT(OUT) :: ErrMsg + REAL(wp), INTENT(IN), OPTIONAL :: rho_inf + REAL(wp), ALLOCATABLE :: q(:) + INTEGER, ALLOCATABLE :: fixed(:) + INTEGER :: nn, ne, i, k + REAL(wp) :: rho + nn = SIZE(z) + ne = nn - 1 + ALLOCATE (q(6*nn)) + q = 0.0_wp + fixed = [INTEGER ::] + DO i = 1, nn + q(6*(i - 1) + 3) = z(i) + q(6*(i - 1) + 6) = mz(i) + fixed = [fixed, 6*(i - 1) + 1, 6*(i - 1) + 2, 6*(i - 1) + 4, 6*(i - 1) + 5] + END DO + fixed = [fixed, 6*nn - 3] + IF (fix_bottom) fixed = [fixed, 3] + rho = 0.0_wp + IF (PRESENT(rho_inf)) rho = rho_inf + CALL CD_HermiteCable_Dyn_Init(model, [(l, k=1, ne)], [(ea, k=1, ne)], [(1.0_wp, k=1, ne)], & + [(rhoa, k=1, ne)], [(w, k=1, ne)], q, fixed, -1.0e3_wp, 0.0_wp, rho, & + ErrStat, ErrMsg) + IF (ErrStat /= CD_HCDYN_OK) RETURN + CALL CD_HermiteCable_Dyn_Set_Axial_Damping(model, [(ba, k=1, ne)], ErrStat, ErrMsg) + END SUBROUTINE vertical_model + + SUBROUTINE march_ramp(model, span, dl_final, dl_start, tr, tend, dt, with_rate, ErrStat, ErrMsg, tension) + !! March to tend, changing the span's total length from its base S by + !! dl(t) = dl_start + (dl_final - dl_start) (1 - cos(pi t/tr))/2 over [0, tr] and holding it + !! after; each element scales by (S + dl)/S, with rate dl_dot l_e/S, before each step + !! (and, optionally, return the top tension after every step). + TYPE(CD_HermiteCableDynType), INTENT(INOUT) :: model + INTEGER, INTENT(IN) :: span(:) + REAL(wp), INTENT(IN) :: dl_final, dl_start, tr, tend, dt + LOGICAL, INTENT(IN) :: with_rate + INTEGER, INTENT(OUT) :: ErrStat + CHARACTER(*), INTENT(OUT) :: ErrMsg + REAL(wp), INTENT(OUT), OPTIONAL :: tension(:) + REAL(wp) :: base(SIZE(span)), s_base, t, dl, dldot + INTEGER :: n, k + base = model%l0(span) + s_base = SUM(base) + n = NINT(tend/dt) + DO k = 1, n + t = REAL(k, wp)*dt + IF (t < tr) THEN + dl = dl_start + (dl_final - dl_start)*0.5_wp*(1.0_wp - COS(PI*t/tr)) + dldot = (dl_final - dl_start)*0.5_wp*(PI/tr)*SIN(PI*t/tr) + ELSE + dl = dl_final + dldot = 0.0_wp + END IF + IF (.NOT. with_rate) dldot = 0.0_wp + CALL CD_HermiteCable_Dyn_Set_SegmentLength(model, span, base*((s_base + dl)/s_base), dldot*base/s_base, & + ErrStat, ErrMsg) + IF (ErrStat /= CD_HCDYN_OK) RETURN + CALL CD_HermiteCable_Dyn_Step(model, dt, 50, 1.0e-10_wp, ErrStat, ErrMsg) + IF (ErrStat /= CD_HCDYN_OK) RETURN + IF (PRESENT(tension)) tension(k) = top_tension(model) + END DO + END SUBROUTINE march_ramp + + SUBROUTINE march_rate(model, span, ldot, with_rate, tend, dt, h, ea, ba, err_max, ErrStat, ErrMsg, tension, & + fresh_force) + !! March a constant pay-out of the span (rate passed when with_rate) and return the largest + !! deviation of the top tension from EA (H/L' - 1) - BA H Ldot/L'**2 after the first second + !! (and, optionally, the top tension after every step). fresh_force drops the committed + !! force cached by the preceding step before each step (re-selecting the force blend does). + TYPE(CD_HermiteCableDynType), INTENT(INOUT) :: model + INTEGER, INTENT(IN) :: span(:) + REAL(wp), INTENT(IN) :: ldot, tend, dt, h, ea, ba + LOGICAL, INTENT(IN) :: with_rate + REAL(wp), INTENT(OUT) :: err_max + INTEGER, INTENT(OUT) :: ErrStat + CHARACTER(*), INTENT(OUT) :: ErrMsg + REAL(wp), INTENT(OUT), OPTIONAL :: tension(:) + LOGICAL, INTENT(IN), OPTIONAL :: fresh_force + REAL(wp) :: base(SIZE(span)), s_base, l_total, t, lp, rate, expect + INTEGER :: n, k + LOGICAL :: fresh + fresh = .FALSE. + IF (PRESENT(fresh_force)) fresh = fresh_force + base = model%l0(span) + s_base = SUM(base) + l_total = SUM(model%l0) + err_max = 0.0_wp + rate = 0.0_wp + IF (with_rate) rate = ldot + n = NINT(tend/dt) + DO k = 1, n + t = REAL(k, wp)*dt + CALL CD_HermiteCable_Dyn_Set_SegmentLength(model, span, base*((s_base + ldot*t)/s_base), rate*base/s_base, & + ErrStat, ErrMsg) + IF (ErrStat /= CD_HCDYN_OK) RETURN + IF (fresh) THEN + CALL CD_HermiteCable_Dyn_Set_ForceBlend(model, .TRUE., ErrStat, ErrMsg) + IF (ErrStat /= CD_HCDYN_OK) RETURN + END IF + CALL CD_HermiteCable_Dyn_Step(model, dt, 50, 1.0e-6_wp, ErrStat, ErrMsg) + IF (ErrStat /= CD_HCDYN_OK) RETURN + IF (PRESENT(tension)) tension(k) = top_tension(model) + IF (t < 1.0_wp) CYCLE + lp = l_total + ldot*t + expect = ea*(h/lp - 1.0_wp) - ba*h*ldot/(lp*lp) + err_max = MAX(err_max, ABS(top_tension(model) - expect)) + END DO + END SUBROUTINE march_rate + + REAL(wp) FUNCTION top_tension(model) RESULT(t) + !! Axial pull of the line on its fixed top node (the last node). + TYPE(CD_HermiteCableDynType), INTENT(INOUT) :: model + REAL(wp) :: f(3) + INTEGER :: es + CHARACTER(200) :: em + CALL CD_HermiteCable_Dyn_Reaction(model, model%nn, f, es, em) + t = -f(3) + IF (es /= CD_HCDYN_OK) t = HUGE(1.0_wp) + END FUNCTION top_tension + + LOGICAL FUNCTION same_bits(x, y) RESULT(same) + REAL(wp), INTENT(IN) :: x(:), y(:) + same = SIZE(x) == SIZE(y) + IF (same) same = ALL(TRANSFER(x, 0_INT64, SIZE(x)) == TRANSFER(y, 0_INT64, SIZE(y))) + END FUNCTION same_bits + + LOGICAL FUNCTION same_bits2(x, y) RESULT(same) + REAL(wp), INTENT(IN) :: x(:, :), y(:, :) + same = SIZE(x, 1) == SIZE(y, 1) .AND. SIZE(x, 2) == SIZE(y, 2) + IF (same) same = same_bits(RESHAPE(x, [SIZE(x)]), RESHAPE(y, [SIZE(y)])) + END FUNCTION same_bits2 + + SUBROUTINE require(condition, message) + LOGICAL, INTENT(IN) :: condition + CHARACTER(*), INTENT(IN) :: message + IF (.NOT. condition) THEN + nfail = nfail + 1 + WRITE (*, '(A)') 'MISMATCH: '//TRIM(message) + END IF + END SUBROUTINE require + +END PROGRAM test_hermite_cable_control diff --git a/tests/test_model.f90 b/tests/test_model.f90 index b8063fcd..b7fd128d 100644 --- a/tests/test_model.f90 +++ b/tests/test_model.f90 @@ -43,6 +43,9 @@ PROGRAM test_model CALL case_lifecycle_static_step() CALL case_segment_length_update() + CALL case_segment_payout_ramp() + CALL case_segment_payout_substeps() + CALL case_segment_force_blend_committed_side() CALL case_copy_model_preserves_state() CALL case_prescribed_step_updates_state() CALL case_recovery_common_path() @@ -163,10 +166,14 @@ END SUBROUTINE case_lifecycle_static_step SUBROUTINE case_segment_length_update() !! Active line control (the CtrlChan mechanism): CD_Update_Model_SegmentLength - !! must leave the model INDISTINGUISHABLE from one BUILT with the new length -- - !! the stale-cache killer (any l0-derived quantity cached at init and not - !! refreshed breaks the bitwise step equivalence). Also: paying out a taut - !! segment drops its tension (sign), and the validation battery fails closed. + !! keeps the committed acceleration and the lengths the committed state was reached + !! with (a re-derived acceleration keeps them too); once the new length is committed + !! (restored = .TRUE., the checkpoint-restart re-application) and the acceleration + !! re-derived (CD_Recompute_Model_Acceleration) the model must be INDISTINGUISHABLE from one + !! BUILT with the new length -- the stale-cache killer (any l0-derived quantity + !! cached at init and not refreshed breaks the bitwise step equivalence). Also: + !! paying out a taut segment drops its tension (sign), and the validation battery + !! fails closed. INTEGER, PARAMETER :: NE = 4, NN = NE + 1, NDOF = 3*NN TYPE(CD_ModelType) :: ma, mb TYPE(GenAlphaConfig) :: cfg @@ -194,16 +201,25 @@ SUBROUTINE case_segment_length_update() ! sign: paying out the taut end segment drops its tension, others unchanged CALL CD_Get_Model_Tension(ma, ten0, es, em) CALL require(es == CD_MODEL_OK, 'seglen:tension-0') + aa = ma%a CALL CD_Update_Model_SegmentLength(ma, NE, l0b(NE), 0.0_wp, es, em) CALL require(es == CD_MODEL_OK, 'seglen:update: '//TRIM(em)) + CALL require(nan_max_abs(ma%a - aa) <= 0.0_wp .AND. nan_max_abs(ma%l0_c - l0) <= 0.0_wp, & + 'seglen:update-keeps-the-committed-acceleration-and-lengths') CALL CD_Get_Model_Tension(ma, ten1, es, em) CALL require(es == CD_MODEL_OK, 'seglen:tension-1') CALL require(ten1(NE) < ten0(NE), 'seglen:payout-drops-end-tension') CALL require(nan_max_abs(ten1(1:NE - 1) - ten0(1:NE - 1)) <= 0.0_wp, 'seglen:other-segments-untouched') - ! equivalence: the updated model matches the fresh-built twin bitwise -- - ! tensions, coupled loads (the re-assembled mass cache), and a full dynamic - ! step under the same trajectory + ! equivalence: committed at the new length, the updated model matches the fresh-built + ! twin bitwise -- tensions, coupled loads (the re-assembled mass cache), and a full + ! dynamic step under the same trajectory + CALL CD_Recompute_Model_Acceleration(ma, es, em) + CALL require(es == CD_MODEL_OK .AND. nan_max_abs(ma%l0_c - l0) <= 0.0_wp .AND. nan_max_abs(ma%a - aa) <= 0.0_wp, & + 'seglen:recompute-keeps-the-committed-lengths') + CALL CD_Update_Model_SegmentLength(ma, NE, l0b(NE), 0.0_wp, es, em, restored=.TRUE.) + CALL CD_Recompute_Model_Acceleration(ma, es, em) + CALL require(es == CD_MODEL_OK .AND. nan_max_abs(ma%l0_c - l0b) <= 0.0_wp, 'seglen:commit-at-new-length') CALL CD_Get_Model_Tension(mb, tenb, es, em) CALL require(nan_max_abs(ten1 - tenb) <= 0.0_wp, 'seglen:tension-equals-fresh-build') CALL CD_Calc_Model_CoupledLoads(ma, loads_a, es, em) @@ -243,8 +259,10 @@ SUBROUTINE case_segment_length_update() CALL CD_Init_Model(mw1, q0, v0, conn, l0b, ea, rho_a, .FALSE., fw1, fixed, cfg, es, em, & dist_load_per_length=wpl) CALL require(es == CD_MODEL_OK, 'seglen:init-weighted-fresh') - CALL CD_Update_Model_SegmentLength(mw0, NE, l0b(NE), 0.0_wp, es, em) + CALL CD_Update_Model_SegmentLength(mw0, NE, l0b(NE), 0.0_wp, es, em, restored=.TRUE.) CALL require(es == CD_MODEL_OK, 'seglen:weighted-update: '//TRIM(em)) + CALL CD_Recompute_Model_Acceleration(mw0, es, em) + CALL require(es == CD_MODEL_OK, 'seglen:weighted-commit: '//TRIM(em)) CALL require(nan_max_abs(mw0%f_ext - mw1%f_ext) <= 0.0_wp, 'seglen:weighted-fext-bitwise') CALL require(nan_max_abs(mw0%l0 - mw1%l0) <= 0.0_wp, 'seglen:weighted-l0-bitwise') CALL require(nan_max_abs(mw0%a - mw1%a) <= 0.0_wp, 'seglen:weighted-accel-bitwise') @@ -282,8 +300,10 @@ SUBROUTINE case_segment_length_update() fx0(3*2 - 1) = fx0(3*2 - 1) + 3.0_wp CALL CD_Update_Model_External_Loads(mx0, fx0, es, em) CALL require(es == CD_MODEL_OK, 'seglen:extload-update: '//TRIM(em)) - CALL CD_Update_Model_SegmentLength(mx0, NE, l0b(NE), 0.0_wp, es, em) + CALL CD_Update_Model_SegmentLength(mx0, NE, l0b(NE), 0.0_wp, es, em, restored=.TRUE.) CALL require(es == CD_MODEL_OK, 'seglen:extload-control: '//TRIM(em)) + CALL CD_Recompute_Model_Acceleration(mx0, es, em) + CALL require(es == CD_MODEL_OK, 'seglen:extload-commit: '//TRIM(em)) ! fresh twin: assembled at the NEW length plus the same bump CALL CD_Assemble_Distributed_Load(conn, l0b, wplx, fx1, es, em) CALL require(es == 0, 'seglen:extload-assemble-fresh') @@ -382,6 +402,300 @@ SUBROUTINE case_segment_length_update() CALL require(es /= CD_MODEL_OK, 'seglen:uninitialized-fails') END SUBROUTINE case_segment_length_update + SUBROUTINE case_segment_payout_ramp() + !! A weightless EI = 0 line between fixed ends H = 10.1 m apart (initial strain 1 %), + !! its end element paid out at Ldot = 0.01 m/s from t = 0, marched with rho_inf = 0.4 + !! and rho_inf = 0. The strain stays uniform, eps = H/L' - 1, so the reported tension + !! (elastic plus Kelvin-Voigt) is EA (H/L' - 1) - BA H Ldot/L'**2. The committed state + !! keeps the lengths it was reached with: re-deriving the committed acceleration under + !! the new length, or evaluating the step-start force of the force blend (the default; + !! under False alpha_force_blend the blended configuration) with the new length, lags the + !! tension by a fixed fraction of its change per step, dT = EA H Ldot dt/L'**2 (the + !! pay-out ramp artifact this check guards against). + INTEGER, PARAMETER :: NE = 10, NN = NE + 1, NDOF = 3*NN + REAL(wp), PARAMETER :: L = 10.0_wp, H = 10.1_wp, EAV = 1.0e5_wp, RHOA = 1.0_wp, BAV = 1.0e5_wp + REAL(wp), PARAMETER :: LDOT = 0.01_wp, TEND = 4.0_wp, DT = 0.01_wp + TYPE(CD_ModelType) :: m + TYPE(GenAlphaConfig) :: cfg + INTEGER :: conn(2, NE), fixed(6), es, n_iter, i, k, pass + REAL(wp) :: l0(NE), ea(NE), rho_a(NE), ba(NE), q0(NDOF), v0(NDOF), f_ext(NDOF), ten(NE) + REAL(wp) :: t, lp, expect, err(3), d_step, hist(NINT(TEND/DT), 3), diff, diff_cfg + LOGICAL :: conv, stalled + CHARACTER(200) :: em + + DO i = 1, NE + conn(:, i) = [i, i + 1] + END DO + l0 = L/REAL(NE, wp) + ea = EAV + rho_a = RHOA + ba = BAV + DO i = 1, NN + q0(3*i - 2:3*i) = [REAL(i - 1, wp)*H/REAL(NE, wp), 0.0_wp, 0.0_wp] + END DO + fixed = [1, 2, 3, NDOF - 2, NDOF - 1, NDOF] + v0 = 0.0_wp + f_ext = 0.0_wp + d_step = EAV*H*LDOT*DT/(L + LDOT*TEND)**2 + err = 0.0_wp + ! pass 1: rho_inf 0.4, 2: rho_inf 0, 3: rho_inf 0.4 with the configuration blend + DO pass = 1, 3 + cfg%rho_inf = MERGE(0.0_wp, 0.4_wp, pass == 2) + cfg%force_blend = pass /= 3 + cfg%rel_tol = 1.0e-10_wp + CALL CD_Init_Model(m, q0, v0, conn, l0, ea, rho_a, .FALSE., f_ext, fixed, cfg, es, em, ba=ba) + CALL require(es == CD_MODEL_OK, 'payout:init: '//TRIM(em)) + IF (es /= CD_MODEL_OK) RETURN + DO k = 1, NINT(TEND/DT) + t = REAL(k, wp)*DT + CALL CD_Update_Model_SegmentLength(m, NE, l0(NE) + LDOT*t, LDOT, es, em) + CALL require(es == CD_MODEL_OK, 'payout:update: '//TRIM(em)) + CALL CD_Step_Model(m, DT, conv, stalled, n_iter, es, em) + CALL require(es == CD_MODEL_OK .AND. conv, 'payout:step: '//TRIM(em)) + IF (es /= CD_MODEL_OK) EXIT + CALL CD_Get_Model_Tension(m, ten, es, em) + hist(k, pass) = ten(1) + IF (t < 1.0_wp) CYCLE + lp = L + LDOT*t + expect = EAV*(H/lp - 1.0_wp) - BAV*H*LDOT/(lp*lp) + err(pass) = MAX(err(pass), ABS(ten(1) - expect), ABS(ten(NE) - expect)) + END DO + CALL CD_End_Model(m, es, em) + END DO + diff = MAXVAL(ABS(hist(NINT(1.0_wp/DT):, 1) - hist(NINT(1.0_wp/DT):, 2))) + diff_cfg = MAXVAL(ABS(hist(NINT(1.0_wp/DT):, 3) - hist(NINT(1.0_wp/DT):, 2))) + WRITE (*, '(A,ES10.3,A,ES12.5,A,ES12.5,A,ES12.5)') ' payout ramp: per-step tension change ', d_step, & + ' N; max error vs the closed form at rho_inf = 0.4 ', err(1), ' N, at 0 ', err(2), ' N; difference ', diff + WRITE (*, '(A,ES12.5,A,ES12.5)') ' payout ramp, False alpha_force_blend at rho_inf = 0.4: max error ', err(3), & + ' N; difference to rho_inf = 0 ', diff_cfg + ! the error is the start-up transient (1.8e-3 d_step at either rho_inf); a step-start force at + ! blended or new lengths under the force blend leaves 7e-3 and 2.6 d_step, and a difference + ! between the two rho_inf of 9e-4 d_step and more + CALL require(err(1) <= 5.0e-3_wp*d_step, 'payout:rho_inf-0.4-follows-the-closed-form') + CALL require(err(2) <= 5.0e-3_wp*d_step, 'payout:rho_inf-0-follows-the-closed-form') + CALL require(diff <= 1.0e-4_wp*d_step, 'payout:rho_inf-0.4-equals-rho_inf-0') + CALL require(err(3) <= 5.0e-3_wp*d_step .AND. diff_cfg <= 1.0e-4_wp*d_step, 'payout:configuration-blend') + END SUBROUTINE case_segment_payout_ramp + + SUBROUTINE case_segment_payout_substeps() + !! A pay-out on a turning EI = 0 line, solved in sub-steps. A 10-segment line, End A fixed + !! at the origin and End B on a circle of radius H = 10.1 m at OMEGA = 2 rad/s (starting in + !! rigid rotation), turns its segments by 2.3 deg per 0.02 s step, so with ei0_substeps auto + !! (the default angle of 1 deg, at most 4 sub-steps) every step is solved again in four + !! sub-steps; its end element is paid out at LDOT = 0.05 m/s with a Kelvin-Voigt dashpot. + !! The sub-steps take the committed lengths at their start and the lengths interpolated in + !! time at their end, so the march equals a march with ei0_substeps off at dt/4 that sets + !! the length at every fine step, to the quintic of the end motion inside a step (3e-8 N + !! against the per-step tension change d_step = 9.9 N). Taking the whole length change in + !! the first sub-step departs from it by 22 N (2.2 d_step) and 5e-3 m. + INTEGER, PARAMETER :: NE = 10, NN = NE + 1, NDOF = 3*NN, NSUB = 4 + REAL(wp), PARAMETER :: L = 10.0_wp, H = 10.1_wp, EAV = 1.0e5_wp, RHOA = 1.0_wp, BAV = 1.0e3_wp + REAL(wp), PARAMETER :: LDOT = 0.05_wp, OMEGA = 2.0_wp, TEND = 2.0_wp, DT = 0.02_wp + TYPE(CD_ModelType) :: sub_m, fine_m + TYPE(GenAlphaConfig) :: cfg + INTEGER :: conn(2, NE), fixed(6), es, n_iter, i, k, j + REAL(wp) :: l0(NE), ea(NE), rho_a(NE), ba(NE), q0(NDOF), v0(NDOF), f_ext(NDOF) + REAL(wp) :: pq(NDOF), pv(NDOF), pa(NDOF), ten_s(NE), ten_f(NE), t, d_step, err_t, err_q + LOGICAL :: conv, stalled, all_conv + CHARACTER(200) :: em + + DO i = 1, NE + conn(:, i) = [i, i + 1] + END DO + l0 = L/REAL(NE, wp) + ea = EAV + rho_a = RHOA + ba = BAV + DO i = 1, NN + q0(3*i - 2:3*i) = [REAL(i - 1, wp)*H/REAL(NE, wp), 0.0_wp, 0.0_wp] + v0(3*i - 2:3*i) = [0.0_wp, OMEGA*q0(3*i - 2), 0.0_wp] + END DO + fixed = [1, 2, 3, NDOF - 2, NDOF - 1, NDOF] + f_ext = 0.0_wp + cfg%rel_tol = 1.0e-10_wp + cfg%ei0_substep_max = NSUB + CALL CD_Init_Model(sub_m, q0, v0, conn, l0, ea, rho_a, .FALSE., f_ext, fixed, cfg, es, em, ba=ba) + CALL require(es == CD_MODEL_OK, 'payout-substeps:init: '//TRIM(em)) + IF (es /= CD_MODEL_OK) RETURN + ! the pay-out rate is the committed one from the start (a constant command) + CALL CD_Update_Model_SegmentLength(sub_m, NE, l0(NE), LDOT, es, em, restored=.TRUE.) + CALL require(es == CD_MODEL_OK, 'payout-substeps:rate: '//TRIM(em)) + ! End B starts with its centripetal acceleration, so the quintic of the end motion inside a + ! step (the sub-step boundaries) follows the circle to (OMEGA DT)**6 + CALL payout_end_on_circle(H, OMEGA, 0.0_wp, pq, pv, pa) + sub_m%a(NDOF - 2:NDOF) = pa(NDOF - 2:NDOF) + CALL CD_Copy_Model(sub_m, fine_m, es, em) + CALL require(es == CD_MODEL_OK, 'payout-substeps:copy: '//TRIM(em)) + fine_m%cfg%ei0_substeps = CD_EI0_SUBSTEPS_OFF + d_step = EAV*H*LDOT*DT/(L + LDOT*TEND)**2 + all_conv = .TRUE. + err_t = 0.0_wp + err_q = 0.0_wp + DO k = 1, NINT(TEND/DT) + t = REAL(k, wp)*DT + CALL CD_Update_Model_SegmentLength(sub_m, NE, l0(NE) + LDOT*t, LDOT, es, em) + all_conv = all_conv .AND. es == CD_MODEL_OK + CALL payout_end_on_circle(H, OMEGA, t, pq, pv, pa) + CALL CD_Step_Model(sub_m, DT, conv, stalled, n_iter, es, em, prescribed_q=pq, prescribed_v=pv, prescribed_a=pa) + all_conv = all_conv .AND. es == CD_MODEL_OK .AND. conv + DO j = 1, NSUB + t = (REAL(k - 1, wp) + REAL(j, wp)/REAL(NSUB, wp))*DT + CALL CD_Update_Model_SegmentLength(fine_m, NE, l0(NE) + LDOT*t, LDOT, es, em) + all_conv = all_conv .AND. es == CD_MODEL_OK + CALL payout_end_on_circle(H, OMEGA, t, pq, pv, pa) + CALL CD_Step_Model(fine_m, DT/REAL(NSUB, wp), conv, stalled, n_iter, es, em, prescribed_q=pq, & + prescribed_v=pv, prescribed_a=pa) + all_conv = all_conv .AND. es == CD_MODEL_OK .AND. conv + END DO + IF (.NOT. all_conv) EXIT + CALL CD_Get_Model_Tension(sub_m, ten_s, es, em) + CALL CD_Get_Model_Tension(fine_m, ten_f, es, em) + err_t = MAX(err_t, MAXVAL(ABS(ten_s - ten_f))) + err_q = MAX(err_q, MAXVAL(ABS(sub_m%q - fine_m%q))) + END DO + CALL require(all_conv, 'payout-substeps:march: '//TRIM(em)) + WRITE (*, '(A,I0,A,I0,A,I0,A,ES10.3,A,ES10.3,A,ES10.3,A)') ' payout sub-steps: ', sub_m%sub_stats%events, & + ' of ', sub_m%sub_stats%calls, ' steps in ', sub_m%sub_stats%max_used, ' sub-steps; tension against dt/4 ', & + err_t, ' N (d_step ', d_step, ' N), position ', err_q, ' m' + CALL require(sub_m%sub_stats%events == NINT(TEND/DT) .AND. sub_m%sub_stats%max_used == NSUB .AND. & + sub_m%sub_stats%fallbacks == 0, 'payout-substeps:every-step-sub-stepped') + CALL require(ALL(sub_m%l0 == fine_m%l0) .AND. ALL(sub_m%l0_c == sub_m%l0), 'payout-substeps:lengths') + CALL require(err_t <= 1.0e-4_wp*d_step .AND. err_q <= 1.0e-9_wp, 'payout-substeps:equals-the-dt/4-march') + CALL CD_End_Model(sub_m, es, em) + CALL CD_End_Model(fine_m, es, em) + END SUBROUTINE case_segment_payout_substeps + + SUBROUTINE payout_end_on_circle(h, omega, tt, pq, pv, pa) + !! End B (the last node) on a circle of radius h about the origin at angular speed omega, + !! at time tt, as full prescribed vectors (End A at the origin). + REAL(wp), INTENT(IN) :: h, omega, tt + REAL(wp), INTENT(OUT) :: pq(:), pv(:), pa(:) + INTEGER :: n + n = SIZE(pq) + pq = 0.0_wp + pv = 0.0_wp + pa = 0.0_wp + pq(n - 2:n) = h*[COS(omega*tt), SIN(omega*tt), 0.0_wp] + pv(n - 2:n) = h*omega*[-SIN(omega*tt), COS(omega*tt), 0.0_wp] + pa(n - 2:n) = -h*omega**2*[COS(omega*tt), SIN(omega*tt), 0.0_wp] + END SUBROUTINE payout_end_on_circle + + SUBROUTINE case_segment_force_blend_committed_side() + !! Under the force blend (the default) the committed side of the first step after a length + !! and rate command is the committed state's own: a weighted, damped, grounded tension-only + !! line paid out at its end element gives, bit for bit, the acceleration recompute, the + !! step-start load (damping at the committed rate, seabed contact with the committed + !! tributary lengths), the step-start internal force and the release-cap data of its + !! uncommanded twin, while the force at t_{n+1}, the present external load and seabed + !! coefficients are the new lengths' and the inertia takes the blended lengths. + INTEGER, PARAMETER :: NE = 4, NN = NE + 1, NDOF = 3*NN + REAL(wp), PARAMETER :: KBOT = 1.0e5_wp, CN_RATIO = 0.05_wp, DL = 0.02_wp, LDOT = 0.3_wp + TYPE(CD_ModelType) :: a, b + TYPE(GenAlphaConfig) :: cfg + INTEGER :: conn(2, NE), fixed(6), es, n_iter, i + REAL(wp) :: l0(NE), l1(NE), ea(NE), rho_a(NE), ba(NE), diam(NE), q0(NDOF), v0(NDOF), wpl(3, NE) + REAL(wp) :: fw(NDOF), fw1(NDOF), lm(NE), af + REAL(wp), ALLOCATABLE :: kn(:), kn1(:) + LOGICAL :: conv, stalled + CHARACTER(200) :: em + + CALL straight_cable(NE, conn, l0, ea, rho_a, q0, fixed) + v0 = 0.0_wp + DO i = 4, NDOF - 3 + v0(i) = 0.05_wp*SIN(1.3_wp*REAL(i, wp)) + END DO + wpl = 0.0_wp + wpl(3, :) = -7.5_wp + ba = 50.0_wp + diam = 0.1_wp + l1 = l0 + l1(NE) = l0(NE) + DL + CALL CD_Assemble_Distributed_Load(conn, l0, wpl, fw, es, em) + CALL CD_Assemble_Distributed_Load(conn, l1, wpl, fw1, es, em) + CALL CD_Nodal_Seabed_Stiffness(KBOT, diam, l0, kn, es, em) + CALL CD_Nodal_Seabed_Stiffness(KBOT, diam, l1, kn1, es, em) + CALL require(es == 0, 'committed-side:seabed-helper') + af = cfg%rho_inf/(cfg%rho_inf + 1.0_wp) + lm = l0 + lm(NE) = (1.0_wp - af)*l1(NE) + af*l0(NE) + CALL CD_Init_Model(a, q0, v0, conn, l0, ea, rho_a, .TRUE., fw, fixed, cfg, es, em, ba=ba, & + dist_load_per_length=wpl, seabed_z_floor=1.0e-3_wp, seabed_kn=kn, seabed_cn=CN_RATIO*kn, & + seabed_kbot=KBOT, seabed_contact_diameter=diam, seabed_cn_over_kn=CN_RATIO) + CALL require(es == CD_MODEL_OK, 'committed-side:init-a: '//TRIM(em)) + CALL CD_Init_Model(b, q0, v0, conn, l0, ea, rho_a, .TRUE., fw, fixed, cfg, es, em, ba=ba, & + dist_load_per_length=wpl, seabed_z_floor=1.0e-3_wp, seabed_kn=kn, seabed_cn=CN_RATIO*kn, & + seabed_kbot=KBOT, seabed_contact_diameter=diam, seabed_cn_over_kn=CN_RATIO) + CALL require(es == CD_MODEL_OK, 'committed-side:init-b: '//TRIM(em)) + IF (es /= CD_MODEL_OK) RETURN + CALL CD_Update_Model_SegmentLength(a, NE, l1(NE), LDOT, es, em) + CALL require(es == CD_MODEL_OK, 'committed-side:update: '//TRIM(em)) + CALL require(nan_max_abs(a%f_ext - fw1) <= 0.0_wp .AND. nan_max_abs(a%seabed_kn - kn1) <= 0.0_wp, & + 'committed-side:present-load-is-the-new-lengths') + ! the committed acceleration, re-derived, is the twin's + CALL CD_Recompute_Model_Acceleration(a, es, em) + CALL require(es == CD_MODEL_OK, 'committed-side:recompute-a: '//TRIM(em)) + CALL CD_Recompute_Model_Acceleration(b, es, em) + CALL require(es == CD_MODEL_OK, 'committed-side:recompute-b: '//TRIM(em)) + CALL require(nan_max_abs(a%a - b%a) <= 0.0_wp, 'committed-side:recompute-equals-twin') + CALL require(nan_max_abs(a%f_ext - fw1) <= 0.0_wp .AND. nan_max_abs(a%seabed_kn - kn1) <= 0.0_wp .AND. & + nan_max_abs(a%seabed_cn - CN_RATIO*kn1) <= 0.0_wp .AND. nan_max_abs(a%l0 - l1) <= 0.0_wp .AND. & + a%l0_dot(NE) == LDOT .AND. nan_max_abs(a%l0_c - l0) <= 0.0_wp, 'committed-side:recompute-restores') + ! the step: the committed side bit for bit the twin's + CALL CD_Step_Model(a, 0.02_wp, conv, stalled, n_iter, es, em) + CALL require(es == CD_MODEL_OK .AND. conv, 'committed-side:step-a: '//TRIM(em)) + CALL CD_Step_Model(b, 0.02_wp, conv, stalled, n_iter, es, em) + CALL require(es == CD_MODEL_OK .AND. conv, 'committed-side:step-b: '//TRIM(em)) + IF (.NOT. (ALLOCATED(a%load_start_work) .AND. ALLOCATED(b%load_start_work))) THEN + CALL require(.FALSE., 'committed-side:start-load-allocated') + RETURN + END IF + CALL require(nan_max_abs(a%load_start_work - b%load_start_work) <= 0.0_wp, 'committed-side:start-load-equals-twin') + CALL require(nan_max_abs(a%dynamic_workspace%fint_n - b%dynamic_workspace%fint_n) <= 0.0_wp .AND. & + nan_max_abs(a%dynamic_workspace%tension_n - b%dynamic_workspace%tension_n) <= 0.0_wp .AND. & + nan_max_abs(a%dynamic_workspace%stretch_n - b%dynamic_workspace%stretch_n) <= 0.0_wp .AND. & + nan_max_abs(a%dynamic_workspace%damp_n - b%dynamic_workspace%damp_n) <= 0.0_wp, & + 'committed-side:start-force-and-cap-data-equal-twin') + CALL require(MAXVAL(ABS(b%dynamic_workspace%damp_n)) > 0.0_wp, 'committed-side:start-dashpot-nonzero') + CALL require(MAXVAL(ABS(b%load_start_work)) > 0.0_wp .AND. MAXVAL(b%dynamic_workspace%tension_n) > 0.0_wp, & + 'committed-side:start-data-nonzero') + CALL require(nan_max_abs(a%dynamic_workspace%mb_l0 - lm) <= 0.0_wp, 'committed-side:inertia-at-blended-lengths') + CALL require(nan_max_abs(a%q - b%q) > 0.0_wp, 'committed-side:command-moves-the-line') + CALL require(nan_max_abs(a%f_ext - fw1) <= 0.0_wp .AND. nan_max_abs(a%l0 - l1) <= 0.0_wp .AND. & + nan_max_abs(a%l0_c - l1) <= 0.0_wp .AND. a%l0_dot_c(NE) == LDOT, 'committed-side:step-commits') + CALL CD_End_Model(a, es, em) + CALL CD_End_Model(b, es, em) + + ! An external-load update between the command and the step: the committed acceleration it + ! re-derives carries the new load (the distributed-load remainder is refreshed before the + ! committed external load is rebuilt from it), as the uncommanded twin given the same load. + BLOCK + REAL(wp) :: bump(NDOF), scale_a + bump = 0.0_wp + bump(3*2 - 1) = 3.0_wp + bump(3*3) = -4.0_wp + CALL CD_Init_Model(a, q0, v0, conn, l0, ea, rho_a, .TRUE., fw, fixed, cfg, es, em, ba=ba, & + dist_load_per_length=wpl, seabed_z_floor=1.0e-3_wp, seabed_kn=kn, seabed_cn=CN_RATIO*kn, & + seabed_kbot=KBOT, seabed_contact_diameter=diam, seabed_cn_over_kn=CN_RATIO) + CALL CD_Init_Model(b, q0, v0, conn, l0, ea, rho_a, .TRUE., fw, fixed, cfg, es, em, ba=ba, & + dist_load_per_length=wpl, seabed_z_floor=1.0e-3_wp, seabed_kn=kn, seabed_cn=CN_RATIO*kn, & + seabed_kbot=KBOT, seabed_contact_diameter=diam, seabed_cn_over_kn=CN_RATIO) + CALL require(es == CD_MODEL_OK, 'committed-side:extload-init: '//TRIM(em)) + CALL CD_Update_Model_SegmentLength(a, NE, l1(NE), LDOT, es, em) + CALL require(es == CD_MODEL_OK, 'committed-side:extload-command: '//TRIM(em)) + CALL CD_Update_Model_External_Loads(a, fw1 + bump, es, em) + CALL require(es == CD_MODEL_OK, 'committed-side:extload-update-a: '//TRIM(em)) + CALL CD_Update_Model_External_Loads(b, fw + bump, es, em) + CALL require(es == CD_MODEL_OK, 'committed-side:extload-update-b: '//TRIM(em)) + scale_a = MAXVAL(ABS(b%a)) + CALL require(scale_a > 0.0_wp .AND. nan_max_abs(a%a - b%a) <= 1.0e-12_wp*scale_a, & + 'committed-side:extload-recompute-equals-twin') + CALL require(nan_max_abs(a%f_ext - (fw1 + bump)) <= 0.0_wp .AND. nan_max_abs(a%l0_c - l0) <= 0.0_wp, & + 'committed-side:extload-keeps-present-load-and-committed-lengths') + CALL CD_End_Model(a, es, em) + CALL CD_End_Model(b, es, em) + END BLOCK + END SUBROUTINE case_segment_force_blend_committed_side + SUBROUTINE case_copy_model_preserves_state() !! Checked model copies preserve persistent state and leave transient solver !! workspaces independent of the source object. diff --git a/tests/test_openfast_aggregate.f90 b/tests/test_openfast_aggregate.f90 index c3a2a6da..67e5db9a 100644 --- a/tests/test_openfast_aggregate.f90 +++ b/tests/test_openfast_aggregate.f90 @@ -20,6 +20,8 @@ PROGRAM test_openfast_aggregate !! 7) ptfm_init_equivalence -- the ptfm_init option == a pre-displaced deck, bit-for-bit, !! against an independent transcription of the NWTC ZYX transform; zero == absent; !! non-finite fails closed. + !! 8) line control -- CONTROL on EI=0 lines and finite-EI cables (alone and mixed), its + !! fail-closed bounds, rewind and bit-identical checkpoint restart (--line-control-only). USE CableDyn_Precision, ONLY: wp USE CableDyn_DeckDriver, ONLY: CD_Deck_Query_dtM, CD_DECKDRV_OK USE CableDyn_OpenFAST_Aggregate, ONLY: CD_AGG_ModuleType, CD_AGG_Init_From_Deck, CD_AGG_NMovingPoints, & @@ -60,7 +62,8 @@ PROGRAM test_openfast_aggregate CD_SystemType, CD_End_System, CD_System_Line_Has_Friction, & CD_Get_System_Line_Friction_Anchors, CD_Set_System_Line_Friction_Anchors USE CableDyn_DeckDriver, ONLY: CD_Init_Deck_System - USE CableDyn_OpenFAST_HermiteFMF, ONLY: CD_HFMF_FrictionMirrorSize + USE CableDyn_OpenFAST_HermiteFMF, ONLY: CD_HFMF_FrictionMirrorSize, CD_HFMF_ModuleType, CD_HFMF_End + USE, INTRINSIC :: ISO_FORTRAN_ENV, ONLY: INT64 USE, INTRINSIC :: IEEE_ARITHMETIC, ONLY: IEEE_IS_FINITE, IEEE_VALUE, IEEE_QUIET_NAN USE, INTRINSIC :: IEEE_EXCEPTIONS, ONLY: IEEE_USUAL, IEEE_GET_HALTING_MODE, IEEE_SET_HALTING_MODE, IEEE_SET_FLAG IMPLICIT NONE @@ -111,6 +114,17 @@ PROGRAM test_openfast_aggregate WRITE (*, '(A)') 'PASS: displaced semitaut mooring initialisation' STOP END IF + IF (TRIM(test_filter) == '--line-control-only') THEN + CALL case_aggregate_line_control() + CALL case_aggregate_cable_control() + CALL case_restart_cable_control() + IF (nfail > 0) THEN + WRITE (*, '(A,I0,A)') 'FAIL: ', nfail, ' line-control assertion(s) failed' + ERROR STOP 1 + END IF + WRITE (*, '(A)') 'PASS: coupled active line control' + STOP + END IF END IF CALL case_pure_mooring_equals_fmf() CALL case_mixed_deck_composition() @@ -151,6 +165,9 @@ PROGRAM test_openfast_aggregate CALL case_farm_shared_anchor() CALL case_aggregate_failures() CALL case_aggregate_line_control() + CALL case_aggregate_cable_control() + CALL case_restart_cable_control() + CALL case_restart_line_control() CALL case_restart_equivalence() CALL case_restart_friction() IF (nfail > 0) THEN @@ -3134,9 +3151,12 @@ SUBROUTINE case_aggregate_line_control() CALL require(es == CD_AGG_OK, 'aggctrl: control init: '//TRIM(em)) CALL require(CD_AGG_NCtrlChans(aggc) == 1 .AND. CD_AGG_NCtrlChans(agg) == 0, 'aggctrl: channel counts') - ! (a) zero command == never applied, bit-identical loads after one step - CALL CD_AGG_Apply_LineControl(aggc, [0.0_wp], [0.0_wp], es, em) + ! (a) zero command == never applied, bit-identical loads after one step; the rate is -0 + ! (a host's negated zero), which must count as +0 + CALL CD_AGG_Apply_LineControl(aggc, [0.0_wp], [SIGN(0.0_wp, -1.0_wp)], es, em) CALL require(es == CD_AGG_OK, 'aggctrl: zero apply: '//TRIM(em)) + CALL require(TRANSFER(aggc%sys%fast%system%lines(aggc%ctrl_line(1))%l0_dot(aggc%ctrl_elem(1)), 0_INT64) == & + 0_INT64, 'aggctrl: a rate of -0 is stored as +0') CALL CD_AGG_GetMovingPointMesh(agg, q0, v0, a0, lf, es, em) v0 = 0.0_wp a0 = 0.0_wp @@ -3206,9 +3226,10 @@ SUBROUTINE case_aggregate_line_control() CALL CD_AGG_End(aggd, es, em) END BLOCK - ! (b3) ATOMIC command validation: with one channel driving BOTH lines - ! (bases 0.98 and 0.48 on the composite deck), a command invalid only for the - ! SECOND row must leave the FIRST line untouched -- pre-fix the loop had + ! (b3) ATOMIC command validation: with one channel driving BOTH lines (line 1 of + ! 0.98 m in one segment, line 2 of 0.50 + 0.48 m in two, MoorDyn-F's UnstrLen/N 0.98 and + ! 0.49 m), a command invalid only for the SECOND row (-0.3 m is within half of 0.98 m + ! but not of 0.49 m) must leave the FIRST line untouched -- pre-fix the loop had ! already updated it before hitting the bad row. BLOCK TYPE(CD_AGG_ModuleType) :: agga @@ -3220,14 +3241,42 @@ SUBROUTINE case_aggregate_line_control() ne1 = CD_System_Line_NElem(agga%sys%fast%system, 1, es, em) ALLOCATE (t1b(ne1), t1a(ne1)) CALL CD_Get_System_Line_Tension(agga%sys%fast%system, 1, t1b, es, em) - CALL CD_AGG_Apply_LineControl(agga, [-0.6_wp], [0.0_wp], es, em) - CALL require(es /= CD_AGG_OK, 'aggctrl: atomic bad-row command fails closed') + CALL CD_AGG_Apply_LineControl(agga, [-0.3_wp], [0.0_wp], es, em) + CALL require(es /= CD_AGG_OK .AND. INDEX(em, 'EI = 0 line 2') > 0, & + 'aggctrl: atomic bad-row command fails closed by the second line') CALL CD_Get_System_Line_Tension(agga%sys%fast%system, 1, t1a, es, em) CALL require(nan_max_abs(t1a - t1b) <= 0.0_wp, & 'aggctrl: a rejected command leaves every line bit-identical (no partial apply)') + ! MoorDyn-F bounds the command by UnstrLen/N of the whole line, not by the controlled + ! segment: on line 2 (controlled segment 0.48 m, UnstrLen/N = 0.49 m) a pay-out of + ! 0.49 m is accepted, as MoorDyn-F accepts it + CALL require(agga%ctrl_nsegs(2) == 2 .AND. ABS(agga%ctrl_unstr_len(2) - 0.98_wp) <= 1.0e-15_wp .AND. & + ABS(agga%ctrl_base_l0(2) - 0.48_wp) <= 1.0e-15_wp, 'aggctrl: line 2 is 0.98 m in two segments') + CALL CD_AGG_Apply_LineControl(agga, [agga%ctrl_unstr_len(2)/REAL(agga%ctrl_nsegs(2), wp)], [0.0_wp], es, em) + CALL require(es == CD_AGG_OK, 'aggctrl: a pay-out of UnstrLen/N > S is accepted, as in MoorDyn-F: '//TRIM(em)) CALL CD_AGG_End(agga, es, em) END BLOCK + ! (b3') a controlled segment shorter than half of UnstrLen/N: a haul-in within MoorDyn-F's + ! bounds that would make it non-positive fails closed by name and writes nothing + BLOCK + TYPE(CD_AGG_ModuleType) :: aggn + REAL(wp), ALLOCATABLE :: keep(:) + CALL write_agg_failure_deck('agg_ctrl_short.dat', control_row='1 2', composite_line2=.TRUE., & + short_tail2=.TRUE.) + CALL CD_AGG_Init_From_Deck(aggn, 'agg_ctrl_short.dat', DT, es, em) + CALL require(es == CD_AGG_OK, 'aggctrl: short-segment deck init: '//TRIM(em)) + IF (es == CD_AGG_OK) THEN + keep = aggn%sys%fast%system%lines(2)%l0 + CALL require(ABS(aggn%ctrl_base_l0(1) - 0.08_wp) <= 1.0e-15_wp, 'aggctrl: the controlled segment is 0.08 m') + CALL CD_AGG_Apply_LineControl(aggn, [-0.2_wp], [0.0_wp], es, em) + CALL require(es /= CD_AGG_OK .AND. INDEX(em, 'EI = 0 line 2') > 0 .AND. INDEX(em, 'non-positive') > 0, & + 'aggctrl: a haul-in that would make the segment non-positive fails closed by name') + CALL require(ALL(aggn%sys%fast%system%lines(2)%l0 == keep), 'aggctrl: the refused haul-in writes nothing') + END IF + CALL CD_AGG_End(aggn, es, em) + END BLOCK + ! (b4) REWIND: a command applied after a snapshot must roll back WITH the ! states -- l0, mass, seabed coefficients, and the distributed-load remainder ! all restore, so the tensions return bit-identically without any re-apply. @@ -3264,26 +3313,612 @@ SUBROUTINE case_aggregate_line_control() 'aggctrl: FAILURE trailing token fails closed') END BLOCK + ! (b6) the controlled segment is the one at the line's fairlead-side end: the end on a + ! host-driven point, else the written NodeB (MoorDyn's AttachB, its segment N). Line 1 + ! is Connect -> Vessel kept in deck order (the vessel is End B of the built model): the + ! vessel-side element is controlled, not the one at the Connect. Line 2 (Connect and + ! Fixed, no host-driven end) controls the element at its written NodeB: the anchor + ! when written Connect -> Fixed (End B); written Fixed -> Connect it is swapped (the + ! Connect is End A) and controls the End-A element. + BLOCK + TYPE(CD_AGG_ModuleType) :: aggv, aggs + REAL(wp) :: qn(9), vn(9), an(9), l1(2), l2(2) + CALL write_agg_failure_deck('agg_ctrl_attachb.dat', control_row='1 1,2', composite_line1=.TRUE., & + composite_line2=.TRUE.) + CALL CD_AGG_Init_From_Deck(aggv, 'agg_ctrl_attachb.dat', DT, es, em) + CALL require(es == CD_AGG_OK, 'aggctrl: AttachB deck init: '//TRIM(em)) + IF (es == CD_AGG_OK) THEN + l1 = aggv%sys%fast%system%lines(1)%l0 + l2 = aggv%sys%fast%system%lines(2)%l0 + CALL require(ALL(aggv%ctrl_elem == [1, 1]), 'aggctrl: lines kept in deck order control their End-B element') + CALL CD_AGG_Apply_LineControl(aggv, [0.05_wp], [0.0_wp], es, em) + CALL require(es == CD_AGG_OK, 'aggctrl: AttachB apply: '//TRIM(em)) + CALL CD_Get_System_Line_State(aggv%sys%fast%system, 1, qn, vn, an, es, em) + CALL require(nan_max_abs(qn(1:3)) <= 1.0e-12_wp .AND. & + aggv%sys%fast%system%lines(1)%l0(1) == l1(1) + 0.05_wp .AND. & + aggv%sys%fast%system%lines(1)%l0(2) == l1(2), & + 'aggctrl: a Connect -> Vessel line in stock order controls the vessel-end segment') + CALL CD_Get_System_Line_State(aggv%sys%fast%system, 2, qn, vn, an, es, em) + CALL require(nan_max_abs(qn(1:3) - [2.0_wp, 0.0_wp, 0.0_wp]) <= 1.0e-12_wp .AND. & + aggv%sys%fast%system%lines(2)%l0(1) == l2(1) + 0.05_wp .AND. & + aggv%sys%fast%system%lines(2)%l0(2) == l2(2), & + 'aggctrl: a line without a host-driven end controls its written-NodeB segment') + END IF + CALL write_agg_failure_deck('agg_ctrl_stock.dat', control_row='1 2', composite_line2=.TRUE., & + stock_line2=.TRUE.) + CALL CD_AGG_Init_From_Deck(aggs, 'agg_ctrl_stock.dat', DT, es, em) + CALL require(es == CD_AGG_OK, 'aggctrl: stock-order deck init: '//TRIM(em)) + IF (es == CD_AGG_OK) THEN + CALL require(ALL(aggs%sys%fast%system%lines(2)%l0 == l2) .AND. aggs%ctrl_elem(1) == 2, & + 'aggctrl: a swapped line builds the same model and controls its End-A element') + CALL CD_AGG_Apply_LineControl(aggs, [0.05_wp], [0.0_wp], es, em) + CALL require(es == CD_AGG_OK .AND. aggs%sys%fast%system%lines(2)%l0(2) == l2(2) + 0.05_wp .AND. & + aggs%sys%fast%system%lines(2)%l0(1) == l2(1), & + 'aggctrl: the swapped line controls its written-NodeB (Connect) segment') + END IF + CALL CD_AGG_End(aggv, es, em) + CALL CD_AGG_End(aggs, es, em) + END BLOCK + + ! (b7) a coupled rod end is host-driven: a line written anchor first to a Coupled rod's + ! End B is kept in deck order (the swap only matches points) and controls its End-B + ! element, the rod end; the same line to a Coupled point at that position is swapped and + ! controls its End-A element, the same physical end. Written fairlead first from the rod + ! end it controls its End-A element. + BLOCK + TYPE(CD_AGG_ModuleType) :: aggr, aggp + INTEGER :: ner + CALL write_host_rod_deck('agg_ctrl_rod.dat', .FALSE., control_row='1 1', stock_line1=.TRUE.) + CALL CD_AGG_Init_From_Deck(aggr, 'agg_ctrl_rod.dat', DT, es, em) + CALL require(es == CD_AGG_OK, 'aggctrl: rod deck init: '//TRIM(em)) + CALL write_host_rod_deck('agg_ctrl_rod_pts.dat', .TRUE., control_row='1 1', stock_line1=.TRUE.) + CALL CD_AGG_Init_From_Deck(aggp, 'agg_ctrl_rod_pts.dat', DT, es, em) + CALL require(es == CD_AGG_OK, 'aggctrl: rod-as-points deck init: '//TRIM(em)) + IF (CD_AGG_IsInitialized(aggr) .AND. CD_AGG_IsInitialized(aggp)) THEN + ner = SIZE(aggr%sys%fast%system%lines(1)%l0) + CALL require(aggr%ctrl_elem(1) == 1 .AND. aggp%ctrl_elem(1) == ner, & + 'aggctrl: a line to a coupled rod end controls the segment at the rod end') + END IF + CALL CD_AGG_End(aggr, es, em) + CALL CD_AGG_End(aggp, es, em) + CALL write_host_rod_deck('agg_ctrl_rod_ff.dat', .FALSE., control_row='1 1') + CALL CD_AGG_Init_From_Deck(aggr, 'agg_ctrl_rod_ff.dat', DT, es, em) + CALL require(es == CD_AGG_OK, 'aggctrl: fairlead-first rod deck init: '//TRIM(em)) + IF (es == CD_AGG_OK) THEN + CALL require(aggr%ctrl_elem(1) == SIZE(aggr%sys%fast%system%lines(1)%l0), & + 'aggctrl: a line written fairlead first from a coupled rod end controls its End-A element') + END IF + CALL CD_AGG_End(aggr, es, em) + END BLOCK + ! (c) fail-closed battery CALL CD_AGG_Apply_LineControl(aggc, [REAL(wp) ::], [REAL(wp) ::], es, em) CALL require(es /= CD_AGG_OK, 'aggctrl: short command vector fails closed') CALL CD_AGG_Apply_LineControl(aggc, [-1.0_wp], [0.0_wp], es, em) CALL require(es /= CD_AGG_OK, 'aggctrl: non-positive segment length fails closed') + ! (d) MoorDyn-F's bounds (MoorDyn.f90, ErrID_Fatal): an increase of more than UnstrLen/N + ! or a reduction of more than half of it stops the run by line, command and bound, and + ! writes nothing; the bounds themselves are allowed, as in MoorDyn-F. + BLOCK + REAL(wp) :: s_base, l_keep + INTEGER :: il, ie + il = aggc%ctrl_line(1) + ie = aggc%ctrl_elem(1) + s_base = aggc%ctrl_unstr_len(1)/REAL(aggc%ctrl_nsegs(1), wp) + CALL require(s_base == aggc%ctrl_base_l0(1), 'aggctrl: on a uniform line UnstrLen/N is the segment length') + CALL CD_AGG_Apply_LineControl(aggc, [s_base], [0.0_wp], es, em) + CALL require(es == CD_AGG_OK, 'aggctrl: a pay-out of one segment length is within the bounds: '//TRIM(em)) + CALL CD_AGG_Apply_LineControl(aggc, [-0.5_wp*aggc%ctrl_unstr_len(1)/REAL(aggc%ctrl_nsegs(1), wp)], [0.0_wp], & + es, em) + CALL require(es == CD_AGG_OK, 'aggctrl: a haul-in of half a segment length is within the bounds: '//TRIM(em)) + l_keep = aggc%sys%fast%system%lines(il)%l0(ie) + CALL CD_AGG_Apply_LineControl(aggc, [1.01_wp*s_base], [0.0_wp], es, em) + CALL require(es /= CD_AGG_OK .AND. INDEX(em, 'EI = 0 line 2') > 0 .AND. INDEX(em, 'MoorDyn-F') > 0 .AND. & + INDEX(em, '-S/2 <= DeltaL <= S') > 0 .AND. INDEX(em, 'UnstrLen/N') > 0, & + 'aggctrl: a pay-out beyond one segment length stops by line and bound') + CALL require(aggc%sys%fast%system%lines(il)%l0(ie) == l_keep, 'aggctrl: a refused pay-out writes nothing') + CALL CD_AGG_Apply_LineControl(aggc, [-0.51_wp*s_base], [0.0_wp], es, em) + CALL require(es /= CD_AGG_OK .AND. INDEX(em, 'EI = 0 line 2') > 0, & + 'aggctrl: a haul-in beyond half a segment length stops by line') + CALL require(aggc%sys%fast%system%lines(il)%l0(ie) == l_keep, 'aggctrl: a refused haul-in writes nothing') + END BLOCK + CALL CD_AGG_End(agg, es, em) CALL CD_AGG_End(aggc, es, em) END SUBROUTINE case_aggregate_line_control - SUBROUTINE write_agg_failure_deck(path, failure_row, control_row, composite_line2) + SUBROUTINE case_aggregate_cable_control() + !! Active line control of finite-EI cables on the coupled aggregate: + !! (a) a cable-only deck controls the trailing span of cable elements that makes up the + !! deck's fairlead-side segment (40/13 m), whether the line is written anchor first + !! (MoorDyn order) or fairlead first; a zero command is bit-identical to no control + !! over a driven march; + !! (b) a pay-out scales every span element by (S + DeltaL)/S, leaves the rest, and the + !! next step converges; + !! (c) a command outside MoorDyn-F's bounds -UnstrLen/N/2 <= DeltaL <= UnstrLen/N (145 m + !! in 47 segments; the controlled segment is 40/13 m) fails closed, naming the line, + !! and writes nothing; the bounds themselves are accepted, as in MoorDyn-F, even + !! where they scale the segment by more than 2; + !! (d) an aggregate snapshot rewinds a command with the cable's caches; + !! (e) MIXED deck (cable = deck line 1, chain = deck line 2): the chain resolves to EI = 0 + !! system line 1 -- its rank among the EI = 0 lines, not its deck position -- and one + !! channel drives both kinds; + !! (f) CONTROL with a finite-EI cable in FAST.Farm fails closed by name; + !! (g) on a mesh the static initialisation refined (adaptive_mesh), the span is the + !! children of the fairlead-side segment, and the command scales all of them. + TYPE(CD_AGG_ModuleType) :: agg, aggc + REAL(wp), PARAMETER :: DT = 0.05_wp + REAL(wp) :: r0(3, 1), v0(3, 1), a0(3, 1), tgt(3, 1), lf(3, 1), lc(3, 1), pf(3, 1), vf(3, 1), af(3, 1) + REAL(wp), ALLOCATABLE :: l0_base(:), l0_keep(:), mgb_keep(:, :) + REAL(wp) :: s_span, lam, t + INTEGER :: es, ni, k, ne, first + LOGICAL :: cv, st, bit_same + CHARACTER(512) :: em + + CALL write_cable_only_deck('agg_cable_plain.dat', stock_order=.TRUE.) + CALL write_cable_only_deck('agg_cable_ctrl.dat', control_row='1 1', stock_order=.TRUE.) + CALL CD_AGG_Init_From_Deck(agg, 'agg_cable_plain.dat', DT, es, em) + CALL require(es == CD_AGG_OK, 'cablectrl: plain init: '//TRIM(em)) + CALL CD_AGG_Init_From_Deck(aggc, 'agg_cable_ctrl.dat', DT, es, em) + CALL require(es == CD_AGG_OK, 'cablectrl: a finite-EI cable with CONTROL initialises: '//TRIM(em)) + IF (es /= CD_AGG_OK) RETURN + CALL require(CD_AGG_NCtrlChans(aggc) == 1 .AND. SIZE(aggc%ctrl_chan) == 1, 'cablectrl: one channel, one row') + CALL require(aggc%ctrl_is_cable(1) .AND. aggc%ctrl_line(1) == 1 .AND. aggc%ctrl_line_id(1) == 1, & + 'cablectrl: the row addresses cable 1, deck line 1') + ne = aggc%cables(1)%line%ne + first = aggc%ctrl_elem(1) + s_span = SUM(aggc%cables(1)%line%l0(first:ne)) + CALL require(first >= 1 .AND. first <= ne .AND. ABS(s_span - 40.0_wp/13.0_wp) <= 1.0e-12_wp*s_span .AND. & + ABS(aggc%ctrl_base_l0(1) - s_span) <= 0.0_wp, & + 'cablectrl: the span is the trailing elements of the 40/13 m fairlead-side segment') + IF (first > 1) CALL require(SUM(aggc%cables(1)%line%l0(first - 1:ne)) > 40.0_wp/13.0_wp + 1.0e-9_wp, & + 'cablectrl: the span stops at the segment boundary') + l0_base = aggc%cables(1)%line%l0 + ! the same cable written fairlead first builds the same model and controls the same + ! fairlead-side span + BLOCK + TYPE(CD_AGG_ModuleType) :: aggf + INTEGER :: nf + CALL write_cable_only_deck('agg_cable_ctrl_ff.dat', control_row='1 1') + CALL CD_AGG_Init_From_Deck(aggf, 'agg_cable_ctrl_ff.dat', DT, es, em) + CALL require(es == CD_AGG_OK, 'cablectrl: fairlead-first deck init: '//TRIM(em)) + IF (es == CD_AGG_OK) THEN + nf = aggf%ctrl_nelem(1) + CALL require(aggf%ctrl_elem(1) == first .AND. nf == ne - first + 1 .AND. & + aggf%ctrl_base_l0(1) == aggc%ctrl_base_l0(1) .AND. ALL(aggf%cables(1)%line%l0 == l0_base), & + 'cablectrl: a cable written fairlead first controls the same fairlead-side span') + END IF + CALL CD_AGG_End(aggf, es, em) + END BLOCK + + ! (a) zero command == never controlled, bit for bit, under a driven fairlead + CALL CD_AGG_GetMovingPointMesh(agg, r0, v0, a0, lf, es, em) + tgt = r0 + v0 = 0.0_wp + a0 = 0.0_wp + bit_same = .TRUE. + DO k = 1, 4 + t = REAL(k, wp)*DT + tgt(1, 1) = r0(1, 1) + 0.2_wp*(1.0_wp - COS(2.0_wp*PI*t/2.0_wp)) + v0(1, 1) = 0.2_wp*(2.0_wp*PI/2.0_wp)*SIN(2.0_wp*PI*t/2.0_wp) + ! the rate alternates between +0 and -0 (a host's negated zero): both are inert + CALL CD_AGG_Apply_LineControl(aggc, [0.0_wp], [SIGN(0.0_wp, REAL(1 - 2*MOD(k, 2), wp))], es, em) + CALL require(es == CD_AGG_OK, 'cablectrl: zero apply: '//TRIM(em)) + CALL CD_AGG_Step_Moving(agg, DT, tgt, v0, a0, cv, st, ni, es, em) + CALL require(es == CD_AGG_OK .AND. cv, 'cablectrl: plain step: '//TRIM(em)) + CALL CD_AGG_Step_Moving(aggc, DT, tgt, v0, a0, cv, st, ni, es, em) + CALL require(es == CD_AGG_OK .AND. cv, 'cablectrl: controlled step: '//TRIM(em)) + CALL CD_AGG_CalcOutput(agg, es, em) + CALL CD_AGG_CalcOutput(aggc, es, em) + CALL CD_AGG_GetMovingPointMesh(agg, pf, vf, af, lf, es, em) + CALL CD_AGG_GetMovingPointMesh(aggc, pf, vf, af, lc, es, em) + bit_same = bit_same .AND. nan_max_abs(lc - lf) <= 0.0_wp .AND. & + nan_max_abs(aggc%cables(1)%line%q - agg%cables(1)%line%q) <= 0.0_wp + END DO + CALL require(bit_same .AND. .NOT. aggc%cables(1)%line%has_ctrl, & + 'cablectrl: a zero command is bit-identical to an uncontrolled cable') + + ! (b) pay-out: every span element scales by (S + DeltaL)/S, the rest is untouched + lam = (s_span + 0.4_wp)/s_span + CALL CD_AGG_Apply_LineControl(aggc, [0.4_wp], [0.1_wp], es, em) + CALL require(es == CD_AGG_OK, 'cablectrl: pay-out apply: '//TRIM(em)) + CALL require(ALL(aggc%cables(1)%line%l0(first:ne) == l0_base(first:ne)*lam) .AND. & + ALL(aggc%cables(1)%line%l0(1:first - 1) == l0_base(1:first - 1)), & + 'cablectrl: the span scales by (S + DeltaL)/S and nothing else moves') + CALL require(ABS(SUM(aggc%cables(1)%line%l0(first:ne)) - (s_span + 0.4_wp)) <= 1.0e-12_wp*s_span, & + 'cablectrl: the controlled segment is S + DeltaL long') + CALL require(ALL(ABS(aggc%cables(1)%line%l0_dot(first:ne) - 0.1_wp*l0_base(first:ne)/s_span) <= & + 1.0e-15_wp) .AND. ALL(aggc%cables(1)%line%l0_dot(1:first - 1) == 0.0_wp), & + 'cablectrl: each span element carries DeltaLdot l_e/S') + CALL CD_AGG_Step_Moving(aggc, DT, tgt, v0, a0, cv, st, ni, es, em) + CALL require(es == CD_AGG_OK .AND. cv, 'cablectrl: the step after a pay-out converges: '//TRIM(em)) + + ! (c) MoorDyn-F's bounds: refused outside, writing nothing; accepted on them + BLOCK + REAL(wp) :: bound + CALL require(aggc%ctrl_nsegs(1) == 47 .AND. ABS(aggc%ctrl_unstr_len(1) - 145.0_wp) <= 1.0e-12_wp, & + 'cablectrl: UnstrLen and N of the line') + bound = aggc%ctrl_unstr_len(1)/REAL(aggc%ctrl_nsegs(1), wp) + l0_keep = aggc%cables(1)%line%l0 + CALL CD_AGG_Apply_LineControl(aggc, [-0.51_wp*bound], [0.0_wp], es, em) + CALL require(es /= CD_AGG_OK .AND. INDEX(em, 'finite-EI line 1') > 0 .AND. INDEX(em, 'MoorDyn-F') > 0, & + 'cablectrl: a haul-in beyond half of UnstrLen/N fails closed by line') + CALL CD_AGG_Apply_LineControl(aggc, [1.01_wp*bound], [0.0_wp], es, em) + CALL require(es /= CD_AGG_OK .AND. INDEX(em, 'finite-EI line 1') > 0, & + 'cablectrl: a pay-out beyond UnstrLen/N fails closed by line') + CALL require(ALL(aggc%cables(1)%line%l0 == l0_keep), 'cablectrl: a refused command writes nothing') + CALL CD_AGG_Apply_LineControl(aggc, [bound], [0.0_wp], es, em) + CALL require(es == CD_AGG_OK .AND. bound > s_span, & + 'cablectrl: a pay-out of UnstrLen/N (> S) is accepted, as in MoorDyn-F: '//TRIM(em)) + CALL CD_AGG_Apply_LineControl(aggc, [-0.5_wp*aggc%ctrl_unstr_len(1)/REAL(aggc%ctrl_nsegs(1), wp)], [0.0_wp], & + es, em) + CALL require(es == CD_AGG_OK, 'cablectrl: a haul-in of half of UnstrLen/N is accepted: '//TRIM(em)) + ! back to the pay-out of (b), which (d) restores to + CALL CD_AGG_Apply_LineControl(aggc, [0.4_wp], [0.1_wp], es, em) + CALL require(es == CD_AGG_OK .AND. ALL(aggc%cables(1)%line%l0 == l0_keep), 'cablectrl: back to the pay-out') + END BLOCK + + ! (d) an aggregate snapshot rewinds a command, caches included + l0_keep = aggc%cables(1)%line%l0 + mgb_keep = aggc%cables(1)%line%Mgb + CALL CD_AGG_Snapshot(aggc, es, em) + CALL CD_AGG_Apply_LineControl(aggc, [-0.3_wp], [-0.2_wp], es, em) + CALL require(es == CD_AGG_OK .AND. ANY(aggc%cables(1)%line%Mgb /= mgb_keep), 'cablectrl: rewind apply') + CALL CD_AGG_Restore(aggc, es, em) + CALL require(es == CD_AGG_OK .AND. ALL(aggc%cables(1)%line%l0 == l0_keep) .AND. & + ALL(aggc%cables(1)%line%Mgb == mgb_keep) .AND. & + ALL(aggc%cables(1)%line%l0_dot(first:ne) == 0.1_wp*l0_base(first:ne)/s_span), & + 'cablectrl: the restore brings back the lengths, rates and mass bit for bit') + CALL CD_AGG_End(agg, es, em) + CALL CD_AGG_End(aggc, es, em) + + ! (e) MIXED deck: the chain is deck line 2 but system line 1 + BLOCK + TYPE(CD_AGG_ModuleType) :: aggm + REAL(wp), ALLOCATABLE :: tb(:), ta(:) + INTEGER :: nec + CALL write_mixed_deck('agg_mixed_ctrl.dat', control_row='1 2') + CALL CD_AGG_Init_From_Deck(aggm, 'agg_mixed_ctrl.dat', DT, es, em) + CALL require(es == CD_AGG_OK, 'cablectrl: mixed deck with a controlled chain: '//TRIM(em)) + IF (es == CD_AGG_OK) THEN + CALL require(.NOT. aggm%ctrl_is_cable(1) .AND. aggm%ctrl_line(1) == 1 .AND. aggm%ctrl_line_id(1) == 2, & + 'cablectrl: deck line 2 resolves to EI = 0 system line 1 (its rank, not its position)') + nec = CD_System_Line_NElem(aggm%sys%fast%system, 1, es, em) + ALLOCATE (tb(nec), ta(nec)) + CALL CD_Get_System_Line_Tension(aggm%sys%fast%system, 1, tb, es, em) + ! the chain is written fairlead first (Vessel NodeA, Fixed NodeB): its vessel end is + ! the fairlead side, End A of the built line (its last element) + CALL CD_AGG_Apply_LineControl(aggm, [0.5_wp], [0.0_wp], es, em) + CALL require(es == CD_AGG_OK .AND. aggm%ctrl_elem(1) == nec .AND. & + aggm%sys%fast%system%lines(1)%l0(nec) == aggm%ctrl_base_l0(1) + 0.5_wp, & + 'cablectrl: the chain''s fairlead segment is base + DeltaL: '//TRIM(em)) + CALL CD_Get_System_Line_Tension(aggm%sys%fast%system, 1, ta, es, em) + CALL require(ta(nec) < tb(nec), 'cablectrl: paying the chain out drops its fairlead tension') + CALL require(.NOT. aggm%cables(1)%line%has_ctrl, 'cablectrl: the cable is not touched') + END IF + CALL CD_AGG_End(aggm, es, em) + CALL write_mixed_deck('agg_mixed_ctrl2.dat', control_row='1 1,2') + CALL CD_AGG_Init_From_Deck(aggm, 'agg_mixed_ctrl2.dat', DT, es, em) + CALL require(es == CD_AGG_OK, 'cablectrl: mixed deck, one channel on both kinds: '//TRIM(em)) + IF (es == CD_AGG_OK) THEN + CALL require(aggm%ctrl_is_cable(1) .AND. .NOT. aggm%ctrl_is_cable(2) .AND. aggm%ctrl_line(2) == 1, & + 'cablectrl: rows for the cable and the chain') + CALL CD_AGG_Apply_LineControl(aggm, [0.3_wp], [0.0_wp], es, em) + nec = SIZE(aggm%sys%fast%system%lines(1)%l0) + CALL require(es == CD_AGG_OK .AND. aggm%cables(1)%line%has_ctrl .AND. & + aggm%sys%fast%system%lines(1)%l0(nec) == aggm%ctrl_base_l0(2) + 0.3_wp, & + 'cablectrl: one channel drives the cable span and the chain segment') + END IF + CALL CD_AGG_End(aggm, es, em) + ! a row that fails after the earlier rows changed their lines (a fault injected into the + ! table, past the prevalidation) takes those lines back bit for bit: the cable row first + ! (rows cable, chain), then the chain row first (rows chain, cable) + BLOCK + TYPE(CD_HFMF_ModuleType) :: cab_keep + REAL(wp), ALLOCATABLE :: l0c(:), ldc(:), fc(:), tc(:), tc2(:) + INTEGER :: keep_elem + CALL CD_AGG_Init_From_Deck(aggm, 'agg_mixed_ctrl2.dat', DT, es, em) + CALL require(es == CD_AGG_OK, 'cablectrl: injected-fault deck init: '//TRIM(em)) + IF (es == CD_AGG_OK) THEN + cab_keep = aggm%cables(1) + keep_elem = aggm%ctrl_elem(2) + aggm%ctrl_elem(2) = 0 + CALL CD_AGG_Apply_LineControl(aggm, [0.3_wp], [0.1_wp], es, em) + aggm%ctrl_elem(2) = keep_elem + CALL require(es /= CD_AGG_OK .AND. INDEX(em, 'line-control update failed') > 0, & + 'cablectrl: the injected chain-row fault fails the command') + CALL require(.NOT. aggm%cables(1)%line%has_ctrl .AND. .NOT. ALLOCATED(aggm%cables(1)%line%l0_dot) .AND. & + ALL(aggm%cables(1)%line%l0 == cab_keep%line%l0) .AND. & + ALL(aggm%cables(1)%line%Mgb == cab_keep%line%Mgb) .AND. & + ALL(aggm%cables(1)%line%trib == cab_keep%line%trib) .AND. & + (aggm%cables(1)%line%tr_valid .EQV. cab_keep%line%tr_valid), & + 'cablectrl: the cable the failed command had changed is taken back bit for bit') + CALL CD_HFMF_End(cab_keep) + END IF + CALL CD_AGG_End(aggm, es, em) + CALL write_mixed_deck('agg_mixed_ctrl3.dat', control_row='1 2,1') + CALL CD_AGG_Init_From_Deck(aggm, 'agg_mixed_ctrl3.dat', DT, es, em) + CALL require(es == CD_AGG_OK, 'cablectrl: chain-first deck init: '//TRIM(em)) + IF (es == CD_AGG_OK) THEN + CALL require(.NOT. aggm%ctrl_is_cable(1) .AND. aggm%ctrl_is_cable(2), 'cablectrl: rows chain, cable') + ! one command to give the chain a committed rate and length to come back to + CALL CD_AGG_Apply_LineControl(aggm, [0.2_wp], [0.05_wp], es, em, restored=.TRUE.) + CALL require(es == CD_AGG_OK, 'cablectrl: chain-first first command: '//TRIM(em)) + ASSOCIATE (chain => aggm%sys%fast%system%lines(1)) + l0c = chain%l0 + ldc = chain%l0_dot + fc = chain%f_ext + nec = SIZE(chain%l0) + ALLOCATE (tc(nec), tc2(nec)) + CALL CD_Get_System_Line_Tension(aggm%sys%fast%system, 1, tc, es, em) + keep_elem = aggm%ctrl_elem(2) + aggm%ctrl_elem(2) = 0 + CALL CD_AGG_Apply_LineControl(aggm, [0.4_wp], [0.1_wp], es, em) + aggm%ctrl_elem(2) = keep_elem + CALL require(es /= CD_AGG_OK .AND. INDEX(em, 'line-control update failed') > 0, & + 'cablectrl: the injected cable-row fault fails the command') + CALL CD_Get_System_Line_Tension(aggm%sys%fast%system, 1, tc2, es, em) + CALL require(ALL(chain%l0 == l0c) .AND. & + ALL(TRANSFER(chain%l0_dot, 0_INT64, nec) == TRANSFER(ldc, 0_INT64, nec)) .AND. & + ALL(chain%l0_c == l0c) .AND. ALL(chain%f_ext == fc) .AND. ALL(tc2 == tc), & + 'cablectrl: the chain the failed command had changed is taken back bit for bit') + END ASSOCIATE + END IF + CALL CD_AGG_End(aggm, es, em) + END BLOCK + END BLOCK + + ! a finite-EI line on the configuration-blended generalised-alpha cannot be controlled + BLOCK + TYPE(CD_AGG_ModuleType) :: aggb + CALL write_cable_only_deck('agg_cable_ctrl_cfgblend.dat', control_row='1 1', config_blend=.TRUE.) + CALL CD_AGG_Init_From_Deck(aggb, 'agg_cable_ctrl_cfgblend.dat', DT, es, em) + CALL require(es /= CD_AGG_OK .AND. INDEX(em, 'CONTROL line 1') > 0 .AND. INDEX(em, 'force-blended') > 0, & + 'cablectrl: CONTROL of a finite-EI line under the configuration blend fails closed by name') + CALL CD_AGG_End(aggb, es, em) + END BLOCK + + ! (g) a mesh the static initialisation refined: the fairlead-side deck segment is now + ! several cable elements, and the command scales all of them + BLOCK + TYPE(CD_AGG_ModuleType) :: aggr + REAL(wp), ALLOCATABLE :: base(:) + INTEGER :: ner, fr + CALL write_cable_only_deck('agg_cable_ctrl_refined.dat', control_row='1 1', adaptive_mesh=.TRUE., & + stock_order=.TRUE.) + CALL CD_AGG_Init_From_Deck(aggr, 'agg_cable_ctrl_refined.dat', DT, es, em) + CALL require(es == CD_AGG_OK, 'cablectrl: refined cable with CONTROL: '//TRIM(em)) + IF (es == CD_AGG_OK) THEN + ner = aggr%cables(1)%line%ne + fr = aggr%ctrl_elem(1) + WRITE (*, '(A,I0,A,I0,A)') ' cable control span on the refined mesh: ', ner - fr + 1, ' of ', ner, & + ' elements' + CALL require(ner > 47 .AND. MOD(ner, 47) == 0 .AND. ner - fr + 1 == ner/47, & + 'cablectrl: the span is the children of the refined fairlead-side segment') + CALL require(ABS(SUM(aggr%cables(1)%line%l0(fr:ner)) - 40.0_wp/13.0_wp) <= 1.0e-12_wp*40.0_wp, & + 'cablectrl: the refined span is the 40/13 m segment') + base = aggr%cables(1)%line%l0 + CALL CD_AGG_Apply_LineControl(aggr, [0.3_wp], [0.0_wp], es, em) + CALL require(es == CD_AGG_OK .AND. & + ALL(aggr%cables(1)%line%l0(fr:ner) == base(fr:ner)*((aggr%ctrl_base_l0(1) + 0.3_wp)/ & + aggr%ctrl_base_l0(1))) .AND. & + ALL(aggr%cables(1)%line%l0(1:fr - 1) == base(1:fr - 1)), & + 'cablectrl: the command scales every child of the segment and nothing else') + END IF + CALL CD_AGG_End(aggr, es, em) + END BLOCK + + ! (f) FAST.Farm: CONTROL on a deck with a finite-EI cable fails closed by name + BLOCK + INTEGER :: u, ios + OPEN (NEWUNIT=u, FILE='agg_farm_cable_ctrl.dat', STATUS='REPLACE', ACTION='WRITE', IOSTAT=ios) + WRITE (u, '(A)') 'farm deck with one finite-EI cable and a CONTROL row' + 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 Fixed 0.0 0.0 -56.0' + WRITE (u, '(A)') '2 Turbine1 90.0 0.0 -14.0' + WRITE (u, '(A)') '--- LINES ---' + WRITE (u, '(A)') 'ID NodeA NodeB Outputs' + WRITE (u, '(A)') '(-) (-) (-) (-)' + WRITE (u, '(A)') '1 2 1 -' + WRITE (u, '(A)') '--- SECTIONS ---' + WRITE (u, '(A)') 'LineID LineType Length NumSegs' + WRITE (u, '(A)') '(-) (-) (m) (-)' + WRITE (u, '(A)') '1 bare 145.0 47' + CALL write_control_section(u, '1 1') + WRITE (u, '(A)') '--- OPTIONS ---' + WRITE (u, '(A)') '9.80665 g' + WRITE (u, '(A)') '1025.0 rhoW' + WRITE (u, '(A)') '--- need this line ---' + CLOSE (u) + CALL CD_AGG_Init_From_Deck(aggc, 'agg_farm_cable_ctrl.dat', DT, es, em, n_turbines=1, & + turbine_ref_pos=RESHAPE([0.0_wp, 0.0_wp, 0.0_wp], [3, 1])) + CALL require(es /= CD_AGG_OK .AND. INDEX(em, 'CONTROL on a FAST.Farm deck') > 0, & + 'cablectrl: CONTROL of a finite-EI cable in FAST.Farm fails closed by name') + CALL CD_AGG_End(aggc, es, em) + END BLOCK + END SUBROUTINE case_aggregate_cable_control + + SUBROUTINE case_restart_cable_control() + !! CHECKPOINT-RESTART of a controlled finite-EI cable, bit for bit (the shell rebuild's + !! recipe): instance A marches under a pay-out ramp and a hold; a fresh instance B is built + !! at the base lengths, takes A's coupled kinematics, re-applies the last command (the + !! shell re-applies the restored DeltaL) and then reloads A's cable mirror; both continue + !! under the same drive and commands. The re-applied lengths rebuild B's mass, tributary + !! lengths and seabed coefficients exactly as A's were rebuilt; the mirror reload that + !! follows brings back the committed force A carries into its next step and takes the + !! lengths in place as those the committed state was reached with (A's l0_c), so the + !! trajectories stay bit-identical, on a suspended cable and on a grounded cable with + !! stick-slip friction. The checkpoint falls in the hold and in the ramp. Deck 4 holds a + !! host fluid field (external_fluid) sampled before each command, as the shell does, and + !! re-sampled after the reload: each sample re-evaluates the committed force, at the + !! committed lengths, so the restart is bit-identical only if the reload took the + !! re-applied lengths as committed (the command goes on before the reload). + TYPE(CD_AGG_ModuleType) :: agg_a, agg_b + REAL(wp), PARAMETER :: DT = 0.05_wp + INTEGER, PARAMETER :: NPOST = 6 + REAL(wp), ALLOCATABLE :: r0(:, :), vel(:, :), acc(:, :), tgt(:, :), pa(:, :), la(:, :), pb(:, :), lb(:, :) + REAL(wp), ALLOCATABLE :: v2(:, :), a2(:, :), cbuf(:), fv(:, :), fa(:, :), wl(:) + REAL(wp) :: dl, dldot + INTEGER :: es, ni, s, npt, deck, npre, nfl + LOGICAL :: cv, st, same, fluid + CHARACTER(512) :: em + CHARACTER(64) :: path + + DO deck = 1, 4 + fluid = deck == 4 + SELECT CASE (deck) + CASE (1) + path = 'agg_restart_cable_ctrl.dat' + CALL write_cable_only_deck(path, control_row='1 1') + npre = 8 + CASE (2, 4) + path = 'agg_restart_cable_ctrl.dat' + npre = 4 + CASE DEFAULT + path = 'agg_restart_ground_ctrl.dat' + CALL write_cable_grounded_deck(path, control_row='1 1') + npre = 8 + END SELECT + CALL CD_AGG_Init_From_Deck(agg_a, TRIM(path), DT, es, em, external_fluid=fluid) + CALL require(es == CD_AGG_OK, 'ctrl-restart:A-init: '//TRIM(em)) + IF (es /= CD_AGG_OK) RETURN + IF (fluid) THEN + nfl = CD_AGG_NFluidNodes(agg_a, es, em) + IF (ALLOCATED(fv)) DEALLOCATE (fv, fa, wl) + ALLOCATE (fv(3, nfl), fa(3, nfl), wl(nfl)) + fv = 0.0_wp + fa = 0.0_wp + wl = 0.0_wp + END IF + npt = CD_AGG_NMovingPoints(agg_a, es, em) + IF (ALLOCATED(r0)) DEALLOCATE (r0, vel, acc, tgt, pa, la, pb, lb, v2, a2) + ALLOCATE (r0(3, npt), vel(3, npt), acc(3, npt), tgt(3, npt), pa(3, npt), la(3, npt), pb(3, npt), & + lb(3, npt), v2(3, npt), a2(3, npt)) + CALL CD_AGG_GetMovingPointMesh(agg_a, r0, vel, acc, la, es, em) + tgt = r0 + vel = 0.0_wp + acc = 0.0_wp + DO s = 1, npre + CALL control_drive(s, DT, r0, tgt, vel, dl, dldot) + IF (fluid) CALL fluid_sample(agg_a, s, fv, fa, wl) + CALL CD_AGG_Apply_LineControl(agg_a, [dl], [dldot], es, em) + CALL CD_AGG_Step_Moving(agg_a, DT, tgt, vel, acc, cv, st, ni, es, em) + CALL require(es == CD_AGG_OK .AND. cv, 'ctrl-restart:A-march: '//TRIM(em)) + IF (es /= CD_AGG_OK) RETURN + END DO + ! the checkpoint: fresh B at the base lengths, A's kinematics and mirror, the last command + CALL CD_AGG_Init_From_Deck(agg_b, TRIM(path), DT, es, em, external_fluid=fluid) + CALL require(es == CD_AGG_OK, 'ctrl-restart:B-init: '//TRIM(em)) + CALL CD_AGG_GetMovingPointMesh(agg_a, pa, v2, a2, la, es, em) + CALL CD_AGG_UpdateStates_Moving(agg_b, pa, v2, a2, es, em) + ! the restored command goes on as the committed state's before the mirror reload (the + ! shell rebuild order), as its lengths are in the uninterrupted run; the reload brings + ! back the committed force + CALL control_drive(npre, DT, r0, tgt, vel, dl, dldot) + CALL CD_AGG_Apply_LineControl(agg_b, [dl], [dldot], es, em, restored=.TRUE.) + CALL require(es == CD_AGG_OK, 'ctrl-restart:B-reapply: '//TRIM(em)) + ALLOCATE (cbuf(CD_HFMF_MirrorSize(agg_a%cables(1)))) + CALL CD_HFMF_PackMirror(agg_a%cables(1), cbuf, es, em) + CALL CD_HFMF_UnpackMirror(agg_b%cables(1), cbuf, agg_a%cables(1)%line%t, es, em) + CALL require(es == CD_HFMF_OK, 'ctrl-restart:cable-unpack: '//TRIM(em)) + DEALLOCATE (cbuf) + ! the shell re-samples the host field on the restored state + IF (fluid) CALL fluid_sample(agg_b, npre, fv, fa, wl) + CALL require(ALL(agg_b%cables(1)%line%l0 == agg_a%cables(1)%line%l0) .AND. & + ALL(agg_b%cables(1)%line%Mgb == agg_a%cables(1)%line%Mgb) .AND. & + ALL(agg_b%cables(1)%line%trib == agg_a%cables(1)%line%trib), & + 'ctrl-restart:re-applied lengths and caches equal the uninterrupted run''s') + IF (agg_a%cables(1)%line%has_contact) & + CALL require(ALL(agg_b%cables(1)%line%contact_kn == agg_a%cables(1)%line%contact_kn) .AND. & + ALL(agg_b%cables(1)%line%fr_k == agg_a%cables(1)%line%fr_k), & + 'ctrl-restart:re-applied seabed coefficients equal the uninterrupted run''s') + same = .TRUE. + DO s = npre + 1, npre + NPOST + CALL control_drive(s, DT, r0, tgt, vel, dl, dldot) + IF (fluid) CALL fluid_sample(agg_a, s, fv, fa, wl) + IF (fluid) CALL fluid_sample(agg_b, s, fv, fa, wl) + CALL CD_AGG_Apply_LineControl(agg_a, [dl], [dldot], es, em) + CALL CD_AGG_Apply_LineControl(agg_b, [dl], [dldot], es, em) + CALL CD_AGG_Step_Moving(agg_a, DT, tgt, vel, acc, cv, st, ni, es, em) + CALL require(es == CD_AGG_OK .AND. cv, 'ctrl-restart:A-continue: '//TRIM(em)) + CALL CD_AGG_Step_Moving(agg_b, DT, tgt, vel, acc, cv, st, ni, es, em) + CALL require(es == CD_AGG_OK .AND. cv, 'ctrl-restart:B-continue: '//TRIM(em)) + CALL CD_AGG_CalcOutput(agg_a, es, em) + CALL CD_AGG_CalcOutput(agg_b, es, em) + CALL CD_AGG_GetMovingPointMesh(agg_a, pa, v2, a2, la, es, em) + CALL CD_AGG_GetMovingPointMesh(agg_b, pb, v2, a2, lb, es, em) + same = same .AND. nan_max_abs(la - lb) <= 0.0_wp .AND. & + nan_max_abs(agg_a%cables(1)%line%q - agg_b%cables(1)%line%q) <= 0.0_wp .AND. & + nan_max_abs(agg_a%cables(1)%line%a - agg_b%cables(1)%line%a) <= 0.0_wp + END DO + WRITE (*, '(A,I0,A,ES10.3)') ' ctrl-restart deck ', deck, ': max load difference ', nan_max_abs(la - lb) + CALL require(same, 'ctrl-restart:the restarted run continues bit-identically') + CALL CD_AGG_End(agg_a, es, em) + CALL CD_AGG_End(agg_b, es, em) + END DO + END SUBROUTINE case_restart_cable_control + + SUBROUTINE fluid_sample(agg, step, fv, fa, wl) + !! A host fluid field for the coming step of case_restart_cable_control: a uniform + !! current that grows with the step count (fa and wl as given). + TYPE(CD_AGG_ModuleType), INTENT(INOUT) :: agg + INTEGER, INTENT(IN) :: step + REAL(wp), INTENT(INOUT) :: fv(:, :) + REAL(wp), INTENT(IN) :: fa(:, :), wl(:) + INTEGER :: esf + CHARACTER(512) :: emf + fv(1, :) = 0.02_wp*REAL(step, wp) + CALL CD_AGG_SetFluidFields(agg, fv, fa, wl, esf, emf) + CALL require(esf == CD_AGG_OK, 'ctrl-restart:fluid field: '//TRIM(emf)) + END SUBROUTINE fluid_sample + + SUBROUTINE control_drive(step, dt, r0, tgt, vel, dl, dldot) + !! Surge drive of every coupled point and the control command at t = step*dt: a 0.3 m + !! pay-out on a half-cosine ramp over 0.3 s, then held. + INTEGER, INTENT(IN) :: step + REAL(wp), INTENT(IN) :: dt, r0(:, :) + REAL(wp), INTENT(INOUT) :: tgt(:, :), vel(:, :) + REAL(wp), INTENT(OUT) :: dl, dldot + REAL(wp), PARAMETER :: TR = 0.3_wp + REAL(wp) :: t + t = REAL(step, wp)*dt + tgt(1, :) = r0(1, :) + 0.2_wp*(1.0_wp - COS(2.0_wp*PI*t/2.0_wp)) + vel(1, :) = 0.2_wp*(2.0_wp*PI/2.0_wp)*SIN(2.0_wp*PI*t/2.0_wp) + IF (t < TR) THEN + dl = 0.3_wp*0.5_wp*(1.0_wp - COS(PI*t/TR)) + dldot = 0.3_wp*0.5_wp*(PI/TR)*SIN(PI*t/TR) + ELSE + dl = 0.3_wp + dldot = 0.0_wp + END IF + END SUBROUTINE control_drive + + SUBROUTINE write_agg_failure_deck(path, failure_row, control_row, composite_line2, composite_line1, stock_line2, & + short_tail2) !! Vessel fairlead + massy Connect junction + Fixed anchor, two 0.98 m lines -- !! the connect rig behind the coupled facade, with optional FAILURE/CONTROL rows. !! composite_line2 splits line 2 into two sections with DIFFERENT segment - !! lengths (0.50 then 0.48) -- the control-base composite regression. + !! lengths (0.50 then 0.48) -- the control-base composite regression; composite_line1 + !! splits line 1 (Connect -> Vessel, kept in deck order) the same way. stock_line2 + !! writes line 2 anchor first (Fixed NodeA, sections reversed), which the anchor-first + !! swap turns into the same line. short_tail2 (with composite_line2) makes line 2's + !! sections 0.90 and 0.08 m, a controlled segment shorter than half of UnstrLen/N. CHARACTER(*), INTENT(IN) :: path CHARACTER(*), INTENT(IN), OPTIONAL :: failure_row, control_row - LOGICAL, INTENT(IN), OPTIONAL :: composite_line2 - LOGICAL :: comp2 + LOGICAL, INTENT(IN), OPTIONAL :: composite_line2, composite_line1, stock_line2, short_tail2 + LOGICAL :: comp2, comp1, stock2, short2 INTEGER :: u, ios + comp1 = .FALSE. + IF (PRESENT(composite_line1)) comp1 = composite_line1 + stock2 = .FALSE. + IF (PRESENT(stock_line2)) stock2 = stock_line2 OPEN (NEWUNIT=u, FILE=path, STATUS='REPLACE', ACTION='WRITE', IOSTAT=ios) WRITE (u, '(A)') 'Coupled connect rig with optional FAILURE' WRITE (u, '(A)') '--- LINE TYPES ---' @@ -3300,14 +3935,31 @@ SUBROUTINE write_agg_failure_deck(path, failure_row, control_row, composite_line WRITE (u, '(A)') 'ID NodeA NodeB Outputs' WRITE (u, '(A)') '(-) (-) (-) (-)' WRITE (u, '(A)') '1 2 1 -' - WRITE (u, '(A)') '2 2 3 -' + IF (stock2) THEN + WRITE (u, '(A)') '2 3 2 -' + ELSE + WRITE (u, '(A)') '2 2 3 -' + END IF WRITE (u, '(A)') '--- SECTIONS ---' WRITE (u, '(A)') 'LineID LineType Length NumSegs' WRITE (u, '(A)') '(-) (-) (m) (-)' - WRITE (u, '(A)') '1 line 0.98 1' + IF (comp1) THEN + WRITE (u, '(A)') '1 line 0.50 1' + WRITE (u, '(A)') '1 line 0.48 1' + ELSE + WRITE (u, '(A)') '1 line 0.98 1' + END IF comp2 = .FALSE. IF (PRESENT(composite_line2)) comp2 = composite_line2 - IF (comp2) THEN + short2 = .FALSE. + IF (PRESENT(short_tail2)) short2 = short_tail2 + IF (comp2 .AND. short2) THEN + WRITE (u, '(A)') '2 line 0.90 1' + WRITE (u, '(A)') '2 line 0.08 1' + ELSE IF (comp2 .AND. stock2) THEN + WRITE (u, '(A)') '2 line 0.48 1' + WRITE (u, '(A)') '2 line 0.50 1' + ELSE IF (comp2) THEN WRITE (u, '(A)') '2 line 0.50 1' WRITE (u, '(A)') '2 line 0.48 1' ELSE @@ -3853,6 +4505,113 @@ SUBROUTINE case_external_fluid_cable() CALL CD_AGG_End(agg_p, es, em) END SUBROUTINE case_external_fluid_cable + SUBROUTINE case_restart_line_control() + !! CHECKPOINT-RESTART of a controlled EI = 0 deck, bit for bit (the shell rebuild's + !! recipe): instance A marches the three VolturnUS chains under a surge drive while + !! channel 1 pays their fairlead segments out on a ramp and then holds; a fresh + !! instance B takes A's coupled kinematics and line interiors [v; q; a], then re-applies + !! the last command as the committed state's (restored = .TRUE.); both continue under the + !! same drive and commands. A step after a length change blends the committed lengths + !! into its generalised-alpha terms, so B must carry A's committed lengths for the + !! trajectories to stay bit-identical. The checkpoint falls in the ramp and in the hold. + TYPE(CD_AGG_ModuleType) :: agg_a, agg_b + REAL(wp), PARAMETER :: DT = 0.05_wp + INTEGER, PARAMETER :: NPOST = 8 + REAL(wp) :: r0(3, 3), vel(3, 3), acc(3, 3), tgt(3, 3), pa(3, 3), la(3, 3), pb(3, 3), lb(3, 3) + REAL(wp) :: v2(3, 3), a2(3, 3), dl, dldot + REAL(wp), ALLOCATABLE :: qL(:), vL(:), aL(:) + INTEGER :: es, ni, s, nl, il, ndof, npre, pass + LOGICAL :: cv, st, same + CHARACTER(512) :: em + + CALL write_volturnus_deck('agg_restart_ctrl.dat', control_row='1 1,2,3') + DO pass = 1, 2 + npre = MERGE(8, 30, pass == 1) + CALL CD_AGG_Init_From_Deck(agg_a, 'agg_restart_ctrl.dat', DT, es, em) + CALL require(es == CD_AGG_OK, 'ctrl-restart:A-init: '//TRIM(em)) + IF (es /= CD_AGG_OK) RETURN + CALL CD_AGG_GetMovingPointMesh(agg_a, r0, vel, acc, la, es, em) + tgt = r0 + vel = 0.0_wp + acc = 0.0_wp + DO s = 1, npre + CALL ctrl_ramp_drive(s, DT, r0, tgt, vel, dl, dldot) + CALL CD_AGG_Apply_LineControl(agg_a, [dl], [dldot], es, em) + CALL CD_AGG_Step_Moving(agg_a, DT, tgt, vel, acc, cv, st, ni, es, em) + CALL require(es == CD_AGG_OK .AND. cv, 'ctrl-restart:A-march: '//TRIM(em)) + IF (es /= CD_AGG_OK) RETURN + END DO + CALL CD_AGG_Init_From_Deck(agg_b, 'agg_restart_ctrl.dat', DT, es, em) + CALL require(es == CD_AGG_OK, 'ctrl-restart:B-init: '//TRIM(em)) + CALL CD_AGG_GetMovingPointMesh(agg_a, pa, v2, a2, la, es, em) + CALL CD_AGG_UpdateStates_Moving(agg_b, pa, v2, a2, es, em) + nl = CD_System_NLines(agg_a%sys%fast%system, es, em) + DO il = 1, nl + ndof = CD_System_Line_NDOF(agg_a%sys%fast%system, il, es, em) + IF (ALLOCATED(qL)) DEALLOCATE (qL, vL, aL) + ALLOCATE (qL(ndof), vL(ndof), aL(ndof)) + CALL CD_Get_System_Line_State(agg_a%sys%fast%system, il, qL, vL, aL, es, em) + CALL CD_Update_System_Line_Interior_State(agg_b%sys%fast%system, il, qL(4:ndof - 3), vL(4:ndof - 3), & + es, em, a_interior=aL(4:ndof - 3)) + CALL require(es == CD_SYSTEM_OK, 'ctrl-restart:B-interior: '//TRIM(em)) + END DO + ! the restored command is the one A's committed state was reached with + CALL ctrl_ramp_drive(npre, DT, r0, tgt, vel, dl, dldot) + CALL CD_AGG_Apply_LineControl(agg_b, [dl], [dldot], es, em, restored=.TRUE.) + CALL require(es == CD_AGG_OK, 'ctrl-restart:B-reapply: '//TRIM(em)) + same = .TRUE. + DO il = 1, nl + same = same .AND. ALL(agg_b%sys%fast%system%lines(il)%l0 == agg_a%sys%fast%system%lines(il)%l0) .AND. & + ALL(agg_b%sys%fast%system%lines(il)%l0_c == agg_a%sys%fast%system%lines(il)%l0_c) + END DO + CALL require(same, 'ctrl-restart:B carries the lengths and the committed lengths of A') + DO s = npre + 1, npre + NPOST + CALL ctrl_ramp_drive(s, DT, r0, tgt, vel, dl, dldot) + CALL CD_AGG_Apply_LineControl(agg_a, [dl], [dldot], es, em) + CALL CD_AGG_Apply_LineControl(agg_b, [dl], [dldot], es, em) + CALL CD_AGG_Step_Moving(agg_a, DT, tgt, vel, acc, cv, st, ni, es, em) + CALL require(es == CD_AGG_OK .AND. cv, 'ctrl-restart:A-continue: '//TRIM(em)) + CALL CD_AGG_Step_Moving(agg_b, DT, tgt, vel, acc, cv, st, ni, es, em) + CALL require(es == CD_AGG_OK .AND. cv, 'ctrl-restart:B-continue: '//TRIM(em)) + CALL CD_AGG_CalcOutput(agg_a, es, em) + CALL CD_AGG_CalcOutput(agg_b, es, em) + CALL CD_AGG_GetMovingPointMesh(agg_a, pa, v2, a2, la, es, em) + CALL CD_AGG_GetMovingPointMesh(agg_b, pb, v2, a2, lb, es, em) + same = same .AND. nan_max_abs(la - lb) <= 0.0_wp + DO il = 1, nl + same = same .AND. nan_max_abs(agg_a%sys%fast%system%lines(il)%q - agg_b%sys%fast%system%lines(il)%q) & + <= 0.0_wp + END DO + END DO + WRITE (*, '(A,I0,A,ES10.3)') ' ctrl-restart (EI = 0) after step ', npre, ': max load difference ', & + nan_max_abs(la - lb) + CALL require(same, 'ctrl-restart:the restarted EI = 0 run continues bit-identically') + CALL CD_AGG_End(agg_a, es, em) + CALL CD_AGG_End(agg_b, es, em) + END DO + END SUBROUTINE case_restart_line_control + + SUBROUTINE ctrl_ramp_drive(step, dt, r0, tgt, vel, dl, dldot) + !! Surge drive of every coupled point and the control command at t = step*dt: a 2 m + !! pay-out on a half-cosine ramp over 1 s, then held (case_restart_line_control). + INTEGER, INTENT(IN) :: step + REAL(wp), INTENT(IN) :: dt, r0(:, :) + REAL(wp), INTENT(INOUT) :: tgt(:, :), vel(:, :) + REAL(wp), INTENT(OUT) :: dl, dldot + REAL(wp), PARAMETER :: TR = 1.0_wp + REAL(wp) :: t + t = REAL(step, wp)*dt + tgt(1, :) = r0(1, :) + 0.5_wp*(1.0_wp - COS(2.0_wp*PI*t/4.0_wp)) + vel(1, :) = 0.5_wp*(2.0_wp*PI/4.0_wp)*SIN(2.0_wp*PI*t/4.0_wp) + IF (t < TR) THEN + dl = 2.0_wp*0.5_wp*(1.0_wp - COS(PI*t/TR)) + dldot = 2.0_wp*0.5_wp*(PI/TR)*SIN(PI*t/TR) + ELSE + dl = 2.0_wp + dldot = 0.0_wp + END IF + END SUBROUTINE ctrl_ramp_drive + SUBROUTINE case_restart_equivalence() !! CHECKPOINT-RESTART semantics at the aggregate level (the shell rebuild's exact !! recipe): march instance A mid-flight, capture what a checkpoint carries -- the @@ -4191,7 +4950,7 @@ END SUBROUTINE write_current_deck ! deck writers ! --------------------------------------------------------------------------------------- - SUBROUTINE write_volturnus_deck(path, fairleads, extra_option, extra_option2, extra_option3) + SUBROUTINE write_volturnus_deck(path, fairleads, extra_option, extra_option2, extra_option3, control_row) !! IEA-15MW VolturnUS-S three-chain mooring (End A = Vessel fairlead, End B = Fixed !! anchor), 20 segments per line -- a pure EI=0 deck (all sections chain, EI = 0). !! fairleads (optional, 3x3): override the three Vessel coordinates, written @@ -4200,9 +4959,10 @@ SUBROUTINE write_volturnus_deck(path, fairleads, extra_option, extra_option2, ex !! bit-for-bit -- the ptfm_init equivalence case keys on that. !! extra_option[23] (optional): verbatim OPTIONS lines appended before the terminator !! (deck current/waves/dtM/TMax variants for the external-fluid cases). + !! control_row (optional): a CONTROL section with this row. CHARACTER(*), INTENT(IN) :: path REAL(wp), INTENT(IN), OPTIONAL :: fairleads(3, 3) - CHARACTER(*), INTENT(IN), OPTIONAL :: extra_option, extra_option2, extra_option3 + CHARACTER(*), INTENT(IN), OPTIONAL :: extra_option, extra_option2, extra_option3, control_row REAL(wp) :: fl(3, 3) INTEGER :: u, ios fl(:, 1) = [-58.0_wp, 0.0_wp, -14.0_wp] @@ -4236,6 +4996,12 @@ SUBROUTINE write_volturnus_deck(path, fairleads, extra_option, extra_option2, ex WRITE (u, '(A)') '1 main 850.0 20' WRITE (u, '(A)') '2 main 850.0 20' WRITE (u, '(A)') '3 main 850.0 20' + IF (PRESENT(control_row)) THEN + WRITE (u, '(A)') '--- CONTROL ---' + WRITE (u, '(A)') 'ChannelID Lines' + WRITE (u, '(A)') '(-) (-)' + WRITE (u, '(A)') TRIM(control_row) + END IF WRITE (u, '(A)') '--- OPTIONS ---' WRITE (u, '(A)') '9.80665 g' WRITE (u, '(A)') '1025.0 rhoW' @@ -4416,13 +5182,15 @@ SUBROUTINE write_touchdown_cable_deck(path, outputs_row) CLOSE (u) END SUBROUTINE write_touchdown_cable_deck - SUBROUTINE write_mixed_deck(path, finite_end_connection, rigid_end_connection) + SUBROUTINE write_mixed_deck(path, finite_end_connection, rigid_end_connection, control_row) !! MIXED deck: one EI=0 catenary chain (mooring) + one finite-EI lazy-wave power cable. !! Cable endpoints (Fixed anchor + Coupled fairlead) sit well above the -200 m seabed, so !! the suspended pinned-span cable ignores WtrDpth while the mooring uses it (touchdown). + !! control_row adds a CONTROL section (cable = deck line 1, chain = deck line 2). CHARACTER(*), INTENT(IN) :: path LOGICAL, INTENT(IN), OPTIONAL :: finite_end_connection LOGICAL, INTENT(IN), OPTIONAL :: rigid_end_connection + CHARACTER(*), INTENT(IN), OPTIONAL :: control_row INTEGER :: u, ios OPEN (NEWUNIT=u, FILE=path, STATUS='REPLACE', ACTION='WRITE', IOSTAT=ios) WRITE (u, '(A)') 'MIXED deck: EI=0 chain mooring + finite-EI lazy-wave cable' @@ -4470,6 +5238,7 @@ SUBROUTINE write_mixed_deck(path, finite_end_connection, rigid_end_connection) WRITE (u, '(A)') '1 A Rigid -0.24716 0 -0.968975' END IF END IF + IF (PRESENT(control_row)) CALL write_control_section(u, control_row) WRITE (u, '(A)') '--- OPTIONS ---' WRITE (u, '(A)') '9.80665 g' WRITE (u, '(A)') '1025.0 rhoW' @@ -4481,6 +5250,26 @@ SUBROUTINE write_mixed_deck(path, finite_end_connection, rigid_end_connection) CLOSE (u) END SUBROUTINE write_mixed_deck + SUBROUTINE write_control_section(u, rows) + !! A CONTROL section; rows holds one or more rows separated by ';'. + INTEGER, INTENT(IN) :: u + CHARACTER(*), INTENT(IN) :: rows + INTEGER :: lo, hi + WRITE (u, '(A)') '--- CONTROL ---' + WRITE (u, '(A)') 'ChannelID Lines' + WRITE (u, '(A)') '(-) (-)' + lo = 1 + DO + hi = INDEX(rows(lo:), ';') + IF (hi == 0) THEN + WRITE (u, '(A)') TRIM(rows(lo:)) + EXIT + END IF + WRITE (u, '(A)') TRIM(rows(lo:lo + hi - 2)) + lo = lo + hi + END DO + END SUBROUTINE write_control_section + SUBROUTINE write_mixed_channels_deck(path, point_channel_id, outputs_row) !! The write_mixed_deck geometry (cable = line 1, mooring chain = line 2) plus an OUTPUTS !! section exercising both objects and multiple channel kinds: FairTen/AnchTen on the mooring, @@ -4578,18 +5367,28 @@ SUBROUTINE write_mooring_channels_deck(path) CLOSE (u) END SUBROUTINE write_mooring_channels_deck - SUBROUTINE write_cable_only_deck(path, modified_newton, cable_load_feedback) + SUBROUTINE write_cable_only_deck(path, modified_newton, cable_load_feedback, control_row, adaptive_mesh, & + stock_order, config_blend) !! A finite-EI lazy-wave power cable, coupled at the fairlead -- no EI=0 line. Bare + !! buoyancy-module properties from the Humboldt / GoMex 15 MW reference (the l3_lazywave !! and deck_hermite_cable convention). Purely SUSPENDED (no WtrDpth). modified_newton - !! adds the OPTIONS row (the tangent-reuse plumbing gate's twin-deck knob). + !! adds the OPTIONS row (the tangent-reuse plumbing gate's twin-deck knob); control_row + !! a CONTROL section; adaptive_mesh the OPTIONS row that lets the static solve refine + !! the 47 deck segments; stock_order writes the line anchor first (MoorDyn order, Fixed + !! NodeA, sections reversed), which the anchor-first swap turns into the same cable; + !! config_blend the OPTIONS row that selects the configuration-blended generalised-alpha. CHARACTER(*), INTENT(IN) :: path - LOGICAL, INTENT(IN), OPTIONAL :: modified_newton + LOGICAL, INTENT(IN), OPTIONAL :: modified_newton, config_blend LOGICAL, INTENT(IN), OPTIONAL :: cable_load_feedback + CHARACTER(*), INTENT(IN), OPTIONAL :: control_row + LOGICAL, INTENT(IN), OPTIONAL :: adaptive_mesh + LOGICAL, INTENT(IN), OPTIONAL :: stock_order INTEGER :: u, ios - LOGICAL :: mn + LOGICAL :: mn, stock mn = .FALSE. IF (PRESENT(modified_newton)) mn = modified_newton + stock = .FALSE. + IF (PRESENT(stock_order)) stock = stock_order OPEN (NEWUNIT=u, FILE=path, STATUS='REPLACE', ACTION='WRITE', IOSTAT=ios) WRITE (u, '(A)') 'finite-EI lazy-wave power cable, coupled at the fairlead (no EI=0 line)' WRITE (u, '(A)') '--- LINE TYPES ---' @@ -4605,18 +5404,35 @@ SUBROUTINE write_cable_only_deck(path, modified_newton, cable_load_feedback) WRITE (u, '(A)') '--- LINES ---' WRITE (u, '(A)') 'ID NodeA NodeB Outputs' WRITE (u, '(A)') '(-) (-) (-) (-)' - WRITE (u, '(A)') '1 2 1 -' + IF (stock) THEN + WRITE (u, '(A)') '1 1 2 -' + ELSE + WRITE (u, '(A)') '1 2 1 -' + END IF WRITE (u, '(A)') '--- SECTIONS ---' WRITE (u, '(A)') 'LineID LineType Length NumSegs' WRITE (u, '(A)') '(-) (-) (m) (-)' - WRITE (u, '(A)') '1 bare 40.0 13' - WRITE (u, '(A)') '1 buoy 50.0 16' - WRITE (u, '(A)') '1 bare 55.0 18' + IF (stock) THEN + WRITE (u, '(A)') '1 bare 55.0 18' + WRITE (u, '(A)') '1 buoy 50.0 16' + WRITE (u, '(A)') '1 bare 40.0 13' + ELSE + WRITE (u, '(A)') '1 bare 40.0 13' + WRITE (u, '(A)') '1 buoy 50.0 16' + WRITE (u, '(A)') '1 bare 55.0 18' + END IF + IF (PRESENT(control_row)) CALL write_control_section(u, control_row) WRITE (u, '(A)') '--- OPTIONS ---' WRITE (u, '(A)') '9.80665 g' WRITE (u, '(A)') '1025.0 rhoW' WRITE (u, '(A)') '0.5 rhoInf' IF (mn) WRITE (u, '(A)') 'true modified_newton' + IF (PRESENT(config_blend)) THEN + IF (config_blend) WRITE (u, '(A)') 'false alpha_force_blend' + END IF + IF (PRESENT(adaptive_mesh)) THEN + IF (adaptive_mesh) WRITE (u, '(A)') 'true adaptive_mesh' + END IF IF (PRESENT(cable_load_feedback)) THEN IF (cable_load_feedback) THEN WRITE (u, '(A)') 'true cable_load_feedback' @@ -4628,15 +5444,16 @@ SUBROUTINE write_cable_only_deck(path, modified_newton, cable_load_feedback) CLOSE (u) END SUBROUTINE write_cable_only_deck - SUBROUTINE write_cable_grounded_deck(path, bathy_path, refined, extra_option) + SUBROUTINE write_cable_grounded_deck(path, bathy_path, refined, extra_option, control_row) !! Coupled finite-EI touchdown cable. The 115 m span between endpoints 96.9 m apart !! develops a grounded run on the -50 m bed without exceeding the 126 m planar !! L-shape capacity (longer fixtures necessarily wad on a frictionless bed). - !! Optional bathymetry_path replaces flat WtrDpth. + !! Optional bathymetry_path replaces flat WtrDpth; control_row adds a CONTROL section. CHARACTER(*), INTENT(IN) :: path CHARACTER(*), INTENT(IN), OPTIONAL :: bathy_path LOGICAL, INTENT(IN), OPTIONAL :: refined CHARACTER(*), INTENT(IN), OPTIONAL :: extra_option + CHARACTER(*), INTENT(IN), OPTIONAL :: control_row INTEGER :: u, ios LOGICAL :: fine_mesh fine_mesh = .FALSE. @@ -4669,6 +5486,7 @@ SUBROUTINE write_cable_grounded_deck(path, bathy_path, refined, extra_option) WRITE (u, '(A)') '1 buoy 40.0 17' WRITE (u, '(A)') '1 bare 45.0 20' END IF + IF (PRESENT(control_row)) CALL write_control_section(u, control_row) WRITE (u, '(A)') '--- OPTIONS ---' WRITE (u, '(A)') '9.80665 g' WRITE (u, '(A)') '1025.0 rhoW' @@ -4762,14 +5580,20 @@ SUBROUTINE write_mixed_free_deck(path) CLOSE (u) END SUBROUTINE write_mixed_free_deck - SUBROUTINE write_host_rod_deck(path, rod_as_points) + SUBROUTINE write_host_rod_deck(path, rod_as_points, control_row, stock_line1) !! A Coupled (platform-borne) vertical rod, End A at z = -1 and End B at z = -3, moored at both !! ends to its own anchor, plus an independent Coupled fairlead with its own line. With !! rod_as_points the rod is replaced by two Coupled points at its end positions (the same - !! lines, the same statics): the reference for the rod's line-end loads. + !! lines, the same statics): the reference for the rod's line-end loads. control_row adds a + !! CONTROL section; stock_line1 writes line 1 anchor first (Fixed NodeA). CHARACTER(*), INTENT(IN) :: path LOGICAL, INTENT(IN) :: rod_as_points + CHARACTER(*), INTENT(IN), OPTIONAL :: control_row + LOGICAL, INTENT(IN), OPTIONAL :: stock_line1 INTEGER :: u + LOGICAL :: stock1 + stock1 = .FALSE. + IF (PRESENT(stock_line1)) stock1 = stock_line1 OPEN (NEWUNIT=u, FILE=path, STATUS='REPLACE', ACTION='WRITE') WRITE (u, '(A)') 'coupled host rod deck' WRITE (u, '(A)') '--- LINE TYPES ---' @@ -4803,7 +5627,11 @@ SUBROUTINE write_host_rod_deck(path, rod_as_points) WRITE (u, '(A)') '--- LINES ---' WRITE (u, '(A)') 'ID NodeA NodeB Outputs' WRITE (u, '(A)') '(-) (-) (-) (-)' - WRITE (u, '(A)') '1 3 1 -' + IF (stock1) THEN + WRITE (u, '(A)') '1 1 3 -' + ELSE + WRITE (u, '(A)') '1 3 1 -' + END IF WRITE (u, '(A)') '2 4 5 -' WRITE (u, '(A)') '3 2 6 -' WRITE (u, '(A)') '--- SECTIONS ---' @@ -4812,6 +5640,7 @@ SUBROUTINE write_host_rod_deck(path, rod_as_points) WRITE (u, '(A)') '1 line 8.0 6' WRITE (u, '(A)') '2 line 9.5 6' WRITE (u, '(A)') '3 line 9.5 6' + IF (PRESENT(control_row)) CALL write_control_section(u, control_row) WRITE (u, '(A)') '--- OPTIONS ---' WRITE (u, '(A)') '9.80665 g' WRITE (u, '(A)') '1025.0 rhoW' diff --git a/validation/scripts/activetension/README.md b/validation/scripts/activetension/README.md index b2056b23..5aaa2db4 100644 --- a/validation/scripts/activetension/README.md +++ b/validation/scripts/activetension/README.md @@ -74,7 +74,9 @@ At the holds, where `DeltaLdot = 0`, the tensions of CableDyn and stock MoorDyn 0.03 %. The tension changes from the baseline, which are the active-tension response, agree to within **0.6 %** on the controlled fairleads and **0.7 %** on the anchors. Both codes report the line-end force, and CableDyn's Newton static equilibrium and MoorDyn's dynamic relaxation give -the same baseline tension to within 0.03 %. During the pay-out -and haul-in ramps, axial damping driven by the commanded rate (`BA·ℓ̇`) produces a transient -that the two element formulations represent slightly differently; it is reported for context -and not scored. +the same baseline tension to within 0.03 %. During the pay-out and haul-in ramps the tensions +differ by at most **0.13 %** of the baseline tension on the controlled fairleads and **0.39 %** +on the anchors; the scorer gates this at 1 %. Before CableDyn kept the committed lengths in the +generalised-α step after a length change, the controlled fairleads had run up to 97 kN (4.1 %) +above MoorDyn during the pay-out and 148 kN (6.3 %) below it during the haul-in, while the holds +agreed as they do now. diff --git a/validation/scripts/openfast_activetension_ab.py b/validation/scripts/openfast_activetension_ab.py index 173c4797..95623770 100644 --- a/validation/scripts/openfast_activetension_ab.py +++ b/validation/scripts/openfast_activetension_ab.py @@ -17,16 +17,18 @@ cancels the codes' small static-tension offset) isolates how each solver renders the commanded length modulation into tension. -The fast pay-out/haul-in RAMPS carry a rate-dependent axial-damping transient (BA*ldot from the -commanded DeltaLdot) that the two element formulations render differently; that is reported as -context but not gated -- the winch setpoint is the controlled quantity, not the slew transient. +The pay-out and haul-in RAMPS are scored too: over each ramp and its settling into the next hold, +the largest difference between the two codes' tensions must stay within GATE_RAMP_PCT of the +MoorDyn baseline tension of that line. The commanded length changes every step there, so this +checks that the length update enters the time integration the way MoorDyn's does. Usage: python validation/scripts/openfast_activetension_ab.py [t_base_lo t_base_hi t_payout_lo t_payout_hi t_haulin_lo t_haulin_hi] Defaults match the DLL schedule (pay out over 40-100 s, hold to 160 s, haul in over 160-220 s, -hold to 260 s): baseline [10,38], pay-out hold [110,158], haul-in hold [228,258]. +hold to 260 s): baseline [10,38], pay-out hold [110,158], haul-in hold [228,258]; the ramps are +scored over [38,110] and [158,228] (from the end of one hold window to the start of the next). Channel names are matched case-insensitively (MoorDyn-F emits UPPERCASE). """ @@ -54,6 +56,9 @@ # a real response -- each controlled hold must change the tension by at least this fraction of # baseline in each code -- so the A/B cannot pass vacuously on a dead cable-control path. GATE_MIN_RESPONSE_PCT = 1.0 # |dT| / baseline, per code, per controlled hold +# Ramp agreement: max |T(=5) - T(=3)| over each ramp, as a percentage of the line's MoorDyn +# baseline tension (controlled fairleads and anchors). +GATE_RAMP_PCT = 1.0 # Note: within a steady hold (DeltaLdot=0) the tension is essentially flat, so the =5-vs-=3 # correlation of the hold window is noise-vs-noise and is reported for context only, NOT gated. # The gated quantity is the tension CHANGE from baseline -- the winch setpoint response. @@ -221,6 +226,36 @@ def report( ANCHORS, "anchor (far-end) tensions -- steady agreement", GATE_ANCHOR_PCT, False ) + # Ramps: the largest tension difference between the codes while the length changes. + ramps = {"pay-out ramp": (bh, pl), "haul-in ramp": (ph, hl)} + print("--- ramps -- largest tension difference while the length changes ---") + for ch in CONTROLLED + ANCHORS: + base3 = window(h3, r3, ch, bl, bh) + c5, c3 = col(h5, ch), col(h3, ch) + if not base3 or c5 < 0 or c3 < 0: + print(f"{ch:10} MISSING") + fails.append(ch) + continue + b3 = mean(base3) + parts = [] + flag = " ok" + for name, (lo, hi) in ramps.items(): + d = max( + ( + abs(x5[c5] - x3[c3]) + for x5, x3 in zip(r5, r3) + if lo <= x5[t5] <= hi and abs(x5[t5] - x3[t3]) <= 0.5 * dt_est + ), + default=math.nan, + ) + parts.append(f"{name} {d / 1e3:7.1f} kN ({pct(d, b3):5.2f}%)") + if not (math.isfinite(d) and pct(d, b3) <= GATE_RAMP_PCT): + flag = " <-- GATE FAIL" + if flag != " ok": + fails.append(ch) + print(f"{ch:10} " + " ".join(parts) + flag) + print() + if fails: print(f"RESULT: FAIL -- {', '.join(dict.fromkeys(fails))}") return 1 @@ -228,7 +263,8 @@ def report( f"RESULT: PASS -- both codes show a real active-tension response " f"(>= {GATE_MIN_RESPONSE_PCT:.0f}% of baseline), the commanded pay-out/haul-in tension " f"response on the controlled lines agrees within {GATE_RESPONSE_PCT:.0f}%, and the anchor " - f"tensions within {GATE_ANCHOR_PCT:.0f}% between CableDyn and stock MoorDyn, end to end " + f"tensions within {GATE_ANCHOR_PCT:.0f}% between CableDyn and stock MoorDyn, and during the " + f"ramps the tensions differ by at most {GATE_RAMP_PCT:.0f}% of the baseline, end to end " "through the OpenFAST ServoDyn cable-control path." ) return 0 From 256157f3f1139734d8030d690ec379b769b425d2 Mon Sep 17 00:00:00 2001 From: Jae Hoon Seo Date: Tue, 20 Oct 2026 14:12:16 +0900 Subject: [PATCH 21/31] fix: whole diagnostic messages; name causes and workarounds (#27) Failure messages were cut off by fixed-size buffers along the solver chain: the tensile qualification failure of a dynamic step ended mid-advice. Every buffer now holds the longest diagnostic it can receive (the C API handle 4096 characters), lists that can outgrow their buffer end with an omission marker, and hot-path kernel buffers keep their short lengths so the step time is unchanged. Messages also name the actual cause and the workaround: weightless and neutrally buoyant lines, Coupled-to-Coupled lines, finite-EI cables on Connect/Free/Coupled points, the still-water rejection by route, and an anchor below the seabed. The initialisation report notes static fairlead strain above maxStrain (10 % if unset) and warns on any section coarser than 1/8 of its line. No acceptance rule or result changes. The controlled-cable snapshot test now marches the restored model and its reference with tangent reuse off from an uncached committed force: Restore clears both caches, so bit-identity with a copy that kept them held only by chance and failed on the Linux Debug runner. Signed-off-by: Jae Hoon Seo --- CHANGELOG.md | 42 ++ CMakeLists.txt | 58 ++ app/cabledyn.f90 | 12 +- doc/capi.rst | 8 +- doc/coupling_boundary.md | 2 +- doc/options.rst | 7 +- doc/troubleshooting.rst | 84 ++- python/cabledyn/deck_file.py | 17 +- python/cabledyn/model.py | 4 +- python/tests/test_deck_file.py | 38 + python/tests/test_native_model.py | 15 + src/CableDyn_Assemble.f90 | 28 +- src/CableDyn_CAPI.f90 | 4 +- src/CableDyn_CAPI.h | 2 +- src/CableDyn_CosseratAssemble.f90 | 6 +- src/CableDyn_CosseratDynamic.f90 | 4 +- src/CableDyn_CosseratEMC.f90 | 8 +- src/CableDyn_CosseratStatic.f90 | 4 +- src/CableDyn_CoupledPlatform.f90 | 6 +- src/CableDyn_DeckDriver.f90 | 667 ++++++++++++------ src/CableDyn_Driver.f90 | 4 +- src/CableDyn_Dynamic.f90 | 15 +- src/CableDyn_FiniteEIModel.f90 | 6 +- src/CableDyn_FiniteEIStatic.f90 | 4 +- src/CableDyn_HermiteArch.f90 | 2 +- src/CableDyn_HermiteCableDynamic.f90 | 121 ++-- src/CableDyn_HermiteCableStatic.f90 | 63 +- src/CableDyn_HermiteTorsion.f90 | 4 +- src/CableDyn_Modal.f90 | 6 +- src/CableDyn_Model.f90 | 175 ++--- src/CableDyn_OpenFAST_Aggregate.f90 | 40 +- src/CableDyn_OpenFAST_FMF.f90 | 10 +- src/CableDyn_OpenFAST_HermiteFMF.f90 | 54 +- src/CableDyn_OpenFAST_Mesh.f90 | 6 +- src/CableDyn_Static.f90 | 60 +- src/CableDyn_StreamWave.f90 | 2 +- src/CableDyn_Syrope.f90 | 2 +- src/CableDyn_System.f90 | 64 +- src/openfast/CableDyn_OF.f90 | 30 +- tests/data/msg_anchor_below_seabed.dat | 35 + tests/data/msg_coarse_section.dat | 37 + tests/data/msg_mixed_coarse_strain.dat | 59 ++ .../data/msg_mixed_connect_coupled_cable.dat | 64 ++ tests/data/msg_mixed_current.dat | 58 ++ tests/data/msg_net_buoyant_ei0.dat | 35 + tests/data/msg_pliant_connect_end_b.dat | 56 ++ tests/data/msg_shared_line.dat | 35 + tests/data/msg_shared_line_finite_ei.dat | 35 + tests/data/msg_static_strain.dat | 35 + tests/data/msg_tensile_safety_motion.txt | 346 +++++++++ tests/data/msg_tensile_safety_truncated.dat | 35 + tests/data/msg_weightless_ei0.dat | 35 + tests/data/msg_weightless_finite_ei.dat | 37 + tests/test_hermite_cable_control.f90 | 10 + 54 files changed, 2045 insertions(+), 551 deletions(-) create mode 100644 tests/data/msg_anchor_below_seabed.dat create mode 100644 tests/data/msg_coarse_section.dat create mode 100644 tests/data/msg_mixed_coarse_strain.dat create mode 100644 tests/data/msg_mixed_connect_coupled_cable.dat create mode 100644 tests/data/msg_mixed_current.dat create mode 100644 tests/data/msg_net_buoyant_ei0.dat create mode 100644 tests/data/msg_pliant_connect_end_b.dat create mode 100644 tests/data/msg_shared_line.dat create mode 100644 tests/data/msg_shared_line_finite_ei.dat create mode 100644 tests/data/msg_static_strain.dat create mode 100644 tests/data/msg_tensile_safety_motion.txt create mode 100644 tests/data/msg_tensile_safety_truncated.dat create mode 100644 tests/data/msg_weightless_ei0.dat create mode 100644 tests/data/msg_weightless_finite_ei.dat diff --git a/CHANGELOG.md b/CHANGELOG.md index d1b295a8..5da378e2 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -593,6 +593,48 @@ All notable changes to CableDyn are recorded in this file. The format follows turning by 2.3° per step and paid out at 0.05 m/s, the sub-stepped march equals one taken as given at a quarter of the step to 3e-8 N; applying the whole change in the first sub-step departs from it by 22 N. +- Failure messages are no longer cut off by fixed-size buffers. The tensile qualification + failure of a dynamic step ended mid-advice (`... at element 64, xi= 0.5000; increase`) because + the buffers that carried it from the Hermite cable through the OpenFAST module and the deck + driver held 200, 300 and 256 characters. Every message buffer of the solver chain, the + C API handle (now 4096 characters; `CableDyn_GetLastError` still truncates to the caller's + buffer, and the Python binding reads 4097 bytes), the standalone driver and the OpenFAST + glue is now long enough for the longest diagnostic. A list that can outgrow its buffer (the + seed notes of a failed `EI = 0` static solve, the initialisation notes of a line) ends with + "further ... notes omitted" instead of stopping mid-note. Results do not change. +- A neutrally buoyant line is named as such. A finite-EI line whose net weight is zero and that + is longer than its span was reported as "the net-heavy line is too long for its span to hang + as a catenary", which is not the cause; the message now says the line is weightless, has no + catenary, and could only bow under axial compression, and advises shortening it to its span + or giving it weight or tension. An `EI = 0` line type rejected as net-buoyant (dry mass not + above the displaced water mass, the unchanged rule) whose mass lies within a relative 1e-6 below + the displaced mass is now named neutrally buoyant, "weightless and slack: its static shape is + indeterminate", with the advice to give it weight or a finite EI and a tension. The Python deck + reader words it the same way. No line type is accepted or rejected differently. +- A line stretched far beyond its elastic range now says so. A line 50 % shorter than its span + converged at 100 % strain and 1.2 GN with no message, because `maxStrain` guards only the + dynamics. The initialisation report notes the static fairlead strain (tension over the EA of + the End A section) of every line, `EI = 0` or finite-EI, above `maxStrain` when the option + is given and positive, and above 10 % otherwise (`0 maxStrain` disables only the dynamic + guard). Only a note: the equilibrium and the outputs are unchanged. +- A section too coarse for its line is warned about. The coarse-mesh warning fired only for a line + with fewer than three segments in all, so a 100 m one-segment top section on a 520 m line + (fairlead tension off by 50 %) passed silently. Every section whose segments are longer than + 1/8 of the line (coarser than a uniform eight-segment line, however the line is split into + sections) now gets a warning, for `EI = 0` and finite-EI lines, in the single-topology driver + and in the standalone mixed route. No example deck is affected. +- Rejection messages name the unsupported capability and the workaround. An `EI = 0` line + between two Coupled points suggests splitting it at a `Connect` point, and a finite-EI one, + which that split does not admit, says to anchor it or model the span with `EI = 0` lines; a + finite-EI cable ending on a `Connect`/`Free`/`Coupled` point, or on a Coupled End A that a deck + with `Connect`/`Free` points cannot drive (it would need `motionFile` coupling), names the point + and what the route supports; the "this coupled mode runs the mooring in + STILL WATER" rejection of deck waves or current now names the route that rejects it (a + standalone mixed deck, which is not coupled, or FAST.Farm) and gives that route's remedy (an + all-`EI = 0` or all-finite-EI deck, or OpenFAST with SeaState; in FAST.Farm, removing the + OPTION); an anchor below the seabed by more than the + tolerance gives the depth, the tolerance rule, and the Z to use. These messages change no + acceptance rule. - The development environment (`environment.yml`) excludes OpenBLAS 0.3.34, which caused the access violation in the modal analysis tests listed under Known issues for 0.1.1. On AMD Zen 4 and Zen 5 CPUs that expose AVX-512, OpenBLAS 0.3.34 enlarges the GEMM blocking, diff --git a/CMakeLists.txt b/CMakeLists.txt index 20a5e70a..a4c6c0e6 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -2195,6 +2195,64 @@ add_test(NAME driver_lazy_wave_planar_refined_att_quiet set_tests_properties(driver_lazy_wave_planar_refined_att_quiet PROPERTIES LABELS "fortran;driver;integration;static") +# Diagnostics that name the cause and the remedy. Each deck below was rejected by a message that +# named the wrong cause or none, or ran with no warning, before the message was written. +function(cabledyn_msg_test name deck rc must_match must_not) + add_test(NAME driver_msg_${name} + COMMAND ${CMAKE_COMMAND} -DDRIVER=$ -DEXPECT_RC=${rc} + "-DARGS=${CMAKE_CURRENT_SOURCE_DIR}/tests/data/${deck}|msg" + "-DMUST_MATCH=${must_match}" "-DMUST_NOT=${must_not}" + -DWORKDIR=${CMAKE_CURRENT_BINARY_DIR}/driver_msg_${name} + -P ${CMAKE_CURRENT_SOURCE_DIR}/tests/check_driver_output.cmake) + set_tests_properties(driver_msg_${name} PROPERTIES LABELS "fortran;driver;integration;static") +endfunction() +# A neutrally buoyant finite-EI line longer than its span has no catenary and no tension-only bow. +cabledyn_msg_test(weightless_finite_ei msg_weightless_finite_ei.dat 2 + "weightless .neutrally buoyant. line is longer than its span;shorten the line to its span, or give it net weight" + "net-heavy") +# An EI=0 line type rejected as net-buoyant whose mass is a relative 4e-9 below the displaced water +# mass is named weightless and slack; one a relative 2e-6 below it keeps the plain message. +cabledyn_msg_test(weightless_ei0 msg_weightless_ei0.dat 1 + "is neutrally buoyant .its dry mass equals the displaced water mass to within a relative 1e-6.;weightless and slack: its static shape is indeterminate" + "") +cabledyn_msg_test(net_buoyant_ei0 msg_net_buoyant_ei0.dat 1 + "is net-buoyant .dry mass <= displaced water mass.: buoyant / lazy-wave sections require a dynamic finite-EI deck" + "weightless") +# A line half the length of its span converges at 100 % strain; the static solve says so. +cabledyn_msg_test(static_strain msg_static_strain.dat 0 + "Note: LINE 1 is stretched to a static strain of 100.0 % at the fairlead;above 10.0 % .the note level used without maxStrain." "") +# A 100 m one-segment top section of a 520 m line. +cabledyn_msg_test(coarse_section msg_coarse_section.dat 0 + "WARNING: LINE 1 section of type \"chain\" .100.00 m in 1 segment.s.. has segments of 100.00 m, 19.2 %" "") +# A well-meshed line with a modest stretch raises neither. +cabledyn_msg_test(quiet_catenary ../../examples/chain_catenary_r3_100m.dat 0 "" + "static strain;too coarse to follow") +cabledyn_msg_test(shared_line msg_shared_line.dat 1 + "LINE 1 End B .NodeB, POINT 2, coupled. must be a Fixed .anchor. point;Workaround for this EI=0 line: split it into two lines that meet at a Connect point" + "cannot be split") +# A finite-EI shared line cannot be split at a Connect point: that advice is not given. +cabledyn_msg_test(shared_line_finite_ei msg_shared_line_finite_ei.dat 1 + "finite-EI LINE 1 End B .NodeB, POINT 2, coupled. must be a Fixed .anchor. point;A finite-EI line cannot be split at a Connect point either;anchor it on a Fixed point" + "Workaround") +cabledyn_msg_test(pliant_connect_end_b msg_pliant_connect_end_b.dat 1 + "finite-EI LINE 1 in a mixed-topology deck needs a Fixed End B;End B is POINT 2 .connect.;Anchor the cable on a Fixed point" + "") +cabledyn_msg_test(mixed_current msg_mixed_current.dat 1 + "the deck current OPTION is not supported for a standalone mixed EI=0/finite-EI deck;runs the mooring in STILL WATER;couple the deck to OpenFAST .CompMooring = 5. with SeaState" + "this coupled mode;the C API;FAST.Farm") +cabledyn_msg_test(mixed_connect_coupled_cable msg_mixed_connect_coupled_cable.dat 1 + "finite-EI LINE 3: a Coupled/Vessel End A .POINT 1. would need motionFile coupling to drive it;remove the Connect/Free points;held still .that route takes no motionFile either." + "is driven by a motionFile") +# The standalone mixed route warns about a coarse section and notes a static strain above maxStrain. +cabledyn_msg_test(mixed_coarse_strain msg_mixed_coarse_strain.dat 0 + "WARNING: LINE 1 section of type \"chain\" .150.00 m in 1 segment.s.. has segments of 150.00 m, 17.6 %;Note: LINE 1 is stretched to a static strain of;above 1.00E-02 % .OPTION maxStrain." + "LINE 2 section of type") +# The tensile qualification failure of a dynamic step names the remedy to the end (the message was +# cut at 256 characters: "... at element 64, xi= 0.5000; increase"). +cabledyn_msg_test(tensile_safety_whole msg_tensile_safety_truncated.dat 2 + "tensile qualification failed;at element 64, xi= 0.5000; increase tensile_strain_tolerance only with an engineering basis, or use warn mode" "") +cabledyn_msg_test(anchor_below_seabed msg_anchor_below_seabed.dat 1 + "POINT 2 .Fixed. lies below the seabed;by 1.00E-02 m, more than the 1.00E-03 m seabed tolerance;Set the anchor Z to -100.00000 m" "") if(WIN32 AND CABLEDYN_RUNTIME_DLLS) add_test( NAME windows_install_runtime diff --git a/app/cabledyn.f90 b/app/cabledyn.f90 index 8cf7357d..1f4bf251 100644 --- a/app/cabledyn.f90 +++ b/app/cabledyn.f90 @@ -64,9 +64,9 @@ PROGRAM cabledyn LOGICAL :: converged, has_dtm, has_tmax, has_motion_file, has_line_outputs, has_objects ! the run-time profile includes the finite-EI cable step counters (not on the mixed route) LOGICAL :: profile_cable_detail = .FALSE. - ! Sized for the aggregate and deck-driver messages it relays (512-character buffers - ! plus deck-line context), so no diagnostic is cut short. - CHARACTER(1024) :: ErrMsg + ! Sized for the aggregate and deck-driver messages it relays (built in buffers of up to + ! 2048 characters, plus deck-line context), so no diagnostic is cut short. + CHARACTER(4096) :: ErrMsg nargs = COMMAND_ARGUMENT_COUNT() @@ -450,7 +450,7 @@ SUBROUTINE run_mixed_held_deck(deck, root, dt, has_dt, run_time, has_run_time, h INTEGER :: es, n_moving, nstep, step, n_iter, miss_count, consecutive_miss, max_consecutive_miss INTEGER :: unit, ios LOGICAL :: step_converged, stalled, file_open - CHARACTER(512) :: em + CHARACTER(4096) :: em CHARACTER(4096) :: static_path, dynamic_path TYPE(StandaloneProgress) :: progress @@ -697,8 +697,8 @@ SUBROUTINE print_mixed_initialization(aggregate, stat, msg) CHARACTER(*), INTENT(OUT) :: msg INTEGER :: n_lines, n_points, n_sections, n_ei0, n_finite, i, line_id, es REAL(wp) :: tension, force(3), inclination, declination, azimuth - CHARACTER(512) :: em - CHARACTER(1024) :: note + CHARACTER(4096) :: em + CHARACTER(2048) :: note CALL CD_AGG_GetInitMetadata(aggregate, n_lines, n_points, n_sections, n_ei0, n_finite, es, em) IF (es /= CD_AGG_OK) THEN diff --git a/doc/capi.rst b/doc/capi.rst index c0cafceb..4281f708 100644 --- a/doc/capi.rst +++ b/doc/capi.rst @@ -382,7 +382,7 @@ A step that finishes without meeting the Newton tolerance still returns ``CD_C_O Diagnostics ~~~~~~~~~~~ -Each handle keeps the text of its last failure, up to 1024 characters. The message is set by a +Each handle keeps the text of its last failure, up to 4096 characters. The message is set by a failing call on a valid handle and cleared by a successful one. ``CableDyn_GetLastError`` does not change it, and neither does ``CableDyn_IsInitialized``. A call rejected with ``CD_C_BAD_HANDLE`` has no handle to store a message in. ``CableDyn_GetLastError`` on such a @@ -1688,7 +1688,7 @@ before the copy and stay zero if the call fails. The model is not changed. - -- - -- - buffer capacity in bytes. A value below 1 makes the call a no-op. A message is at most - 1024 characters, so a buffer of 1025 bytes always holds the full message and its + 4096 characters, so a buffer of 4097 bytes always holds the full message and its terminating ``NUL``. State and size queries @@ -1979,7 +1979,7 @@ surges ±0.05 m with a 10 s period. The program needs no input file. static int report(void *h, const char *where, int err) { - char msg[1024]; + char msg[4097]; /* a message is at most 4096 characters, plus the NUL */ CableDyn_GetLastError(h, msg, (int)sizeof msg); fprintf(stderr, "%s failed (status %d): %s\n", where, err, msg); return 1; @@ -2066,7 +2066,7 @@ host writes its own motion into the blocks of the points it drives before each s int major, minor, patch, abi, err = CD_C_OK, status = 1; void *h = NULL; double *q = NULL, *v = NULL, *a = NULL, *loads = NULL; - char msg[1024]; + char msg[4097]; /* a message is at most 4096 characters, plus the NUL */ CableDyn_GetVersion(&major, &minor, &patch, &abi); if (abi != CABLEDYN_CAPI_ABI_VERSION) { diff --git a/doc/coupling_boundary.md b/doc/coupling_boundary.md index 5f4e36e4..14725a37 100644 --- a/doc/coupling_boundary.md +++ b/doc/coupling_boundary.md @@ -96,7 +96,7 @@ Rules shared by every entry point: xyz triples; connectivity and fixed-DOF indices are 1-based. - Calls with an `err_stat` argument return `CD_C_OK`, `CD_C_BAD_HANDLE`, `CD_C_ALLOC_FAIL`, `CD_C_BAD_INPUT`, `CD_C_SOLVE_FAIL`, or `CD_C_NOT_INITIALIZED`. Diagnostics are kept per handle - (up to 1024 characters) and copied by `CableDyn_GetLastError`. + (up to 4096 characters) and copied by `CableDyn_GetLastError`. - `CableDyn_NPoints` returns the column count expected by `CableDyn_UpdatePointFluidFields`; it can exceed `NCoupledDOF/3` when a deck has output-only fixed or coupled points. - Deck initialisation is transactional: a failed `CableDyn_InitDeck` or `CableDyn_InitDeckAt` diff --git a/doc/options.rst b/doc/options.rst index f01f4ee6..a257318a 100644 --- a/doc/options.rst +++ b/doc/options.rst @@ -317,8 +317,11 @@ rejected as unknown. The dynamic Newton controls are set with ``dynamic_solver`` strain of steel, polyester, and nylon lines), stops the run with exit code 2 and a message naming the line, element, strain, estimated elastic tension, and time. It catches a numerically unstable march whose Newton residual still converges; a physical run never - reaches the default. Finite-EI cables are guarded by ``tensile_safety`` instead - - both (``EI = 0`` lines) + reaches the default. Finite-EI cables are guarded by ``tensile_safety`` instead. The static + solve is not stopped by it: when the static fairlead strain of any line, ``EI = 0`` or + finite-EI (tension over the EA of the End A section), exceeds this value, or 10 % when the + OPTION is not given or is ``0``, the run prints a ``Note`` and continues + - both for the dynamic guard (``EI = 0`` lines); standalone for the static note (every line) - ``0.5 maxStrain`` * - ``dynamic_solver rel abs max_iter backtracks [rhoInf]`` - keyword-first record: two reals, two integers, optional real diff --git a/doc/troubleshooting.rst b/doc/troubleshooting.rst index b7e0c42b..cc83934a 100644 --- a/doc/troubleshooting.rst +++ b/doc/troubleshooting.rst @@ -61,6 +61,10 @@ Auxiliary files use their own label in place of ``deck`` (for example ``motionFi instead: a duplicate or undefined id is quoted in the message (``duplicate POINT id 4``, ``LINE 2 references undefined POINT id 9``). +A solver failure message is not cut off by a fixed-size buffer: it can run to several hundred characters (the tensile +qualification failure of a dynamic step names the element, the force, its limit, and the remedy), +the driver prints it whole, and the C API retains up to 4096 characters per handle. + .. _deck-rejected: A deck is rejected (exit 1) @@ -253,10 +257,48 @@ Model data - End A is the fairlead/upper end. A stock anchor-first row (``Fixed`` NodeA, fairlead NodeB) is swapped automatically; this message means the fairlead point itself lies below the anchor. Check the point coordinates. - * - ``LINE End A (NodeA) must be Coupled/Vessel/Body ...`` / ``LINE End B (NodeB) must be a - Fixed (anchor) point`` - - in a deck without dynamic points every line runs from a fairlead to an anchor. Use - ``Connect``/``Free`` points for line-to-line junctions. + * - ``LINE End A (NodeA) must be Coupled/Vessel/Body ...`` / ``LINE End B (NodeB, POINT + , ) must be a Fixed (anchor) point`` + - in a deck without dynamic points every line runs from a fairlead to an anchor. A line + between two Coupled points (a shared line) is supported only between two ``Turbine`` + fairleads of a FAST.Farm deck. An ``EI = 0`` line can be split into two lines that meet at + a ``Connect`` point in the middle; each line then ends on one Coupled point, and the deck + becomes dynamic and needs ``dtM`` and ``TMax``. A finite-EI line cannot be split that way + (beside ``Connect`` points a finite-EI cable needs a Fixed End B and cannot end on a + ``Connect`` point; the message then starts ``finite-EI LINE ``): anchor it on a Fixed + point, or model the shared span with ``EI = 0`` line types split at a ``Connect`` point. + * - ``finite-EI LINE in a mixed-topology deck needs a Fixed End B ... End B is POINT + ()`` + - a deck with ``Connect``/``Free`` points, bodies or rods that also has finite-EI cables drives + each cable at End A, so End B must be a ``Fixed`` point. A cable that ends on a ``Connect``/``Free``/``Coupled`` + point (a junction with other lines, a buoy, a pliant-wave hang-off) is not supported in a + deck with ``Connect``/``Free`` points, bodies or rods, which is marched as one multibody + system. Anchor the cable on a Fixed point, or run the cable and the lines it joins as + separate decks. + * - ``finite-EI LINE : a Coupled/Vessel End A (POINT ) would need motionFile coupling + to drive it`` + - a mixed-topology deck that has ``Connect``/``Free`` points or bodies is marched as one + multibody system, which does not take ``motionFile`` coupling, so nothing would drive a + finite-EI cable on a Coupled End A. Attach the cable to a Rigid6 body, a rod end or a + Fixed point. Or remove the ``Connect``/``Free`` points so the deck becomes a coupled mixed + deck (the ``EI = 0`` lines on the Coupled point directly): a host (OpenFAST + ``CompMooring = 5`` or the C API) drives its Coupled points, and the standalone driver + runs it with them held still (that route takes no ``motionFile`` either). + * - ``the deck current OPTION is not supported for a standalone mixed EI=0/finite-EI deck`` / + ``the deck waves OPTION ...`` + - the standalone driver runs a mixed ``EI = 0``/finite-EI deck in still water: no ambient + fluid field covers its span. Remove the ``waves``/``current`` OPTION, run a deck whose + lines are all ``EI = 0`` or all finite-EI (those standalone routes evaluate the deck waves + and current), or couple the deck to OpenFAST (``CompMooring = 5``) with SeaState, which + supplies them. + * - ``the deck current OPTION is not supported in FAST.Farm`` / ``the deck waves OPTION ...`` + - the shared mooring of a FAST.Farm farm runs in still water (no fluid field spans the + farm). Remove the ``waves``/``current`` OPTION. + * - ``POINT (Fixed) lies below the seabed ... by m, more than the m seabed + tolerance`` + - a Fixed anchor within ``max(1 mm, 1e-5 |z_seabed|)`` of the seabed (``-WtrDpth``, or the + bathymetry surface) rests on it and is placed on it. A deeper anchor is never moved + silently: set its ``Z`` to the seabed elevation named in the message, or higher. * - ``finite-EI section (EI>0) requires a dynamic deck with dtM and TMax`` - a single-family finite-EI deck is solved by the dynamic finite-EI workflow. Add ``dtM``/``TMax`` (``TMax = 0`` gives the static configuration only). @@ -265,6 +307,14 @@ Model data route — a lazy-wave arch needs the finite-EI path. Give the buoyant section an ``EI > 0`` line type, or specify it by target submerged weight (the ``EQUIVALENT BUOYANCY`` block in :doc:`driver_format`). + * - ``is neutrally buoyant (its dry mass equals the displaced water mass to within a + relative 1e-6)`` + - the net-buoyant rejection above (dry mass ≤ displaced mass, unchanged) of an ``EI = 0`` + line type whose dry mass lies less than a relative 1e-6 (the precision of a typed mass) + below the displaced water mass: it has no net weight, so a slack line of it is + weightless and its static shape is indeterminate (every slack shape balances). Give the + line type weight (a larger ``MassDenInAir``), or use a finite ``EI`` with a tension that + holds the line taut. * - ``the viscoelastic dynamic stiffness Ed (EA = Es|Ed) must be finite and exceed the static Es`` - ``Ed`` must be strictly greater than ``Es``; equal values make the series spring infinite. @@ -438,6 +488,14 @@ but a few geometries are genuinely hard: - **A large grounded touchdown on the** ``EI = 0`` **path.** A long, near-horizontal grounded run can make the linear-Lagrange tangent singular regardless of seed. If the case is a lazy-wave or bending-dominated cable, use the finite-EI path (``EI > 0``), which is built for it. +- **A weightless finite-EI line longer than its span.** ``the weightless (neutrally buoyant) + line is longer than its span`` means every element has zero net weight (to a relative 1e-6 of + its displaced weight, attachments included). Such a line has no catenary: with no weight a + tension-only line is straight, and a longer one could only bow by bending under axial + compression, which a cable does not carry. Shorten the line to its span, or give it net weight + (a larger ``MassDenInAir``, or clumps) or a tension that holds it taut. A line heavier than + water with the same symptom gets ``the net-heavy line is too long for its span to hang as a + catenary`` instead. - **A finite-EI lazy-wave cable at too coarse a mesh.** An under-resolved arch or touchdown carries a large element ``h·κ`` and can stall the dynamic Newton. The resolution metric flags this; the builder can auto-refine a fragile mesh when the deck opts in (``adaptive_mesh True``). @@ -557,6 +615,24 @@ Warnings and notes that do not stop a run raise ``NX``, ``NY``, ``NZ`` to keep the spacing. A SeaState file written for the platform alone, such as the r-test ``MD_Shared`` file, triggers it. See :ref:`openfast:SeaState grid` for sizes and memory. + * - ``Note: LINE is stretched to a static strain of ... % at the fairlead`` + - the fairlead tension over the EA of the End A section exceeds ``maxStrain`` (when the + OPTION is given and positive) or 10 % (when it is not given or is ``0``, which disables + only the dynamic guard). Any line, ``EI = 0`` or finite-EI, is assessed on every + standalone route. A line far shorter than its span converges at + such a strain without failing, because the dynamic ``maxStrain`` guard does not apply to + the static solve. Check the line length against the span and the EA. Only a note: the + equilibrium and the outputs are unchanged. Types with a Syrope working curve or a + load-dependent stiffness are not assessed. + * - ``WARNING: LINE section of type "" (... m in segment(s)) has segments of ... + m, ... % of the line length`` + - a section whose segments are longer than 1/8 (12.5 %) of the line, i.e. coarser than a + uniform eight-segment line, is too coarse to follow the line shape there; a 100 m + one-segment top section of a 520 m line shifts the fairlead tension by tens of percent. + The rule compares the segment length with the whole line, so it does not depend on how + the line is split into sections. Refine its ``NumSegs``; a converged tension usually needs + segments well below this bound. (A line with fewer than three segments in all is reported + whole.) * - ``WARNING: line type ... sinks ... m into the seabed ...; kBot is soft for this line`` - a grounded run of this type would sink deeper than its own diameter into the penalty seabed. Raise ``kBot``; the default ``1.0e5`` embeds a heavy chain by about half its diff --git a/python/cabledyn/deck_file.py b/python/cabledyn/deck_file.py index e2a92563..3ff8dd6f 100644 --- a/python/cabledyn/deck_file.py +++ b/python/cabledyn/deck_file.py @@ -300,6 +300,9 @@ _NATIVE_MAX_COORDINATE = 1.0e6 _NATIVE_MAX_COEFFICIENT = 1.0e15 _NATIVE_MAX_SMALL_COEFFICIENT = 1.0e3 +# Relative band around the displaced water mass within which a line type is neutrally buoyant +# (the native NEUTRAL_BUOYANCY_REL_TOL). +_NATIVE_NEUTRAL_BUOYANCY_REL_TOL = 1.0e-6 _NATIVE_MIN_EA = 1.0e-3 _NATIVE_MIN_DIAMETER = 1.0e-6 _NATIVE_MAX_GRAVITY = 1.0e3 @@ -3603,9 +3606,21 @@ def is_body_kind(kind: str, pinned: bool) -> bool: # Native net-buoyancy gate: an EI=0 route cannot build a buoyant # (lazy-wave) arch, so a used section whose dry mass does not exceed # its displaced water mass needs a dynamic finite-EI line type. - if mass <= water_density * (math.pi / 4.0) * diameter**2 and ( + # Within the rejection, an EI=0 type in the neutral band just below the displaced + # mass is named weightless (the native message). + displaced_mass = water_density * (math.pi / 4.0) * diameter**2 + if mass <= displaced_mass and ( ei <= 0.0 or not (has_dtm or self.caller_driven or mixed_static) ): + if ei <= 0.0 and mass > displaced_mass * (1.0 - _NATIVE_NEUTRAL_BUOYANCY_REL_TOL): + raise DeckFormatError( + f"{self._label}: used LINE TYPE {line_type!r} is neutrally buoyant " + "(its dry mass equals the displaced water mass to within a relative " + "1e-6), so an EI=0 line of it is weightless and slack: its static " + "shape is indeterminate (every slack shape balances). Give the line " + "type weight (a larger MassDenInAir), or a finite EI with a tension that " + "holds it taut" + ) raise DeckFormatError( f"{self._label}: used LINE TYPE {line_type!r} is net-buoyant (dry mass <= " "displaced water mass): buoyant / lazy-wave sections require a dynamic " diff --git a/python/cabledyn/model.py b/python/cabledyn/model.py index 8cf17336..bc55aea1 100644 --- a/python/cabledyn/model.py +++ b/python/cabledyn/model.py @@ -37,8 +37,8 @@ FloatArray = npt.NDArray[np.float64] ArrayInput = npt.ArrayLike -# The C library retains up to 1024 characters per handle; +1 for the NUL. -_MESSAGE_BUFFER = 1025 +# The C library retains up to 4096 characters per handle; +1 for the NUL. +_MESSAGE_BUFFER = 4097 def _as_real_array(x: ArrayInput, name: str) -> FloatArray: diff --git a/python/tests/test_deck_file.py b/python/tests/test_deck_file.py index 62a65f6c..12bc59d3 100644 --- a/python/tests/test_deck_file.py +++ b/python/tests/test_deck_file.py @@ -4,6 +4,7 @@ from __future__ import annotations import json +import math import os import re from pathlib import Path @@ -2972,6 +2973,43 @@ def test_net_buoyant_ei0_line_type_fails_like_native(tmp_path, mass): DeckFile.read(path) +@pytest.mark.parametrize( + ("scale", "ei", "message"), + [ + # inside the neutral band below the displaced mass: named weightless (EI = 0 only) + (1.0 - 1.0e-7, "0.0", "neutrally buoyant .* weightless and slack"), + (1.0 - 9.0e-7, "0.0", "neutrally buoyant .* weightless and slack"), + # below the band: the net-buoyant rejection + (1.0 - 2.0e-6, "0.0", r"net-buoyant \(dry mass <="), + # above the displaced mass the gate admits the type, as it always did + (1.0 + 1.0e-7, "0.0", None), + # a dynamic finite-EI type is admitted on either side of the displaced mass + (1.0 - 1.0e-7, "1.0e4", None), + (1.0 + 1.0e-7, "1.0e4", None), + ], +) +def test_neutral_buoyancy_band_keeps_the_rejection_rule(tmp_path, scale, ei, message): + # The gate rejects mass <= displaced mass, unchanged; only the wording of an EI=0 type + # within a relative 1e-6 below the displaced mass says it is weightless. + mass = 1025.0 * math.pi / 4.0 * 0.2466**2 * scale + replacements = [ + ( + "0.2466 373.5 1.607e9 -1.0 0.0 ", + f"0.2466 {mass:.9f} 1.607e9 -1.0 {ei} ", + ) + ] + if ei != "0.0": + replacements.append((_OPTIONS_HEADER, _OPTIONS_HEADER + "0.1 dtM\n1.0 TMax\n")) + path = _chain_variant(tmp_path, *replacements) + if message is None: + DeckFile.read(path) + return + with pytest.raises(DeckFormatError, match=message) as caught: + DeckFile.read(path) + if "dry mass <=" in message: + assert "weightless" not in str(caught.value) + + @pytest.mark.parametrize(("weight", "buoyant"), [("100.0", False), ("-100.0", True)]) def test_net_buoyancy_uses_the_equivalent_buoyancy_conversion(tmp_path, weight, buoyant): section = ( diff --git a/python/tests/test_native_model.py b/python/tests/test_native_model.py index cc3a50fe..bb258212 100644 --- a/python/tests/test_native_model.py +++ b/python/tests/test_native_model.py @@ -370,3 +370,18 @@ def test_home_relative_deck_path_is_expanded(tmp_path, monkeypatch): monkeypatch.setenv("USERPROFILE", str(tmp_path)) with cabledyn.CableDyn("~/volturnus.dat") as m: assert m.deck == deck.resolve() + + +def test_long_failure_message_is_kept_whole(): + # The weightless-line diagnosis names the cause, three nested solver reasons, and the + # remedy; it is longer than the 1024 characters the handle once retained, and its closing + # advice must reach the caller. + deck = REPO / "tests" / "data" / "msg_weightless_finite_ei.dat" + with cabledyn.CableDyn() as m: + with pytest.raises(CableDynError) as caught: + m.init_deck(deck) + detail = caught.value.detail + assert len(detail) > 1024 + assert "weightless (neutrally buoyant) line is longer than its span" in detail + assert detail.endswith("or a tension that holds it taut") + assert "net-heavy" not in detail diff --git a/src/CableDyn_Assemble.f90 b/src/CableDyn_Assemble.f90 index 9e2e4f07..e6d54fdd 100644 --- a/src/CableDyn_Assemble.f90 +++ b/src/CableDyn_Assemble.f90 @@ -104,9 +104,12 @@ SUBROUTINE CD_Assemble_Cable_Tangent_Force(nodes, elem_conn, l0, ea, & Kt = CD_ZERO fint = CD_ZERO tension = CD_ZERO - CALL check_topology(nodes, elem_conn, n_nodes, n_elem, ErrStat, ErrMsg, topology_validated) + ! the input checks write messages of at most 80 characters into a 120-character share + ErrMsg = '' + CALL check_topology(nodes, elem_conn, n_nodes, n_elem, ErrStat, ErrMsg(1:MIN(LEN(ErrMsg), 120)), & + topology_validated) IF (ErrStat /= 0) RETURN - CALL check_props(l0, ea, n_elem, ErrStat, ErrMsg) + CALL check_props(l0, ea, n_elem, ErrStat, ErrMsg(1:MIN(LEN(ErrMsg), 120))) IF (ErrStat /= 0) RETURN IF (.NOT. shape_ok_2d(Kt, 3*n_nodes) .OR. SIZE(fint) /= 3*n_nodes & .OR. SIZE(tension) /= n_elem) THEN @@ -233,9 +236,12 @@ SUBROUTINE CD_Assemble_Cable_Tangent_Force_Banded_Free(nodes, elem_conn, l0, ea, Kb = CD_ZERO fint = CD_ZERO tension = CD_ZERO - CALL check_topology(nodes, elem_conn, n_nodes, n_elem, ErrStat, ErrMsg, topology_validated) + ! the input checks write messages of at most 80 characters into a 120-character share + ErrMsg = '' + CALL check_topology(nodes, elem_conn, n_nodes, n_elem, ErrStat, ErrMsg(1:MIN(LEN(ErrMsg), 120)), & + topology_validated) IF (ErrStat /= 0) RETURN - CALL check_props(l0, ea, n_elem, ErrStat, ErrMsg) + CALL check_props(l0, ea, n_elem, ErrStat, ErrMsg(1:MIN(LEN(ErrMsg), 120))) IF (ErrStat /= 0) RETURN ndof = 3*n_nodes ldab = 2*kl + ku + 1 @@ -345,9 +351,12 @@ SUBROUTINE CD_Assemble_Cable_Internal_Force(nodes, elem_conn, l0, ea, tension_on CHARACTER(120) :: em fint = CD_ZERO - CALL check_topology(nodes, elem_conn, n_nodes, n_elem, ErrStat, ErrMsg, topology_validated) + ! the input checks write messages of at most 80 characters into a 120-character share + ErrMsg = '' + CALL check_topology(nodes, elem_conn, n_nodes, n_elem, ErrStat, ErrMsg(1:MIN(LEN(ErrMsg), 120)), & + topology_validated) IF (ErrStat /= 0) RETURN - CALL check_props(l0, ea, n_elem, ErrStat, ErrMsg) + CALL check_props(l0, ea, n_elem, ErrStat, ErrMsg(1:MIN(LEN(ErrMsg), 120))) IF (ErrStat /= 0) RETURN IF (SIZE(fint) /= 3*n_nodes) THEN CALL fail(ErrStat, ErrMsg, 'fint must have shape (3 n_nodes)') @@ -431,9 +440,12 @@ SUBROUTINE CD_Compute_Cable_Tension(nodes, elem_conn, l0, ea, tension_only, & CHARACTER(120) :: em tension = CD_ZERO - CALL check_topology(nodes, elem_conn, n_nodes, n_elem, ErrStat, ErrMsg, topology_validated) + ! the input checks write messages of at most 80 characters into a 120-character share + ErrMsg = '' + CALL check_topology(nodes, elem_conn, n_nodes, n_elem, ErrStat, ErrMsg(1:MIN(LEN(ErrMsg), 120)), & + topology_validated) IF (ErrStat /= 0) RETURN - CALL check_props(l0, ea, n_elem, ErrStat, ErrMsg) + CALL check_props(l0, ea, n_elem, ErrStat, ErrMsg(1:MIN(LEN(ErrMsg), 120))) IF (ErrStat /= 0) RETURN IF (SIZE(tension) /= n_elem) THEN CALL fail(ErrStat, ErrMsg, 'tension must have shape (n_elem)') diff --git a/src/CableDyn_CAPI.f90 b/src/CableDyn_CAPI.f90 index b2455028..ab228e3a 100644 --- a/src/CableDyn_CAPI.f90 +++ b/src/CableDyn_CAPI.f90 @@ -92,7 +92,7 @@ MODULE CableDyn_CAPI CD_C_LINE_DECLINATION = 7_C_INT, CD_C_LINE_AZIMUTH = 8_C_INT, & CD_C_LINE_SEGMENT_TENSION = 9_C_INT, CD_C_LINE_DECK_NODE = 10_C_INT !> Capacity of the per-handle diagnostic retained for CableDyn_GetLastError. - INTEGER, PARAMETER :: CD_C_MSG_LEN = 1024 + INTEGER, PARAMETER :: CD_C_MSG_LEN = 4096 ! Live-handle integrity. A handle is valid only if its C_PTR is in the registry of ! handles this module created and has not closed (so a foreign, stale, or @@ -2682,7 +2682,7 @@ END SUBROUTINE init_one_raw_model SUBROUTINE end_temp_models(models) TYPE(CD_ModelType), INTENT(INOUT) :: models(:) INTEGER :: i, es - CHARACTER(120) :: em + CHARACTER(1024) :: em DO i = 1, SIZE(models) CALL CD_End_Model(models(i), es, em) diff --git a/src/CableDyn_CAPI.h b/src/CableDyn_CAPI.h index ed888f9f..8c5de611 100644 --- a/src/CableDyn_CAPI.h +++ b/src/CableDyn_CAPI.h @@ -16,7 +16,7 @@ * indices are 1-based. The Jacobians written by * CableDyn_CalcOutputDerivatives are n-by-n column-major: * J[i + j*n] = d(load_i)/d(q_j). - * - Diagnostics are retained per handle (up to 1024 characters) and copied by + * - Diagnostics are retained per handle (up to 4096 characters) and copied by * CableDyn_GetLastError, truncated to message_len - 1 and NUL-terminated. * - Create and Close are thread-safe. InitDeck, InitDeckAt, InitLine, and * InitLines are serialised process-wide (they parse files through the Fortran diff --git a/src/CableDyn_CosseratAssemble.f90 b/src/CableDyn_CosseratAssemble.f90 index f6472df8..3c25f44b 100644 --- a/src/CableDyn_CosseratAssemble.f90 +++ b/src/CableDyn_CosseratAssemble.f90 @@ -112,7 +112,7 @@ SUBROUTINE CD_Assemble_Cosserat_Tangent_Force(nodes_ref, elem_conn, ea, gas, ei, fe = 0.0_wp Ke = 0.0_wp elem_es = 0 - elem_em = '' + ! elem_em(e) is written with elem_es(e) and read only where elem_es(e) /= 0: no blank fill !$OMP PARALLEL DEFAULT(NONE) & !$OMP SHARED(n_elem, elem_conn, nodes_ref, q, ea, gas, ei, gj, reduced_shear, fe, Ke, elem_es, elem_em) & !$OMP PRIVATE(e, a, b, Lam0, L0, qe, finte, Kte, es, em) @@ -315,7 +315,7 @@ SUBROUTINE CD_Assemble_Cosserat_Tangent_Force_Banded_Free_Workspace(nodes_ref, e work%fe(:, 1:n_elem) = 0.0_wp work%Ke(:, :, 1:n_elem) = 0.0_wp work%elem_es(1:n_elem) = 0 - work%elem_em(1:n_elem) = '' + ! elem_em(e) is written with elem_es(e) and read only where elem_es(e) /= 0: no blank fill !$OMP PARALLEL DEFAULT(NONE) & !$OMP SHARED(n_elem, elem_conn, nodes_ref, q, ea, gas, ei, gj, reduced_shear, work) & !$OMP PRIVATE(e, a, b, Lam0, L0, qe, finte, Kte, es, em) @@ -431,7 +431,7 @@ SUBROUTINE CD_Assemble_Cosserat_Internal_Force_Workspace(nodes_ref, elem_conn, e IF (ErrStat /= 0) RETURN work%fe(:, 1:n_elem) = 0.0_wp work%elem_es(1:n_elem) = 0 - work%elem_em(1:n_elem) = '' + ! elem_em(e) is written with elem_es(e) and read only where elem_es(e) /= 0: no blank fill !$OMP PARALLEL DEFAULT(NONE) & !$OMP SHARED(n_elem, elem_conn, nodes_ref, q, ea, gas, ei, gj, reduced_shear, work) & !$OMP PRIVATE(e, a, b, Lam0, L0, qe, finte, es, em) diff --git a/src/CableDyn_CosseratDynamic.f90 b/src/CableDyn_CosseratDynamic.f90 index a600dedf..2c315ad0 100644 --- a/src/CableDyn_CosseratDynamic.f90 +++ b/src/CableDyn_CosseratDynamic.f90 @@ -860,7 +860,7 @@ SUBROUTINE CD_Cosserat_Initial_Acceleration(nodes_ref, elem_conn, ea, gas, ei, g TYPE(CD_CosseratGenAlphaWorkspace), POINTER :: work INTEGER, POINTER :: free(:) REAL(wp), POINTER :: fint(:), rhs(:), M_band(:, :), support_accel(:), support_force(:) - CHARACTER(120) :: em + CHARACTER(1024) :: em a0 = CD_ZERO; ErrStat = CD_DYN_OK; ErrMsg = '' n_dof = SIZE(q) IF (MOD(n_dof, 6) /= 0 .OR. n_dof < 12 .OR. SIZE(f_ext) /= n_dof .OR. SIZE(a0) /= n_dof) THEN @@ -1023,7 +1023,7 @@ SUBROUTINE CD_Cosserat_Gen_Alpha_Step(nodes_ref, elem_conn, ea, gas, ei, gj, rho REAL(wp), ALLOCATABLE :: theta_n_abs(:, :) ! absolute t_n nodal rotations (multiplicative path) REAL(wp), ALLOCATABLE :: rot_chain(:, :, :) ! per-node consistent-tangent chain Jacobian J_c REAL(wp), ALLOCATABLE :: q_cand(:) ! composed end-of-step candidate pose (validation) - CHARACTER(120) :: em + CHARACTER(1024) :: em q_new = CD_ZERO; v_new = CD_ZERO; a_new = CD_ZERO converged = .FALSE.; stalled = .FALSE.; n_iter = 0 diff --git a/src/CableDyn_CosseratEMC.f90 b/src/CableDyn_CosseratEMC.f90 index 80df5df3..8ae47593 100644 --- a/src/CableDyn_CosseratEMC.f90 +++ b/src/CableDyn_CosseratEMC.f90 @@ -170,7 +170,7 @@ SUBROUTINE CD_Cosserat_EMC_Step(nodes_ref, elem_conn, ea, gas, ei, gj, rho_a, i_ REAL(wp) :: th(3), om(3), Om0(3), eps, rnorm, r0, denom INTEGER :: n3 LOGICAL :: cmass - CHARACTER(160) :: em2 + CHARACTER(1024) :: em2 LOGICAL :: ok ErrStat = CD_DYN_OK; ErrMsg = ''; converged = .FALSE.; n_iter = 0 @@ -440,7 +440,7 @@ SUBROUTINE emc_analytic_jacobian(Ptry, Jout, uout, vout, okout) REAL(wp) :: ph(3), pih(3), Oh(3), psi(3), dr(3), thn(3), thh(3), Rdn(3, 3), ejw(3) REAL(wp) :: Wn, W1, dWlin, dq2, corr, KG(6, 6), blk(6, 6), Gg(3, 3), I3(3, 3), I6(6, 6) INTEGER :: a, c, jj, es, k - CHARACTER(240) :: em + CHARACTER(1024) :: em okout = .TRUE.; I3 = diag3([CD_ONE, CD_ONE, CD_ONE]) I6 = CD_ZERO DO k = 1, 6 @@ -587,7 +587,7 @@ SUBROUTINE emc_residual(Ptry, okout, Rout) REAL(wp) :: dw3(n3), mdw(n3) INTEGER :: b, es LOGICAL :: okl - CHARACTER(160) :: em + CHARACTER(1024) :: em okout = .TRUE. ! velocity translational momentum balance uses M3 (w - v_n): assemble the increment matvec IF (cmass) THEN @@ -717,7 +717,7 @@ SUBROUTINE strain_energy(qq, W, okout) LOGICAL, INTENT(INOUT) :: okout REAL(wp) :: se, ke, vv(ndof) INTEGER :: es - CHARACTER(160) :: em + CHARACTER(1024) :: em vv = CD_ZERO CALL CD_Cosserat_Mechanical_Energy(nodes_ref, elem_conn, ea, gas, ei, gj, rho_a, i_rho_t, i_rho_n, & reduced_shear, qq, vv, se, ke, es, em, multiplicative=.TRUE.) diff --git a/src/CableDyn_CosseratStatic.f90 b/src/CableDyn_CosseratStatic.f90 index 9e69ce00..2c88d550 100644 --- a/src/CableDyn_CosseratStatic.f90 +++ b/src/CableDyn_CosseratStatic.f90 @@ -58,7 +58,7 @@ SUBROUTINE CD_Static_Cosserat_Solve(nodes_ref, elem_conn, ea, gas, ei, gj, q0, f REAL(wp), ALLOCATABLE :: Kb(:, :), fint(:), R_free(:), dq(:) REAL(wp), ALLOCATABLE :: dq_global(:), q_trial(:), R_trial(:), fint0(:) REAL(wp) :: f_ext_base, conv_scale, rnorm, merit, merit_trial, alpha, scale_trial - CHARACTER(120) :: em + CHARACTER(1024) :: em converged = .FALSE.; stalled = .FALSE.; n_iter = 0 ErrStat = CD_COS_OK; ErrMsg = '' @@ -179,7 +179,7 @@ SUBROUTINE eval_residual(qe, Rf, sc) REAL(wp), INTENT(OUT) :: Rf(:), sc REAL(wp), ALLOCATABLE :: fint_e(:) INTEGER :: es_e - CHARACTER(120) :: em_e + CHARACTER(1024) :: em_e ALLOCATE (fint_e(n_dof)) CALL CD_Assemble_Cosserat_Internal_Force(nodes_ref, elem_conn, ea, gas, ei, gj, qe, & reduced_shear, fint_e, es_e, em_e) diff --git a/src/CableDyn_CoupledPlatform.f90 b/src/CableDyn_CoupledPlatform.f90 index 887e4ea2..8d82643c 100644 --- a/src/CableDyn_CoupledPlatform.f90 +++ b/src/CableDyn_CoupledPlatform.f90 @@ -68,7 +68,7 @@ SUBROUTINE CD_Fairlead_Solve(seed, elem_conn, l0, ea, tension_only, f_ext, ancho REAL(wp), ALLOCATABLE :: k_rr(:, :), k_rf(:, :), k_fr(:, :), xcol(:) REAL(wp) :: k_ff(3, 3) LOGICAL :: conv, stalled, at_floor - CHARACTER(160) :: em + CHARACTER(1024) :: em ErrStat = CD_PLAT_OK; ErrMsg = '' q = CD_ZERO; g = CD_ZERO; k_fair = CD_ZERO @@ -191,7 +191,7 @@ SUBROUTINE CD_Solve_Platform_Mooring(n_lines, elem_conn, l0, ea, tension_only, f REAL(wp) :: forces(3, n_lines), trial_forces(3, n_lines) REAL(wp) :: merit, merit_trial, alpha, fscale, mscale LOGICAL :: ok, trial_ok - CHARACTER(200) :: em + CHARACTER(1024) :: em REAL(wp), PARAMETER :: ARMIJO_C1 = 1.0e-4_wp ErrStat = CD_PLAT_OK; ErrMsg = '' @@ -333,7 +333,7 @@ SUBROUTINE CD_Platform_Residual_Tangent(pose, n_lines, elem_conn, l0, ea, tensio REAL(wp) :: jac(3, 6), jt_kf(6, 3), geom(3, 3) REAL(wp), ALLOCATABLE :: qline(:) INTEGER :: li, es_l, n_dof - CHARACTER(200) :: em_l + CHARACTER(1024) :: em_l all_ok = .TRUE.; ErrStat = CD_PLAT_OK; ErrMsg = '' residual = CD_ZERO; k_sys = CD_ZERO diff --git a/src/CableDyn_DeckDriver.f90 b/src/CableDyn_DeckDriver.f90 index ed9ed449..a72d2fac 100644 --- a/src/CableDyn_DeckDriver.f90 +++ b/src/CableDyn_DeckDriver.f90 @@ -163,6 +163,18 @@ MODULE CableDyn_DeckDriver INTEGER, PARAMETER :: INSTALLED_SEQUENCE_COARSE_FLOOR = 24 ! Deepest mesh hierarchy CD_HermiteCable_Sequence_* accepts (levels including the user mesh). INTEGER, PARAMETER :: SEQUENCE_MAX_LEVELS = 20 + ! Relative band within which a net weight counts as zero (neutrally buoyant) to the precision + ! of a typed mass (a mass written to seven digits against a diameter does not cancel exactly). + ! It only selects the wording of a diagnosis -- an EI=0 line type rejected as net-buoyant + ! whose mass lies within it below the displaced water mass, a finite-EI line whose every + ! element weighs within it of nothing -- and changes no acceptance rule. + REAL(wp), PARAMETER :: NEUTRAL_BUOYANCY_REL_TOL = 1.0e-6_wp + ! A section whose segments are longer than COARSE_SECTION_FRACTION of its line (coarser than a + ! uniform eight-segment line) is warned about as too coarse (warn_coarse_sections). A static + ! strain above STATIC_STRAIN_NOTE_DEFAULT is noted (static_strain_note) when OPTION maxStrain + ! is not positive. + REAL(wp), PARAMETER :: COARSE_SECTION_FRACTION = 0.125_wp + REAL(wp), PARAMETER :: STATIC_STRAIN_NOTE_DEFAULT = 0.1_wp PUBLIC :: CD_Run_Deck_Driver PUBLIC :: CD_Deck_Equilibrium_Jacobian_Check @@ -539,6 +551,7 @@ MODULE CableDyn_DeckDriver ! Per-step plausibility guard (OPTION maxStrain): a committed dynamic state with any ! element stretched beyond this strain (or non-finite) fails the run; 0 disables. REAL(wp) :: max_strain = 0.5_wp + LOGICAL :: has_max_strain = .FALSE. ! WaveKinMod-1 elevation history reduced once to its real Fourier components. ! These feed the same arbitrary-component Airy kernel used by reference-matched ! irregular seas; wave_eta_mean carries the zero-frequency waterline offset. @@ -962,9 +975,10 @@ MODULE CableDyn_DeckDriver REAL(wp) :: fair_declination = CD_ZERO REAL(wp) :: fair_azimuth = CD_ZERO LOGICAL :: force_is_total = .TRUE. - ! Static-initialisation notes of a finite-EI line (compression, mesh refinement, - ! accepted residual floor), one per text line; empty when there is nothing to report. - CHARACTER(1024) :: note = '' + ! Static-initialisation notes of the line (finite-EI compression, mesh refinement, accepted + ! residual floor; the static strain note of any line), one per text line (append_note_line); + ! empty when there is nothing to report. It holds a whole cable note (1024) and a strain note. + CHARACTER(2048) :: note = '' END TYPE CD_LineInitSummary TYPE :: CD_DeckAggregateType @@ -1247,7 +1261,7 @@ SUBROUTINE init_deck_models_from_parsed(types, points, lines, sections, opts, mo TYPE(CD_BathymetryType), INTENT(IN), OPTIONAL :: bathymetry INTEGER :: i, es - CHARACTER(256) :: em + CHARACTER(1024) :: em ErrStat = CD_DECKDRV_OK ErrMsg = '' @@ -1295,7 +1309,7 @@ SUBROUTINE init_deck_system_from_parsed(types, points, lines, sections, opts, sy TYPE(CD_LineEndpointBinding), ALLOCATABLE :: bindings(:) TYPE(DeckPoint), ALLOCATABLE :: pts(:) INTEGER :: i, es, nres, maxid - CHARACTER(256) :: em + CHARACTER(1024) :: em ErrStat = CD_DECKDRV_OK ErrMsg = '' @@ -1390,7 +1404,7 @@ SUBROUTINE init_finite_deck_models(types, points, lines, sections, opts, models, TYPE(CD_BathymetryType), INTENT(IN), OPTIONAL :: bathymetry INTEGER :: i, es - CHARACTER(256) :: em + CHARACTER(1024) :: em ErrStat = CD_DECKDRV_OK ErrMsg = '' @@ -1444,7 +1458,7 @@ SUBROUTINE init_one_finite_model(ln, sections, types, points, opts, deck_model, REAL(wp), ALLOCATABLE :: load_per_length(:, :), w(:) REAL(wp) :: anchor(3), fairlead(3) INTEGER :: pa, pb, es, nnode, ndof - CHARACTER(200) :: em + CHARACTER(1024) :: em ErrStat = CD_DECKDRV_OK ErrMsg = '' @@ -1645,8 +1659,12 @@ RECURSIVE SUBROUTINE build_one_hermite_cable(ln, sections, types, points, opts, ! Elements of the mesh whose equilibrium failed the stability test before that refinement. INTEGER :: stability_from_ne LOGICAL :: tensile_error - CHARACTER(400) :: note_text - CHARACTER(512) :: limit_text + CHARACTER(1024) :: note_text + CHARACTER(1024) :: limit_text + ! The geometric cause of a line with no admissible planar equilibrium clear of the seabed: + ! too long to hang as a catenary (net-heavy), or weightless (no catenary exists at all). + LOGICAL :: weightless_line + CHARACTER(400) :: geom_cause, geom_advice ! Steady deck current for the static solve (unallocated: no current and no static friction). TYPE(CD_HermiteStaticCurrentType), ALLOCATABLE :: cur_obj, cur_exact ! Static seabed friction toward the as-laid position (static springs, continued by @@ -1867,6 +1885,19 @@ RECURSIVE SUBROUTINE build_one_hermite_cable(ln, sections, types, points, opts, CALL attachment_nodes(l0, ln%att(1, :), att_node, att_offset) CALL smear_attachments(w, l0, att_node, ln%att, opts%rhoW, opts%g) END IF + ! Zero net weight everywhere (to the neutral-buoyancy band, attachments included): the line has + ! no catenary, and the net-heavy diagnosis of a line too long for its span does not apply. + weightless_line = ALL(ABS(w) <= NEUTRAL_BUOYANCY_REL_TOL*opts%rhoW*opts%g*QUARTER_PI*diam**2) + IF (weightless_line) THEN + geom_cause = 'the weightless (neutrally buoyant) line is longer than its span, so it cannot hang as a '// & + 'catenary: with no net weight a tension-only line is straight, and a longer one could only bow '// & + 'by bending under axial compression' + geom_advice = 'shorten the line to its span, or give it net weight (MassDenInAir above the displaced '// & + 'water mass, or clumps) or a tension that holds it taut' + ELSE + geom_cause = 'the net-heavy line is too long for its span to hang as a catenary' + geom_advice = 'shorten the line or move the anchor' + END IF anchor_on_flat_bed = contact_enabled .AND. (.NOT. PRESENT(bathymetry) .OR. bathymetry_flat) .AND. & ABS(anchor(3) - contact_z) <= 1.0e-6_wp*MAX(CD_ONE, ABS(contact_z)) ! A net-buoyant section anywhere makes this a lazy-wave (buoyant-arch) line and needs @@ -2578,8 +2609,8 @@ RECURSIVE SUBROUTINE build_one_hermite_cable(ln, sections, types, points, opts, ! the anchor back (hermite_static_primary) gave no admissible equilibrium either; ! em says why (where the walk stopped, or what rejected its state). CALL fail_solve(ErrStat, ErrMsg, 'finite-EI cable static solve found no admissible planar '// & - 'equilibrium clear of the seabed: the net-heavy line is too long for its span to '// & - 'hang as a catenary ('//TRIM(em)//'); shorten the line or move the anchor'); RETURN + 'equilibrium clear of the seabed: '//TRIM(geom_cause)// & + ' ('//TRIM(em)//'); '//TRIM(geom_advice)); RETURN ELSE IF (.NOT. primary_done .AND. es /= CD_HCSTAT_OK) THEN primary_msg = em END IF @@ -2687,11 +2718,11 @@ RECURSIVE SUBROUTINE build_one_hermite_cable(ln, sections, types, points, opts, END IF IF (walk_rejected) THEN CALL fail_solve(ErrStat, ErrMsg, 'finite-EI cable static solve found no admissible planar equilibrium '// & - 'clear of the seabed: the net-heavy line is too long for its span to hang as a catenary, '// & + 'clear of the seabed: '//TRIM(geom_cause)//', '// & 'and the equilibrium held by its bending stiffness that the anchor walk reached is '// & 'rejected ('// & TRIM(short_message(primary_msg, 360))//'); mesh-sequenced route: '// & - TRIM(short_message(sequence_msg, 240))//'; shorten the line or move the anchor'); RETURN + TRIM(short_message(sequence_msg, 240))//'; '//TRIM(geom_advice)); RETURN END IF ! A current with no tension-only equilibrium is named first, in full: the nested ! route diagnostics below are bounded and would cut it. A line already compressed @@ -4017,7 +4048,7 @@ LOGICAL FUNCTION as_laid_cross_slope() RESULT(cross) REAL(wp) :: az, laid_t, o_xy(2), dir(2), e_cross(2), span, ds, zf, gx, gy INTEGER :: k, n_s, es_c LOGICAL :: from_top - CHARACTER(200) :: em_c + CHARACTER(1024) :: em_c cross = .FALSE. IF (.NOT. (contact_enabled .AND. opts%has_friction .AND. & opts%static_friction == CD_STATIC_FRICTION_AS_LAID)) RETURN @@ -4162,7 +4193,7 @@ SUBROUTINE anchor_overshoot_note() REAL(wp), PARAMETER :: GROUNDED_TOL = 0.05_wp REAL(wp) :: e_h(2), span, past, floor_z, xg, yg, pos(3) INTEGER :: k, esb - CHARACTER(200) :: emb + CHARACTER(1024) :: emb span = NORM2(fairlead(1:2) - anchor(1:2)) IF (span <= 1.0e-9_wp*MAX(CD_ONE, SUM(l0))) RETURN e_h = (fairlead(1:2) - anchor(1:2))/span @@ -4193,13 +4224,7 @@ SUBROUTINE report_note(text) !! One initialisation note: printed on a standalone run, appended to init_note. CHARACTER(*), INTENT(IN) :: text IF (standalone_mode) WRITE (error_unit, '(A)') ' Note: '//TRIM(text)//'.' - IF (PRESENT(init_note)) THEN - IF (LEN_TRIM(init_note) > 0) THEN - init_note = TRIM(init_note)//NEW_LINE('a')//TRIM(text) - ELSE - init_note = TRIM(text) - END IF - END IF + IF (PRESENT(init_note)) CALL append_note_line(init_note, text) END SUBROUTINE report_note END SUBROUTINE build_one_hermite_cable @@ -4313,7 +4338,7 @@ SUBROUTINE solve_with(scale, dq_max) REAL(wp), INTENT(IN) :: scale REAL(wp), INTENT(OUT), OPTIONAL :: dq_max INTEGER :: it, es - CHARACTER(512) :: em + CHARACTER(1024) :: em CHARACTER(48) :: num_buf f_drag = CD_ZERO IF (has_drag) THEN @@ -4368,7 +4393,7 @@ SUBROUTINE attachment_static_drag(q, node, att, opts, frame_cs, f, ErrStat, ErrM CHARACTER(*), INTENT(OUT) :: ErrMsg INTEGER :: k, base, es REAL(wp) :: ug(3), ul(3), fd(3) - CHARACTER(200) :: em + 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 @@ -4517,16 +4542,16 @@ RECURSIVE SUBROUTINE hermite_static_primary(anchor, fairlead, l0, ea, ei, w, dia ! Anchor retreats tried for a line too long for its span (see seed_walk). INTEGER, PARAMETER :: WALK_MAX_TRIES = 6 LOGICAL :: walk_ok, fold - CHARACTER(400) :: walk_msg_c + CHARACTER(1024) :: walk_msg_c REAL(wp) :: walk_d, a_seed(3) - CHARACTER(512) :: walk_msg + CHARACTER(1024) :: walk_msg LOGICAL :: tensile, refine_all, planar_bed, walk_needed, laid REAL(wp) :: h_target REAL(wp) :: origin(2), a_l(3), f_l(3), seabed_z, seabed_slope, horizontal_tension, grounded_length REAL(wp) :: lambda0, ratio, span(2), span_len, t, xg, yg, zf, sx, sz, sxx, sxz, xl, yl REAL(wp) :: res_cont, cont_tol, phi, penetration, zfit(NFIT), fit_misfit, fine_limit, seed_bed, anchor_bed REAL(wp), ALLOCATABLE :: pos(:), q_seed(:), q_cont(:), curv_cont(:), knnode(:), tdir(:, :), stretch(:) - CHARACTER(512) :: em + CHARACTER(1024) :: em ErrStat = CD_HCSTAT_OK ErrMsg = '' @@ -4951,7 +4976,7 @@ SUBROUTINE laid_seed_positions(ok) REAL(wp) :: c, s, a_g(3), f_g(3), xl_, yl_ INTEGER :: e_, k_, es_ld LOGICAL :: conv_ld - CHARACTER(512) :: em_ld + CHARACTER(1024) :: em_ld ok = .FALSE. c = frame_cs(1) s = frame_cs(2) @@ -5036,7 +5061,7 @@ SUBROUTINE walked_compression(text) CHARACTER(*), INTENT(OUT) :: text TYPE(CD_HermiteBranchAuditType) :: audit_w INTEGER :: es_w, ios_w - CHARACTER(200) :: em_w + CHARACTER(1024) :: em_w text = '' CALL CD_HermiteCable_Branch_Audit(l0, q_cont, ea, audit_w, es_w, em_w) IF (es_w /= CD_HCSTAT_OK) RETURN @@ -5124,8 +5149,8 @@ SUBROUTINE walk_anchor() LOGICAL :: have_prev, energy, folded, fold_now REAL(wp) :: fit, path_len, r_td(2), p, up(3), tl, xb_w, yb_w, zb_w INTEGER :: k_td, kk, es_b - CHARACTER(512) :: em_b - CHARACTER(512) :: em_w + CHARACTER(1024) :: em_b + CHARACTER(1024) :: em_w ALLOCATE (q_try(6*nnode), q_new(6*nnode), q_prev(6*nnode), sref(nnode), curv_w(nnode)) sref(1) = CD_ZERO DO k = 2, nnode @@ -5328,7 +5353,7 @@ RECURSIVE SUBROUTINE graded_restart() LOGICAL :: planar, inadm_g, walked_sub INTEGER :: kend(2), iend, e_end, k, j, n_g, nf, es_g, slot REAL(wp) :: t_end, blayer - CHARACTER(512) :: em_g + CHARACTER(1024) :: em_g IF (PRESENT(refined_pass) .OR. fold) RETURN kend = 0 DO iend = 1, 2 @@ -5431,7 +5456,7 @@ RECURSIVE SUBROUTINE refined_restart() REAL(wp), ALLOCATABLE :: l0_r(:), q_r(:), q_ref_r(:), ea_r(:), ei_r(:), w_r(:), diam_r(:), dry_r(:) INTEGER, ALLOCATABLE :: fixed_r(:) INTEGER :: scale, scale_need, k, es_r, parent - CHARACTER(512) :: em_r + CHARACTER(1024) :: em_r LOGICAL :: inadm_r, walked_sub IF (PRESENT(refined_pass) .OR. fold) RETURN scale_need = bending_refine_scale(l0, ei, w) @@ -5630,7 +5655,7 @@ SUBROUTINE hermite_static_stable(l0_deck, l0, ea, ei, w, diam_deck, dry_deck, q, REAL(wp), ALLOCATABLE :: diam(:), dry(:), knnode(:), q_eval(:), curv(:) REAL(wp) :: res INTEGER :: i, ne, it, es - CHARACTER(512) :: em + CHARACTER(1024) :: em ErrStat = CD_DECKDRV_OK ErrMsg = '' @@ -5763,7 +5788,7 @@ SUBROUTINE audit_hermite_static(l0, q, ea, ei, w, diam, endconn_mode, physical, REAL(wp) :: zone(2), qe(12), t_end, total, allowance, hl_max, excess, denom LOGICAL :: report_c INTEGER :: ne, iend, e, es - CHARACTER(200) :: em + CHARACTER(1024) :: em physical = .FALSE. message = '' @@ -6238,15 +6263,31 @@ SUBROUTINE CD_Init_Deck_Aggregate(deck_path, dt, agg, ErrStat, ErrMsg, env_gravi END IF IF (PRESENT(forbid_deck_ambient)) THEN IF (forbid_deck_ambient) THEN + ! The two callers that forbid deck ambient fluid: the FAST.Farm shell (n_turbines >= 1) and + ! the standalone runner of a mixed EI=0/finite-EI deck. Each gets the advice of its route. IF (opts%has_wave) THEN - CALL fail(ErrStat, ErrMsg, 'CD_Init_Deck_Aggregate: this coupled mode runs the mooring in '// & - 'STILL WATER (no ambient fluid field covers the mooring span); remove the deck '// & - 'waves OPTION'); RETURN + IF (nturb > 0) THEN + CALL fail(ErrStat, ErrMsg, 'CD_Init_Deck_Aggregate: the deck waves OPTION is not supported in '// & + 'FAST.Farm: the shared mooring of a farm runs in STILL WATER (no fluid field spans the '// & + 'farm). Remove the waves OPTION'); RETURN + END IF + CALL fail(ErrStat, ErrMsg, 'CD_Init_Deck_Aggregate: the deck waves OPTION is not supported for a '// & + 'standalone mixed EI=0/finite-EI deck: this route runs the mooring in STILL WATER, because '// & + 'no ambient fluid field covers its span. Remove the waves OPTION, run a deck whose lines are '// & + 'all EI=0 or all finite-EI (those standalone routes evaluate the deck waves), or couple the '// & + 'deck to OpenFAST (CompMooring = 5) with SeaState, which supplies the waves'); RETURN END IF IF (opts%has_current .OR. opts%has_current_profile) THEN - CALL fail(ErrStat, ErrMsg, 'CD_Init_Deck_Aggregate: this coupled mode runs the mooring in '// & - 'STILL WATER (no ambient fluid field covers the mooring span); remove the deck '// & - 'current OPTION'); RETURN + IF (nturb > 0) THEN + CALL fail(ErrStat, ErrMsg, 'CD_Init_Deck_Aggregate: the deck current OPTION is not supported in '// & + 'FAST.Farm: the shared mooring of a farm runs in STILL WATER (no fluid field spans the '// & + 'farm). Remove the current OPTION'); RETURN + END IF + CALL fail(ErrStat, ErrMsg, 'CD_Init_Deck_Aggregate: the deck current OPTION is not supported for a '// & + 'standalone mixed EI=0/finite-EI deck: this route runs the mooring in STILL WATER, because '// & + 'no ambient fluid field covers its span. Remove the current OPTION, run a deck whose lines are '// & + 'all EI=0 or all finite-EI (those standalone routes evaluate the deck current), or couple the '// & + 'deck to OpenFAST (CompMooring = 5) with SeaState, which supplies the current'); RETURN END IF END IF END IF @@ -6679,6 +6720,22 @@ SUBROUTINE CD_Init_Deck_Aggregate(deck_path, dt, agg, ErrStat, ErrMsg, env_gravi IF (ErrStat /= CD_DECKDRV_OK) THEN CALL CD_End_Deck_Aggregate(agg); RETURN END IF + ! A static strain above the note level is named in the line's initialisation note (every route that + ! prints the notes of this summary shows it), and the standalone mixed route -- the caller that + ! asks for the range graphs -- also warns about coarse sections, as the single-topology driver does. + BLOCK + INTEGER :: il + CHARACTER(1024) :: strain_note + DO il = 1, SIZE(agg%init_lines) + CALL static_strain_note(agg%init_lines(il)%line_id, agg%init_lines(il)%fair_tension, sections, types, opts, & + strain_note) + IF (LEN_TRIM(strain_note) == 0) CYCLE + CALL append_note_line(agg%init_lines(il)%note, strain_note) + END DO + IF (PRESENT(range_files)) THEN + IF (range_files) CALL warn_coarse_sections(lines, sections) + END IF + END BLOCK ! Per moving slot, the driving turbine (0 outside farm mode) -- the SAME ! enumeration the coupled_positions override uses: the system's BOUND @@ -6768,7 +6825,7 @@ SUBROUTINE build_aggregate_control_table(ctrls, lines, points, rods, sections, t REAL(wp), ALLOCATABLE :: l0_deck(:), ea(:), mpl(:), diam(:), ei(:), gas(:), gj(:), i_rt(:), i_rn(:) REAL(wp) :: span CHARACTER(24) :: lid - CHARACTER(512) :: em + CHARACTER(1024) :: em ErrStat = CD_DECKDRV_OK ErrMsg = '' @@ -7212,7 +7269,7 @@ SUBROUTINE CD_End_Deck_Aggregate(agg) !! `cables` deallocated here). TYPE(CD_DeckAggregateType), INTENT(INOUT) :: agg INTEGER :: c, es - CHARACTER(240) :: em + CHARACTER(1024) :: em IF (agg%has_sys) CALL CD_End_System(agg%sys, es, em) agg%has_sys = .FALSE. agg%n_turbines = 0 @@ -7297,7 +7354,7 @@ SUBROUTINE run_deck_driver(deck_path, out_root, converged, ErrStat, ErrMsg) CHARACTER(NAMELEN), ALLOCATABLE :: channels(:) REAL(wp), ALLOCATABLE :: q_all(:), ten_all(:), end_all(:, :), end_vec(:, :, :) INTEGER, ALLOCATABLE :: q_off(:), ten_off(:), nn(:), ne(:) - CHARACTER(512) :: fail_msg + CHARACTER(1024) :: fail_msg TYPE(CD_ModelType), ALLOCATABLE :: models(:) TYPE(FiniteDeckModel), ALLOCATABLE :: finite_models(:) TYPE(CD_HFMF_ModuleType), ALLOCATABLE :: hermite_models(:) @@ -7307,7 +7364,7 @@ SUBROUTINE run_deck_driver(deck_path, out_root, converged, ErrStat, ErrMsg) TYPE(CD_LineInitSummary), ALLOCATABLE :: init_summaries(:) INTEGER :: nl, li, es, j, n_finite LOGICAL :: line_conv, has_line_outputs, has_finite, has_dyn_points, has_rigid6, hermite_standalone_eligible - CHARACTER(512) :: em + CHARACTER(1024) :: em converged = .FALSE. ErrStat = CD_DECKDRV_OK @@ -7387,6 +7444,7 @@ SUBROUTINE run_deck_driver(deck_path, out_root, converged, ErrStat, ErrMsg) CALL CD_Profile_Enter(CD_PROF_INIT) END IF CALL print_static_input_warnings(types, points, 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 ! about their pins, a rod pinned to a body with the body) @@ -7491,7 +7549,8 @@ SUBROUTINE run_deck_driver(deck_path, out_root, converged, ErrStat, ErrMsg) IF (ErrStat == CD_DECKDRV_OK .AND. opts%n_modes > 0) & CALL write_deck_modes_hermite(out_root, lines, opts, hermite_models, ErrStat, ErrMsg) IF (ErrStat == CD_DECKDRV_OK) THEN - CALL print_deck_init_report(deck_path, lines, points, sections, n_finite, init_summaries) + CALL print_deck_init_report(deck_path, lines, points, sections, n_finite, init_summaries, & + types=types, opts=opts) CALL write_hermite_dynamic_out(out_root, channels, lines, points, opts, hermite_models, & converged, ErrStat, ErrMsg, bathymetry=bathymetry) END IF @@ -7516,7 +7575,8 @@ SUBROUTINE run_deck_driver(deck_path, out_root, converged, ErrStat, ErrMsg) IF (opts%has_bathymetry_file) CALL CD_End_Bathymetry(bathymetry) RETURN END IF - CALL print_deck_init_report(deck_path, lines, points, sections, n_finite, init_summaries) + CALL print_deck_init_report(deck_path, lines, points, sections, n_finite, init_summaries, & + types=types, opts=opts) CALL write_finite_dynamic_out(out_root, channels, lines, points, opts, finite_models, & converged, ErrStat, ErrMsg, bathymetry=bathymetry) CALL end_finite_models(finite_models) @@ -7558,7 +7618,8 @@ SUBROUTINE run_deck_driver(deck_path, out_root, converged, ErrStat, ErrMsg) IF (opts%has_bathymetry_file) CALL CD_End_Bathymetry(bathymetry) RETURN END IF - CALL print_deck_init_report(deck_path, lines, points, sections, n_finite, init_summaries) + CALL print_deck_init_report(deck_path, lines, points, sections, n_finite, init_summaries, & + types=types, opts=opts) IF (opts%has_bathymetry_file) THEN CALL write_rod_dynamic_out(out_root, channels, rod_types, rods, lines, points, opts, point_system, & converged, ErrStat, ErrMsg, bathymetry=bathymetry) @@ -7591,7 +7652,8 @@ SUBROUTINE run_deck_driver(deck_path, out_root, converged, ErrStat, ErrMsg) IF (opts%has_bathymetry_file) CALL CD_End_Bathymetry(bathymetry) RETURN END IF - CALL print_deck_init_report(deck_path, lines, points, sections, n_finite, init_summaries) + CALL print_deck_init_report(deck_path, lines, points, sections, n_finite, init_summaries, & + types=types, opts=opts) IF (opts%has_bathymetry_file) THEN CALL write_rigid6_dynamic_out(out_root, channels, bodies, lines, points, opts, point_system, & converged, ErrStat, ErrMsg, bathymetry=bathymetry, rod_types=rod_types, & @@ -7624,7 +7686,8 @@ SUBROUTINE run_deck_driver(deck_path, out_root, converged, ErrStat, ErrMsg) IF (opts%has_bathymetry_file) CALL CD_End_Bathymetry(bathymetry) RETURN END IF - CALL print_deck_init_report(deck_path, lines, points, sections, n_finite, init_summaries) + CALL print_deck_init_report(deck_path, lines, points, sections, n_finite, init_summaries, & + types=types, opts=opts) CALL write_system_dynamic_out(out_root, channels, lines, points, opts, point_system, converged, & ErrStat, ErrMsg, failures=fails, bathymetry=bathymetry) CALL CD_End_System(point_system, es, em) @@ -7645,7 +7708,8 @@ SUBROUTINE run_deck_driver(deck_path, out_root, converged, ErrStat, ErrMsg) IF (opts%has_bathymetry_file) CALL CD_End_Bathymetry(bathymetry) RETURN END IF - CALL print_deck_init_report(deck_path, lines, points, sections, n_finite, init_summaries) + CALL print_deck_init_report(deck_path, lines, points, sections, n_finite, init_summaries, & + types=types, opts=opts) CALL write_dynamic_out(out_root, channels, lines, points, opts, models, converged, ErrStat, ErrMsg, & bathymetry=bathymetry) CALL end_models(models) @@ -7707,7 +7771,8 @@ SUBROUTINE run_deck_driver(deck_path, out_root, converged, ErrStat, ErrMsg) IF (converged) THEN CALL collect_raw_init_summaries(lines, points, ne, q_all, q_off, ten_all, ten_off, init_summaries, & end_ten=end_all, end_force=end_vec) - CALL print_deck_init_report(deck_path, lines, points, sections, n_finite, init_summaries) + CALL print_deck_init_report(deck_path, lines, points, sections, n_finite, init_summaries, & + types=types, opts=opts) IF (.NOT. (opts%has_wtrdpth .OR. opts%has_bathymetry_file)) & CALL warn_line_below_anchor(lines, points, sections, q_all, q_off) END IF @@ -7811,7 +7876,7 @@ SUBROUTINE init_one_model(ln, sections, types, points, opts, model, ErrStat, Err REAL(wp), PARAMETER :: factors(4) = [0.25_wp, 0.5_wp, 0.75_wp, CD_ONE] INTEGER :: j, i, e, es LOGICAL :: want_wave_cfg - CHARACTER(200) :: em + CHARACTER(1024) :: em ! static seabed friction of this line: lay azimuth override [rad] (unallocated: the ! default, the chord direction from the line's lower end) and as-laid tension [N] REAL(wp), ALLOCATABLE :: lay_az_opt @@ -8164,7 +8229,7 @@ SUBROUTINE init_one_syrope_model(types, syt, ln, lts, secs, anchor, fairlead, l0 REAL(wp), ALLOCATABLE :: sslow(:), stmax(:), kn(:), diam(:), cn(:), t_static(:) REAL(wp) :: eps0, t_ref, secant, total_l0, t_hist, eps_bar, t_mean_static INTEGER :: ne, e, es, n_owc, iter - CHARACTER(200) :: em + CHARACTER(1024) :: em CHARACTER(24) :: s_eps, s_lo, s_hi ! static seabed friction of this line: lay azimuth override [rad] and as-laid tension REAL(wp), ALLOCATABLE :: lay_az_opt @@ -8468,7 +8533,7 @@ SUBROUTINE end_models(models) !! Best-effort cleanup for partially initialized model arrays. TYPE(CD_ModelType), INTENT(INOUT) :: models(:) INTEGER :: i, es - CHARACTER(80) :: em + CHARACTER(1024) :: em DO i = 1, SIZE(models) CALL CD_End_Model(models(i), es, em) END DO @@ -8478,7 +8543,7 @@ SUBROUTINE end_finite_models(models) !! Best-effort cleanup for finite-EI dynamic deck model arrays. TYPE(FiniteDeckModel), INTENT(INOUT) :: models(:) INTEGER :: i, es - CHARACTER(80) :: em + CHARACTER(1024) :: em DO i = 1, SIZE(models) CALL CD_End_FiniteEI_Model(models(i)%model, es, em) IF (ALLOCATED(models(i)%l0)) DEALLOCATE (models(i)%l0) @@ -8806,7 +8871,7 @@ SUBROUTINE finite_lazy_wave_reference_and_state(anchor, fairlead, l0, nodes_ref, REAL(wp) :: chord(3), chord_len, chord_dir(3), lift(3), lift_norm, tan_a(3), tan_b(3) REAL(wp) :: handle_scale INTEGER :: nnode, es - CHARACTER(200) :: em + CHARACTER(1024) :: em ErrStat = CD_DECKDRV_OK ErrMsg = '' @@ -9212,7 +9277,7 @@ SUBROUTINE finite_environment_force(model, opts, time, q, v, f_ext, ErrStat, Err INTEGER :: idx(6) REAL(wp) :: xa(3), xb(3), va(3), vb(3), eta_a, eta_b REAL(wp) :: fluid_a(3), fluid_b(3), accel_a(3), accel_b(3), f2(6) - CHARACTER(160) :: em + CHARACTER(200) :: em ! per-element kinematics and Morison messages (at most 160 characters) f_ext = CD_ZERO ErrStat = CD_DECKDRV_OK @@ -9280,7 +9345,7 @@ SUBROUTINE finite_environment_load_banded(model, opts, time, q, v, free, kl, ku, INTEGER :: idx(6) REAL(wp) :: xa(3), xb(3), va(3), vb(3), eta_a, eta_b REAL(wp) :: fluid_a(3), fluid_b(3), accel_a(3), accel_b(3), f2(6), jq2(6, 6), jv2(6, 6) - CHARACTER(160) :: em + CHARACTER(200) :: em ! per-element kinematics and Morison messages (at most 160 characters) ErrStat = CD_DECKDRV_OK ErrMsg = '' @@ -9374,7 +9439,7 @@ SUBROUTINE finite_environment_node(opts, time, x, eta, fluid_velocity, fluid_acc CHARACTER(*), INTENT(OUT) :: ErrMsg REAL(wp) :: current_velocity(3) INTEGER :: es - CHARACTER(160) :: em + CHARACTER(200) :: em ! per-node kinematics messages (at most 160 characters) eta = CD_ZERO fluid_velocity = CD_ZERO @@ -9534,6 +9599,150 @@ SUBROUTINE print_static_input_warnings(types, points, lines, sections, opts) END IF END SUBROUTINE print_static_input_warnings + SUBROUTINE warn_coarse_sections(lines, sections) + !! Standard-output WARNINGS for a section too coarse for the line it belongs to: a section whose + !! segments (section length / NumSegs) are longer than COARSE_SECTION_FRACTION (1/8) of the + !! line's total length, i.e. coarser than a uniform eight-segment line. The rule looks only at + !! the segment length relative to the whole line, so it does not depend on how the line is + !! split into sections (an eight-segment uniform line written as two four-segment sections is + !! not reported). Each segment of an EI=0 line is a straight chord and each element of a + !! finite-EI line a cubic-Hermite span, so a one-element 100 m top section on a 520 m line + !! cannot follow the line shape there and shifts the fairlead tension by tens of percent. The + !! whole-line check of print_static_input_warnings (fewer than three segments) does not see a + !! coarse section inside a finely meshed line, and a line with fewer than three segments is + !! reported whole by that check, not here. + TYPE(DeckLine), INTENT(IN) :: lines(:) + TYPE(DeckSection), INTENT(IN) :: sections(:) + INTEGER :: i, j, nseg_line + REAL(wp) :: total, seg_len + CHARACTER(32) :: b1, b2, b3 + + DO i = 1, SIZE(lines) + total = CD_ZERO + nseg_line = 0 + DO j = 1, SIZE(sections) + IF (sections(j)%line_id /= lines(i)%id) CYCLE + total = total + sections(j)%length + nseg_line = nseg_line + sections(j)%nsegs + END DO + IF (.NOT. (total > CD_ZERO) .OR. nseg_line < 3) CYCLE + DO j = 1, SIZE(sections) + IF (sections(j)%line_id /= lines(i)%id .OR. sections(j)%nsegs < 1) CYCLE + seg_len = sections(j)%length/REAL(sections(j)%nsegs, wp) + ! (the relative 1e-9 keeps a uniform eight-segment line, split in any way, below the bound) + IF (seg_len <= COARSE_SECTION_FRACTION*total*(CD_ONE + 1.0e-9_wp)) CYCLE + WRITE (b1, '(F12.2)') sections(j)%length + WRITE (b2, '(F12.2)') seg_len + WRITE (b3, '(F6.1)') 100.0_wp*seg_len/total + WRITE (output_unit, '(A)') ' WARNING: LINE '//TRIM(int_to_str(lines(i)%id))//' section of type "'// & + TRIM(sections(j)%ltype_name)//'" ('//TRIM(ADJUSTL(b1))//' m in '//TRIM(int_to_str(sections(j)%nsegs))// & + ' segment(s)) has segments of '//TRIM(ADJUSTL(b2))//' m, '//TRIM(ADJUSTL(b3))// & + ' % of the line length: too coarse to follow the line shape there, which can shift the tensions '// & + 'by tens of percent; refine its NumSegs (this warning applies above 1/8 = 12.5 % of the line length, '// & + 'and a converged tension usually needs finer segments)' + END DO + END DO + END SUBROUTINE warn_coarse_sections + + SUBROUTINE append_note_line(buffer, text) + !! Append one initialisation note as a new text line of buffer. A note that does not fit + !! with room left for the omission marker is replaced by the marker, which ends the buffer, + !! so no note is ever cut short. Notes that ended with the marker in a shorter buffer (a + !! cable's notes copied into a line summary) still take a note that fits: it goes before + !! the marker, which stays last. + CHARACTER(*), INTENT(INOUT) :: buffer + CHARACTER(*), INTENT(IN) :: text + CHARACTER(*), PARAMETER :: OMITTED = 'further initialisation notes omitted' + INTEGER :: n, nb + IF (LEN_TRIM(text) == 0) RETURN + n = LEN_TRIM(buffer) + IF (n > 0) THEN + IF (n >= LEN(OMITTED)) THEN + IF (buffer(n - LEN(OMITTED) + 1:n) == OMITTED) THEN + nb = MAX(0, n - LEN(OMITTED) - 1) ! the notes before the marker and its line break + IF (nb > 0) THEN + IF (nb + 1 + LEN_TRIM(text) + 1 + LEN(OMITTED) <= LEN(buffer)) & + buffer = buffer(1:nb)//NEW_LINE('a')//TRIM(text)//NEW_LINE('a')//OMITTED + ELSE IF (LEN_TRIM(text) + 1 + LEN(OMITTED) <= LEN(buffer)) THEN + buffer = TRIM(text)//NEW_LINE('a')//OMITTED + END IF + RETURN + END IF + END IF + IF (n + 1 + LEN_TRIM(text) + 1 + LEN(OMITTED) <= LEN(buffer)) THEN + buffer = buffer(1:n)//NEW_LINE('a')//TRIM(text) + ELSE IF (n + 1 + LEN(OMITTED) <= LEN(buffer)) THEN + buffer = buffer(1:n)//NEW_LINE('a')//OMITTED + END IF + ELSE IF (LEN_TRIM(text) + 1 + LEN(OMITTED) <= LEN(buffer)) THEN + buffer = TRIM(text) + ELSE IF (LEN(OMITTED) <= LEN(buffer)) THEN + buffer = OMITTED + END IF + END SUBROUTINE append_note_line + + SUBROUTINE static_strain_note(line_id, tension, sections, types, opts, note) + !! The static initial state of a line stretched beyond OPTION maxStrain when it is given and + !! positive, or else STATIC_STRAIN_NOTE_DEFAULT (10 %; maxStrain 0 disables the dynamic guard, + !! not this note): the fairlead tension over the EA of the section at End A. A + !! line far shorter than its span converges at such a strain without any message, because + !! the dynamic strain guard (maxStrain) does not apply to the static solve. Only a note -- + !! the equilibrium and every output are unchanged. Types whose tension is not EA times + !! strain (Syrope working curves, load-dependent stiffness) are not assessed. + INTEGER, INTENT(IN) :: line_id + REAL(wp), INTENT(IN) :: tension + TYPE(DeckSection), INTENT(IN) :: sections(:) + TYPE(DeckLineType), INTENT(IN) :: types(:) + TYPE(DeckOptions), INTENT(IN) :: opts + CHARACTER(*), INTENT(OUT) :: note + INTEGER :: j, k + REAL(wp) :: strain, limit + CHARACTER(32) :: b1, b2, b3 + CHARACTER(64) :: source + + note = '' + IF (.NOT. (tension > CD_ZERO .AND. tension < HUGE(CD_ONE))) RETURN + DO j = 1, SIZE(sections) + IF (sections(j)%line_id /= line_id) CYCLE + k = find_type(types, sections(j)%ltype_name) + IF (k < 1) RETURN + IF (types(k)%is_syrope .OR. types(k)%elastic_mod == 3 .OR. .NOT. (types(k)%ea > CD_ZERO)) RETURN + strain = tension/types(k)%ea + limit = STATIC_STRAIN_NOTE_DEFAULT + IF (opts%has_max_strain .AND. opts%max_strain > CD_ZERO) THEN + limit = opts%max_strain + source = 'OPTION maxStrain' + ELSE IF (opts%has_max_strain) THEN + source = 'the note level used when maxStrain is 0' + ELSE + source = 'the note level used without maxStrain' + END IF + IF (.NOT. (strain > limit)) RETURN + CALL percent_text(100.0_wp*strain, b1) + CALL percent_text(100.0_wp*limit, b2) + WRITE (b3, '(ES10.3)') tension + note = 'LINE '//TRIM(int_to_str(line_id))//' is stretched to a static strain of '//TRIM(ADJUSTL(b1))// & + ' % at the fairlead (tension '//TRIM(ADJUSTL(b3))//' N over the EA of section type '// & + TRIM(types(k)%name)//'), above '//TRIM(ADJUSTL(b2))//' % ('//TRIM(source)// & + '): check the line length against the span and the EA. The dynamic maxStrain guard does '// & + 'not apply to the static solve' + RETURN + END DO + + CONTAINS + + SUBROUTINE percent_text(percent, text) + !! One decimal from 0.1 % up; a smaller value (a small maxStrain) keeps its leading digits. + REAL(wp), INTENT(IN) :: percent + CHARACTER(*), INTENT(OUT) :: text + IF (percent >= 0.1_wp) THEN + WRITE (text, '(F10.1)') percent + ELSE + WRITE (text, '(ES9.2)') percent + END IF + END SUBROUTINE percent_text + END SUBROUTINE static_strain_note + SUBROUTINE warn_line_below_anchor(lines, points, sections, q_all, q_off) !! Standard-output WARNING for a deck with no seabed (no WtrDpth or bathymetryFile) on !! which a line hangs below its lowest Fixed end by more than max(1 m, 1 % of its @@ -9609,7 +9818,7 @@ SUBROUTINE solve_one_line(ln, sections, types, points, opts, q, tension, converg REAL(wp), ALLOCATABLE :: kn(:) REAL(wp) :: anchor(3), fairlead(3), force_a(3), force_b(3) INTEGER :: ne, n_dof, i, j, ns, es - CHARACTER(200) :: em + CHARACTER(1024) :: em TYPE(CableSolverConfig) :: cfg TYPE(CD_StaticLineReport) :: report TYPE(CableCurrentLoad) :: cur @@ -9871,7 +10080,7 @@ SUBROUTINE parse_deck(path, types, bodies, rod_types, rods, points, lines, secti CHARACTER(3*DECK_RECLEN) :: row ! The whole header record: a title banner may carry "INPUT FILE" far to the right. CHARACTER(DECK_RECLEN) :: secname - CHARACTER(256) :: why + CHARACTER(1024) :: why ! Deck line of each OUTPUTS channel, for finalizer messages. INTEGER, ALLOCATABLE :: channel_lines(:) INTEGER :: nch_before, i_ch @@ -10548,7 +10757,7 @@ SUBROUTINE read_waterkin_records(path, deck_directory, opts, ErrStat, ErrMsg, li INTEGER, INTENT(OUT) :: lineno INTEGER :: unit, ios, k, nrow, wavekinmod, currentmod, row_status - CHARACTER(256) :: why + CHARACTER(1024) :: why ! Value lines are split into whitespace tokens and each value is parsed whole: a ! list-directed READ would stop an unquoted WaveKinFile path at its first '/' and ! read "0.5/2" as 0.5. @@ -10804,7 +11013,7 @@ SUBROUTINE read_wave_elevation_components(path, opts, dt_wave, wave_dir, fft_tma INTEGER :: unit, ios, n, n_window, j, k, nc, nraw, bracket, row_status, lineno CHARACTER(DECK_RECLEN) :: line - CHARACTER(256) :: why + CHARACTER(1024) :: why REAL(wp) :: te_row(2), tr, dt, tol, angle, ca, sa, scale, frac REAL(wp) :: cos_step, sin_step, cos_j, sin_j, cos_next, trig_norm REAL(wp), ALLOCATABLE :: times(:), eta_rows(:), sample_eta(:) @@ -11192,7 +11401,7 @@ SUBROUTINE read_table(name, nmin, nmax, headers, t) INTEGER :: unit, ios, st, lineno, nrow, nc_row LOGICAL :: started CHARACTER(DECK_RECLEN) :: line - CHARACTER(256) :: why + CHARACTER(1024) :: why CHARACTER(CD_DECK_PATHLEN) :: fpath ALLOCATE (t(nmax, 16)) fpath = path_join(dir, TRIM(name)) @@ -12820,7 +13029,7 @@ SUBROUTINE apply_equivalent_buoyancy(types, equivs, opts, ErrStat, ErrMsg) REAL(wp) :: mass_per_length(1) INTEGER :: i, j, idx, es - CHARACTER(200) :: em + CHARACTER(1024) :: em ErrStat = 0 ErrMsg = '' @@ -13202,6 +13411,7 @@ SUBROUTINE apply_option(line, opts, ErrStat, ErrMsg) CALL rd(val, opts%ramp_time, ErrStat, ErrMsg) CASE ('maxstrain', 'max_strain') CALL rd(val, opts%max_strain, ErrStat, ErrMsg) + opts%has_max_strain = ErrStat == 0 CASE ('streamorder', 'stream_order') CALL rd(val, x1, ErrStat, ErrMsg) IF (ErrStat == 0) THEN @@ -13969,7 +14179,7 @@ SUBROUTINE check_fixed_point_above_seabed(pt, z_floor, what, ErrStat, ErrMsg, z_ INTEGER, INTENT(OUT) :: ErrStat CHARACTER(*), INTENT(OUT) :: ErrMsg REAL(wp), INTENT(IN), OPTIONAL :: z_grid - CHARACTER(32) :: zs, fs, ts + CHARACTER(32) :: zs, fs, ts, ds REAL(wp) :: tol ErrStat = 0; ErrMsg = '' @@ -13989,10 +14199,13 @@ SUBROUTINE check_fixed_point_above_seabed(pt, z_floor, what, ErrStat, ErrMsg, z_ WRITE (zs, '(G0.8)') pt%pos(3) WRITE (fs, '(G0.8)') z_floor WRITE (ts, '(ES9.2)') tol + WRITE (ds, '(ES9.2)') z_floor - pt%pos(3) CALL fail(ErrStat, ErrMsg, 'POINT '//TRIM(int_to_str(pt%id))//' (Fixed) lies below the seabed: z = '// & TRIM(ADJUSTL(zs))//' m is under '//what//' = '//TRIM(ADJUSTL(fs))// & - ' m by more than the '//TRIM(ADJUSTL(ts))//' m seabed tolerance; place the anchor on (or above) '// & - 'the seabed') + ' m by '//TRIM(ADJUSTL(ds))//' m, more than the '//TRIM(ADJUSTL(ts))//' m seabed tolerance '// & + '(max(1 mm, 1e-5 |seabed z|); an anchor within it rests on the seabed and is placed on it, '// & + 'a deeper one is never moved silently). Set the anchor Z to '//TRIM(ADJUSTL(fs))// & + ' m (the seabed) or higher') END SUBROUTINE check_fixed_point_above_seabed SUBROUTINE check_fixed_points_on_bathymetry(points, bathymetry, ErrStat, ErrMsg) @@ -14005,7 +14218,7 @@ SUBROUTINE check_fixed_points_on_bathymetry(points, bathymetry, ErrStat, ErrMsg) CHARACTER(*), INTENT(OUT) :: ErrMsg INTEGER :: i, es REAL(wp) :: z_floor, z_grid - CHARACTER(160) :: em + CHARACTER(1024) :: em ErrStat = 0; ErrMsg = '' DO i = 1, SIZE(points) @@ -14070,6 +14283,7 @@ SUBROUTINE finalize_checks(types, bodies, rod_types, rods, points, lines, sectio INTEGER :: i, j, idx, nsec_for_line, body_id, body_idx, rod_id, rod_idx, na_ref, nb_ref INTEGER :: nstep LOGICAL :: grid_ok + REAL(wp) :: displaced_mass CHARACTER(NAMELEN) :: ta, tb ErrStat = 0; ErrMsg = '' at_line = 0 @@ -14773,8 +14987,34 @@ SUBROUTINE finalize_checks(types, bodies, rod_types, rods, points, lines, sectio IF (.NOT. ((tb == 'coupled' .OR. tb == 'vessel') .AND. & points(find_point(points, lines(i)%nodeA))%turbine_id > 0 .AND. & points(find_point(points, lines(i)%nodeB))%turbine_id > 0)) THEN - CALL fail(ErrStat, ErrMsg, 'LINE End B (NodeB) must be a Fixed (anchor) point '// & - '(exception: a FAST.Farm shared line between two Turbine fairleads)'); RETURN + ! The Connect-point split is a workaround only for an EI=0 line: in a deck with + ! Connect points a finite-EI cable needs a Fixed End B and cannot end on a Connect point. + BLOCK + INTEGER :: js, ks + LOGICAL :: shared_finite + shared_finite = .FALSE. + DO js = 1, SIZE(sections) + IF (sections(js)%line_id /= lines(i)%id) CYCLE + ks = find_type(types, sections(js)%ltype_name) + IF (ks < 1) CYCLE + IF (types(ks)%ei > CD_ZERO) shared_finite = .TRUE. + END DO + IF (shared_finite) THEN + CALL fail(ErrStat, ErrMsg, 'finite-EI LINE '//TRIM(int_to_str(lines(i)%id))//' End B (NodeB, '// & + 'POINT '//TRIM(int_to_str(lines(i)%nodeB))//', '//TRIM(tb)//') must be a Fixed '// & + '(anchor) point: a line between two moving points (a shared line) is not supported, '// & + 'except a FAST.Farm shared line between two Turbine fairleads. A finite-EI line '// & + 'cannot be split at a Connect point either (beside Connect points a finite-EI cable '// & + 'needs a Fixed End B and cannot end on a Connect point): anchor it on a Fixed point, '// & + 'or model the shared span with EI=0 line types split at a Connect point'); RETURN + END IF + END BLOCK + CALL fail(ErrStat, ErrMsg, 'LINE '//TRIM(int_to_str(lines(i)%id))//' End B (NodeB, POINT '// & + TRIM(int_to_str(lines(i)%nodeB))//', '//TRIM(tb)//') must be a Fixed (anchor) point: a line '// & + 'between two moving points (a shared line) is not supported, except a FAST.Farm shared line '// & + 'between two Turbine fairleads. Workaround for this EI=0 line: split it into two lines '// & + 'that meet at a Connect point in the middle (each line then ends on one Coupled point; the '// & + 'deck becomes dynamic and needs dtM and TMax)'); RETURN END IF ELSE IF (points(find_point(points, lines(i)%nodeA))%pos(3) < & @@ -14856,11 +15096,20 @@ SUBROUTINE finalize_checks(types, bodies, rod_types, rods, points, lines, sectio ! route has the cubic-Hermite arch seed and may proceed. A dynamic standalone ! run gets its clock from dtM; the executable's metadata scan also admits a ! clock-free static aggregate solve. Unsupported endpoint coupling is rejected - ! before initialization. - IF (types(idx)%mass <= opts%rhoW*QUARTER_PI*types(idx)%diam**2) THEN + ! before initialization. The rejection condition is mass <= displaced mass; within it, an + ! EI=0 type whose mass lies in the neutral band just below the displaced mass is named weightless. + displaced_mass = opts%rhoW*QUARTER_PI*types(idx)%diam**2 + IF (types(idx)%mass <= displaced_mass) THEN IF (types(idx)%ei <= CD_ZERO .OR. & (.NOT. opts%has_dtm .AND. .NOT. caller_driven .AND. & .NOT. (allow_static_finite_ei .AND. .NOT. opts%has_tmax))) THEN + IF (types(idx)%ei <= CD_ZERO .AND. types(idx)%mass > displaced_mass*(CD_ONE - NEUTRAL_BUOYANCY_REL_TOL)) THEN + CALL fail(ErrStat, ErrMsg, 'LINE TYPE "'//TRIM(types(idx)%name)//'" is neutrally buoyant (its dry '// & + 'mass equals the displaced water mass to within a relative 1e-6), so an EI=0 line of it is '// & + 'weightless and slack: its static shape is indeterminate (every slack shape balances). '// & + 'Give the line type weight (a larger MassDenInAir), or a finite EI with a tension that '// & + 'holds it taut'); RETURN + END IF CALL fail(ErrStat, ErrMsg, 'LINE TYPE "'//TRIM(types(idx)%name)// & '" is net-buoyant (dry mass <= displaced water mass): buoyant / lazy-wave '// & 'sections require a dynamic finite-EI deck'); RETURN @@ -15037,7 +15286,7 @@ SUBROUTINE write_out(out_root, channels, lines, points, ne, q_all, q_off, ten_al TYPE(CD_BathymetryType), INTENT(IN), OPTIONAL :: bathymetry INTEGER :: unit, ios, i, nch, li, line_id, comp, es CHARACTER(LEN(out_root) + 8) :: path - CHARACTER(512) :: em + CHARACTER(1024) :: em REAL(wp) :: val TYPE(CD_RangeSet) :: ranges ErrStat = 0; ErrMsg = '' @@ -15258,7 +15507,7 @@ SUBROUTINE open_dynamic_line_outputs(out_root, lines, models, pos_units, ten_uni INTEGER :: i, ios, ndof, nnode, ne, node, seg, es CHARACTER(LEN(out_root) + 32) :: path - CHARACTER(256) :: em + CHARACTER(1024) :: em ErrStat = CD_DECKDRV_OK ErrMsg = '' @@ -15320,7 +15569,7 @@ SUBROUTINE open_dynamic_system_line_outputs(out_root, lines, system, pos_units, INTEGER :: i, ios, ndof, nnode, ne, node, seg, es CHARACTER(LEN(out_root) + 32) :: path - CHARACTER(256) :: em + CHARACTER(1024) :: em ErrStat = CD_DECKDRV_OK ErrMsg = '' @@ -15382,7 +15631,7 @@ SUBROUTINE write_dynamic_line_outputs(time, lines, models, pos_units, ten_units, CHARACTER(*), INTENT(OUT) :: ErrMsg INTEGER :: i, ndof, nnode, ne, es - CHARACTER(256) :: em + CHARACTER(1024) :: em ErrStat = CD_DECKDRV_OK ErrMsg = '' @@ -15492,7 +15741,7 @@ SUBROUTINE write_dynamic_system_line_outputs(time, lines, system, pos_units, ten CHARACTER(*), INTENT(OUT) :: ErrMsg INTEGER :: i, ndof, nnode, ne, es - CHARACTER(256) :: em + CHARACTER(1024) :: em ErrStat = CD_DECKDRV_OK ErrMsg = '' @@ -15607,7 +15856,7 @@ SUBROUTINE write_dynamic_finite_line_outputs(time, lines, models, pos_units, ten CHARACTER(*), INTENT(OUT) :: ErrMsg INTEGER :: i, nnode, ndof, ne, es - CHARACTER(256) :: em + CHARACTER(1024) :: em ErrStat = CD_DECKDRV_OK ErrMsg = '' @@ -15769,7 +16018,7 @@ SUBROUTINE write_dynamic_out(out_root, channels, lines, points, opts, models, co INTEGER :: miss_count, consecutive_miss, max_consecutive_miss INTEGER :: recovery_event_count, recovery_max_substeps_used CHARACTER(LEN(out_root) + 8) :: path - CHARACTER(256) :: em + CHARACTER(1024) :: em LOGICAL :: step_converged, stalled REAL(wp) :: t, first_miss_time, last_miss_time TYPE(MotionTable) :: motion @@ -15944,7 +16193,7 @@ SUBROUTINE write_system_dynamic_out(out_root, channels, lines, points, opts, sys INTEGER, ALLOCATABLE :: pos_units(:), ten_units(:) INTEGER :: miss_count, consecutive_miss, max_consecutive_miss CHARACTER(LEN(out_root) + 8) :: path - CHARACTER(256) :: em + CHARACTER(1024) :: em LOGICAL :: step_converged, stalled REAL(wp) :: t, first_miss_time, last_miss_time TYPE(HydroUpdateWorkspace) :: hydro_work @@ -16121,7 +16370,7 @@ SUBROUTINE CD_Replay_Deck_Failures(system, lines, points, failures, target_faile INTEGER :: k, j, li, i, es, maxid INTEGER, ALLOCATABLE :: model_lines(:) - CHARACTER(256) :: em + CHARACTER(1024) :: em ErrStat = CD_DECKDRV_OK ErrMsg = '' @@ -16183,7 +16432,7 @@ SUBROUTINE check_and_fire_failures(system, lines, points, failures, t, ErrStat, REAL(wp), ALLOCATABLE :: tension(:) REAL(wp) :: ten_end LOGICAL :: fire - CHARACTER(256) :: em + CHARACTER(1024) :: em ErrStat = CD_DECKDRV_OK ErrMsg = '' @@ -16318,7 +16567,7 @@ SUBROUTINE write_rigid6_dynamic_out(out_root, channels, bodies, lines, points, o INTEGER, ALLOCATABLE :: pos_units(:), ten_units(:) INTEGER :: miss_count, consecutive_miss, max_consecutive_miss CHARACTER(LEN(out_root) + 8) :: path - CHARACTER(256) :: em + CHARACTER(1024) :: em LOGICAL :: step_converged, stalled REAL(wp) :: t, first_miss_time, last_miss_time TYPE(HydroUpdateWorkspace) :: hydro_work @@ -16491,7 +16740,7 @@ SUBROUTINE write_rod_dynamic_out(out_root, channels, rod_types, rods, lines, poi INTEGER, ALLOCATABLE :: rod_pos_units(:) INTEGER :: miss_count, consecutive_miss, max_consecutive_miss CHARACTER(LEN(out_root) + 8) :: path - CHARACTER(256) :: em + CHARACTER(1024) :: em LOGICAL :: step_converged, stalled REAL(wp) :: t, first_miss_time, last_miss_time TYPE(HydroUpdateWorkspace) :: hydro_work @@ -17073,7 +17322,7 @@ SUBROUTINE object_channel_value(ch, val, found, rigid, rods, points, opts, time, INTEGER :: oid, node, qty, ib, ir, body_of, es REAL(wp) :: ang(3), rr(3, 3), axis(3), half, ends(3), f6(6), ten(2), sub, arm(3), phi, beta TYPE(RodState) :: rs - CHARACTER(256) :: em + CHARACTER(1024) :: em REAL(wp), PARAMETER :: R2D = 45.0_wp/QUARTER_PI val = CD_ZERO @@ -17213,7 +17462,7 @@ SUBROUTINE point_line_force(points, pidx, system, mb, f, ErrStat, ErrMsg) CHARACTER(*), INTENT(OUT) :: ErrMsg INTEGER :: k, c, es REAL(wp) :: f_first(3), f_last(3), fl(3) - CHARACTER(200) :: em + CHARACTER(1024) :: em f = CD_ZERO ErrStat = CD_DECKDRV_OK ErrMsg = '' @@ -17343,7 +17592,7 @@ SUBROUTINE rod_net_wrench(rs, body_of, points, opts, time, f6, ten, sub, ErrStat REAL(wp) :: f(3), m(3), f2(3), m2(3), a6(6, 6), d6(6, 6), pa(3), pb(3), fe(3, 2), eta(2), za, zb, s0, s1 REAL(wp) :: wv(3), wa(3) INTEGER :: ip, e, es - CHARACTER(200) :: em + CHARACTER(1024) :: em f6 = CD_ZERO ten = CD_ZERO @@ -17593,7 +17842,7 @@ SUBROUTINE write_objects_dynamic_out(out_root, channels, bodies, rod_types, rods TYPE(DeckRod), ALLOCATABLE :: own(:) INTEGER :: unit, ios, step, nstep, k, es, nsub, isub REAL(wp) :: t, acc(3), alpha(3), dv0(6), dts, ts - CHARACTER(160) :: em + CHARACTER(1024) :: em TYPE(DriverProgress) :: progress converged = .TRUE. @@ -17922,7 +18171,7 @@ SUBROUTINE write_multibody_dynamic_out(deck_path, out_root, channels, types, bod LOGICAL :: step_converged, stalled REAL(wp) :: t, first_miss_time, last_miss_time, rb(3, 3) CHARACTER(LEN(out_root) + 8) :: path - CHARACTER(256) :: em + CHARACTER(1024) :: em TYPE(HydroUpdateWorkspace) :: hydro_work TYPE(ModelOutputWorkspace) :: output_work TYPE(DriverProgress) :: progress @@ -17967,7 +18216,13 @@ SUBROUTINE write_multibody_dynamic_out(deck_path, out_root, channels, types, bod IF (is_fin(i)) THEN IF (TRIM(points(pb)%ptype) /= 'fixed') THEN CALL fail(ErrStat, ErrMsg, 'finite-EI LINE '//TRIM(int_to_str(lines(i)%id))//' in a mixed-topology '// & - 'deck needs a Fixed End B (the cable is driven at End A)'); RETURN + 'deck needs a Fixed End B (the cable is driven at End A), but End B is POINT '// & + TRIM(int_to_str(points(pb)%id))//' ('//TRIM(points(pb)%ptype)//'). A finite-EI cable that '// & + 'ends on a Connect/Free/Coupled point (a junction with other lines, a buoy or a pliant-wave '// & + 'hang-off) '// & + 'is not supported in a deck with Connect/Free points, bodies or rods (the multibody '// & + 'march). Anchor the cable on a Fixed point, or run the cable and the lines it joins as '// & + 'separate decks'); RETURN END IF IF (TRIM(points(pa)%ptype) == 'free' .OR. TRIM(points(pa)%ptype) == 'connect' .OR. & point_on_point3_body(points(pa), bodies)) THEN @@ -17976,8 +18231,14 @@ SUBROUTINE write_multibody_dynamic_out(deck_path, out_root, channels, types, bod 'a rod end or a Fixed point'); RETURN END IF IF (TRIM(points(pa)%ptype) == 'coupled' .OR. TRIM(points(pa)%ptype) == 'vessel') THEN - CALL fail(ErrStat, ErrMsg, 'finite-EI LINE '//TRIM(int_to_str(lines(i)%id))//': a Coupled End A '// & - 'needs motionFile coupling, which a mixed-topology deck does not support'); RETURN + CALL fail(ErrStat, ErrMsg, 'finite-EI LINE '//TRIM(int_to_str(lines(i)%id))//': a Coupled/Vessel End A '// & + '(POINT '//TRIM(int_to_str(points(pa)%id))//') would need motionFile coupling to drive it, '// & + 'which a mixed-topology deck with Connect/Free points or bodies (marched as one multibody '// & + 'system) does not support. Attach the cable to a Rigid6 body, a rod end or a Fixed point; or '// & + 'remove the Connect/Free points so the deck becomes a coupled mixed deck (EI=0 lines on the '// & + 'Coupled point directly), which a host (OpenFAST CompMooring=5 or the C API) drives and the '// & + 'standalone driver runs with its Coupled points held still (that route takes no motionFile '// & + 'either)'); RETURN END IF IF (lines(i)%endconn_mode(1) /= CD_ENDCONN_PINNED .AND. TRIM(points(pa)%ptype) /= 'fixed') THEN ! a clamped or elastic End A on a body or rod: implicit (monolithic step) only @@ -18110,7 +18371,8 @@ SUBROUTINE write_multibody_dynamic_out(deck_path, out_root, channels, types, bod ALLOCATE (sum_cab(0)) END IF summaries = [sum_sys, sum_cab] - CALL print_deck_init_report(deck_path, lines, points, sections, n_finite, summaries) + CALL print_deck_init_report(deck_path, lines, points, sections, n_finite, summaries, & + types=types, opts=opts) ! ---- objects ---- CALL init_rigid6_states(bodies, points, mb%rigid, ErrStat, ErrMsg, rod_types, rods, allow_no_points=.TRUE.) @@ -18302,7 +18564,7 @@ SUBROUTINE probe_record(col, time) BLOCK REAL(wp) :: ke, se INTEGER :: es_p - CHARACTER(200) :: em_p + CHARACTER(1024) :: em_p CALL CD_HermiteCable_Dyn_Energy(mb%cables(1)%line, ke, se, es_p, em_p) probe_rec(23, col) = ke + se IF (es_p /= CD_HCDYN_OK) probe_rec(23, col) = -HUGE(CD_ONE) @@ -18477,7 +18739,7 @@ SUBROUTINE mb_cable_drive(mb, c, dt, ErrStat, ErrMsg) CHARACTER(*), INTENT(OUT) :: ErrMsg REAL(wp) :: xa(3), va(3), aa(3), dcm(3, 3), wa(3), ala(3) INTEGER :: es - CHARACTER(300) :: em + CHARACTER(1024) :: em ErrStat = CD_DECKDRV_OK ErrMsg = '' mb%cables(c)%dt = dt @@ -18502,7 +18764,7 @@ SUBROUTINE mb_cable_committed_loads(mb, c, f, m, ErrStat, ErrMsg) INTEGER, INTENT(OUT) :: ErrStat CHARACTER(*), INTENT(OUT) :: ErrMsg INTEGER :: es - CHARACTER(300) :: em + CHARACTER(1024) :: em ErrStat = CD_DECKDRV_OK ErrMsg = '' CALL CD_HFMF_CalcOutput(mb%cables(c), f, es, em, y_moment=m) @@ -18787,7 +19049,7 @@ SUBROUTINE mb_group_solve(m6b, rhsb, xb, wb, has_body, nc, m6c, rhsc, pinw, rc, INTEGER :: k, n, o, nb REAL(wp) :: p(3), l(3), xk(6) REAL(wp), ALLOCATABLE :: amat(:, :), bvec(:) - CHARACTER(160) :: em + CHARACTER(1024) :: em ErrStat = CD_DECKDRV_OK ErrMsg = '' @@ -18943,7 +19205,7 @@ SUBROUTINE mb_scatter(mb, points, ErrStat, ErrMsg) INTEGER :: es, ir, k, base INTEGER :: bases(2) REAL(wp) :: arms(3, 2) - CHARACTER(160) :: em + CHARACTER(1024) :: em ErrStat = CD_DECKDRV_OK ErrMsg = '' IF (.NOT. mb%has_sys) RETURN @@ -18974,7 +19236,7 @@ SUBROUTINE mb_line_loads(mb, ErrStat, ErrMsg) INTEGER, INTENT(OUT) :: ErrStat CHARACTER(*), INTENT(OUT) :: ErrMsg INTEGER :: es, c - CHARACTER(160) :: em + CHARACTER(1024) :: em ErrStat = CD_DECKDRV_OK ErrMsg = '' IF (mb%has_sys) THEN @@ -19145,7 +19407,7 @@ SUBROUTINE mb_step_once(mb, points, opts, time, dt, converged, stalled, n_iter, TYPE(CD_BathymetryType), INTENT(IN), OPTIONAL :: bathymetry INTEGER :: ib, ir, c, es REAL(wp) :: x(3), v(3), a(3) - CHARACTER(160) :: em + CHARACTER(1024) :: em converged = .TRUE. stalled = .FALSE. @@ -19478,7 +19740,7 @@ SUBROUTINE mb_imp_scatter(mb, points, ErrStat, ErrMsg) CHARACTER(*), INTENT(OUT) :: ErrMsg INTEGER :: ir, k, base, p, es, bases(2) REAL(wp) :: arms(3, 2) - CHARACTER(160) :: em + CHARACTER(1024) :: em ErrStat = CD_DECKDRV_OK ErrMsg = '' IF (.NOT. mb%has_sys) RETURN @@ -19846,7 +20108,7 @@ RECURSIVE SUBROUTINE mb_step_implicit(mb, points, opts, time, dt, converged, sta INTEGER, PARAMETER :: TAN_MAX_AGE = 20 REAL(wp) :: rho, am, af, beta_na, gam_na, t_af, h, fac, dth, worst, tol_it, am_p, gam_p, beta_p REAL(wp), ALLOCATABLE :: x(:), xp(:), r(:), rp(:), jac(:, :), dx(:), kg(:, :), ga(:, :), rscale(:) - CHARACTER(160) :: em + CHARACTER(1024) :: em converged = .FALSE. stalled = .FALSE. @@ -20397,7 +20659,7 @@ FUNCTION line_attachment_stiffness(system, dof) RESULT(katt) REAL(wp) :: katt(3, 3) REAL(wp) :: t(3), chord(3), lc_len, k_ax, ten, el(3), ll, eye(3, 3) INTEGER :: i, j, lo, nc, es, node, far, nn, ee - CHARACTER(160) :: em + CHARACTER(1024) :: em katt = CD_ZERO eye = CD_ZERO @@ -20734,7 +20996,7 @@ SUBROUTINE step_rod_once(system, points, opts, rod_state, time, dt, converged, s INTEGER :: ir, es REAL(wp) :: dv0(6), acc(3), alpha(3), arm(3) - CHARACTER(160) :: em + CHARACTER(1024) :: em TYPE(RigidBodyState) :: no_parent(0) converged = .FALSE. @@ -21095,7 +21357,7 @@ SUBROUTINE step_prescribed_rod_system(system, points, opts, motion, rod_state, t TYPE(CD_BathymetryType), INTENT(IN), OPTIONAL :: bathymetry INTEGER :: es - CHARACTER(160) :: em + CHARACTER(1024) :: em converged = .FALSE. stalled = .FALSE. @@ -21143,7 +21405,7 @@ SUBROUTINE apply_rod_states_to_system(system, points, rod_state, work, ErrStat, CHARACTER(*), INTENT(OUT) :: ErrMsg INTEGER :: es - CHARACTER(160) :: em + CHARACTER(1024) :: em ErrStat = CD_DECKDRV_OK ErrMsg = '' @@ -21272,7 +21534,9 @@ SUBROUTINE rod_seabed_contact(rod, opts, force, moment, load_dv, ErrStat, ErrMsg arm = MATMUL(rod%rot_mat, [s, CD_ZERO, CD_ZERO]) r_eval = rod%r + arm v_eval = rod%v + cross3(rod%omega, arm) - CALL deck_seabed_floor_at(r_eval(1), r_eval(2), opts, has_floor, z_floor, ErrStat, ErrMsg, bathymetry) + ! (a floor query message is at most 126 characters: it resets only that share of ErrMsg) + CALL deck_seabed_floor_at(r_eval(1), r_eval(2), opts, has_floor, z_floor, ErrStat, & + ErrMsg(1:MIN(LEN(ErrMsg), 200)), bathymetry) IF (ErrStat /= CD_DECKDRV_OK) RETURN IF (.NOT. has_floor) CYCLE penetration = z_floor - r_eval(3) @@ -21906,7 +22170,7 @@ SUBROUTINE fluid_at(xq, s, uq, duq, etaq, pdq, want_pdyn) LOGICAL, INTENT(IN) :: want_pdyn INTEGER :: es, ih REAL(wp) :: tq - CHARACTER(160) :: em + CHARACTER(200) :: em ! per-node kinematics messages (at most 160 characters) uq = CD_ZERO duq = CD_ZERO @@ -22233,7 +22497,7 @@ SUBROUTINE solve_body_equilibrium_core(types, bodies, rod_types, rods, points, l INTEGER :: nobj, n, i, j, k, it, inner, info, worst, jk LOGICAL :: ok, only_points REAL(wp) :: sc, rnorm, rnorm_try, mu, step_cap, len_min, dmax, trust, pred - CHARACTER(160) :: lin_msg + CHARACTER(1024) :: lin_msg CHARACTER(24) :: b1 ErrStat = CD_DECKDRV_OK @@ -22770,7 +23034,7 @@ SUBROUTINE own_loads(xs, fk, mk, cen, sc_out, good) TYPE(RodState), ALLOCATABLE :: rst(:) REAL(wp) :: f(3), m(3), f2(3), m2(3), w6(6, 6), a6(6, 6), d3(3, 3), meff, u(3), xb(3), rb(3, 3) INTEGER :: kk, es_l, ib - CHARACTER(512) :: em_l + CHARACTER(1024) :: em_l TYPE(DeckRod) :: rg good = .FALSE. @@ -23270,7 +23534,7 @@ SUBROUTINE prepare_line(jl, es_out, em_out) TYPE(CD_LineSection), ALLOCATABLE :: secs(:) REAL(wp), ALLOCATABLE :: mpl(:), diam(:), load(:, :) INTEGER :: js, ii, ns, ne, es_l - CHARACTER(200) :: em_l + CHARACTER(1024) :: em_l es_out = CD_DECKDRV_OK em_out = '' @@ -23357,7 +23621,7 @@ SUBROUTINE cached_line_solve(jl, pts, es_out, em_out, want_k, k_ok) REAL(wp) :: anchor(3), fairlead(3), fa(3), fb(3) INTEGER :: nn, ii, es_l, nit LOGICAL :: conv, stalled, at_floor - CHARACTER(512) :: em_l + CHARACTER(1024) :: em_l es_out = CD_DECKDRV_OK em_out = '' @@ -23486,7 +23750,7 @@ SUBROUTINE condensed_end_stiffness(jl, zf, ok) INTEGER, ALLOCATABLE :: free(:), ipiv(:) REAL(wp) :: kee(6, 6), blk(3, 3), chord(3), tt(3), ll, tens, dfx, eye(3, 3), bp(3, 3) INTEGER :: nn, ne, nf, kl, ku, ldab, ee, na, nb, ii, jj, es_l, info, pair, ni, nj, si, sj - CHARACTER(200) :: em_l + CHARACTER(1024) :: em_l EXTERNAL :: dgbsv ok = .FALSE. @@ -23780,8 +24044,8 @@ SUBROUTINE hermite_end_loads(jl, fm, km, rot) TYPE(DeckPoint), ALLOCATABLE :: pc(:) REAL(wp) :: rclamp(3, 3), dclamp(3), dtb INTEGER :: node, es - CHARACTER(512) :: note - CHARACTER(300) :: em + CHARACTER(1024) :: note + CHARACTER(1024) :: em fm = CD_ZERO km = CD_ZERO lnc = lines(jl) @@ -24453,7 +24717,7 @@ SUBROUTINE CD_Rod_HostWrench(system, rt, loads, k, force, moment, ErrStat, ErrMs INTEGER :: ir, base, j, n, es REAL(wp) :: arm(3), f_end(3, 2), f_env(3), m_env(3), f_sb(3), m_sb(3), added6(6, 6), drag6(6, 6) REAL(wp) :: dv(6, 6), acc6(6), ig(3, 3), mc(3), acc(3), alpha(3), pin_host(9) - CHARACTER(160) :: em + CHARACTER(1024) :: em force = CD_ZERO moment = CD_ZERO @@ -25133,7 +25397,7 @@ SUBROUTINE step_rigid6_once(system, points, opts, rigid, time, dt, converged, st INTEGER :: ib, es, p, base REAL(wp) :: dv0(6), acc(3), alpha(3) - CHARACTER(160) :: em + CHARACTER(1024) :: em ! detached: the active free points that are not deck points -- the reserve points a line ! FAILURE moved line ends onto. They are integrated on their line-end loads; every other ! point follows its body or stays held. @@ -25300,7 +25564,7 @@ SUBROUTINE rigid_start_loads(system, q, v, a, loads, dload_da, ErrStat, ErrMsg) INTEGER, INTENT(OUT) :: ErrStat CHARACTER(*), INTENT(OUT) :: ErrMsg INTEGER :: es - CHARACTER(160) :: em + CHARACTER(1024) :: em ErrStat = CD_DECKDRV_OK ErrMsg = '' @@ -25403,7 +25667,7 @@ SUBROUTINE step_prescribed_rigid6_system(system, points, opts, motion, rigid, ti TYPE(HydroUpdateWorkspace), INTENT(INOUT) :: hydro_work INTEGER :: es - CHARACTER(160) :: em + CHARACTER(1024) :: em converged = .FALSE. stalled = .FALSE. @@ -25454,7 +25718,7 @@ SUBROUTINE apply_rigid6_states_to_system(system, points, rigid, work, ErrStat, E CHARACTER(*), INTENT(OUT) :: ErrMsg INTEGER :: es - CHARACTER(160) :: em + CHARACTER(1024) :: em ErrStat = CD_DECKDRV_OK ErrMsg = '' @@ -25873,7 +26137,7 @@ SUBROUTINE rigid6_wet_fraction(body, opts, time, phi, ErrStat, ErrMsg) CHARACTER(*), INTENT(OUT) :: ErrMsg INTEGER :: es REAL(wp) :: x_cb(3), eta, u(3), du(3), r_e, h - CHARACTER(160) :: em + CHARACTER(200) :: em ! kinematics messages (at most 160 characters) ErrStat = CD_DECKDRV_OK ErrMsg = '' @@ -25996,7 +26260,7 @@ SUBROUTINE rigid6_environment_force(body, opts, time, force, effective_mass, dra INTEGER :: es REAL(wp) :: eta, rel(3), rel_speed, fluid_velocity(3), fluid_acceleration(3), phi, fk - CHARACTER(160) :: em + CHARACTER(200) :: em ! kinematics messages (at most 160 characters) ErrStat = CD_DECKDRV_OK ErrMsg = '' @@ -26077,7 +26341,7 @@ SUBROUTINE write_hermite_dynamic_out(out_root, channels, lines, points, opts, ca INTEGER :: recovery_events, recovery_max_used INTEGER, ALLOCATABLE :: pos_units(:), ten_units(:) CHARACTER(LEN(out_root) + 8) :: path - CHARACTER(256) :: em + CHARACTER(1024) :: em REAL(wp) :: t, up(3), uv(3), ua(3), tensile_force, tensile_threshold, tensile_xi, tensile_time, turn ! Per-step tangent turn [deg] above which the time-step note is printed (see below). REAL(wp), PARAMETER :: TURN_NOTE_FORCE_BLEND = 0.25_wp, TURN_NOTE_CONFIG_BLEND = 0.1_wp @@ -26391,7 +26655,7 @@ SUBROUTINE write_hermite_static_element_profile(out_root, lines, cables, ErrStat REAL(wp) :: qr(12), l0, arc_start, arc_end, curvature_peak, u_curvature_internal, & u_curvature_public, arc_peak, moment_peak, minimum_resultant, minimum_u_internal, & minimum_u_public, maximum_resultant, maximum_u_internal, maximum_u_public - CHARACTER(200) :: em + CHARACTER(1024) :: em CHARACTER(LEN(out_root) + 20) :: path CHARACTER(1) :: tab @@ -26462,7 +26726,7 @@ SUBROUTINE apply_motion_to_hermite_cables(cables, lines, points, motion, time_in CHARACTER(*), INTENT(OUT) :: ErrMsg INTEGER :: i, pidx, es REAL(wp) :: q(3), v(3), a(3) - CHARACTER(200) :: em + CHARACTER(1024) :: em ErrStat = CD_DECKDRV_OK; ErrMsg = '' IF (SIZE(cables) /= SIZE(lines)) THEN @@ -26500,7 +26764,8 @@ SUBROUTINE update_hermite_deck_fluid(cables, opts, time, ErrStat, ErrMsg) CHARACTER(*), INTENT(OUT) :: ErrMsg INTEGER :: i, j, nn, es REAL(wp) :: eta, wv(3), wa(3) - CHARACTER(200) :: em + CHARACTER(1024) :: em + CHARACTER(200) :: em_k ! a per-node current or wave kinematics message (at most 160 characters) ErrStat = CD_DECKDRV_OK; ErrMsg = '' IF (.NOT. (opts%has_current .OR. opts%has_wave)) RETURN DO i = 1, SIZE(cables) @@ -26514,15 +26779,15 @@ SUBROUTINE update_hermite_deck_fluid(cables, opts, time, ErrStat, ErrMsg) fv = CD_ZERO; fa = CD_ZERO; wl = CD_ZERO DO j = 1, nn IF (opts%has_current) THEN - fv(:, j) = deck_current_velocity(opts, xyz(3, j), es, em) + fv(:, j) = deck_current_velocity(opts, xyz(3, j), es, em_k) IF (es /= CD_HYDRO_OK) THEN - CALL hermite_fluid_fail('current profile', em); RETURN + CALL hermite_fluid_fail('current profile', em_k); RETURN END IF END IF IF (opts%has_wave) THEN - CALL deck_wave_kinematics(opts, xyz(1, j), xyz(2, j), xyz(3, j), time, eta, wv, wa, es, em) + CALL deck_wave_kinematics(opts, xyz(1, j), xyz(2, j), xyz(3, j), time, eta, wv, wa, es, em_k) IF (es /= CD_HYDRO_OK) THEN - CALL hermite_fluid_fail('wave kinematics', em); RETURN + CALL hermite_fluid_fail('wave kinematics', em_k); RETURN END IF fv(:, j) = fv(:, j) + wv; fa(:, j) = wa; wl(j) = eta END IF @@ -26557,7 +26822,7 @@ SUBROUTINE write_hermite_model_row(unit, time, channels, lines, points, cables, INTEGER :: i, line_id, li, pidx, comp, pp, mi, k, es REAL(wp) :: val, f(3), fl(3) CHARACTER(NAMELEN) :: lo - CHARACTER(200) :: em + CHARACTER(1024) :: em ErrStat = CD_DECKDRV_OK; ErrMsg = '' IF (PRESENT(ranges)) THEN DO li = 1, SIZE(lines) @@ -26769,7 +27034,7 @@ SUBROUTINE write_finite_dynamic_out(out_root, channels, lines, points, opts, mod INTEGER, ALLOCATABLE :: pos_units(:), ten_units(:) INTEGER :: miss_count, consecutive_miss, max_consecutive_miss CHARACTER(LEN(out_root) + 8) :: path - CHARACTER(256) :: em + CHARACTER(1024) :: em LOGICAL :: step_converged, stalled REAL(wp) :: t, first_miss_time, last_miss_time TYPE(MotionTable) :: motion @@ -27087,7 +27352,7 @@ SUBROUTINE write_deck_modes_ei0(out_root, types, points, lines, sections, opts, REAL(wp), ALLOCATABLE :: kmat(:, :), mmat(:, :), floor_z(:) LOGICAL, ALLOCATABLE :: free(:) INTEGER :: li, n, nm, es, kd - CHARACTER(512) :: em + CHARACTER(1024) :: em ALLOCATE (models(0)) ! defined descriptor for the INTENT(OUT) dummy (-Wmaybe-uninitialized at -O0) CALL init_deck_models_from_parsed(types, points, lines, sections, opts, models, ErrStat, ErrMsg) @@ -27149,7 +27414,7 @@ SUBROUTINE write_deck_modes_hermite(out_root, lines, opts, cables, ErrStat, ErrM REAL(wp), ALLOCATABLE :: kmat(:, :), mmat(:, :), floor_z(:) LOGICAL, ALLOCATABLE :: free(:) INTEGER :: li, n, nm, es, kd - CHARACTER(512) :: em + CHARACTER(1024) :: em ErrStat = CD_DECKDRV_OK ErrMsg = '' @@ -27408,7 +27673,7 @@ SUBROUTINE update_system_point_hydro(system, points, opts, time, work, ErrStat, INTEGER :: i, es REAL(wp) :: eta, wave_velocity(3), wave_acceleration(3) REAL(wp) :: fluid_density - CHARACTER(160) :: em + CHARACTER(1024) :: em LOGICAL :: points_ready ErrStat = CD_DECKDRV_OK @@ -27495,7 +27760,7 @@ SUBROUTINE update_system_line_hydro(system, opts, time, work, ErrStat, ErrMsg, i INTEGER :: i, j, ndof, nnode, es REAL(wp) :: eta, wave_velocity(3), wave_acceleration(3) LOGICAL :: at_initial_condition, changed - CHARACTER(160) :: em + CHARACTER(1024) :: em ErrStat = CD_DECKDRV_OK ErrMsg = '' @@ -27595,7 +27860,7 @@ SUBROUTINE update_wave_models(models, opts, time, work, ErrStat, ErrMsg, initial INTEGER :: i, j, ndof, nnode, es REAL(wp) :: eta, wave_velocity(3), wave_acceleration(3) LOGICAL :: at_initial_condition, changed - CHARACTER(160) :: em + CHARACTER(1024) :: em ErrStat = CD_DECKDRV_OK ErrMsg = '' @@ -27815,7 +28080,7 @@ SUBROUTINE check_model_plausibility(model, max_strain, line_id, time, ErrStat, E INTEGER :: e, na, nb, worst_elem REAL(wp) :: strain, worst_strain - CHARACTER(200) :: detail + CHARACTER(1024) :: detail ErrStat = CD_DECKDRV_OK ErrMsg = '' @@ -28022,7 +28287,7 @@ SUBROUTINE write_planned_row(unit, time, channels, lines, points, work, label, E INTEGER :: i, k, n, li, off, nd, ne, nnode, stride, es LOGICAL :: has_motion, ok REAL(wp) :: val, q_point(3), v_point(3), a_point(3) - CHARACTER(160) :: em + CHARACTER(1024) :: em ErrStat = CD_DECKDRV_OK ErrMsg = '' @@ -28125,7 +28390,7 @@ SUBROUTINE write_planned_row(unit, time, channels, lines, points, work, label, E SUBROUTINE sample_ranges() !! Sample every line with a range file or TDP channel at this row's committed state. INTEGER :: il, es_r - CHARACTER(512) :: em_r + CHARACTER(1024) :: em_r DO il = 1, SIZE(lines) IF (.NOT. CD_Range_Needs_Sample(work%rset, il)) CYCLE IF (PRESENT(models)) THEN @@ -28180,7 +28445,7 @@ SUBROUTINE fetch_state(il, fetched) INTEGER, INTENT(IN) :: il LOGICAL, INTENT(OUT) :: fetched INTEGER :: o, m, es - CHARACTER(160) :: msg + CHARACTER(1024) :: msg fetched = work%state_row(il) == work%row IF (fetched) RETURN o = work%state_off(il) @@ -28208,7 +28473,7 @@ SUBROUTINE end_tension_override(il, inode, nel, v) INTEGER, INTENT(IN) :: il, inode, nel REAL(wp), INTENT(INOUT) :: v INTEGER :: es_o - CHARACTER(160) :: msg_o + CHARACTER(1024) :: msg_o IF (inode /= 1 .AND. inode /= nel + 1) RETURN IF (PRESENT(models)) THEN CALL line_model_end_tension(models(il), inode, nel + 1, v, es_o, msg_o) @@ -28228,7 +28493,7 @@ SUBROUTINE fetch_tension(il, fetched) INTEGER, INTENT(IN) :: il LOGICAL, INTENT(OUT) :: fetched INTEGER :: o, m, es - CHARACTER(160) :: msg + CHARACTER(1024) :: msg fetched = work%ten_row(il) == work%row IF (fetched) RETURN o = work%ten_off(il) @@ -28253,7 +28518,7 @@ SUBROUTINE line_sizes(il, sized, tension_sized) INTEGER, INTENT(IN) :: il LOGICAL, INTENT(OUT) :: sized, tension_sized INTEGER :: es, ndof_l, ne_l - CHARACTER(160) :: msg + CHARACTER(1024) :: msg tension_sized = .FALSE. IF (PRESENT(models)) THEN ndof_l = CD_Model_NDOF(models(il), es, msg) @@ -28520,7 +28785,7 @@ SUBROUTINE CD_Classify_Dynamic_Completion(label, nstep, miss_count, max_consecut INTEGER, INTENT(OUT) :: ErrStat CHARACTER(*), INTENT(OUT) :: ErrMsg - CHARACTER(512) :: msg_buf + CHARACTER(1024) :: msg_buf INTEGER :: ios ErrStat = CD_DECKDRV_OK ErrMsg = '' @@ -28551,7 +28816,7 @@ SUBROUTINE system_channel_value(ch, lines, points, system, work, val, ErrStat, E INTEGER :: li, pidx, comp, kind, node, ndof, nnode, es, ne, inode REAL(wp) :: q_point(3), v_point(3), a_point(3) CHARACTER(NAMELEN) :: lo - CHARACTER(160) :: em + CHARACTER(1024) :: em ErrStat = CD_DECKDRV_OK ErrMsg = '' @@ -28696,7 +28961,7 @@ SUBROUTINE finite_model_channel_value(ch, lines, points, models, work, val, ErrS INTEGER :: li, pidx, comp, kind, node, nnode, es, inode, ppos, midx CHARACTER(NAMELEN) :: lo - CHARACTER(160) :: em + CHARACTER(1024) :: em ErrStat = CD_DECKDRV_OK ErrMsg = '' @@ -28833,7 +29098,7 @@ SUBROUTINE finite_model_tension(deck_model, tension, work, ErrStat, ErrMsg) INTEGER :: e, es, nnode REAL(wp) :: xa(3), xb(3), length - CHARACTER(160) :: em + CHARACTER(1024) :: em tension = CD_ZERO ErrStat = CD_DECKDRV_OK @@ -28873,7 +29138,7 @@ SUBROUTINE model_channel_value(ch, lines, points, models, work, val, ErrStat, Er INTEGER :: li, pidx, comp, kind, node, ndof, nnode, es, ne, inode, midx CHARACTER(NAMELEN) :: lo - CHARACTER(160) :: em + CHARACTER(1024) :: em ErrStat = CD_DECKDRV_OK ErrMsg = '' @@ -29015,7 +29280,7 @@ SUBROUTINE model_point_channel_value(point_id, comp, lines, points, models, work CHARACTER(*), INTENT(OUT) :: ErrMsg INTEGER :: i, es, ndof, nnode, internal_node, ppos - CHARACTER(160) :: em + CHARACTER(1024) :: em ErrStat = CD_DECKDRV_OK ErrMsg = '' @@ -29068,7 +29333,7 @@ INTEGER FUNCTION model_nelem_from_line(line, model, ErrStat, ErrMsg) RESULT(ne) CHARACTER(*), INTENT(OUT) :: ErrMsg INTEGER :: ndof, es - CHARACTER(160) :: em + CHARACTER(1024) :: em ndof = CD_Model_NDOF(model, es, em) IF (es /= CD_MODEL_OK) THEN @@ -29099,7 +29364,7 @@ SUBROUTINE seed_finite_initial_acceleration(models, opts, ErrStat, ErrMsg) INTEGER :: i, es LOGICAL :: use_live_env - CHARACTER(160) :: em + CHARACTER(1024) :: em ErrStat = CD_DECKDRV_OK ErrMsg = '' @@ -29172,7 +29437,7 @@ SUBROUTINE step_finite_held_models(models, opts, time, dt, converged, stalled, n INTEGER :: i, es, line_iter, active_model LOGICAL :: line_converged, line_stalled, use_motion, use_live_env, line_has_live_load - CHARACTER(160) :: em + CHARACTER(1024) :: em converged = .TRUE. stalled = .FALSE. @@ -29349,7 +29614,7 @@ SUBROUTINE finite_motion_targets(model, line, points, motion, time_index, q_ft, INTEGER, INTENT(OUT) :: ErrStat CHARACTER(*), INTENT(OUT) :: ErrMsg INTEGER :: ndof, pa, pb, es - CHARACTER(160) :: em + CHARACTER(1024) :: em ErrStat = CD_DECKDRV_OK ErrMsg = '' ndof = SIZE(q_ft) @@ -29379,7 +29644,7 @@ SUBROUTINE step_held_models(models, dt, recovery_max_substeps, converged, stalle INTEGER :: i, j, ndof, nc, es, line_iter, line_substeps LOGICAL :: line_converged, line_stalled - CHARACTER(160) :: em + CHARACTER(1024) :: em converged = .TRUE. stalled = .FALSE. @@ -29450,7 +29715,7 @@ SUBROUTINE step_motion_models(models, lines, points, motion, time_index, dt, rec INTEGER :: i, ndof, es, line_iter, line_substeps LOGICAL :: line_converged, line_stalled - CHARACTER(160) :: em + CHARACTER(1024) :: em converged = .TRUE. stalled = .FALSE. @@ -29502,7 +29767,7 @@ SUBROUTINE apply_motion_to_models(models, lines, points, motion, time_index, Err INTEGER :: i, j, ndof, nc, es INTEGER, ALLOCATABLE :: coupled_dofs(:) REAL(wp), ALLOCATABLE :: qc(:), vc(:), ac(:) - CHARACTER(160) :: em + CHARACTER(1024) :: em TYPE(LineStepWorkspace) :: work ErrStat = CD_DECKDRV_OK @@ -29566,7 +29831,7 @@ SUBROUTINE apply_motion_to_finite_models(models, lines, points, motion, time_ind INTEGER :: dofs(6) REAL(wp) :: q_vals(6), v_vals(6), a_vals(6) LOGICAL :: do_recompute - CHARACTER(160) :: em + CHARACTER(1024) :: em ErrStat = CD_DECKDRV_OK ErrMsg = '' @@ -29604,7 +29869,7 @@ SUBROUTINE prescribed_full_state(model, line, points, motion, time_index, q, v, CHARACTER(*), INTENT(OUT) :: ErrMsg INTEGER :: ndof, es, pa, pb - CHARACTER(160) :: em + CHARACTER(1024) :: em ErrStat = CD_DECKDRV_OK ErrMsg = '' @@ -29741,7 +30006,7 @@ SUBROUTINE read_motion_file(path, points, opts, motion, ErrStat, ErrMsg, include CHARACTER(DECK_RECLEN) :: roll_tok REAL(wp) :: t, qv(3), vv(3), av(3), tol, row(11), trow(21), rq(3, 3), rp(3) CHARACTER(DECK_RECLEN) :: line - CHARACTER(256) :: why + CHARACTER(1024) :: why LOGICAL, ALLOCATABLE :: seen(:, :), turb_seen(:, :) LOGICAL :: accept_rod_points, accept_body_points, grid_ok INTEGER :: jturb @@ -30071,7 +30336,7 @@ SUBROUTINE read_vessel_record(path, opts, motion, rref, vref, aref, ErrStat, Err CHARACTER(*), INTENT(OUT) :: ErrMsg REAL(wp), PARAMETER :: D2R = QUARTER_PI/45.0_wp CHARACTER(DECK_RECLEN) :: line - CHARACTER(256) :: why + CHARACTER(1024) :: why INTEGER :: unit, ios, lineno, ntok, nform, row_status, it, off REAL(wp) :: row(20), tol, qn LOGICAL, ALLOCATABLE :: seen(:) @@ -30177,7 +30442,7 @@ SUBROUTINE read_rao_table(path, rao, ErrStat, ErrMsg) CHARACTER(*), INTENT(OUT) :: ErrMsg INTEGER, PARAMETER :: MAXH = 361, MAXP = 2000 CHARACTER(DECK_RECLEN) :: line - CHARACTER(256) :: why + CHARACTER(1024) :: why CHARACTER(DECK_RECLEN) :: tok INTEGER :: unit, ios, lineno, nh, np, np_first, row_status, i, j, k, es INTEGER, ALLOCATABLE :: perm_p(:), perm_h(:) @@ -30185,7 +30450,7 @@ SUBROUTINE read_rao_table(path, rao, ErrStat, ErrMsg) REAL(wp), ALLOCATABLE :: heads(:), pers(:, :), amp(:, :, :), ph(:, :, :) REAL(wp), ALLOCATABLE :: amp_s(:, :, :), ph_s(:, :, :), per_s(:), head_s(:) LOGICAL :: found, ok - CHARACTER(200) :: em + CHARACTER(1024) :: em ErrStat = CD_DECKDRV_OK; ErrMsg = '' ! read buffers at the table limits (about 75 MB); STAT keeps a failed allocation a clean error @@ -30336,7 +30601,7 @@ SUBROUTINE synthesize_vessel_rao(path, opts, motion, rref, vref, aref, ErrStat, REAL(wp) :: cb, sb, r, rd, rdd, x6(6), v6(6), a6(6) INTEGER :: nc, i, it, es, nclamp LOGICAL :: clamped - CHARACTER(200) :: em + CHARACTER(1024) :: em ErrStat = CD_DECKDRV_OK; ErrMsg = '' rref = CD_ZERO; vref = CD_ZERO; aref = CD_ZERO @@ -30775,7 +31040,7 @@ SUBROUTINE line_model_anchor_force(model, lo, val, ErrStat, ErrMsg) CHARACTER(*), INTENT(OUT) :: ErrMsg REAL(wp) :: f_first(3), f_last(3) INTEGER :: es - CHARACTER(160) :: em + CHARACTER(1024) :: em val = CD_ZERO ErrStat = CD_DECKDRV_OK @@ -30839,7 +31104,7 @@ SUBROUTINE point_force_value(ch, lines, models, val, ErrStat, ErrMsg) CHARACTER(*), INTENT(OUT) :: ErrMsg INTEGER :: pidx, comp, k, es REAL(wp) :: f(3), f_first(3), f_last(3) - CHARACTER(160) :: em + CHARACTER(1024) :: em ErrStat = CD_DECKDRV_OK ErrMsg = '' @@ -30875,7 +31140,7 @@ SUBROUTINE system_point_force_value(ch, system, val, ErrStat, ErrMsg) CHARACTER(*), INTENT(OUT) :: ErrMsg INTEGER :: pidx, comp, k, es REAL(wp) :: f(3), f_first(3), f_last(3) - CHARACTER(160) :: em + CHARACTER(1024) :: em ErrStat = CD_DECKDRV_OK ErrMsg = '' @@ -31314,7 +31579,7 @@ SUBROUTINE collect_aggregate_init_summaries(lines, agg, ErrStat, ErrMsg) INTEGER :: i, es REAL(wp) :: tension, declination, azimuth, fair_force(3), f_first(3) CHARACTER(NAMELEN) :: cten, cdec, cazi - CHARACTER(240) :: em + CHARACTER(1024) :: em ErrStat = CD_DECKDRV_OK ErrMsg = '' @@ -31401,7 +31666,7 @@ SUBROUTINE collect_model_init_summaries(lines, points, models, summaries, ErrSta INTEGER :: i, es REAL(wp) :: tension, declination, azimuth, f_first(3), fair_force(3) CHARACTER(NAMELEN) :: cten, cdec, cazi - CHARACTER(160) :: em + CHARACTER(1024) :: em ErrStat = CD_DECKDRV_OK; ErrMsg = '' ALLOCATE (summaries(SIZE(lines))) @@ -31435,7 +31700,7 @@ SUBROUTINE collect_system_init_summaries(lines, points, system, summaries, ErrSt INTEGER :: i, es REAL(wp) :: tension, declination, azimuth, f_first(3), fair_force(3) CHARACTER(NAMELEN) :: cten, cdec, cazi - CHARACTER(160) :: em + CHARACTER(1024) :: em ErrStat = CD_DECKDRV_OK; ErrMsg = '' ALLOCATE (summaries(SIZE(lines))) @@ -31510,7 +31775,7 @@ SUBROUTINE collect_hermite_init_summaries(lines, cables, summaries, ErrStat, Err END DO END SUBROUTINE collect_hermite_init_summaries - SUBROUTINE print_deck_init_report(deck_path, lines, points, sections, n_finite, summaries) + SUBROUTINE print_deck_init_report(deck_path, lines, points, sections, n_finite, summaries, types, opts) !! The initialization report goes to stderr (see doc/cli.rst). CHARACTER(*), INTENT(IN) :: deck_path TYPE(DeckLine), INTENT(IN) :: lines(:) @@ -31518,8 +31783,11 @@ SUBROUTINE print_deck_init_report(deck_path, lines, points, sections, n_finite, TYPE(DeckSection), INTENT(IN) :: sections(:) INTEGER, INTENT(IN) :: n_finite TYPE(CD_LineInitSummary), INTENT(IN) :: summaries(:) + TYPE(DeckLineType), INTENT(IN), OPTIONAL :: types(:) + TYPE(DeckOptions), INTENT(IN), OPTIONAL :: opts INTEGER :: i REAL(wp) :: f_incl + CHARACTER(1024) :: strain_note WRITE (error_unit, '(A)') ' Parsing CableDyn input file: '//TRIM(deck_path) WRITE (error_unit, '(A,I0,A,I0,A,I0,A,I0,A,I0,A)') & @@ -31545,6 +31813,10 @@ SUBROUTINE print_deck_init_report(deck_path, lines, points, sections, n_finite, WRITE (error_unit, '(A,F9.3,A,F9.3,A,F9.3,A)') ' line tangent: inclination=', & summaries(i)%fair_inclination, ' deg, declination=', summaries(i)%fair_declination, & ' deg, azimuth=', summaries(i)%fair_azimuth, ' deg' + IF (PRESENT(types) .AND. PRESENT(opts)) THEN + CALL static_strain_note(summaries(i)%line_id, summaries(i)%fair_tension, sections, types, opts, strain_note) + IF (LEN_TRIM(strain_note) > 0) WRITE (error_unit, '(A)') ' Note: '//TRIM(strain_note)//'.' + END IF END DO WRITE (error_unit, '(A)') ' CableDyn initialization completed.' END SUBROUTINE print_deck_init_report @@ -31587,7 +31859,7 @@ SUBROUTINE range_setup(rset, lines, channels, opts, nnodes, by_id, ErrStat, ErrM INTEGER, ALLOCATABLE :: ids(:) LOGICAL, ALLOCATABLE :: want_r(:), want_t(:) INTEGER :: i, k, n, line_id, comp, es - CHARACTER(512) :: em + CHARACTER(1024) :: em n = SIZE(nnodes) ALLOCATE (ids(n), want_r(n), want_t(n)) @@ -31638,7 +31910,7 @@ SUBROUTINE range_setup_planned(rset, lines, channels, opts, ErrStat, ErrMsg, mod TYPE(CD_HFMF_ModuleType), INTENT(IN), OPTIONAL :: cables(:) TYPE(CD_BathymetryType), INTENT(IN), OPTIONAL :: bathymetry INTEGER :: nnodes(SIZE(lines)), il, es - CHARACTER(160) :: em + CHARACTER(1024) :: em ErrStat = CD_DECKDRV_OK ErrMsg = '' @@ -31668,7 +31940,7 @@ SUBROUTINE range_write(rset, out_root, ErrStat, ErrMsg) INTEGER, INTENT(OUT) :: ErrStat CHARACTER(*), INTENT(OUT) :: ErrMsg INTEGER :: es - CHARACTER(512) :: em + CHARACTER(1024) :: em CALL CD_Range_Write_Files(rset, out_root, es, em) CALL range_status(es, em, ErrStat, ErrMsg) END SUBROUTINE range_write @@ -31710,7 +31982,7 @@ SUBROUTINE range_sample_model(model, rl, ErrStat, ErrMsg) INTEGER, INTENT(OUT) :: ErrStat CHARACTER(*), INTENT(OUT) :: ErrMsg INTEGER :: nn, es - CHARACTER(160) :: em + CHARACTER(1024) :: em ErrStat = CD_DECKDRV_OK ErrMsg = '' @@ -31762,7 +32034,7 @@ SUBROUTINE range_sample_fmodel(fmodel, rl, ErrStat, ErrMsg) CHARACTER(*), INTENT(OUT) :: ErrMsg INTEGER :: nn, ne, e, j, inode, es REAL(wp) :: xa(3), xb(3), length, kc(3), kr(3) - CHARACTER(160) :: em + CHARACTER(1024) :: em ErrStat = CD_DECKDRV_OK ErrMsg = '' @@ -31809,7 +32081,8 @@ SUBROUTINE range_sample_cable(cable, rl, ErrStat, ErrMsg) CHARACTER(*), INTENT(OUT) :: ErrMsg INTEGER :: nn, ne, e, j, k, inode, es REAL(wp) :: curv, bend - CHARACTER(200) :: em + CHARACTER(200) :: em ! per-element curvature messages (at most 55 characters) + CHARACTER(1024) :: em_rec ! the one node-value recovery message of the sample ErrStat = CD_DECKDRV_OK ErrMsg = '' @@ -31838,11 +32111,11 @@ SUBROUTINE range_sample_cable(cable, rl, ErrStat, ErrMsg) ! equilibrium node values, one pass over the elements straight into the public-order rows ! (internal node i is public node nn + 1 - i); the segment tensions (internal order) stay ! in rl%ten_e for the .t.out row - CALL CD_HermiteCable_Dyn_Node_Recovery(cable%line, es, em, tension=rl%val(CD_RQ_TENSION, nn:1:-1), & + CALL CD_HermiteCable_Dyn_Node_Recovery(cable%line, es, em_rec, tension=rl%val(CD_RQ_TENSION, nn:1:-1), & curvature=rl%val(CD_RQ_CURVATURE, nn:1:-1), & bend_moment=rl%val(CD_RQ_BEND, nn:1:-1), segment_tension=rl%ten_e) IF (es /= CD_HCDYN_OK) THEN - CALL fail_solve(ErrStat, ErrMsg, 'range-graph node-value recovery failed: '//TRIM(em)); RETURN + CALL fail_solve(ErrStat, ErrMsg, 'range-graph node-value recovery failed: '//TRIM(em_rec)); RETURN END IF ELSE CALL range_sample_cable_element(ErrStat, ErrMsg) @@ -31915,7 +32188,7 @@ SUBROUTINE aggregate_line_positions(system, cables, line_is_cable, line_obj_inde INTEGER, INTENT(OUT) :: ErrStat CHARACTER(*), INTENT(OUT) :: ErrMsg INTEGER :: nn, j, k, inode, obj, es - CHARACTER(200) :: em + CHARACTER(1024) :: em ErrStat = CD_DECKDRV_OK ErrMsg = '' @@ -31967,7 +32240,7 @@ SUBROUTINE range_setup_aggregate(rset, lines, channels, opts, has_sys, system, c TYPE(CD_BathymetryType), INTENT(IN), OPTIONAL :: bathymetry INTEGER, ALLOCATABLE :: nnodes(:) INTEGER :: k, obj, es - CHARACTER(512) :: em + CHARACTER(1024) :: em ErrStat = CD_DECKDRV_OK ErrMsg = '' @@ -32013,7 +32286,7 @@ SUBROUTINE CD_Deck_Range_Sample_Aggregate(rset, has_sys, system, cables, line_is INTEGER, INTENT(OUT) :: ErrStat CHARACTER(*), INTENT(OUT) :: ErrMsg INTEGER :: k, obj, es - CHARACTER(512) :: em + CHARACTER(1024) :: em ErrStat = CD_DECKDRV_OK ErrMsg = '' @@ -32057,7 +32330,7 @@ SUBROUTINE aggregate_tdp_value(ch, system, cables, line_is_cable, line_obj_index INTEGER, INTENT(OUT) :: ErrStat CHARACTER(*), INTENT(OUT) :: ErrMsg INTEGER :: line_id, comp, nn, es - CHARACTER(512) :: em + CHARACTER(1024) :: em val = CD_ZERO ErrStat = CD_DECKDRV_OK @@ -32128,7 +32401,7 @@ SUBROUTINE CD_Eval_Aggregate_Channel(ch, has_sys, system, cables, line_is_cable, LOGICAL :: found INTEGER :: line_id, node, kind, comp, pidx, es, k, c REAL(wp) :: qp(3), vp(3), ap(3), f(3), f_first(3), f_last(3), fl(3) - CHARACTER(200) :: em + CHARACTER(1024) :: em ErrStat = CD_DECKDRV_OK ErrMsg = '' @@ -32304,7 +32577,7 @@ SUBROUTINE CD_Eval_Aggregate_Segment_Tensions(line_id, has_sys, system, cables, CHARACTER(*), INTENT(OUT) :: ErrMsg INTEGER :: obj, ne, es - CHARACTER(200) :: em + CHARACTER(1024) :: em ErrStat = CD_DECKDRV_OK ErrMsg = '' @@ -32443,7 +32716,7 @@ SUBROUTINE line_model_end_tension(model, inode, nnode, val, ErrStat, ErrMsg) CHARACTER(*), INTENT(OUT) :: ErrMsg REAL(wp) :: f_first(3), f_last(3) INTEGER :: es - CHARACTER(160) :: em + CHARACTER(1024) :: em val = CD_ZERO ErrStat = CD_DECKDRV_OK @@ -32475,7 +32748,7 @@ SUBROUTINE eval_system_line_channel(system, li, ch, val, ErrStat, ErrMsg) CHARACTER(NAMELEN) :: lo INTEGER :: line_id, node, kind, comp, ndof, nnode, ne, inode, es - CHARACTER(200) :: em + CHARACTER(1024) :: em ErrStat = CD_DECKDRV_OK ErrMsg = '' @@ -32599,7 +32872,7 @@ SUBROUTINE eval_cable_channel(cable, ch, val, ErrStat, ErrMsg, mesh_node) INTEGER :: line_id, node, kind, comp, nnode, nelem, inode, es LOGICAL :: deck_numbering REAL(wp) :: sec_ten, sec_curv, sec_bend - CHARACTER(200) :: em + CHARACTER(1024) :: em ErrStat = CD_DECKDRV_OK ErrMsg = '' @@ -32859,7 +33132,7 @@ SUBROUTINE cable_end_tension(cable, inode, tension, ErrStat, ErrMsg) CHARACTER(*), INTENT(OUT) :: ErrMsg REAL(wp) :: force(3) INTEGER :: es - CHARACTER(200) :: em + CHARACTER(1024) :: em ErrStat = CD_DECKDRV_OK ErrMsg = '' @@ -32882,7 +33155,7 @@ SUBROUTINE cable_node_values(cable, inode, tension, curvature, bend_moment, ErrS INTEGER, INTENT(OUT) :: ErrStat CHARACTER(*), INTENT(OUT) :: ErrMsg INTEGER :: es - CHARACTER(200) :: em + CHARACTER(1024) :: em ErrStat = CD_DECKDRV_OK; ErrMsg = '' CALL CD_HermiteCable_Dyn_Node_Values(cable%line, inode, tension, curvature, bend_moment, es, em) IF (es /= CD_HCDYN_OK) CALL fail_solve(ErrStat, ErrMsg, 'finite-EI node-value recovery failed: '//TRIM(em)) @@ -32898,7 +33171,7 @@ SUBROUTINE cable_segment_tensions(cable, tension, ErrStat, ErrMsg) INTEGER, INTENT(OUT) :: ErrStat CHARACTER(*), INTENT(OUT) :: ErrMsg INTEGER :: ne, e, es - CHARACTER(200) :: em + CHARACTER(1024) :: em ErrStat = CD_DECKDRV_OK; ErrMsg = '' ne = cable%line%ne IF (cable%line%output_element_recovery) THEN @@ -33887,7 +34160,7 @@ SUBROUTINE host_substep_start(system, nsub, q0h, v0h, a0h, ErrStat, ErrMsg, host CHARACTER(*), INTENT(OUT) :: ErrMsg LOGICAL, INTENT(IN), OPTIONAL :: host_mask(:) INTEGER :: es - CHARACTER(160) :: em + CHARACTER(1024) :: em ErrStat = CD_DECKDRV_OK ErrMsg = '' IF (.NOT. PRESENT(host_mask) .OR. nsub <= 1) RETURN @@ -34215,8 +34488,8 @@ SUBROUTINE load_bathymetry_file(path, bathymetry, ErrStat, ErrMsg, points) REAL(wp), ALLOCATABLE :: xr(:), yr(:), dr(:), xgrid(:), ygrid(:), depth(:, :) LOGICAL, ALLOCATABLE :: filled(:, :) CHARACTER(DECK_RECLEN) :: line - CHARACTER(200) :: em - CHARACTER(256) :: why + CHARACTER(1024) :: em + CHARACTER(1024) :: why ErrStat = CD_DECKDRV_OK ErrMsg = '' @@ -34411,7 +34684,7 @@ SUBROUTINE read_syrope_settings(path, owc_strain, owc_tension, wc_mod, p1, p2, E LOGICAL :: have_owc, have_wc, have_k1, have_k2 REAL(wp) :: row(2) REAL(wp), ALLOCATABLE :: es(:), ts(:) - CHARACTER(256) :: why + CHARACTER(1024) :: why ErrStat = 0; ErrMsg = '' IF (PRESENT(owc_file)) owc_file = '' diff --git a/src/CableDyn_Driver.f90 b/src/CableDyn_Driver.f90 index 0082c547..000c6fa8 100644 --- a/src/CableDyn_Driver.f90 +++ b/src/CableDyn_Driver.f90 @@ -73,7 +73,7 @@ SUBROUTINE CD_Run_Static_Driver(input_path, output_path, converged, ErrStat, Err LOGICAL :: tension_only, has_seabed, stalled, at_floor INTEGER :: n_iter, es, i REAL(wp), ALLOCATABLE :: kn_arr(:) - CHARACTER(256) :: em + CHARACTER(1024) :: em TYPE(CableSolverConfig) :: cfg converged = .FALSE. @@ -206,7 +206,7 @@ SUBROUTINE CD_Run_Line_Static_Driver(input_path, output_path, converged, ErrStat REAL(wp), ALLOCATABLE :: l0(:), ea(:), mass_pl(:), diam(:), w(:), load(:, :) REAL(wp), ALLOCATABLE :: f_ext(:), q0(:), q(:), tension(:), kn(:) INTEGER :: n_elem, n_nodes, n_dof, es, i, n_iter, n_stages - CHARACTER(256) :: em + CHARACTER(1024) :: em converged = .FALSE. ErrStat = CD_DRIVER_OK diff --git a/src/CableDyn_Dynamic.f90 b/src/CableDyn_Dynamic.f90 index 03df8de5..c5cb4fb6 100644 --- a/src/CableDyn_Dynamic.f90 +++ b/src/CableDyn_Dynamic.f90 @@ -434,7 +434,7 @@ SUBROUTINE CD_Cable_Initial_Acceleration(q, v, elem_conn, l0, ea, rho_a, tension TYPE(CD_CableGenAlphaWorkspace), TARGET :: local_workspace TYPE(CD_CableGenAlphaWorkspace), POINTER :: work INTEGER :: es - CHARACTER(120) :: em + CHARACTER(1024) :: em LOGICAL :: use_element_mass_band a0 = CD_ZERO @@ -758,7 +758,7 @@ SUBROUTINE CD_Cable_Gen_Alpha_Step(q, v, a, elem_conn, l0, ea, rho_a, tension_on LOGICAL :: factored_now, guess_used, prev_end_ok, reuse_factor, reused, warm_call, r_at_qk LOGICAL :: scales_stale, trial_is_iterate INTEGER :: es - CHARACTER(120) :: em + CHARACTER(1024) :: em q_new = CD_ZERO v_new = CD_ZERO @@ -1431,15 +1431,16 @@ SUBROUTINE end_junction_data() !! end tangent K_E = dR_E/dq_E|_{R_F = 0} (the implicit-function derivative the outer !! junction Newton needs), by forward differences of the step residual: column j of !! S_FE/S_EE from a perturbation of end DOF j, X_j = S_FF^-1 S_FE e_j with the step's - !! factored effective band, and K = S_EE - S_EF X with S_EF taken as S_FE^T (the effective - !! tangent's mass, stiffness and drag-velocity blocks are symmetric; the small asymmetric - !! load terms only slow the outer Newton, never its converged result). A step that + !! factored effective band, and K = S_EE - S_EF X with S_EF taken as S_FE^T (the mass, + !! material-stiffness and drag-velocity blocks are symmetric; the asymmetric parts, from + !! the load terms and, on EI = 0 lines, the force blend's release cap and dashpot share, + !! only slow the outer Newton, never its converged result). A step that !! converged from its warm start without factoring keeps the previous map and tangent !! (the end moved by a Newton correction of the same step); a cold step without a factor !! factors the tangent at qk once. INTEGER :: nfx, j, i, k2, es2 REAL(wp) :: h, acc - CHARACTER(120) :: em2 + CHARACTER(1024) :: em2 LOGICAL :: keep LOGICAL :: act(SIZE(fixed)) REAL(wp), ALLOCATABLE :: sfe(:, :) @@ -2586,7 +2587,7 @@ SUBROUTINE validate_topology_once(work, elem_conn, n_nodes, validated) INTEGER, INTENT(IN) :: elem_conn(:, :), n_nodes LOGICAL, INTENT(OUT) :: validated INTEGER :: es, istat - CHARACTER(160) :: em + CHARACTER(1024) :: em validated = work%topo_valid IF (validated) validated = work%topo_n_nodes == n_nodes diff --git a/src/CableDyn_FiniteEIModel.f90 b/src/CableDyn_FiniteEIModel.f90 index 84f60be5..38555917 100644 --- a/src/CableDyn_FiniteEIModel.f90 +++ b/src/CableDyn_FiniteEIModel.f90 @@ -77,7 +77,7 @@ SUBROUTINE CD_Init_FiniteEI_Model(model, nodes_ref, elem_conn, ea, gas, ei, gj, INTEGER :: n_nodes, n_elem, n_dof, i, es TYPE(CD_FiniteEIModelType) :: old_model - CHARACTER(160) :: em + CHARACTER(1024) :: em ErrStat = CD_DYN_OK ErrMsg = '' @@ -324,7 +324,7 @@ SUBROUTINE CD_Set_FiniteEI_Model_PrescribedDofs(model, dofs, q_vals, v_vals, a_v INTEGER :: i, d, es LOGICAL :: do_recompute REAL(wp), ALLOCATABLE :: q_tmp(:), v_tmp(:), a_tmp(:), a_presc(:) - CHARACTER(160) :: em + CHARACTER(1024) :: em ErrStat = CD_DYN_OK ErrMsg = '' @@ -410,7 +410,7 @@ SUBROUTINE CD_Set_FiniteEI_Model_Load(model, f_ext, ErrStat, ErrMsg, recompute_a LOGICAL :: recompute INTEGER :: es REAL(wp), ALLOCATABLE :: a_tmp(:), a_presc(:) - CHARACTER(160) :: em + CHARACTER(1024) :: em ErrStat = CD_DYN_OK ErrMsg = '' diff --git a/src/CableDyn_FiniteEIStatic.f90 b/src/CableDyn_FiniteEIStatic.f90 index 7b948a19..db382be5 100644 --- a/src/CableDyn_FiniteEIStatic.f90 +++ b/src/CableDyn_FiniteEIStatic.f90 @@ -344,7 +344,7 @@ SUBROUTINE newton_nd(q0, nodes_ref, elem_conn, ea, gas, ei, gj, f_ext, fixed, kn REAL(wp), ALLOCATABLE :: R_free(:), dq(:), dq_global(:), q_trial(:), R_trial(:) REAL(wp) :: f_ext_base, conv_scale, scale_trial, rnorm, merit, merit_trial, alpha INTEGER :: n_free, iteration, bt, nd, zdof, es - CHARACTER(120) :: em + CHARACTER(1024) :: em converged = .FALSE.; stalled = .FALSE. ErrStat = CD_FEI_OK; ErrMsg = '' @@ -422,7 +422,7 @@ SUBROUTINE eval_residual(qe, Rf, sc) REAL(wp), INTENT(IN) :: qe(:) REAL(wp), INTENT(OUT) :: Rf(:), sc INTEGER :: ndl, zdofl, es_e - CHARACTER(120) :: em_e + CHARACTER(1024) :: em_e CALL CD_Assemble_Cosserat_Internal_Force(nodes_ref, elem_conn, ea, gas, ei, gj, qe, & .TRUE., fint, es_e, em_e) IF (es_e /= 0) THEN diff --git a/src/CableDyn_HermiteArch.f90 b/src/CableDyn_HermiteArch.f90 index 1b6f14a4..0bbda671 100644 --- a/src/CableDyn_HermiteArch.f90 +++ b/src/CableDyn_HermiteArch.f90 @@ -230,7 +230,7 @@ SUBROUTINE CD_FiniteEI_Hermite_Arch_Seed_LengthMatched(end_a, end_b, tan_a, tan_ REAL(wp), ALLOCATABLE :: q_trial(:), nodes_trial(:, :), arc_trial(:), curvature_trial(:) REAL(wp) :: total_l, lo, hi, mid, trial_len, tol INTEGER :: n_elem, n_nodes, iter, es - CHARACTER(200) :: em + CHARACTER(1024) :: em ErrStat = CD_HARCH_OK ErrMsg = '' diff --git a/src/CableDyn_HermiteCableDynamic.f90 b/src/CableDyn_HermiteCableDynamic.f90 index 02a635a3..246dca11 100644 --- a/src/CableDyn_HermiteCableDynamic.f90 +++ b/src/CableDyn_HermiteCableDynamic.f90 @@ -554,7 +554,7 @@ SUBROUTINE CD_HermiteCable_Dyn_Init(model, l0, EA, EI, rho_a, w, seed, fixed_dof INTEGER :: ne, nn, ndof, i, e, es, nf, gi REAL(wp) :: Me(12, 12), rho - CHARACTER(200) :: em2 + CHARACTER(1024) :: em2 ErrStat = CD_HCDYN_OK ErrMsg = '' @@ -717,7 +717,7 @@ SUBROUTINE CD_HermiteCable_Dyn_Set_Contact(model, kn_node, cn_node, mu, ErrStat, REAL(wp), ALLOCATABLE :: new_kn(:), new_cn(:), old_kn(:), old_cn(:), old_a(:) LOGICAL :: old_has_contact, old_has_bathymetry TYPE(CD_BathymetryType) :: new_bathymetry, old_bathymetry - CHARACTER(200) :: em + CHARACTER(1024) :: em ErrStat = CD_HCDYN_OK; ErrMsg = '' model%rc_epoch = model%rc_epoch + 1 @@ -888,7 +888,7 @@ SUBROUTINE CD_HermiteCable_Dyn_Set_Friction_Anchors(model, anchors, ErrStat, Err REAL(wp), ALLOCATABLE :: a_old(:), anchor_old(:, :) LOGICAL :: active_old INTEGER :: es - CHARACTER(200) :: em + CHARACTER(1024) :: em ErrStat = CD_HCDYN_OK; ErrMsg = '' IF (.NOT. model%initialized) THEN @@ -957,7 +957,7 @@ SUBROUTINE CD_HermiteCable_Dyn_Set_Attachments(model, node, mass, volume, cda, c CHARACTER(*), INTENT(OUT) :: ErrMsg INTEGER :: n, k, d, dof, es REAL(wp), ALLOCATABLE :: a_old(:), mgb_old(:, :) - CHARACTER(200) :: em + CHARACTER(1024) :: em ErrStat = CD_HCDYN_OK; ErrMsg = '' n = SIZE(node) @@ -1557,7 +1557,7 @@ SUBROUTINE assemble_committed_force(model, ErrStat, ErrMsg) CHARACTER(*), INTENT(OUT) :: ErrMsg TYPE(committed_lengths_aside) :: aside INTEGER :: es - CHARACTER(200) :: em + CHARACTER(1024) :: em CALL enter_committed_lengths(model, aside, es, em) IF (es /= CD_HCDYN_OK) THEN @@ -1579,7 +1579,7 @@ SUBROUTINE solve_committed_acceleration(model, ErrStat, ErrMsg, pres_dofs, pres_ REAL(wp), INTENT(IN), OPTIONAL :: pres_a(:) TYPE(committed_lengths_aside) :: aside INTEGER :: es - CHARACTER(200) :: em + CHARACTER(1024) :: em CALL enter_committed_lengths(model, aside, es, em) IF (es /= CD_HCDYN_OK) THEN @@ -1848,7 +1848,7 @@ SUBROUTINE CD_HermiteCable_Dyn_Set_EndConnection(model, k_rot, d0, ErrStat, ErrM LOGICAL :: had_conn, snap_was_valid LOGICAL, ALLOCATABLE :: solve_mask_old(:) INTEGER :: es - CHARACTER(200) :: em + CHARACTER(1024) :: em ErrStat = CD_HCDYN_OK; ErrMsg = '' ! A load-configuration change invalidates the cached committed force F_n. @@ -2316,7 +2316,7 @@ SUBROUTINE CD_HermiteCable_Dyn_Set_Axial_Damping(model, BA, ErrStat, ErrMsg) REAL(wp), ALLOCATABLE :: old_BA(:), new_BA(:), old_a(:) LOGICAL :: old_has INTEGER :: es, istat - CHARACTER(300) :: em + CHARACTER(1024) :: em ErrStat = CD_HCDYN_OK model%rc_epoch = model%rc_epoch + 1 @@ -2483,7 +2483,7 @@ SUBROUTINE CD_HermiteCable_Dyn_Set_Waves(model, height, period, direction_deg, d REAL(wp) :: h_old, om_old, k_old, dep_old, dir_old, omega, k LOGICAL :: had_wave INTEGER :: es - CHARACTER(200) :: em2 + CHARACTER(1024) :: em2 ErrStat = CD_HCDYN_OK; ErrMsg = '' model%rc_epoch = model%rc_epoch + 1 @@ -2603,7 +2603,7 @@ SUBROUTINE CD_HermiteCable_Dyn_Set_Irregular_Waves(model, amplitude, period, pha REAL(wp) :: h_old, om_old, k_old, dep_old, dir_old LOGICAL :: had_wave INTEGER :: i, n, nc_old, es - CHARACTER(200) :: em2 + CHARACTER(1024) :: em2 ErrStat = CD_HCDYN_OK; ErrMsg = '' model%rc_epoch = model%rc_epoch + 1 @@ -2741,7 +2741,7 @@ SUBROUTINE CD_HermiteCable_Dyn_Set_Held_Fluid(model, fluid_velocity, fluid_accel CHARACTER(*), INTENT(OUT) :: ErrMsg INTEGER :: istat, es LOGICAL :: had_field - CHARACTER(240) :: em + CHARACTER(1024) :: em ErrStat = CD_HCDYN_OK; ErrMsg = '' model%rc_epoch = model%rc_epoch + 1 ! A load-configuration change invalidates the cached committed force F_n. The carried step @@ -3081,7 +3081,7 @@ SUBROUTINE dyn_step_core(model, dt, max_iter, tol, ErrStat, ErrMsg, iters_out, r ! Newton's. REAL(wp), PARAMETER :: XS_TOL_FACTOR = 0.3_wp INTEGER(INT64) :: pc0, pc1, pcr, pt0, pt1 - CHARACTER(200) :: em2 + CHARACTER(1024) :: em2 ErrStat = CD_HCDYN_OK ErrMsg = '' @@ -3902,7 +3902,7 @@ SUBROUTINE dyn_step_core(model, dt, max_iter, tol, ErrStat, ErrMsg, iters_out, r ! cache; a failure here only leaves it invalid (a query then evaluates and reports it) BLOCK INTEGER :: es_tc - CHARACTER(200) :: em_tc + CHARACTER(1024) :: em_tc CALL torsion_cache_fill(model, es_tc, em_tc) END BLOCK END IF @@ -4292,7 +4292,7 @@ SUBROUTINE torsion_theta_at(model, q_cfg, ends, theta, ErrStat, ErrMsg) CHARACTER(*), INTENT(OUT) :: ErrMsg REAL(wp) :: raw INTEGER :: es - CHARACTER(200) :: em + CHARACTER(1024) :: em theta = model%torsion%theta CALL CD_HermiteTorsion_Line(q_cfg, model%l0, ends, raw, model%tors_gq, es, em, & quadrature_order=model%torsion%quadrature_order, work=model%tors_work) @@ -4385,7 +4385,7 @@ SUBROUTINE CD_HermiteCable_Dyn_Step_Recovering(model, dt, max_iter, tol, ErrStat ! The step-rotation diagnostic must not keep the turn of a step that is rewound. REAL(wp) :: rotation_save REAL(wp) :: tors_theta0, tors_phi0, tors_phi1, tors_ends0(3, 4), tors_ends1(3, 4), tors_sub(3, 4) - CHARACTER(300) :: em + CHARACTER(1024) :: em ! Tensile-qualification failure flag reported by each step (classified by flag, not by ! message text, so a short caller buffer cannot change the recovery decision). LOGICAL :: tensile_fail @@ -4919,7 +4919,7 @@ SUBROUTINE CD_HermiteCable_Dyn_Energy(model, kinetic, strain, ErrStat, ErrMsg, c REAL(wp), INTENT(OUT), OPTIONAL :: connection INTEGER :: e, es REAL(wp) :: qe(12), Ee, fe(12), Ke(12, 12), connection_energy, end_energy - CHARACTER(200) :: em2 + CHARACTER(1024) :: em2 ErrStat = CD_HCDYN_OK; ErrMsg = ''; kinetic = CD_ZERO; strain = CD_ZERO connection_energy = CD_ZERO IF (PRESENT(connection)) connection = CD_ZERO @@ -5011,7 +5011,7 @@ SUBROUTINE CD_HermiteCable_Dyn_Curvature_Exact(model, curv_out, ErrStat, ErrMsg) CHARACTER(*), INTENT(OUT) :: ErrMsg INTEGER :: a, es REAL(wp) :: qe(12), kL, kR - CHARACTER(200) :: em2 + CHARACTER(1024) :: em2 ErrStat = CD_HCDYN_OK; ErrMsg = '' IF (.NOT. model%initialized) THEN ErrStat = CD_HCDYN_BADINPUT; ErrMsg = 'CD_HermiteCable_Dyn_Curvature_Exact: model not initialised'; RETURN @@ -5065,7 +5065,7 @@ SUBROUTINE CD_HermiteCable_Dyn_Reaction(model, node, freac, ErrStat, ErrMsg) INTEGER, INTENT(OUT) :: ErrStat CHARACTER(*), INTENT(OUT) :: ErrMsg INTEGER :: es, gi - CHARACTER(200) :: em2 + CHARACTER(1024) :: em2 ErrStat = CD_HCDYN_OK; ErrMsg = ''; freac = CD_ZERO IF (.NOT. model%initialized) THEN ErrStat = CD_HCDYN_BADINPUT; ErrMsg = 'CD_HermiteCable_Dyn_Reaction: model not initialised'; RETURN @@ -5117,7 +5117,7 @@ SUBROUTINE CD_HermiteCable_Dyn_End_Force(model, node, force, ErrStat, ErrMsg) REAL(wp) :: curv_e(3), fcrease_e(3), kcrease_e(3, 3) INTEGER :: e, i0, iz, zslot, es, k LOGICAL :: dry, has_jac - CHARACTER(200) :: em2 + CHARACTER(1024) :: em2 ErrStat = CD_HCDYN_OK; ErrMsg = ''; force = CD_ZERO; gap = -HUGE(CD_ONE) IF (.NOT. model%initialized) THEN @@ -5789,7 +5789,7 @@ SUBROUTINE CD_HermiteCable_Dyn_EndConnection_Moment(model, node, moment, ErrStat INTEGER :: iend, base, es REAL(wp) :: f_ec(3), k_ec(3, 3), direction(3), bend_moment(3) - CHARACTER(200) :: em + CHARACTER(1024) :: em moment = CD_ZERO ErrStat = CD_HCDYN_OK @@ -5905,7 +5905,7 @@ SUBROUTINE CD_HermiteCable_Dyn_Set_Torsion(model, torsion, ErrStat, ErrMsg) REAL(wp) :: saved_drive_ends(3, 4), saved_drive_phi LOGICAL :: saved_snap_valid, saved_drive_set INTEGER :: es, iend - CHARACTER(200) :: em + CHARACTER(1024) :: em ErrStat = CD_HCDYN_OK ErrMsg = '' IF (.NOT. model%initialized) THEN @@ -6025,7 +6025,7 @@ SUBROUTINE CD_HermiteCable_Dyn_Torsion_State(model, theta, torque, ErrStat, ErrM REAL(wp), ALLOCATABLE :: g(:) REAL(wp) :: raw, eg(6), c INTEGER :: es, nb - CHARACTER(200) :: em + CHARACTER(1024) :: em theta = CD_ZERO torque = CD_ZERO IF (PRESENT(grad)) grad = CD_ZERO @@ -6107,7 +6107,7 @@ SUBROUTINE torsion_cache_fill(model, ErrStat, ErrMsg) CHARACTER(*), INTENT(OUT) :: ErrMsg REAL(wp) :: raw, eg(6), th INTEGER :: es, nb, i - CHARACTER(200) :: em + CHARACTER(1024) :: em ErrStat = CD_HCDYN_OK ErrMsg = '' model%tors_c_valid = .FALSE. @@ -6418,7 +6418,11 @@ SUBROUTINE assemble_residual(model, q_cfg, v_cfg, t_eval, want_residual, want_ta LOGICAL :: dry REAL(wp) :: endconn_d0_eval(3, 2), support(3), dsupport(3), nin(3), mend INTEGER :: inode, jr, jc - CHARACTER(200) :: em2 + CHARACTER(1024) :: em2 + ! em_e takes the messages of the per-element kernels (element, axial damping, drag, wave load), + ! fixed texts of at most 184 characters with the nested CableDyn_Hydro ones. Each kernel resets + ! its message at every call, so this buffer stays as short as those texts allow. + CHARACTER(200) :: em_e ErrStat = CD_HCDYN_OK; ErrMsg = '' ne = model%ne @@ -6465,17 +6469,17 @@ SUBROUTINE assemble_residual(model, q_cfg, v_cfg, t_eval, want_residual, want_ta qe(7:9) = q_cfg(6*e + 1:6*e + 3) qe(10:12) = q_cfg(6*e + 4:6*e + 6) IF (want_tangent) THEN - CALL CD_HermiteCable_Element(qe, model%l0(e), model%EA(e), model%EI(e), Ee, fe, Ke, es, em2, & + CALL CD_HermiteCable_Element(qe, model%l0(e), model%EA(e), model%EI(e), Ee, fe, Ke, es, em_e, & symmetric_half=.TRUE., & axial_quadrature_order=model%axial_quadrature_order, & bending_quadrature_order=model%bending_quadrature_order) ELSE - CALL CD_HermiteCable_Element(qe, model%l0(e), model%EA(e), model%EI(e), Ee, fe, ErrStat=es, ErrMsg=em2, & + CALL CD_HermiteCable_Element(qe, model%l0(e), model%EA(e), model%EI(e), Ee, fe, ErrStat=es, ErrMsg=em_e, & axial_quadrature_order=model%axial_quadrature_order, & bending_quadrature_order=model%bending_quadrature_order) END IF IF (es /= CD_HCABLE_OK) THEN - ErrStat = CD_HCDYN_NOCONVERGE; ErrMsg = 'element: '//TRIM(em2); RETURN + ErrStat = CD_HCDYN_NOCONVERGE; ErrMsg = 'element: '//TRIM(em_e); RETURN END IF IF (want_residual) THEN DO a = 1, 12 @@ -6614,24 +6618,24 @@ SUBROUTINE assemble_residual(model, q_cfg, v_cfg, t_eval, want_residual, want_ta ve(7:9) = v_cfg(6*e + 1:6*e + 3); ve(10:12) = v_cfg(6*e + 4:6*e + 6) IF (want_tangent .AND. model%has_ctrl) THEN CALL CD_HermiteCable_Axial_Damping_Element(qe, ve, model%l0(e), model%BA(e), & - fdamp, kdq, kdv, es, em2, & + fdamp, kdq, kdv, es, em_e, & model%axial_quadrature_order, model%l0_dot(e)) ELSE IF (want_tangent) THEN CALL CD_HermiteCable_Axial_Damping_Element(qe, ve, model%l0(e), model%BA(e), & - fdamp, kdq, kdv, es, em2, & + fdamp, kdq, kdv, es, em_e, & model%axial_quadrature_order) ELSE IF (model%has_ctrl) THEN CALL CD_HermiteCable_Axial_Damping_Element(qe, ve, model%l0(e), model%BA(e), & - fdamp, ErrStat=es, ErrMsg=em2, & + fdamp, ErrStat=es, ErrMsg=em_e, & quadrature_order=model%axial_quadrature_order, & l0_dot=model%l0_dot(e)) ELSE CALL CD_HermiteCable_Axial_Damping_Element(qe, ve, model%l0(e), model%BA(e), & - fdamp, ErrStat=es, ErrMsg=em2, & + fdamp, ErrStat=es, ErrMsg=em_e, & quadrature_order=model%axial_quadrature_order) END IF IF (es /= CD_HCDYN_OK) THEN - ErrStat = CD_HCDYN_NOCONVERGE; ErrMsg = TRIM(em2); RETURN + ErrStat = CD_HCDYN_NOCONVERGE; ErrMsg = TRIM(em_e); RETURN END IF IF (want_residual) THEN DO a = 1, 12 @@ -6661,7 +6665,7 @@ SUBROUTINE assemble_residual(model, q_cfg, v_cfg, t_eval, want_residual, want_ta IF (model%has_wave .AND. model%wv_ncomp > 0) THEN CALL CD_HermiteCable_Drag_Element(qe, ve, model%l0(e), model%current, model%waterline_z, & model%rho_w, model%diam(e), model%cdn(e), model%cdt(e), & - fdrag, djq, djv, es, em2, & + fdrag, djq, djv, es, em_e, & wv_depth=model%wv_depth, wv_dir=model%wv_dir, wv_t=t_eval, & wvc_amp=model%wv_ampc, wvc_om=model%wv_omc, & wvc_k=model%wv_kc, wvc_ph=model%wv_phc, & @@ -6669,7 +6673,7 @@ SUBROUTINE assemble_residual(model, q_cfg, v_cfg, t_eval, want_residual, want_ta ELSE IF (model%has_wave) THEN CALL CD_HermiteCable_Drag_Element(qe, ve, model%l0(e), model%current, model%waterline_z, & model%rho_w, model%diam(e), model%cdn(e), model%cdt(e), & - fdrag, djq, djv, es, em2, & + fdrag, djq, djv, es, em_e, & wv_h=model%wv_h, wv_om=model%wv_om, wv_k=model%wv_k, & wv_depth=model%wv_depth, wv_dir=model%wv_dir, wv_t=t_eval) ELSE IF (model%has_held_field) THEN @@ -6680,17 +6684,17 @@ SUBROUTINE assemble_residual(model, q_cfg, v_cfg, t_eval, want_residual, want_ta model%current + 0.5_wp*(model%hf_u(:, e) + model%hf_u(:, e + 1)), & 0.5_wp*(model%hf_wl(e) + model%hf_wl(e + 1)), & model%rho_w, model%diam(e), model%cdn(e), model%cdt(e), & - fdrag, djq, djv, es, em2) + fdrag, djq, djv, es, em_e) ELSE CALL CD_HermiteCable_Drag_Element(qe, ve, model%l0(e), model%current, model%waterline_z, & model%rho_w, model%diam(e), model%cdn(e), model%cdt(e), & - fdrag, djq, djv, es, em2) + fdrag, djq, djv, es, em_e) END IF ELSE IF (model%has_wave .AND. model%wv_ncomp > 0) THEN CALL CD_HermiteCable_Drag_Element(qe, ve, model%l0(e), model%current, model%waterline_z, & model%rho_w, model%diam(e), model%cdn(e), model%cdt(e), & - fdrag, ErrStat=es, ErrMsg=em2, & + fdrag, ErrStat=es, ErrMsg=em_e, & wv_depth=model%wv_depth, wv_dir=model%wv_dir, wv_t=t_eval, & wvc_amp=model%wv_ampc, wvc_om=model%wv_omc, & wvc_k=model%wv_kc, wvc_ph=model%wv_phc, & @@ -6698,7 +6702,7 @@ SUBROUTINE assemble_residual(model, q_cfg, v_cfg, t_eval, want_residual, want_ta ELSE IF (model%has_wave) THEN CALL CD_HermiteCable_Drag_Element(qe, ve, model%l0(e), model%current, model%waterline_z, & model%rho_w, model%diam(e), model%cdn(e), model%cdt(e), & - fdrag, ErrStat=es, ErrMsg=em2, & + fdrag, ErrStat=es, ErrMsg=em_e, & wv_h=model%wv_h, wv_om=model%wv_om, wv_k=model%wv_k, & wv_depth=model%wv_depth, wv_dir=model%wv_dir, wv_t=t_eval) ELSE IF (model%has_held_field) THEN @@ -6706,15 +6710,15 @@ SUBROUTINE assemble_residual(model, q_cfg, v_cfg, t_eval, want_residual, want_ta model%current + 0.5_wp*(model%hf_u(:, e) + model%hf_u(:, e + 1)), & 0.5_wp*(model%hf_wl(e) + model%hf_wl(e + 1)), & model%rho_w, model%diam(e), model%cdn(e), model%cdt(e), & - fdrag, ErrStat=es, ErrMsg=em2) + fdrag, ErrStat=es, ErrMsg=em_e) ELSE CALL CD_HermiteCable_Drag_Element(qe, ve, model%l0(e), model%current, model%waterline_z, & model%rho_w, model%diam(e), model%cdn(e), model%cdt(e), & - fdrag, ErrStat=es, ErrMsg=em2) + fdrag, ErrStat=es, ErrMsg=em_e) END IF END IF IF (es /= CD_HCDYN_OK) THEN - ErrStat = es; ErrMsg = TRIM(em2); RETURN + ErrStat = es; ErrMsg = TRIM(em_e); RETURN END IF IF (want_residual) THEN DO a = 1, 12 @@ -6763,7 +6767,7 @@ SUBROUTINE assemble_residual(model, q_cfg, v_cfg, t_eval, want_residual, want_ta CALL CD_HermiteCable_FK_Element(qe, model%l0(e), model%am_wl, model%am_rho, model%am_diam(e), & model%am_can(e), model%am_cat(e), & wv_depth=model%wv_depth, wv_dir=model%wv_dir, wv_t=t_eval, & - ffk=ffk, fjq=fjq, ErrStat=es, ErrMsg=em2, & + ffk=ffk, fjq=fjq, ErrStat=es, ErrMsg=em_e, & wvc_amp=model%wv_ampc, wvc_om=model%wv_omc, & wvc_k=model%wv_kc, wvc_ph=model%wv_phc, & wvc_e2kd=model%wv_e2kd) @@ -6771,7 +6775,7 @@ SUBROUTINE assemble_residual(model, q_cfg, v_cfg, t_eval, want_residual, want_ta CALL CD_HermiteCable_FK_Element(qe, model%l0(e), model%am_wl, model%am_rho, model%am_diam(e), & model%am_can(e), model%am_cat(e), & wv_depth=model%wv_depth, wv_dir=model%wv_dir, wv_t=t_eval, & - ffk=ffk, ErrStat=es, ErrMsg=em2, & + ffk=ffk, ErrStat=es, ErrMsg=em_e, & wvc_amp=model%wv_ampc, wvc_om=model%wv_omc, & wvc_k=model%wv_kc, wvc_ph=model%wv_phc, & wvc_e2kd=model%wv_e2kd) @@ -6782,17 +6786,17 @@ SUBROUTINE assemble_residual(model, q_cfg, v_cfg, t_eval, want_residual, want_ta model%am_can(e), model%am_cat(e), & wv_h=model%wv_h, wv_om=model%wv_om, wv_k=model%wv_k, & wv_depth=model%wv_depth, wv_dir=model%wv_dir, wv_t=t_eval, & - ffk=ffk, fjq=fjq, ErrStat=es, ErrMsg=em2) + ffk=ffk, fjq=fjq, ErrStat=es, ErrMsg=em_e) ELSE CALL CD_HermiteCable_FK_Element(qe, model%l0(e), model%am_wl, model%am_rho, model%am_diam(e), & model%am_can(e), model%am_cat(e), & wv_h=model%wv_h, wv_om=model%wv_om, wv_k=model%wv_k, & wv_depth=model%wv_depth, wv_dir=model%wv_dir, wv_t=t_eval, & - ffk=ffk, ErrStat=es, ErrMsg=em2) + ffk=ffk, ErrStat=es, ErrMsg=em_e) END IF END IF IF (es /= CD_HCDYN_OK) THEN - ErrStat = es; ErrMsg = TRIM(em2); RETURN + ErrStat = es; ErrMsg = TRIM(em_e); RETURN END IF IF (want_residual) THEN DO a = 1, 12 @@ -6820,7 +6824,7 @@ SUBROUTINE assemble_residual(model, q_cfg, v_cfg, t_eval, want_residual, want_ta model%am_rho, model%am_diam(e), & model%am_can(e), model%am_cat(e), & wv_depth=CD_ZERO, wv_dir=CD_ZERO, wv_t=CD_ZERO, & - ffk=ffk, fjq=fjq, ErrStat=es, ErrMsg=em2, & + ffk=ffk, fjq=fjq, ErrStat=es, ErrMsg=em_e, & hf_a=hf_mid) ELSE hf_mid(1) = 0.5_wp*(model%hf_ud(1, e) + model%hf_ud(1, e + 1)) @@ -6831,11 +6835,11 @@ SUBROUTINE assemble_residual(model, q_cfg, v_cfg, t_eval, want_residual, want_ta model%am_rho, model%am_diam(e), & model%am_can(e), model%am_cat(e), & wv_depth=CD_ZERO, wv_dir=CD_ZERO, wv_t=CD_ZERO, & - ffk=ffk, ErrStat=es, ErrMsg=em2, & + ffk=ffk, ErrStat=es, ErrMsg=em_e, & hf_a=hf_mid) END IF IF (es /= CD_HCDYN_OK) THEN - ErrStat = es; ErrMsg = TRIM(em2); RETURN + ErrStat = es; ErrMsg = TRIM(em_e); RETURN END IF IF (want_residual) THEN DO a = 1, 12 @@ -6870,7 +6874,7 @@ SUBROUTINE assemble_torsion(model, q_cfg, want_residual, want_tangent, ErrStat, REAL(wp), POINTER :: g(:) REAL(wp) :: raw, th, mt, phi INTEGER :: es, i - CHARACTER(200) :: em + CHARACTER(1024) :: em ErrStat = CD_HCDYN_OK ErrMsg = '' IF (want_tangent) THEN @@ -7246,9 +7250,12 @@ SUBROUTINE evaluate_tangent_element(model, e, q_cfg, v_cfg, t_eval, Kstruct, Kdr REAL(wp) :: djq(12, 12), djv(12, 12), fjq(12, 12) REAL(wp) :: hf_mid(3) INTEGER :: es + ! The element kernels write fixed messages of at most 184 characters (nested ones included), + ! which fit em and the per-element buffer ws_elem_em this fills. Each kernel resets em at every + ! call, so em stays short; ErrMsg is written only on a failure (the caller reads it only then). CHARACTER(200) :: em - ErrStat = CD_HCDYN_OK; ErrMsg = '' + ErrStat = CD_HCDYN_OK qe(1:6) = q_cfg(6*(e - 1) + 1:6*e) qe(7:12) = q_cfg(6*e + 1:6*(e + 1)) ve(1:6) = v_cfg(6*(e - 1) + 1:6*e) @@ -7591,6 +7598,8 @@ SUBROUTINE CD_HermiteCable_Drag_Element(qe, ve, l0, fluid, waterline_z, rho, dia REAL(wp) :: scale, eta_w, uw(3), aw(3) LOGICAL :: has_wv, has_shared, has_trio, has_cmp, any_wv_arg, want_jac INTEGER :: g, s, c, sp, cp, a, b, es + ! the message of a per-Gauss-point CableDyn_Hydro kinematics or Morison call (at most 154 + ! characters): a short buffer, as these calls reset it at every Gauss point CHARACTER(200) :: em2 ErrStat = CD_HCDYN_OK; ErrMsg = '' @@ -7864,6 +7873,8 @@ SUBROUTINE CD_HermiteCable_FK_Element(qe, l0, waterline_z, rho, diam, can, cat, REAL(wp) :: fpl(3), Jtan(3, 3), proj(3, 3), projk(3), dalpha LOGICAL :: has_trio, has_cmp, has_held, want_jac INTEGER :: g, s, c, sp, cp, a, b, k, es + ! the message of a per-Gauss-point CableDyn_Hydro kinematics call (at most 154 characters): a + ! short buffer, as these calls reset it at every Gauss point CHARACTER(200) :: em2 ErrStat = CD_HCDYN_OK; ErrMsg = '' @@ -8038,7 +8049,7 @@ SUBROUTINE assemble_added_mass(model, q_cfg, ErrStat, ErrMsg) CHARACTER(*), INTENT(OUT) :: ErrMsg INTEGER :: e, es REAL(wp) :: qe(12), Me(12, 12), wl_e - CHARACTER(200) :: em2 + CHARACTER(1024) :: em2 ErrStat = CD_HCDYN_OK; ErrMsg = '' model%ws_Mamb = CD_ZERO IF (.NOT. model%has_am) RETURN @@ -8074,7 +8085,7 @@ SUBROUTINE build_rigid_bases(model, directions, bases, ErrStat, ErrMsg) INTEGER, INTENT(OUT) :: ErrStat CHARACTER(*), INTENT(OUT) :: ErrMsg INTEGER :: iend, es - CHARACTER(200) :: em + CHARACTER(1024) :: em bases = CD_ZERO ErrStat = CD_HCDYN_OK ErrMsg = '' @@ -8097,7 +8108,7 @@ SUBROUTINE project_rigid_tangents(model, directions, q, ErrStat, ErrMsg) CHARACTER(*), INTENT(OUT) :: ErrMsg INTEGER :: iend, base, es REAL(wp) :: projected(3) - CHARACTER(200) :: em + CHARACTER(1024) :: em ErrStat = CD_HCDYN_OK ErrMsg = '' DO iend = 1, 2 @@ -8284,7 +8295,7 @@ SUBROUTINE solve_consistent_acceleration(model, ErrStat, ErrMsg, pres_dofs, pres INTEGER :: nf, np, i, ip, jp, gdof, es, iend, base LOGICAL :: has_pres REAL(wp) :: rigid_basis(3, 3, 2), old_acceleration(3), axial_acceleration - CHARACTER(200) :: em2 + CHARACTER(1024) :: em2 ErrStat = CD_HCDYN_OK; ErrMsg = '' ! This solve factors the mass into ws_Keffb: the carried step factor is gone. model%tr_valid = .FALSE. diff --git a/src/CableDyn_HermiteCableStatic.f90 b/src/CableDyn_HermiteCableStatic.f90 index 626c2efe..88829029 100644 --- a/src/CableDyn_HermiteCableStatic.f90 +++ b/src/CableDyn_HermiteCableStatic.f90 @@ -515,7 +515,7 @@ SUBROUTINE CD_HermiteCable_Static_Solve(l0, EA, EI, w, seed, fixed_dofs, seabed_ REAL(wp) :: end_share_last(2), end_share_pi(2) LOGICAL :: end_share_held, end_share_caller INTEGER :: end_es - CHARACTER(200) :: end_em + CHARACTER(1024) :: end_em ErrStat = CD_HCSTAT_OK ErrMsg = '' @@ -1093,7 +1093,8 @@ RECURSIVE SUBROUTINE newton_step(rnorm, es, em, do_update) INTEGER :: jr, jc INTEGER :: e, a, b, gi, gj, j, es2, bt, es_trial, zdof(4) LOGICAL :: dry, accepted - CHARACTER(200) :: em2, em_trial + CHARACTER(1024) :: em2, em_trial + CHARACTER(160) :: em_b ! a per-node bathymetry query message (at most 69 characters) es = CD_HCSTAT_OK; em = ''; rnorm = CD_ZERO; merit = CD_ZERO IF (use_rigid) THEN @@ -1246,9 +1247,9 @@ RECURSIVE SUBROUTINE newton_step(rnorm, es, em, do_update) IF (use_bathymetry) THEN xg = contact_cs(1)*q(gi - 2) - contact_cs(2)*q(gi - 1) yg = contact_cs(2)*q(gi - 2) + contact_cs(1)*q(gi - 1) - CALL CD_Bathymetry_Floor_Gradient(bathymetry, xg, yg, z_floor, gxg, gyg, es2, em2, crease_curvature=curv_g) + CALL CD_Bathymetry_Floor_Gradient(bathymetry, xg, yg, z_floor, gxg, gyg, es2, em_b, crease_curvature=curv_g) IF (es2 /= CD_BATHY_OK) THEN - es = CD_HCSTAT_NOCONVERGE; em = 'bathymetry query failed: '//TRIM(em2); RETURN + es = CD_HCSTAT_NOCONVERGE; em = 'bathymetry query failed: '//TRIM(em_b); RETURN END IF gx = contact_cs(1)*gxg + contact_cs(2)*gyg gy = -contact_cs(2)*gxg + contact_cs(1)*gyg @@ -1556,7 +1557,7 @@ RECURSIVE SUBROUTINE energy_update(es, em) REAL(wp) :: pi0, pi_abs0, merit0, dmax, gd, alpha, trial_norm, sc, share0(2) INTEGER :: shift, bt, j, i, es_trial, info LOGICAL :: accepted - CHARACTER(200) :: em_trial + CHARACTER(1024) :: em_trial EXTERNAL :: dpbtrf, dpbtrs es = CD_HCSTAT_OK; em = '' @@ -1714,7 +1715,7 @@ SUBROUTINE add_torsion(ecs, ecm) CHARACTER(*), INTENT(OUT) :: ecm REAL(wp) :: raw, th, e_t INTEGER :: ks - CHARACTER(200) :: km + CHARACTER(1024) :: km ecs = CD_HCSTAT_OK ecm = '' IF (skip_tangent) THEN @@ -1781,7 +1782,7 @@ SUBROUTINE torsion_take_step(scale, ecs, ecm) CHARACTER(*), INTENT(OUT) :: ecm REAL(wp) :: sfac, raw, th INTEGER :: k, ks - CHARACTER(200) :: km + CHARACTER(1024) :: km tors_q = q sfac = scale km = '' @@ -1819,8 +1820,8 @@ SUBROUTINE torsion_continuation(ecs, ecm) REAL(wp) :: raw, phi0, total, lam, lam_try, dlam, dlam_max, th_keep, res_untwisted INTEGER :: ks, cuts, wios LOGICAL :: ok - CHARACTER(200) :: km - CHARACTER(512) :: why + CHARACTER(1024) :: km + CHARACTER(1024) :: why CHARACTER(1024) :: wbuf ecs = CD_HCSTAT_OK ecm = '' @@ -1913,7 +1914,7 @@ SUBROUTINE torsion_stage(ok, why) INTEGER :: it2, ks, wios REAL(wp) :: rn LOGICAL :: st - CHARACTER(512) :: km + CHARACTER(1024) :: km CHARACTER(1024) :: wbuf ok = .FALSE. why = '' @@ -1970,7 +1971,7 @@ SUBROUTINE torsion_stability(st, ecs, ecm) CHARACTER(*), INTENT(OUT) :: ecm REAL(wp) :: rn, ztol INTEGER :: ks, kin, nb, nk - CHARACTER(512) :: km + CHARACTER(1024) :: km st = .FALSE. ecs = CD_HCSTAT_OK ecm = '' @@ -2039,7 +2040,7 @@ SUBROUTINE torsion_descent(ok, why) REAL(wp) :: e0, amp, a, rn, vscale, th0 INTEGER :: attempt, k, j, ks, it2 LOGICAL :: saved_energy, st, moved - CHARACTER(512) :: km + CHARACTER(1024) :: km ok = .FALSE. why = '' km = '' @@ -2516,7 +2517,7 @@ SUBROUTINE add_end_support(iend, e, inode, sgn, sp_stat, sp_msg) REAL(wp) :: z_fl, gxg_s, gyg_s, g_s(2), sf, n_in(3), pen_s, normal_s, normal_gap_s, elem, delem, mom REAL(wp) :: elem_pi INTEGER :: base, bin, i, j - CHARACTER(200) :: em_s + CHARACTER(1024) :: em_s sp_stat = CD_HCSTAT_OK sp_msg = '' base = MERGE(3, 6*(nn - 1) + 3, iend == 1) ! end tangent DOFs are base+1 .. base+3 @@ -2642,7 +2643,7 @@ SUBROUTINE CD_HermiteCable_As_Laid_Offsets(fr, l0, EA, node_load, node_kn, offse REAL(wp), ALLOCATABLE :: ref_g(:, :), ref_0(:, :), wn(:), sn(:), kn_o(:), l0_r(:), ea_r(:) REAL(wp) :: dg(2), dg0(2), cs(2) INTEGER :: k, ne, es - CHARACTER(200) :: em + CHARACTER(1024) :: em ErrStat = CD_HCSTAT_OK ErrMsg = '' ne = SIZE(l0) @@ -3053,10 +3054,10 @@ FUNCTION current_compression_note(l0, EA, qx, seabed_z, flat, frictional, fricti ! TRUE for the two frictionless grounded-run diagnoses (the run folds against its end or ! is pushed along the seabed in compression). LOGICAL, INTENT(OUT), OPTIONAL :: frictionless_run - CHARACTER(512) :: note + CHARACTER(1024) :: note REAL(wp) :: t_min, t_max, s_min, z_min, z_top INTEGER :: k, k_min, wios, ne, es - CHARACTER(200) :: em + CHARACTER(1024) :: em note = '' IF (PRESENT(frictionless_run)) frictionless_run = .FALSE. ne = SIZE(l0) @@ -3162,7 +3163,7 @@ SUBROUTINE CD_HermiteCable_Static_Solve_Continuation(l0, EA, EI, w, seed, fixed_ REAL(wp) :: lambda, lambda_try, dlog, stage_tol, res REAL(wp), ALLOCATABLE :: q(:), q_try(:), curv(:), ei_stage(:) REAL(wp) :: k_stage(2) - CHARACTER(512) :: em + CHARACTER(1024) :: em LOGICAL :: final_stage, restart_stage, snapped ! The current is brought in after the still-water EI continuation (unallocated: the ! stages run without the configuration-dependent drag). @@ -3171,12 +3172,12 @@ SUBROUTINE CD_HermiteCable_Static_Solve_Continuation(l0, EA, EI, w, seed, fixed_ REAL(wp) :: cur_frac LOGICAL :: picard_ok, drag_homotopy, planar_run_limit INTEGER :: iters_first - CHARACTER(512) :: arc_msg + CHARACTER(1024) :: arc_msg ! Arclength workspace: residual, banded tangent (and a copy to factor), drag load, free DOFs. REAL(wp), ALLOCATABLE :: fres(:), kband(:, :), kwork(:, :), dvec(:) LOGICAL, ALLOCATABLE :: free(:) REAL(wp) :: wq - CHARACTER(512) :: first_msg + CHARACTER(1024) :: first_msg CHARACTER(16) :: frac_txt ! Seabed friction of the current (active in every stage after the still-water one). LOGICAL :: use_fric @@ -3479,7 +3480,7 @@ LOGICAL FUNCTION frictionless_run_limit(qx) RESULT(run_limit) !! TRUE when the diagnosis of state qx is a grounded run driven along a frictionless !! seabed (see current_compression_note). REAL(wp), INTENT(IN) :: qx(:) - CHARACTER(512) :: note + CHARACTER(1024) :: note LOGICAL :: flat flat = .NOT. PRESENT(bathymetry) run_limit = .FALSE. @@ -3491,7 +3492,7 @@ END FUNCTION frictionless_run_limit FUNCTION compression_note(qx) RESULT(note) !! current_compression_note for this line (flat seabed plane unless bathymetry). REAL(wp), INTENT(IN) :: qx(:) - CHARACTER(512) :: note + CHARACTER(1024) :: note LOGICAL :: flat flat = .NOT. PRESENT(bathymetry) note = '' @@ -3803,7 +3804,7 @@ SUBROUTINE friction_capacity(qx, cap) REAL(wp) :: z_floor, gxg, gyg, xg, yg, normal, normal_gap, trib_k, cs(2), mu_c, q_c, gq_c(2) REAL(wp), ALLOCATABLE :: fr_ref_c(:, :), kn_c(:) INTEGER :: k, es_c - CHARACTER(200) :: em_c + CHARACTER(1024) :: em_c cs = [CD_ONE, CD_ZERO] IF (PRESENT(contact_frame_cs)) cs = contact_frame_cs IF (current%friction%mu_axial > CD_ZERO .AND. ABS(current%friction%mu_axial - current%friction%mu) > CD_ZERO) THEN @@ -4514,10 +4515,10 @@ SUBROUTINE solve_seq_try(l0, EA, EI, w, seed, fixed_dofs, seabed_z, kn, & REAL(wp), ALLOCATABLE :: q_prev(:) INTEGER, ALLOCATABLE :: fx_l(:), nodes_l(:), nodes_prev(:) TYPE(CD_HermiteResolutionType) :: coarse_diag - CHARACTER(300) :: em_l + CHARACTER(1024) :: em_l ! The level solve failed only on its final residual (a finite best iterate to continue from). LOGICAL :: unmet_l - CHARACTER(200) :: diagnostic_msg + CHARACTER(1024) :: diagnostic_msg CHARACTER(240) :: level_context LOGICAL :: contact_active, use_level_nodal_contact, rebuild_coarse_tangents, coarse_seed_ready LOGICAL :: use_gentle_hierarchy, use_fine_hierarchy @@ -4970,7 +4971,7 @@ SUBROUTINE project_contact(q_seed, old_nodes, new_nodes, stat, msg) CHARACTER(*), INTENT(OUT) :: msg INTEGER :: node, gi, bathy_stat REAL(wp) :: z_floor, xg, yg - CHARACTER(200) :: bathy_msg + CHARACTER(1024) :: bathy_msg stat = CD_HCSTAT_OK msg = '' @@ -5066,7 +5067,7 @@ SUBROUTINE reject_unresolved_sequence(l0, q, ErrStat, ErrMsg) CHARACTER(*), INTENT(INOUT) :: ErrMsg INTEGER :: es, ne TYPE(CD_HermiteResolutionType) :: diag - CHARACTER(200) :: em + CHARACTER(1024) :: em IF (ErrStat /= CD_HCSTAT_OK) RETURN ne = SIZE(l0) @@ -5139,7 +5140,7 @@ SUBROUTINE CD_HermiteCable_Resolution_Metrics(l0, q, seabed_z, contact_band, & axial_element_min, axial_element_min_xi, axial_element_max, axial_element_max_xi, & axial_element_strain, tol_e, tol_rel, ratio REAL(wp), ALLOCATABLE :: elem_min(:), elem_min_xi(:), elem_max(:) - CHARACTER(120) :: em3 + CHARACTER(1024) :: em3 LOGICAL, ALLOCATABLE :: contact_node(:) LOGICAL :: in_island, axial_strain_seen @@ -5473,7 +5474,7 @@ SUBROUTINE CD_HermiteCable_Branch_Audit(l0, q, EA, audit, ErrStat, ErrMsg, end_z REAL(wp) :: H(4), dH(4), r(3), rp(3), ke, u_peak, nmin, nmax, umin, umax, ea_max, nmean, ng, allowance REAL(wp) :: reversal, emean(SIZE(l0)), sm, wl LOGICAL :: reject_c, folded - CHARACTER(160) :: em + CHARACTER(1024) :: em ErrStat = CD_HCSTAT_OK ErrMsg = '' @@ -5950,7 +5951,7 @@ SUBROUTINE compressive_refinement_marks(l0, q, EA, marks, ErrStat, ErrMsg, compr REAL(wp) :: qe(12), nmin, xmin, nmax, xmax, tol_rel, tol_e REAL(wp), ALLOCATABLE :: elem_min(:) LOGICAL, ALLOCATABLE :: raw(:) - CHARACTER(160) :: em + CHARACTER(1024) :: em ErrStat = CD_HCSTAT_OK; ErrMsg = '' IF (SIZE(l0) < 1 .OR. SIZE(EA) /= SIZE(l0) .OR. SIZE(q) /= 6*(SIZE(l0) + 1)) THEN @@ -6597,7 +6598,7 @@ REAL(wp) FUNCTION max_penetration(qx) RESULT(pen) REAL(wp), INTENT(IN) :: qx(:) INTEGER :: node, gz, esx REAL(wp) :: z_floor - CHARACTER(200) :: emx + CHARACTER(1024) :: emx pen = CD_ZERO DO node = 1, SIZE(qx)/6 gz = 6*(node - 1) + 3 @@ -6614,7 +6615,7 @@ SUBROUTINE floor_at(xy, z_floor, esx, emx) CHARACTER(*), INTENT(OUT) :: emx INTEGER :: bstat REAL(wp) :: xg, yg - CHARACTER(200) :: bmsg + CHARACTER(1024) :: bmsg esx = CD_HCSTAT_OK emx = '' z_floor = seabed_z diff --git a/src/CableDyn_HermiteTorsion.f90 b/src/CableDyn_HermiteTorsion.f90 index abbab9dd..998ef475 100644 --- a/src/CableDyn_HermiteTorsion.f90 +++ b/src/CableDyn_HermiteTorsion.f90 @@ -237,7 +237,7 @@ SUBROUTINE CD_HermiteTorsion_Bordered_Solve(ab, kl, ku, g, compliance, rhs, x, E REAL(wp) :: sigma, eta, knorm INTEGER :: n, ldab, attempt, refine LOGICAL :: ok, finite_fail - CHARACTER(160) :: why + CHARACTER(1024) :: why x = CD_ZERO IF (PRESENT(backward_error)) backward_error = HUGE(CD_ONE) @@ -329,7 +329,7 @@ SUBROUTINE dense_solve(success) LOGICAL, INTENT(OUT) :: success REAL(wp), ALLOCATABLE :: kd(:, :) INTEGER :: i, j, info - CHARACTER(200) :: lmsg + CHARACTER(1024) :: lmsg ALLOCATE (kd(n, n)) DO j = 1, n DO i = 1, n diff --git a/src/CableDyn_Modal.f90 b/src/CableDyn_Modal.f90 index ed705916..358870f3 100644 --- a/src/CableDyn_Modal.f90 +++ b/src/CableDyn_Modal.f90 @@ -184,7 +184,7 @@ SUBROUTINE CD_Modal_Bar_Band(q, elem_conn, l0, ea, rho_a, tension_only, kd, K, M REAL(wp), INTENT(IN), OPTIONAL :: seabed_kn(:), floor_z(:) INTEGER :: n, nn, ne, e, a, b, ia, ib, i, j, conn1(2, 1), gd(6) REAL(wp) :: d(3), l, t, ke(3, 3), mm, ke6(6, 6), me6(6, 6), ma(6, 6), q2(6), wl2(2), l02(1), f, df - CHARACTER(200) :: em + CHARACTER(1024) :: em ErrStat = CD_MODAL_OK ErrMsg = '' @@ -298,7 +298,7 @@ SUBROUTINE CD_Modal_Hermite_Band(q, l0, ea, ei, rho_a, kd, K, M, ErrStat, ErrMsg REAL(wp), INTENT(IN), OPTIONAL :: contact_kn(:), floor_z(:) INTEGER :: n, nn, ne, e, i0, i, ao, bo, gd(12) REAL(wp) :: qe(12), energy, fint(12), kt(12, 12), me(12, 12), ma(12, 12), f, df - CHARACTER(200) :: em + CHARACTER(1024) :: em ErrStat = CD_MODAL_OK ErrMsg = '' @@ -441,7 +441,7 @@ SUBROUTINE CD_Modal_Solve_Band(K, M, kd, free, n_modes, omega2, shapes, n_found, REAL(wp), ALLOCATABLE :: vec(:, :), bvec(:, :) REAL(wp) :: qdum(1, 1), zdum(1, 1), anorm, bnorm, shift, scale, nrm, res, rq, noise LOGICAL :: converged - CHARACTER(512) :: em + CHARACTER(1024) :: em EXTERNAL :: dsbgvx ErrStat = CD_MODAL_OK diff --git a/src/CableDyn_Model.f90 b/src/CableDyn_Model.f90 index 631fc344..8bb49c75 100644 --- a/src/CableDyn_Model.f90 +++ b/src/CableDyn_Model.f90 @@ -171,6 +171,13 @@ MODULE CableDyn_Model REAL(wp), ALLOCATABLE :: l0(:), l0_dot(:), f_ext(:), kn(:), cn(:) END TYPE model_lengths_aside + ! The per-element and per-node kernels of the load and added-mass assemblies write messages of + ! at most 187 characters (Hydro, Damping, Viscoelastic, Syrope, bathymetry and band-scatter texts, + ! with their prefixes) and blank their message on entry, also when inputs_validated skips their + ! input scan. They receive the first KERNEL_MSG_LEN characters of the caller's message buffer, + ! so each call resets that much and not the whole (up to 1024-character) buffer. + INTEGER, PARAMETER :: KERNEL_MSG_LEN = 200 + TYPE :: CD_ModelType !! Persistent positions-only EI=0 model state and immutable mesh/properties. LOGICAL :: initialized = .FALSE. @@ -485,7 +492,7 @@ SUBROUTINE CD_Init_Model(model, q0, v0, elem_conn, l0, ea, rho_a, tension_only, INTEGER :: n_dof, n_elem, n_nodes, es, istat, e INTEGER, ALLOCATABLE :: free(:) TYPE(CD_ModelType) :: old_model - CHARACTER(160) :: em + CHARACTER(1024) :: em LOGICAL :: use_seabed, use_seabed_damping, use_seabed_friction LOGICAL :: use_damping, use_drag, use_fk, use_buoyancy, use_added_mass, has_load LOGICAL :: use_viscoelastic, use_syrope @@ -1518,7 +1525,7 @@ SUBROUTINE CD_Init_Line_Model(model, anchor, fairlead, line_types, sections, gra REAL(wp) :: laid_az, laid_t LOGICAL :: reverse_line, converged, use_current LOGICAL :: use_seabed, use_seabed_damping, use_seabed_friction, use_damping - CHARACTER(200) :: em + CHARACTER(1024) :: em TYPE(CableCurrentLoad) :: cur TYPE(CD_StaticLineReport) :: report @@ -2029,7 +2036,7 @@ SUBROUTINE CD_Step_Model(model, dt, converged, stalled, n_iter, ErrStat, ErrMsg, BLOCK TYPE(model_lengths_aside) :: aside INTEGER :: es_c - CHARACTER(160) :: em_c + CHARACTER(1024) :: em_c ! without the loads nothing is rebuilt, so this cannot fail CALL enter_committed_lengths(model, aside, .FALSE., es_c, em_c) CALL sub_tensions_scratch(model, 0) @@ -2115,7 +2122,7 @@ SUBROUTINE run_substeps(n, ok_run) INTEGER :: k, it_k, es_k LOGICAL :: conv_k, stall_k REAL(wp) :: h - CHARACTER(300) :: em_k + CHARACTER(1024) :: em_k ! a plain step's message (discarded: the step falls back) CALL sub_load(model, 1) h = dt/REAL(n, wp) ok_run = .TRUE. @@ -2331,7 +2338,7 @@ SUBROUTINE sub_lengths_at(model, frac, ErrStat) REAL(wp) :: a, b INTEGER :: e, es LOGICAL :: moved - CHARACTER(160) :: em + CHARACTER(KERNEL_MSG_LEN) :: em ErrStat = CD_MODEL_OK moved = .FALSE. DO e = 1, model%n_elem @@ -2385,7 +2392,7 @@ SUBROUTINE sub_tensions(model, tension) REAL(wp), INTENT(OUT) :: tension(:) INTEGER :: e, na, nb, es REAL(wp) :: strain - CHARACTER(160) :: em + CHARACTER(1024) :: em ! model_law_tensions: a law message with its prefix DO e = 1, model%n_elem na = model%elem_conn(1, e) nb = model%elem_conn(2, e) @@ -2439,7 +2446,7 @@ REAL(wp) FUNCTION segment_wave_stiffness(model, e, tension) RESULT(stiff) REAL(wp), INTENT(IN) :: tension REAL(wp) :: ea_d_eff, ea_1_eff INTEGER :: es - CHARACTER(200) :: em + CHARACTER(KERNEL_MSG_LEN) :: em ! a per-element law message (the kernels' bound) stiff = model%ea_dyn(e) IF (stiff > CD_ZERO) RETURN stiff = model%ea(e) @@ -2540,7 +2547,7 @@ SUBROUTINE step_model_plain(model, dt, converged, stalled, n_iter, ErrStat, ErrM REAL(wp), INTENT(IN), OPTIONAL :: prescribed_q(:), prescribed_v(:), prescribed_a(:) INTEGER :: es, e - CHARACTER(160) :: em + CHARACTER(1024) :: em LOGICAL :: has_load, blend, force_lengths REAL(wp) :: af REAL(wp), ALLOCATABLE :: l0_new(:), l0_dot_new(:), l0_start(:), l0_mass(:), f_ext_new(:), f_ext_c(:) @@ -2873,7 +2880,7 @@ SUBROUTINE step_start_load(es_s, em_s) !! committed lengths entered after a length change). INTEGER, INTENT(OUT) :: es_s CHARACTER(*), INTENT(OUT) :: em_s - CHARACTER(160) :: em_c + CHARACTER(1024) :: em_c es_s = CD_MODEL_OK em_s = '' IF (.NOT. (has_load .AND. model%cfg%force_blend)) THEN @@ -2998,7 +3005,7 @@ SUBROUTINE CD_Step_Model_Recovering(model, dt, converged, stalled, n_iter, ErrSt REAL(wp) :: subdt, fraction, hmax0 TYPE(CD_SubstepStats) :: stats0 REAL(wp), ALLOCATABLE :: pq(:), pv(:), pa(:) - CHARACTER(300) :: em, first_em + CHARACTER(1024) :: em, first_em converged = .FALSE. stalled = .FALSE. @@ -3196,7 +3203,7 @@ SUBROUTINE enter_committed_lengths(model, aside, loads, ErrStat, ErrMsg) REAL(wp), ALLOCATABLE :: f_c(:), kn_c(:) LOGICAL :: rebuild INTEGER :: es - CHARACTER(160) :: em + CHARACTER(KERNEL_MSG_LEN) :: em ErrStat = CD_MODEL_OK ErrMsg = '' @@ -3287,13 +3294,14 @@ SUBROUTINE mapped_friction_anchors(model, q, v, commit, ErrStat, ErrMsg) LOGICAL, INTENT(IN) :: commit INTEGER, INTENT(OUT) :: ErrStat CHARACTER(*), INTENT(OUT) :: ErrMsg - INTEGER :: i, ix + INTEGER :: i, ix, lk REAL(wp) :: normal, cap, d(2), dlen, k, mu_d, q_d, gq_d(2) ErrStat = CD_MODEL_OK ErrMsg = '' + lk = MIN(LEN(ErrMsg), KERNEL_MSG_LEN) ! the per-node query's share of ErrMsg DO i = 1, SIZE(model%fr_anchor, 2) ix = 3*i - 2 - normal = seabed_normal_reaction(model, q(ix), q(ix + 1), q(ix + 2), v(ix:ix + 2), i, ErrStat, ErrMsg) + normal = seabed_normal_reaction(model, q(ix), q(ix + 1), q(ix + 2), v(ix:ix + 2), i, ErrStat, ErrMsg(1:lk)) IF (ErrStat /= CD_MODEL_OK) RETURN IF (.NOT. commit) CYCLE IF (model%seabed_friction_aniso) THEN @@ -3711,7 +3719,7 @@ SUBROUTINE CD_Set_Model_Syrope_State(model, slow, tmax, ErrStat, ErrMsg) CHARACTER(*), INTENT(OUT) :: ErrMsg INTEGER :: e, es REAL(wp) :: ws(CD_SYROPE_NWC), wt(CD_SYROPE_NWC), wsl(CD_SYROPE_NWC) - CHARACTER(160) :: em + CHARACTER(1024) :: em ErrStat = CD_MODEL_OK ErrMsg = '' IF (.NOT. model%initialized) THEN @@ -3871,7 +3879,7 @@ SUBROUTINE CD_Calc_Model_CoupledLoads(model, coupled_loads, ErrStat, ErrMsg) CHARACTER(*), INTENT(OUT) :: ErrMsg INTEGER :: es, istat, k - CHARACTER(160) :: em + CHARACTER(1024) :: em ErrStat = CD_MODEL_OK ErrMsg = '' @@ -3955,7 +3963,7 @@ SUBROUTINE CD_Calc_Model_CoupledKinematicDerivatives(model, dload_dq, dload_dv, CHARACTER(*), INTENT(OUT) :: ErrMsg INTEGER :: es, nc, n_free, i, j, row, col - CHARACTER(160) :: em + CHARACTER(1024) :: em ErrStat = CD_MODEL_OK ErrMsg = '' @@ -4105,7 +4113,7 @@ SUBROUTINE CD_Update_Model_CoupledAccelDerivative(model, ErrStat, ErrMsg) INTEGER :: idx(6), conn1(2, 1) REAL(wp) :: coeff, s, q2(6), l02(1), wl2(2), m2(6, 6) LOGICAL :: hit, ok - CHARACTER(160) :: em + CHARACTER(1024) :: em ErrStat = CD_MODEL_OK ErrMsg = '' @@ -4454,7 +4462,7 @@ SUBROUTINE CD_Update_Model_SegmentLength(model, elem, l0_new, l0_dot, ErrStat, E LOGICAL, INTENT(IN), OPTIONAL :: restored INTEGER :: es REAL(wp) :: rate - CHARACTER(160) :: em + CHARACTER(1024) :: em ErrStat = CD_MODEL_OK ErrMsg = '' rate = positive_zero(l0_dot) @@ -4674,7 +4682,7 @@ SUBROUTINE CD_Get_Model_EndNodeAddedMass(model, coupled_slot, ma_block, ErrStat, CHARACTER(*), INTENT(OUT) :: ErrMsg INTEGER :: e, node, d0, idx(6), es REAL(wp) :: q2(6), wl2(2), m2(6, 6) - CHARACTER(160) :: em + CHARACTER(1024) :: em ma_block = CD_ZERO ErrStat = CD_MODEL_OK ErrMsg = '' @@ -4979,7 +4987,7 @@ SUBROUTINE CD_Get_Model_EndForces(model, force_first, force_last, ErrStat, ErrMs REAL(wp) :: load(9) REAL(wp) :: fint_first(3), fint_last(3), nodes6(6), Kt6(6, 6), fint6(6), Te INTEGER :: es, n, nn, e, a, b - CHARACTER(160) :: em + CHARACTER(1024) :: em force_first = CD_ZERO force_last = CD_ZERO @@ -5035,7 +5043,7 @@ SUBROUTINE CD_Get_Model_Tension(model, tension, ErrStat, ErrMsg) CHARACTER(*), INTENT(OUT) :: ErrMsg INTEGER :: es - CHARACTER(160) :: em + CHARACTER(1024) :: em tension = CD_ZERO ErrStat = CD_MODEL_OK @@ -5096,7 +5104,7 @@ SUBROUTINE model_law_tensions(model, tension, ErrStat, ErrMsg) INTEGER, INTENT(OUT) :: ErrStat CHARACTER(*), INTENT(OUT) :: ErrMsg INTEGER :: es - CHARACTER(160) :: em + CHARACTER(KERNEL_MSG_LEN) :: em ! a per-element law message (the kernels' bound) ErrStat = CD_MODEL_OK ErrMsg = '' @@ -5340,7 +5348,7 @@ SUBROUTINE CD_Update_Model_External_Loads(model, f_ext, ErrStat, ErrMsg) REAL(wp) :: f_dist(SIZE(model%f_ext)) REAL(wp), ALLOCATABLE :: base_entry(:) INTEGER :: es2 - CHARACTER(160) :: em2 + CHARACTER(1024) :: em2 IF (ALLOCATED(model%dist_load)) THEN CALL CD_Assemble_Distributed_Load(model%elem_conn, model%l0, model%dist_load, f_dist, es2, em2) IF (es2 /= 0) THEN @@ -5489,7 +5497,7 @@ SUBROUTINE recompute_model_acceleration_now(model, ErrStat, ErrMsg) CHARACTER(*), INTENT(OUT) :: ErrMsg INTEGER :: es - CHARACTER(160) :: em + CHARACTER(1024) :: em LOGICAL :: has_load INTEGER :: nc LOGICAL :: prescribed_workspace_ready @@ -5559,7 +5567,7 @@ SUBROUTINE apply_prescribed_acceleration_coupling(model, prescribed_a, ErrStat, CHARACTER(*), INTENT(OUT) :: ErrMsg INTEGER :: es, n_free, i, j, row, col - CHARACTER(160) :: em + CHARACTER(1024) :: em ErrStat = CD_MODEL_OK ErrMsg = '' @@ -5795,7 +5803,7 @@ SUBROUTINE CD_Audit_Model_Step(model, time, dt, new_spike) REAL(wp) :: d(3), ell, strain, u(3), c, line_max, tn, h REAL(wp), ALLOCATABLE :: law(:) LOGICAL :: fresh, laws - CHARACTER(160) :: em + CHARACTER(1024) :: em new_spike = .FALSE. IF (.NOT. model%initialized .OR. model%n_elem < 1) RETURN @@ -6093,7 +6101,7 @@ SUBROUTINE CD_Copy_Model(src, dst, ErrStat, ErrMsg) TYPE(CD_ModelType) :: work INTEGER :: es - CHARACTER(200) :: em + CHARACTER(1024) :: em ErrStat = CD_MODEL_OK ErrMsg = '' @@ -6497,7 +6505,7 @@ SUBROUTINE copy_syrope_types(src, dst, ErrStat, ErrMsg) CHARACTER(*), INTENT(OUT) :: ErrMsg INTEGER :: istat, e, es2 - CHARACTER(160) :: em2 + CHARACTER(1024) :: em2 ErrStat = CD_MODEL_OK ErrMsg = '' @@ -6589,7 +6597,7 @@ SUBROUTINE restore_after_init_alloc_fail(model, old_model, label, ErrStat, ErrMs CHARACTER(*), INTENT(OUT) :: ErrMsg INTEGER :: es - CHARACTER(160) :: em + CHARACTER(1024) :: em CALL CD_End_Model(model, es, em) model = old_model @@ -7084,7 +7092,9 @@ SUBROUTINE model_contributor_load_banded(model, q, v, free, kl, ku, force, jac_q REAL(wp) :: q2(6), v2(6), f2(6), jq2(6, 6), jv2(6, 6), ea_d_eff, ea_1_eff, syr_tm, syr_ds LOGICAL :: free_map_ready REAL(wp) :: fluid2(3, 2), accel2(3, 2), wl2(2), dfdv(2, 2) + INTEGER :: lk ! the kernels' share of ErrMsg (KERNEL_MSG_LEN) + lk = MIN(LEN(ErrMsg), KERNEL_MSG_LEN) force = CD_ZERO jac_q_band = CD_ZERO jac_v_band = CD_ZERO @@ -7131,7 +7141,7 @@ SUBROUTINE model_contributor_load_banded(model, q, v, free, kl, ku, force, jac_q iy = 3*i - 1 iz = 3*i IF (model%has_bathymetry) THEN - CALL model_floor_gradient(model, q(ix), q(iy), z_floor, dfdx, dfdy, ErrStat, ErrMsg, curvature=curv_n) + CALL model_floor_gradient(model, q(ix), q(iy), z_floor, dfdx, dfdy, ErrStat, ErrMsg(1:lk), curvature=curv_n) IF (ErrStat /= CD_MODEL_OK) RETURN ELSE z_floor = model%seabed_z_floor @@ -7151,7 +7161,7 @@ SUBROUTINE model_contributor_load_banded(model, q, v, free, kl, ku, force, jac_q DO cb = 1, 3 DO ra = 1, 3 CALL scatter_scalar_band(jac_q_band, model%free_map_work, kl, ku, ix + ra - 1, ix + cb - 1, & - jac3(ra, cb), ErrStat, ErrMsg) + jac3(ra, cb), ErrStat, ErrMsg(1:lk)) IF (ErrStat /= CD_MODEL_OK) RETURN END DO END DO @@ -7161,7 +7171,7 @@ SUBROUTINE model_contributor_load_banded(model, q, v, free, kl, ku, force, jac_q CALL CD_Seabed_Normal_Law(gap, model%seabed_kn(i), normal, tangent) force(iz) = force(iz) + normal CALL scatter_scalar_band(jac_q_band, model%free_map_work, kl, ku, iz, iz, tangent, & - ErrStat, ErrMsg) + ErrStat, ErrMsg(1:lk)) IF (ErrStat /= CD_MODEL_OK) RETURN END DO END IF @@ -7172,16 +7182,16 @@ SUBROUTINE model_contributor_load_banded(model, q, v, free, kl, ku, force, jac_q iy = 3*i - 1 iz = 3*i ! damping along the floor normal, at the normal penetration and normal velocity - CALL node_contact_normal(model, q(ix), q(iy), q(iz), v(ix:iz), gap, vn, nvec, sloped, ErrStat, ErrMsg) + CALL node_contact_normal(model, q(ix), q(iy), q(iz), v(ix:iz), gap, vn, nvec, sloped, ErrStat, ErrMsg(1:lk)) IF (ErrStat /= CD_MODEL_OK) RETURN CALL seabed_normal_damping_terms(gap, vn, model%seabed_cn(i), damp_force, damp_dgap, damp_dvz) IF (.NOT. sloped) THEN force(iz) = force(iz) + damp_force CALL scatter_scalar_band(jac_q_band, model%free_map_work, kl, ku, iz, iz, damp_dgap, & - ErrStat, ErrMsg) + ErrStat, ErrMsg(1:lk)) IF (ErrStat /= CD_MODEL_OK) RETURN CALL scatter_scalar_band(jac_v_band, model%free_map_work, kl, ku, iz, iz, -damp_dvz, & - ErrStat, ErrMsg) + ErrStat, ErrMsg(1:lk)) IF (ErrStat /= CD_MODEL_OK) RETURN CYCLE END IF @@ -7192,10 +7202,10 @@ SUBROUTINE model_contributor_load_banded(model, q, v, free, kl, ku, force, jac_q DO cb = 1, 3 DO ra = 1, 3 CALL scatter_scalar_band(jac_q_band, model%free_map_work, kl, ku, ix + ra - 1, ix + cb - 1, & - damp_dgap*nvec(ra)*nvec(cb), ErrStat, ErrMsg) + damp_dgap*nvec(ra)*nvec(cb), ErrStat, ErrMsg(1:lk)) IF (ErrStat /= CD_MODEL_OK) RETURN CALL scatter_scalar_band(jac_v_band, model%free_map_work, kl, ku, ix + ra - 1, ix + cb - 1, & - -damp_dvz*nvec(ra)*nvec(cb), ErrStat, ErrMsg) + -damp_dvz*nvec(ra)*nvec(cb), ErrStat, ErrMsg(1:lk)) IF (ErrStat /= CD_MODEL_OK) RETURN END DO END DO @@ -7208,7 +7218,7 @@ SUBROUTINE model_contributor_load_banded(model, q, v, free, kl, ku, force, jac_q ix = 3*i - 2 iy = 3*i - 1 iz = 3*i - normal = seabed_normal_reaction(model, q(ix), q(iy), q(iz), v(ix:iz), i, ErrStat, ErrMsg) + normal = seabed_normal_reaction(model, q(ix), q(iy), q(iz), v(ix:iz), i, ErrStat, ErrMsg(1:lk)) IF (ErrStat /= CD_MODEL_OK) RETURN IF (normal <= CD_ZERO) CYCLE ! stick-slip spring to the committed anchor; the load on the node is -f @@ -7226,23 +7236,23 @@ SUBROUTINE model_contributor_load_banded(model, q, v, free, kl, ku, force, jac_q END IF force(ix) = force(ix) - g(1) force(iy) = force(iy) - g(2) - CALL scatter_scalar_band(jac_q_band, model%free_map_work, kl, ku, ix, ix, dfdv(1, 1), ErrStat, ErrMsg) + CALL scatter_scalar_band(jac_q_band, model%free_map_work, kl, ku, ix, ix, dfdv(1, 1), ErrStat, ErrMsg(1:lk)) IF (ErrStat /= CD_MODEL_OK) RETURN - CALL scatter_scalar_band(jac_q_band, model%free_map_work, kl, ku, ix, iy, dfdv(1, 2), ErrStat, ErrMsg) + CALL scatter_scalar_band(jac_q_band, model%free_map_work, kl, ku, ix, iy, dfdv(1, 2), ErrStat, ErrMsg(1:lk)) IF (ErrStat /= CD_MODEL_OK) RETURN - CALL scatter_scalar_band(jac_q_band, model%free_map_work, kl, ku, iy, ix, dfdv(2, 1), ErrStat, ErrMsg) + CALL scatter_scalar_band(jac_q_band, model%free_map_work, kl, ku, iy, ix, dfdv(2, 1), ErrStat, ErrMsg(1:lk)) IF (ErrStat /= CD_MODEL_OK) RETURN - CALL scatter_scalar_band(jac_q_band, model%free_map_work, kl, ku, iy, iy, dfdv(2, 2), ErrStat, ErrMsg) + CALL scatter_scalar_band(jac_q_band, model%free_map_work, kl, ku, iy, iy, dfdv(2, 2), ErrStat, ErrMsg(1:lk)) IF (ErrStat /= CD_MODEL_OK) RETURN IF (ABS(dfc(1)) + ABS(dfc(2)) <= CD_ZERO) CYCLE ! sliding: the capacity follows the normal reaction CALL scatter_seabed_friction_position_band(model, q(ix), q(iy), q(iz), v(ix:iz), i, ix, dfc(1), jac_q_band, & - model%free_map_work, kl, ku, ErrStat, ErrMsg, mu_c) + model%free_map_work, kl, ku, ErrStat, ErrMsg(1:lk), mu_c) IF (ErrStat /= CD_MODEL_OK) RETURN CALL scatter_seabed_friction_position_band(model, q(ix), q(iy), q(iz), v(ix:iz), i, iy, dfc(2), jac_q_band, & - model%free_map_work, kl, ku, ErrStat, ErrMsg, mu_c) + model%free_map_work, kl, ku, ErrStat, ErrMsg(1:lk), mu_c) IF (ErrStat /= CD_MODEL_OK) RETURN - CALL seabed_normal_velocity_gradient(model, q(ix), q(iy), q(iz), v(ix:iz), i, dn_dv, ErrStat, ErrMsg) + CALL seabed_normal_velocity_gradient(model, q(ix), q(iy), q(iz), v(ix:iz), i, dn_dv, ErrStat, ErrMsg(1:lk)) IF (ErrStat /= CD_MODEL_OK) RETURN BLOCK INTEGER :: rr, cc @@ -7251,7 +7261,7 @@ SUBROUTINE model_contributor_load_banded(model, q, v, free, kl, ku, force, jac_q ! a level floor has dn_dv = (0, 0, d): skip its structural zeros IF (cc < 3 .AND. .NOT. (ABS(dn_dv(cc)) > CD_ZERO)) CYCLE CALL scatter_scalar_band(jac_v_band, model%free_map_work, kl, ku, ix + rr - 1, ix + cc - 1, & - mu_c*dn_dv(cc)*dfc(rr), ErrStat, ErrMsg) + mu_c*dn_dv(cc)*dfc(rr), ErrStat, ErrMsg(1:lk)) IF (ErrStat /= CD_MODEL_OK) RETURN END DO END DO @@ -7269,39 +7279,39 @@ SUBROUTINE model_contributor_load_banded(model, q, v, free, kl, ku, force, jac_q CALL extract_element_state(model, e, q, v, idx, q2, v2) IF (model%has_damping) THEN CALL CD_Axial_Damping_Element_Load(q2(1:3), q2(4:6), v2(1:3), v2(4:6), model%l0(e), & - model%ba_dyn(e), f2, jq2, jv2, ErrStat, ErrMsg, & + model%ba_dyn(e), f2, jq2, jv2, ErrStat, ErrMsg(1:lk), & l0_dot=model%l0_dot(e), inputs_validated=.TRUE.) IF (ErrStat /= 0) RETURN CALL scatter_element_vector(force, idx, f2) - CALL scatter_element_matrix_band(jac_q_band, model%free_map_work, kl, ku, idx, jq2, ErrStat, ErrMsg) + CALL scatter_element_matrix_band(jac_q_band, model%free_map_work, kl, ku, idx, jq2, ErrStat, ErrMsg(1:lk)) IF (ErrStat /= CD_MODEL_OK) RETURN - CALL scatter_element_matrix_band(jac_v_band, model%free_map_work, kl, ku, idx, jv2, ErrStat, ErrMsg) + CALL scatter_element_matrix_band(jac_v_band, model%free_map_work, kl, ku, idx, jv2, ErrStat, ErrMsg(1:lk)) IF (ErrStat /= CD_MODEL_OK) RETURN END IF IF (model%has_viscoelastic) THEN IF (model%ve_mode(e) /= 0) THEN - CALL model_viscoelastic_coeffs(model, e, ea_d_eff, ea_1_eff, ErrStat, ErrMsg) + CALL model_viscoelastic_coeffs(model, e, ea_d_eff, ea_1_eff, ErrStat, ErrMsg(1:lk)) IF (ErrStat /= CD_MODEL_OK) RETURN CALL CD_Viscoelastic_Element_Load(q2(1:3), q2(4:6), v2(1:3), v2(4:6), model%l0(e), & ea_d_eff, ea_1_eff, model%ve_ba(e), & model%ve_ba_d(e), model%ve_dl_1(e), model%ve_dt, & - f2, jq2, jv2, ErrStat, ErrMsg) + f2, jq2, jv2, ErrStat, ErrMsg(1:lk)) IF (ErrStat /= 0) RETURN CALL scatter_element_vector(force, idx, f2) - CALL scatter_element_matrix_band(jac_q_band, model%free_map_work, kl, ku, idx, jq2, ErrStat, ErrMsg) + CALL scatter_element_matrix_band(jac_q_band, model%free_map_work, kl, ku, idx, jq2, ErrStat, ErrMsg(1:lk)) IF (ErrStat /= CD_MODEL_OK) RETURN - CALL scatter_element_matrix_band(jac_v_band, model%free_map_work, kl, ku, idx, jv2, ErrStat, ErrMsg) + CALL scatter_element_matrix_band(jac_v_band, model%free_map_work, kl, ku, idx, jv2, ErrStat, ErrMsg(1:lk)) IF (ErrStat /= CD_MODEL_OK) RETURN END IF END IF IF (model%has_syrope) THEN IF (model%syrope_is(e)) THEN - CALL model_syrope_element(model, e, q2, v2, f2, jq2, jv2, syr_tm, syr_ds, ErrStat, ErrMsg) + CALL model_syrope_element(model, e, q2, v2, f2, jq2, jv2, syr_tm, syr_ds, ErrStat, ErrMsg(1:lk)) IF (ErrStat /= CD_MODEL_OK) RETURN CALL scatter_element_vector(force, idx, f2) - CALL scatter_element_matrix_band(jac_q_band, model%free_map_work, kl, ku, idx, jq2, ErrStat, ErrMsg) + CALL scatter_element_matrix_band(jac_q_band, model%free_map_work, kl, ku, idx, jq2, ErrStat, ErrMsg(1:lk)) IF (ErrStat /= CD_MODEL_OK) RETURN - CALL scatter_element_matrix_band(jac_v_band, model%free_map_work, kl, ku, idx, jv2, ErrStat, ErrMsg) + CALL scatter_element_matrix_band(jac_v_band, model%free_map_work, kl, ku, idx, jv2, ErrStat, ErrMsg(1:lk)) IF (ErrStat /= CD_MODEL_OK) RETURN END IF END IF @@ -7311,13 +7321,13 @@ SUBROUTINE model_contributor_load_banded(model, q, v, free, kl, ku, force, jac_q CALL CD_Morison_Drag_Element_Load(q2(1:3), q2(4:6), v2(1:3), v2(4:6), model%l0(e), & fluid2(:, 1), fluid2(:, 2), wl2(1), wl2(2), model%drag_rho, & model%drag_diameter_elem(e), model%drag_cdn_elem(e), & - model%drag_cdt_elem(e), f2, jq2, jv2, ErrStat, ErrMsg, & + model%drag_cdt_elem(e), f2, jq2, jv2, ErrStat, ErrMsg(1:lk), & inputs_validated=.TRUE.) IF (ErrStat /= 0) RETURN CALL scatter_element_vector(force, idx, f2) - CALL scatter_element_matrix_band(jac_q_band, model%free_map_work, kl, ku, idx, jq2, ErrStat, ErrMsg) + CALL scatter_element_matrix_band(jac_q_band, model%free_map_work, kl, ku, idx, jq2, ErrStat, ErrMsg(1:lk)) IF (ErrStat /= CD_MODEL_OK) RETURN - CALL scatter_element_matrix_band(jac_v_band, model%free_map_work, kl, ku, idx, jv2, ErrStat, ErrMsg) + CALL scatter_element_matrix_band(jac_v_band, model%free_map_work, kl, ku, idx, jv2, ErrStat, ErrMsg(1:lk)) IF (ErrStat /= CD_MODEL_OK) RETURN END IF IF (model%has_froude_krylov) THEN @@ -7326,11 +7336,11 @@ SUBROUTINE model_contributor_load_banded(model, q, v, free, kl, ku, force, jac_q CALL CD_Froude_Krylov_Element_Load(q2(1:3), q2(4:6), v2(1:3), v2(4:6), model%l0(e), & accel2(:, 1), accel2(:, 2), wl2(1), wl2(2), model%fk_rho, & model%fk_diameter_elem(e), model%fk_can_elem(e), & - model%fk_cat_elem(e), f2, jq2, jv2, ErrStat, ErrMsg, & + model%fk_cat_elem(e), f2, jq2, jv2, ErrStat, ErrMsg(1:lk), & inputs_validated=.TRUE.) IF (ErrStat /= 0) RETURN CALL scatter_element_vector(force, idx, f2) - CALL scatter_element_matrix_band(jac_q_band, model%free_map_work, kl, ku, idx, jq2, ErrStat, ErrMsg) + CALL scatter_element_matrix_band(jac_q_band, model%free_map_work, kl, ku, idx, jq2, ErrStat, ErrMsg(1:lk)) IF (ErrStat /= CD_MODEL_OK) RETURN ! jv2 is identically zero (a velocity-independent load), and adding zeros changes no ! entry of a band that starts at +0 and only accumulates: its scatter is skipped. The @@ -7341,11 +7351,11 @@ SUBROUTINE model_contributor_load_banded(model, q, v, free, kl, ku, force, jac_q CALL extract_nodal_scalar(model%buoyancy_waterline_z, model, e, wl2) CALL CD_Buoyancy_Recovery_Element_Load(q2(1:3), q2(4:6), model%l0(e), wl2(1), wl2(2), & model%buoyancy_rho, model%buoyancy_diameter_elem(e), & - model%buoyancy_gravity, f2, jq2, jv2, ErrStat, ErrMsg, & + model%buoyancy_gravity, f2, jq2, jv2, ErrStat, ErrMsg(1:lk), & inputs_validated=.TRUE.) IF (ErrStat /= 0) RETURN CALL scatter_element_vector(force, idx, f2) - CALL scatter_element_matrix_band(jac_q_band, model%free_map_work, kl, ku, idx, jq2, ErrStat, ErrMsg) + CALL scatter_element_matrix_band(jac_q_band, model%free_map_work, kl, ku, idx, jq2, ErrStat, ErrMsg(1:lk)) IF (ErrStat /= CD_MODEL_OK) RETURN ! jv2 is identically zero: no scatter (as for Froude-Krylov above) END IF @@ -7386,7 +7396,9 @@ SUBROUTINE model_contributor_force(model, q, v, force, ErrStat, ErrMsg, end_node REAL(wp) :: d_fr(2) REAL(wp) :: q2(6), v2(6), f2(6), ea_d_eff, ea_1_eff, syr_tm, syr_ds, syr_jac(6, 6), syr_jac_v(6, 6) REAL(wp) :: fluid2(3, 2), accel2(3, 2), wl2(2) + INTEGER :: lk ! the kernels' share of ErrMsg (KERNEL_MSG_LEN) + lk = MIN(LEN(ErrMsg), KERNEL_MSG_LEN) force = CD_ZERO n = SIZE(q) ends = .FALSE. @@ -7430,7 +7442,7 @@ SUBROUTINE model_contributor_force(model, q, v, force, ErrStat, ErrMsg, end_node ! sloped seabed: frictionless contact along the surface normal BLOCK REAL(wp) :: fvec(3), jac3(3, 3), gx, gy, curv(3) - CALL model_floor_gradient(model, q(ix), q(iy), z_floor, gx, gy, ErrStat, ErrMsg, curvature=curv) + CALL model_floor_gradient(model, q(ix), q(iy), z_floor, gx, gy, ErrStat, ErrMsg(1:lk), curvature=curv) IF (ErrStat /= CD_MODEL_OK) RETURN IF (ABS(gx) > CD_ZERO .OR. ABS(gy) > CD_ZERO .OR. ANY(ABS(curv) > CD_ZERO)) THEN CALL CD_Seabed_Normal_Contact(z_floor - q(iz), gx, gy, model%seabed_kn(i), fvec, jac3, curvature=curv) @@ -7456,7 +7468,7 @@ SUBROUTINE model_contributor_force(model, q, v, force, ErrStat, ErrMsg, end_node BLOCK REAL(wp) :: vn, nvec(3) LOGICAL :: sloped - CALL node_contact_normal(model, q(ix), q(iy), q(iz), v(ix:iz), gap, vn, nvec, sloped, ErrStat, ErrMsg) + CALL node_contact_normal(model, q(ix), q(iy), q(iz), v(ix:iz), gap, vn, nvec, sloped, ErrStat, ErrMsg(1:lk)) IF (ErrStat /= CD_MODEL_OK) RETURN CALL seabed_normal_damping_terms(gap, vn, model%seabed_cn(i), damp_force, damp_dgap, damp_dvz) IF (sloped) THEN @@ -7474,7 +7486,7 @@ SUBROUTINE model_contributor_force(model, q, v, force, ErrStat, ErrMsg, end_node ix = 3*i - 2 iy = 3*i - 1 iz = 3*i - normal = seabed_normal_reaction(model, q(ix), q(iy), q(iz), v(ix:iz), i, ErrStat, ErrMsg) + normal = seabed_normal_reaction(model, q(ix), q(iy), q(iz), v(ix:iz), i, ErrStat, ErrMsg(1:lk)) IF (ErrStat /= CD_MODEL_OK) RETURN IF (normal <= CD_ZERO) CYCLE d_fr(1) = q(ix) - model%fr_anchor(1, i) @@ -7501,19 +7513,19 @@ SUBROUTINE model_contributor_force(model, q, v, force, ErrStat, ErrMsg, end_node IF (ends) idx = [(slot(idx(i)), i=1, 6)] IF (model%has_damping) THEN CALL CD_Axial_Damping_Element_Force(q2(1:3), q2(4:6), v2(1:3), v2(4:6), model%l0(e), & - model%ba_dyn(e), f2, ErrStat, ErrMsg, & + model%ba_dyn(e), f2, ErrStat, ErrMsg(1:lk), & l0_dot=model%l0_dot(e), inputs_validated=.TRUE.) IF (ErrStat /= 0) RETURN CALL scatter_element_vector(force, idx, f2) END IF IF (model%has_viscoelastic) THEN IF (model%ve_mode(e) /= 0) THEN - CALL model_viscoelastic_coeffs(model, e, ea_d_eff, ea_1_eff, ErrStat, ErrMsg) + CALL model_viscoelastic_coeffs(model, e, ea_d_eff, ea_1_eff, ErrStat, ErrMsg(1:lk)) IF (ErrStat /= CD_MODEL_OK) RETURN CALL CD_Viscoelastic_Element_Force(q2(1:3), q2(4:6), v2(1:3), v2(4:6), model%l0(e), & ea_d_eff, ea_1_eff, model%ve_ba(e), & model%ve_ba_d(e), model%ve_dl_1(e), model%ve_dt, & - f2, ErrStat, ErrMsg) + f2, ErrStat, ErrMsg(1:lk)) IF (ErrStat /= 0) RETURN CALL scatter_element_vector(force, idx, f2) IF (PRESENT(law_tension)) law_tension(e) = element_law_tension() @@ -7522,7 +7534,7 @@ SUBROUTINE model_contributor_force(model, q, v, force, ErrStat, ErrMsg, end_node END IF IF (model%has_syrope) THEN IF (model%syrope_is(e)) THEN - CALL model_syrope_element(model, e, q2, v2, f2, syr_jac, syr_jac_v, syr_tm, syr_ds, ErrStat, ErrMsg) + CALL model_syrope_element(model, e, q2, v2, f2, syr_jac, syr_jac_v, syr_tm, syr_ds, ErrStat, ErrMsg(1:lk)) IF (ErrStat /= CD_MODEL_OK) RETURN CALL scatter_element_vector(force, idx, f2) IF (PRESENT(law_tension)) law_tension(e) = element_law_tension() @@ -7536,7 +7548,7 @@ SUBROUTINE model_contributor_force(model, q, v, force, ErrStat, ErrMsg, end_node CALL CD_Morison_Drag_Element_Force(q2(1:3), q2(4:6), v2(1:3), v2(4:6), model%l0(e), & fluid2(:, 1), fluid2(:, 2), wl2(1), wl2(2), model%drag_rho, & model%drag_diameter_elem(e), model%drag_cdn_elem(e), & - model%drag_cdt_elem(e), f2, ErrStat, ErrMsg, inputs_validated=.TRUE.) + model%drag_cdt_elem(e), f2, ErrStat, ErrMsg(1:lk), inputs_validated=.TRUE.) IF (ErrStat /= 0) RETURN CALL scatter_element_vector(force, idx, f2) END IF @@ -7546,7 +7558,7 @@ SUBROUTINE model_contributor_force(model, q, v, force, ErrStat, ErrMsg, end_node CALL CD_Froude_Krylov_Element_Force(q2(1:3), q2(4:6), v2(1:3), v2(4:6), model%l0(e), & accel2(:, 1), accel2(:, 2), wl2(1), wl2(2), model%fk_rho, & model%fk_diameter_elem(e), model%fk_can_elem(e), & - model%fk_cat_elem(e), f2, ErrStat, ErrMsg, inputs_validated=.TRUE.) + model%fk_cat_elem(e), f2, ErrStat, ErrMsg(1:lk), inputs_validated=.TRUE.) IF (ErrStat /= 0) RETURN CALL scatter_element_vector(force, idx, f2) END IF @@ -7554,7 +7566,7 @@ SUBROUTINE model_contributor_force(model, q, v, force, ErrStat, ErrMsg, end_node CALL extract_nodal_scalar(model%buoyancy_waterline_z, model, e, wl2) CALL CD_Buoyancy_Recovery_Element_Force(q2(1:3), q2(4:6), model%l0(e), wl2(1), wl2(2), & model%buoyancy_rho, model%buoyancy_diameter_elem(e), & - model%buoyancy_gravity, f2, ErrStat, ErrMsg, & + model%buoyancy_gravity, f2, ErrStat, ErrMsg(1:lk), & inputs_validated=.TRUE.) IF (ErrStat /= 0) RETURN CALL scatter_element_vector(force, idx, f2) @@ -8134,7 +8146,9 @@ SUBROUTINE model_added_mass_banded(model, q, accel, free, kl, ku, M_add_a, M_add INTEGER :: e, i, n, ldab, idx(6) REAL(wp) :: q2(6), a2(6), wl2(2), m2(6, 6), dm2(6, 6), ma2(6), le LOGICAL :: want_tangent, zero_accel, free_map_ready + INTEGER :: lk ! the kernels' share of ErrMsg (KERNEL_MSG_LEN) + lk = MIN(LEN(ErrMsg), KERNEL_MSG_LEN) ErrStat = CD_MODEL_OK ErrMsg = '' want_tangent = .TRUE. @@ -8204,14 +8218,14 @@ SUBROUTINE model_added_mass_banded(model, q, accel, free, kl, ku, M_add_a, M_add CALL CD_Added_Mass_Element_Matrix(q2(1:3), q2(4:6), le, wl2(1), wl2(2), & model%added_mass_rho, model%added_mass_diameter_elem(e), & model%added_mass_can_elem(e), model%added_mass_cat_elem(e), & - m2, ErrStat, ErrMsg, inputs_validated=.TRUE.) + m2, ErrStat, ErrMsg(1:lk), inputs_validated=.TRUE.) IF (ErrStat /= 0) RETURN ma2 = CD_ZERO ELSE CALL CD_Added_Mass_Element(q2(1:3), q2(4:6), a2(1:3), a2(4:6), le, wl2(1), wl2(2), & model%added_mass_rho, model%added_mass_diameter_elem(e), & model%added_mass_can_elem(e), model%added_mass_cat_elem(e), & - m2, dm2, ErrStat, ErrMsg, inputs_validated=.TRUE.) + m2, dm2, ErrStat, ErrMsg(1:lk), inputs_validated=.TRUE.) IF (ErrStat /= 0) RETURN ma2 = MATMUL(m2, a2) END IF @@ -8219,15 +8233,15 @@ SUBROUTINE model_added_mass_banded(model, q, accel, free, kl, ku, M_add_a, M_add CALL CD_Added_Mass_Element_Force(q2(1:3), q2(4:6), a2(1:3), a2(4:6), le, wl2(1), wl2(2), & model%added_mass_rho, model%added_mass_diameter_elem(e), & model%added_mass_can_elem(e), model%added_mass_cat_elem(e), & - ma2, ErrStat, ErrMsg, inputs_validated=.TRUE.) + ma2, ErrStat, ErrMsg(1:lk), inputs_validated=.TRUE.) IF (ErrStat /= 0) RETURN END IF CALL scatter_element_vector(M_add_a, idx, ma2) IF (want_tangent) THEN - CALL scatter_element_matrix_band(M_add_band, model%free_map_work, kl, ku, idx, m2, ErrStat, ErrMsg) + CALL scatter_element_matrix_band(M_add_band, model%free_map_work, kl, ku, idx, m2, ErrStat, ErrMsg(1:lk)) IF (ErrStat /= CD_MODEL_OK) RETURN IF (.NOT. zero_accel) THEN - CALL scatter_element_matrix_band(dMa_a_dq_band, model%free_map_work, kl, ku, idx, dm2, ErrStat, ErrMsg) + CALL scatter_element_matrix_band(dMa_a_dq_band, model%free_map_work, kl, ku, idx, dm2, ErrStat, ErrMsg(1:lk)) IF (ErrStat /= CD_MODEL_OK) RETURN END IF END IF @@ -8270,7 +8284,10 @@ SUBROUTINE model_added_mass_force(model, q, accel, M_add_a, ErrStat, ErrMsg) INTEGER :: e, idx(6) REAL(wp) :: q2(6), a2(6), wl2(2), ma2(6) + INTEGER :: lk ! the kernels' share of ErrMsg (KERNEL_MSG_LEN) + lk = MIN(LEN(ErrMsg), KERNEL_MSG_LEN) + ErrMsg = '' ! the part past lk stays blank when a kernel fails M_add_a = CD_ZERO DO e = 1, model%n_elem CALL extract_element_positions(model, e, q, idx, q2) @@ -8279,7 +8296,7 @@ SUBROUTINE model_added_mass_force(model, q, accel, M_add_a, ErrStat, ErrMsg) CALL CD_Added_Mass_Element_Force(q2(1:3), q2(4:6), a2(1:3), a2(4:6), model%l0(e), wl2(1), wl2(2), & model%added_mass_rho, model%added_mass_diameter_elem(e), & model%added_mass_can_elem(e), model%added_mass_cat_elem(e), & - ma2, ErrStat, ErrMsg) + ma2, ErrStat, ErrMsg(1:lk)) IF (ErrStat /= 0) RETURN CALL scatter_element_vector(M_add_a, idx, ma2) END DO diff --git a/src/CableDyn_OpenFAST_Aggregate.f90 b/src/CableDyn_OpenFAST_Aggregate.f90 index 1b06e130..a7ffb3ba 100644 --- a/src/CableDyn_OpenFAST_Aggregate.f90 +++ b/src/CableDyn_OpenFAST_Aggregate.f90 @@ -155,7 +155,7 @@ MODULE CableDyn_OpenFAST_Aggregate ! Per-cable status staging lets independent finite-EI cables advance concurrently while ! preserving deterministic, cable-order error reporting after the parallel region. INTEGER, ALLOCATABLE :: cable_stat(:) - CHARACTER(512), ALLOCATABLE :: cable_msg(:) + CHARACTER(1024), ALLOCATABLE :: cable_msg(:) ! Host-driven ambient-fluid surface over the EI=0 system's LINE NODES (the sampling ! points a coupled host feeds with wave kinematics): nfluid = total line-node count, ! fl_off(li) = the node offset of system line li in the flat (3, nfluid) arrays, and @@ -580,7 +580,7 @@ SUBROUTINE CD_AGG_GetMovingPointMesh(self, position, velocity, acceleration, loa INTEGER :: c, col, es REAL(wp) :: y_fair(3) - CHARACTER(512) :: em + CHARACTER(1024) :: em position = CD_ZERO velocity = CD_ZERO @@ -746,7 +746,7 @@ SUBROUTINE CD_AGG_UpdateStates_Moving(self, position, velocity, acceleration, Er INTEGER :: c, col, es REAL(wp) :: zero_angular(3) LOGICAL :: is_output_probe - CHARACTER(512) :: em + CHARACTER(1024) :: em IF (.NOT. require_initialized(self, ErrStat, ErrMsg)) RETURN zero_angular = CD_ZERO @@ -910,7 +910,7 @@ SUBROUTINE CD_AGG_Step_Moving(self, dt, position, velocity, acceleration, conver INTEGER :: c, col, es, nsys, nsub LOGICAL :: csys, ssys, staged REAL(wp) :: t_start - CHARACTER(512) :: em + CHARACTER(1024) :: em converged = .FALSE. stalled = .FALSE. @@ -1235,7 +1235,7 @@ SUBROUTINE CD_AGG_Snapshot(self, ErrStat, ErrMsg) INTEGER, INTENT(OUT) :: ErrStat CHARACTER(*), INTENT(OUT) :: ErrMsg INTEGER :: c, es - CHARACTER(512) :: em + CHARACTER(1024) :: em IF (.NOT. require_initialized(self, ErrStat, ErrMsg)) RETURN IF (self%has_sys) THEN CALL CD_FMF_Snapshot(self%sys, es, em) @@ -1274,7 +1274,7 @@ SUBROUTINE CD_AGG_Restore(self, ErrStat, ErrMsg) INTEGER, INTENT(OUT) :: ErrStat CHARACTER(*), INTENT(OUT) :: ErrMsg INTEGER :: c, es - CHARACTER(512) :: em + CHARACTER(1024) :: em IF (.NOT. require_initialized(self, ErrStat, ErrMsg)) RETURN IF (self%has_sys) THEN CALL CD_FMF_Restore(self%sys, es, em) @@ -1305,7 +1305,7 @@ SUBROUTINE undo_staged_step(self, ErrMsg) TYPE(CD_AGG_ModuleType), INTENT(INOUT) :: self CHARACTER(*), INTENT(INOUT) :: ErrMsg INTEGER :: c, es - CHARACTER(512) :: em + CHARACTER(1024) :: em IF (self%has_sys) THEN CALL CD_FMF_Restore(self%sys, es, em) IF (es /= CD_FMF_OK) ErrMsg = TRIM(ErrMsg)//'; RESTORE FAILED (system): '//TRIM(em) @@ -1328,7 +1328,7 @@ SUBROUTINE size_fluid_surface(candidate, ErrStat, ErrMsg) INTEGER, INTENT(OUT) :: ErrStat CHARACTER(*), INTENT(OUT) :: ErrMsg INTEGER :: nl, li, ic, ib, ir, ip, nbody, nrod, nhydropt, ndof, nn, maxdof, nblk, es, istat - CHARACTER(300) :: em + CHARACTER(1024) :: em ErrStat = CD_AGG_OK ErrMsg = '' candidate%nfluid = 0 @@ -1428,7 +1428,7 @@ SUBROUTINE CD_AGG_GetFluidNodePositions(self, xyz, ErrStat, ErrMsg) INTEGER, INTENT(OUT) :: ErrStat CHARACTER(*), INTENT(OUT) :: ErrMsg INTEGER :: li, ndof, nn, i, es - CHARACTER(300) :: em + CHARACTER(1024) :: em xyz = CD_ZERO IF (.NOT. require_initialized(self, ErrStat, ErrMsg)) RETURN IF (SIZE(xyz, 1) /= 3 .OR. SIZE(xyz, 2) /= self%nfluid) THEN @@ -1518,7 +1518,7 @@ SUBROUTINE CD_AGG_SetFluidFields(self, fluid_velocity, fluid_acceleration, water CHARACTER(*), INTENT(OUT) :: ErrMsg REAL(wp), INTENT(IN), OPTIONAL :: dynamic_pressure(:) INTEGER :: li, o1, o2, i, es - CHARACTER(300) :: em + CHARACTER(1024) :: em IF (.NOT. require_initialized(self, ErrStat, ErrMsg)) RETURN ! Uniform contract for BOTH line families: host fields are only accepted on a ! build that declared them. Cables always carry a drag/added-mass configuration, @@ -1650,7 +1650,7 @@ SUBROUTINE CD_AGG_CalcOutput(self, ErrStat, ErrMsg) CHARACTER(*), INTENT(OUT) :: ErrMsg INTEGER :: es - CHARACTER(512) :: em + CHARACTER(1024) :: em IF (.NOT. require_initialized(self, ErrStat, ErrMsg)) RETURN IF (self%has_sys) THEN @@ -1693,7 +1693,7 @@ SUBROUTINE CD_AGG_Set_Failure_Flags(self, flags, ErrStat, ErrMsg) INTEGER, INTENT(OUT) :: ErrStat CHARACTER(*), INTENT(OUT) :: ErrMsg INTEGER :: es - CHARACTER(512) :: em + CHARACTER(1024) :: em ErrStat = CD_AGG_OK ErrMsg = '' IF (.NOT. require_initialized(self, ErrStat, ErrMsg)) RETURN @@ -1752,7 +1752,7 @@ SUBROUTINE CD_AGG_Apply_LineControl(self, delta_l, delta_l_dot, ErrStat, ErrMsg, INTEGER :: c, ch, es, nspan, k, nrow REAL(wp) :: lambda, mean_seg - CHARACTER(512) :: em + CHARACTER(1024) :: em CHARACTER(16) :: line_kind ErrStat = CD_AGG_OK @@ -1857,7 +1857,7 @@ SUBROUTINE take_back(last, msg) INTEGER, INTENT(IN) :: last CHARACTER(*), INTENT(IN) :: msg INTEGER :: r, es2 - CHARACTER(512) :: em2, em_undo + CHARACTER(1024) :: em2, em_undo em_undo = '' DO r = last, 1, -1 IF (self%ctrl_is_cable(r)) THEN @@ -2119,7 +2119,7 @@ SUBROUTINE CD_AGG_EvalChannel(self, i, value, ErrStat, ErrMsg) CHARACTER(*), INTENT(OUT) :: ErrMsg INTEGER :: es - CHARACTER(300) :: em + CHARACTER(1024) :: em value = CD_ZERO IF (.NOT. require_initialized(self, ErrStat, ErrMsg)) RETURN @@ -2152,7 +2152,7 @@ SUBROUTINE CD_AGG_Range_Sample(self, time, ErrStat, ErrMsg) INTEGER, INTENT(OUT) :: ErrStat CHARACTER(*), INTENT(OUT) :: ErrMsg INTEGER :: es - CHARACTER(512) :: em + CHARACTER(1024) :: em IF (.NOT. require_initialized(self, ErrStat, ErrMsg)) RETURN IF (.NOT. self%ranges%active) RETURN @@ -2176,7 +2176,7 @@ SUBROUTINE CD_AGG_Range_Write(self, root, ErrStat, ErrMsg) INTEGER, INTENT(OUT) :: ErrStat CHARACTER(*), INTENT(OUT) :: ErrMsg INTEGER :: es - CHARACTER(512) :: em + CHARACTER(1024) :: em IF (.NOT. require_initialized(self, ErrStat, ErrMsg)) RETURN CALL CD_Deck_Range_Write(self%ranges, root, es, em) @@ -2199,7 +2199,7 @@ SUBROUTINE CD_AGG_WriteStaticProfile(self, path, ErrStat, ErrMsg) LOGICAL :: refined REAL(wp) :: s, xyz(3), xyz_prev(3), tension, curvature, bend_moment, declination, azimuth CHARACTER(CD_DECK_NAMELEN) :: ch - CHARACTER(512) :: em + CHARACTER(1024) :: em CHARACTER(1) :: tab ErrStat = CD_AGG_OK @@ -2377,7 +2377,7 @@ SUBROUTINE overlay_host_objects(self, output_probe, ErrStat, ErrMsg) INTEGER, INTENT(OUT) :: ErrStat CHARACTER(*), INTENT(OUT) :: ErrMsg INTEGER :: es - CHARACTER(512) :: em + CHARACTER(1024) :: em ErrStat = CD_AGG_OK ErrMsg = '' IF (self%nhost_rod + self%nhost_body == 0 .OR. .NOT. self%has_sys) RETURN @@ -2408,7 +2408,7 @@ SUBROUTINE set_host_objects(self, position, velocity, acceleration, ErrStat, Err LOGICAL, INTENT(IN), OPTIONAL :: step_start INTEGER :: c0, c1, es LOGICAL :: at_start - CHARACTER(512) :: em + CHARACTER(1024) :: em ErrStat = CD_AGG_OK ErrMsg = '' at_start = .FALSE. diff --git a/src/CableDyn_OpenFAST_FMF.f90 b/src/CableDyn_OpenFAST_FMF.f90 index b540dd46..2ac5ba61 100644 --- a/src/CableDyn_OpenFAST_FMF.f90 +++ b/src/CableDyn_OpenFAST_FMF.f90 @@ -162,7 +162,7 @@ SUBROUTINE CD_FMF_Init_From_Deck(self, deck_path, dt, ErrStat, ErrMsg, env_gravi TYPE(CD_FMF_ModuleType) :: candidate REAL(wp) :: deck_dt, gravity, rho_water INTEGER :: es, n_coupled - CHARACTER(512) :: em + CHARACTER(1024) :: em ErrStat = CD_FMF_OK ErrMsg = '' @@ -221,7 +221,7 @@ SUBROUTINE CD_FMF_Init_From_System(self, system, dt, gravity, rho_water, ErrStat TYPE(CD_FMF_ModuleType) :: candidate INTEGER :: es, n_coupled - CHARACTER(512) :: em + CHARACTER(1024) :: em ErrStat = CD_FMF_OK ErrMsg = '' @@ -475,7 +475,7 @@ SUBROUTINE build_moving_blocks(self, ErrStat, ErrMsg) INTEGER, ALLOCATABLE :: blocks(:) INTEGER :: i, k, n_all, es, istat - CHARACTER(512) :: em + CHARACTER(1024) :: em ErrStat = CD_FMF_OK ErrMsg = '' @@ -666,7 +666,7 @@ SUBROUTINE CD_FMF_Snapshot(self, ErrStat, ErrMsg) INTEGER, INTENT(OUT) :: ErrStat CHARACTER(*), INTENT(OUT) :: ErrMsg INTEGER :: es - CHARACTER(300) :: em + CHARACTER(1024) :: em IF (.NOT. require_initialized(self, ErrStat, ErrMsg)) RETURN CALL CD_System_Snapshot(self%fast%system, es, em) IF (es /= CD_SYSTEM_OK) THEN @@ -694,7 +694,7 @@ SUBROUTINE CD_FMF_Restore(self, ErrStat, ErrMsg) INTEGER, INTENT(OUT) :: ErrStat CHARACTER(*), INTENT(OUT) :: ErrMsg INTEGER :: es - CHARACTER(300) :: em + CHARACTER(1024) :: em IF (.NOT. require_initialized(self, ErrStat, ErrMsg)) RETURN CALL CD_System_Restore(self%fast%system, es, em) IF (es /= CD_SYSTEM_OK) THEN diff --git a/src/CableDyn_OpenFAST_HermiteFMF.f90 b/src/CableDyn_OpenFAST_HermiteFMF.f90 index 01853ea9..3fde5015 100644 --- a/src/CableDyn_OpenFAST_HermiteFMF.f90 +++ b/src/CableDyn_OpenFAST_HermiteFMF.f90 @@ -171,7 +171,7 @@ SUBROUTINE CD_HFMF_Init(self, l0, EA, EI, rho_a, w, q_static, fixed_dofs, seabed INTEGER, INTENT(IN), OPTIONAL :: axial_quadrature_order, bending_quadrature_order TYPE(CD_HFMF_ModuleType) :: candidate INTEGER :: es, s, gd - CHARACTER(300) :: em + CHARACTER(1024) :: em ErrStat = CD_HFMF_OK; ErrMsg = '' IF (.NOT. CD_Is_Finite(dt) .OR. dt <= CD_ZERO) THEN @@ -244,7 +244,7 @@ SUBROUTINE CD_HFMF_Set_Drag(self, rho_w, diam, cdn, cdt, waterline_z, current, E CHARACTER(*), INTENT(OUT) :: ErrMsg REAL(wp), INTENT(IN), OPTIONAL :: gravity INTEGER :: es - CHARACTER(300) :: em + CHARACTER(1024) :: em ErrStat = CD_HFMF_OK; ErrMsg = '' IF (.NOT. self%initialized) THEN ErrStat = CD_HFMF_BADINPUT; ErrMsg = 'CD_HFMF_Set_Drag: module not initialised'; RETURN @@ -265,7 +265,7 @@ SUBROUTINE CD_HFMF_Set_Attachments(self, node, mass, volume, cda, cdax, ca, rho_ INTEGER, INTENT(OUT) :: ErrStat CHARACTER(*), INTENT(OUT) :: ErrMsg INTEGER :: es - CHARACTER(300) :: em + CHARACTER(1024) :: em ErrStat = CD_HFMF_OK; ErrMsg = '' IF (.NOT. self%initialized) THEN ErrStat = CD_HFMF_BADINPUT; ErrMsg = 'CD_HFMF_Set_Attachments: module not initialised'; RETURN @@ -284,7 +284,7 @@ SUBROUTINE CD_HFMF_Set_Axial_Damping(self, BA, ErrStat, ErrMsg) INTEGER, INTENT(OUT) :: ErrStat CHARACTER(*), INTENT(OUT) :: ErrMsg INTEGER :: es - CHARACTER(300) :: em + CHARACTER(1024) :: em ErrStat = CD_HFMF_OK ErrMsg = '' IF (.NOT. self%initialized) THEN @@ -315,7 +315,7 @@ SUBROUTINE CD_HFMF_Set_EndConnection(self, k_rot, d0_global, ErrStat, ErrMsg, & LOGICAL :: endpoint_connected REAL(wp) :: d0_local(3, 2) REAL(wp) :: parent_d0(3), parent_d0_norm, dcm(3, 3) - CHARACTER(300) :: em + CHARACTER(1024) :: em ErrStat = CD_HFMF_OK ErrMsg = '' @@ -417,7 +417,7 @@ SUBROUTINE CD_HFMF_Set_Torsion(self, torsion, ErrStat, ErrMsg, coupled_frame_par REAL(wp), INTENT(IN), OPTIONAL :: coupled_frame_parent(3, 2), parent_orientation(3, 3) INTEGER :: es, ci REAL(wp) :: dl(3), nl(3) - CHARACTER(300) :: em + CHARACTER(1024) :: em ErrStat = CD_HFMF_OK ErrMsg = '' IF (.NOT. self%initialized) THEN @@ -499,7 +499,7 @@ SUBROUTINE CD_HFMF_Set_ModifiedNewton(self, enabled, ErrStat, ErrMsg) INTEGER, INTENT(OUT) :: ErrStat CHARACTER(*), INTENT(OUT) :: ErrMsg INTEGER :: es - CHARACTER(300) :: em + CHARACTER(1024) :: em ErrStat = CD_HFMF_OK; ErrMsg = '' IF (.NOT. self%initialized) THEN ErrStat = CD_HFMF_BADINPUT; ErrMsg = 'CD_HFMF_Set_ModifiedNewton: module not initialised'; RETURN @@ -516,7 +516,7 @@ SUBROUTINE CD_HFMF_Set_Tensile_Safety(self, enabled, ErrStat, ErrMsg) INTEGER, INTENT(OUT) :: ErrStat CHARACTER(*), INTENT(OUT) :: ErrMsg INTEGER :: es - CHARACTER(200) :: em + CHARACTER(1024) :: em ErrStat = CD_HFMF_OK; ErrMsg = '' IF (.NOT. self%initialized) THEN ErrStat = CD_HFMF_BADINPUT; ErrMsg = 'CD_HFMF_Set_Tensile_Safety: module not initialised'; RETURN @@ -534,7 +534,7 @@ SUBROUTINE CD_HFMF_Set_Tensile_Monitor(self, mode, ErrStat, ErrMsg, strain_toler CHARACTER(*), INTENT(OUT) :: ErrMsg REAL(wp), INTENT(IN), OPTIONAL :: strain_tolerance INTEGER :: es - CHARACTER(200) :: em + CHARACTER(1024) :: em ErrStat = CD_HFMF_OK; ErrMsg = '' IF (.NOT. self%initialized) THEN ErrStat = CD_HFMF_BADINPUT; ErrMsg = 'CD_HFMF_Set_Tensile_Monitor: module not initialised'; RETURN @@ -552,7 +552,7 @@ SUBROUTINE CD_HFMF_Get_Tensile_Diagnostics(self, event_count, worst_force, worst REAL(wp), INTENT(OUT) :: worst_force, worst_threshold, worst_xi, worst_time CHARACTER(*), INTENT(OUT) :: ErrMsg INTEGER :: es - CHARACTER(200) :: em + CHARACTER(1024) :: em IF (.NOT. self%initialized) THEN event_count = 0; worst_element = 0 worst_force = CD_ZERO; worst_threshold = CD_ZERO; worst_xi = CD_ZERO; worst_time = CD_ZERO @@ -572,7 +572,7 @@ SUBROUTINE CD_HFMF_Get_Recovery_Diagnostics(self, event_count, max_substeps_used INTEGER, INTENT(OUT) :: event_count, max_substeps_used, ErrStat CHARACTER(*), INTENT(OUT) :: ErrMsg INTEGER :: es - CHARACTER(200) :: em + CHARACTER(1024) :: em IF (.NOT. self%initialized) THEN event_count = 0; max_substeps_used = 0 ErrStat = CD_HFMF_BADINPUT; ErrMsg = 'CD_HFMF_Get_Recovery_Diagnostics: module not initialised'; RETURN @@ -611,7 +611,7 @@ SUBROUTINE CD_HFMF_Set_AddedMass(self, rho_w, diam, can, cat, waterline_z, ErrSt INTEGER, INTENT(OUT) :: ErrStat CHARACTER(*), INTENT(OUT) :: ErrMsg INTEGER :: es - CHARACTER(300) :: em + CHARACTER(1024) :: em ErrStat = CD_HFMF_OK; ErrMsg = '' IF (.NOT. self%initialized) THEN ErrStat = CD_HFMF_BADINPUT; ErrMsg = 'CD_HFMF_Set_AddedMass: module not initialised'; RETURN @@ -629,7 +629,7 @@ SUBROUTINE CD_HFMF_Set_Waves(self, height, period, direction_deg, depth, gravity INTEGER, INTENT(OUT) :: ErrStat CHARACTER(*), INTENT(OUT) :: ErrMsg INTEGER :: es - CHARACTER(300) :: em + CHARACTER(1024) :: em ErrStat = CD_HFMF_OK; ErrMsg = '' IF (.NOT. self%initialized) THEN ErrStat = CD_HFMF_BADINPUT; ErrMsg = 'CD_HFMF_Set_Waves: module not initialised'; RETURN @@ -657,7 +657,7 @@ SUBROUTINE CD_HFMF_UpdateStates(self, u_pos, u_vel, u_acc, ErrStat, ErrMsg, u_or REAL(wp) :: tors_ends(3, 4), tors_phi REAL(wp) :: target_dcm(3, 3), target_d0(3, 2), target_omega(3), target_alpha(3) REAL(wp) :: target_d0_rate(3, 2), target_d0_acceleration(3, 2), omega_local(3), alpha_local(3) - CHARACTER(300) :: em + CHARACTER(1024) :: em ErrStat = CD_HFMF_OK; ErrMsg = '' IF (.NOT. self%initialized) THEN ErrStat = CD_HFMF_BADINPUT; ErrMsg = 'CD_HFMF_UpdateStates: module not initialised'; RETURN @@ -763,7 +763,7 @@ SUBROUTINE CD_HFMF_Snapshot(self, ErrStat, ErrMsg) INTEGER, INTENT(OUT) :: ErrStat CHARACTER(*), INTENT(OUT) :: ErrMsg INTEGER :: es - CHARACTER(300) :: em + CHARACTER(1024) :: em ErrStat = CD_HFMF_OK; ErrMsg = '' IF (.NOT. self%initialized) THEN ErrStat = CD_HFMF_BADINPUT; ErrMsg = 'CD_HFMF_Snapshot: module not initialised'; RETURN @@ -785,7 +785,7 @@ SUBROUTINE CD_HFMF_Restore(self, ErrStat, ErrMsg) INTEGER, INTENT(OUT) :: ErrStat CHARACTER(*), INTENT(OUT) :: ErrMsg INTEGER :: es - CHARACTER(300) :: em + CHARACTER(1024) :: em ErrStat = CD_HFMF_OK; ErrMsg = '' IF (.NOT. self%initialized) THEN ErrStat = CD_HFMF_BADINPUT; ErrMsg = 'CD_HFMF_Restore: module not initialised'; RETURN @@ -813,7 +813,7 @@ SUBROUTINE CD_HFMF_PreflightCoupledKinematics(self, u_pos, u_vel, u_acc, ErrStat REAL(wp), INTENT(IN), OPTIONAL :: u_angular_velocity(3), u_angular_acceleration(3) REAL(wp) :: target_dcm(3, 3), d0_target(3, 2), tangent_q(3), tangent_v(3), tangent_a(3) REAL(wp) :: target_omega(3), target_alpha(3) - CHARACTER(300) :: em + CHARACTER(1024) :: em CALL prepare_coupled_kinematics(self, u_pos, u_vel, u_acc, target_dcm, target_omega, target_alpha, & d0_target, tangent_q, tangent_v, tangent_a, ErrStat, em, & @@ -830,7 +830,7 @@ SUBROUTINE CD_HFMF_PreflightCoupledKinematics(self, u_pos, u_vel, u_acc, ErrStat REAL(wp), ALLOCATABLE :: qc(:), g(:) REAL(wp) :: ends(3, 4), raw, th INTEGER :: ks, k - CHARACTER(200) :: km + CHARACTER(1024) :: km ends = coupled_torsion_ends(self, target_dcm) DO k = 1, 3, 2 IF (ABS(NORM2(ends(:, k)) - CD_ONE) > 1.0e-8_wp .OR. ABS(NORM2(ends(:, k + 1)) - CD_ONE) > 1.0e-8_wp & @@ -909,7 +909,7 @@ SUBROUTINE CD_HFMF_SetCoupledKinematics(self, u_pos, u_vel, u_acc, ErrStat, ErrM REAL(wp) :: tangent_q(3), tangent_v(3), tangent_a(3) REAL(wp) :: target_omega(3), target_alpha(3), tors_ends(3, 4) INTEGER :: base, es - CHARACTER(300) :: em + CHARACTER(1024) :: em CALL prepare_coupled_kinematics(self, u_pos, u_vel, u_acc, target_dcm, target_omega, target_alpha, & d0_target, tangent_q, tangent_v, tangent_a, ErrStat, em, & @@ -998,7 +998,7 @@ SUBROUTINE prepare_coupled_kinematics(self, u_pos, u_vel, u_acc, target_dcm, tar REAL(wp) :: target_direction_rate(3), target_direction_acceleration(3) REAL(wp) :: omega_local(3), alpha_local(3), rotation_check(3, 3) INTEGER :: base, ecstat - CHARACTER(200) :: ecmsg + CHARACTER(1024) :: ecmsg ErrStat = CD_HFMF_OK ErrMsg = '' @@ -1141,7 +1141,7 @@ SUBROUTINE CD_HFMF_Set_Held_Fluid(self, fluid_velocity, fluid_acceleration, wate CHARACTER(*), INTENT(OUT) :: ErrMsg INTEGER :: es, i LOGICAL :: has_heading - CHARACTER(300) :: em + CHARACTER(1024) :: em ErrStat = CD_HFMF_OK; ErrMsg = '' IF (.NOT. self%initialized) THEN ErrStat = CD_HFMF_BADINPUT; ErrMsg = 'CD_HFMF_Set_Held_Fluid: module not initialised'; RETURN @@ -1178,7 +1178,7 @@ SUBROUTINE CD_HFMF_Set_Contact(self, kn_node, cn_node, mu, ErrStat, ErrMsg, bath CHARACTER(*), INTENT(OUT) :: ErrMsg TYPE(CD_BathymetryType), INTENT(IN), OPTIONAL :: bathymetry INTEGER :: es - CHARACTER(240) :: em + CHARACTER(1024) :: em ErrStat = CD_HFMF_OK; ErrMsg = '' IF (.NOT. self%initialized) THEN @@ -1207,7 +1207,7 @@ SUBROUTINE CD_HFMF_Set_SegmentLength(self, elems, l0_new, l0_dot, ErrStat, ErrMs INTEGER, INTENT(OUT) :: ErrStat CHARACTER(*), INTENT(OUT) :: ErrMsg INTEGER :: es - CHARACTER(300) :: em + CHARACTER(1024) :: em ErrStat = CD_HFMF_OK; ErrMsg = '' IF (.NOT. self%initialized) THEN @@ -1228,7 +1228,7 @@ SUBROUTINE CD_HFMF_Refresh_Acceleration(self, ErrStat, ErrMsg) CHARACTER(*), INTENT(OUT) :: ErrMsg INTEGER :: es REAL(wp) :: coupled_a(3) - CHARACTER(240) :: em + CHARACTER(1024) :: em ErrStat = CD_HFMF_OK; ErrMsg = '' IF (.NOT. self%initialized) THEN @@ -1283,7 +1283,7 @@ SUBROUTINE CD_HFMF_CalcOutput(self, y_fair, ErrStat, ErrMsg, y_moment) CHARACTER(*), INTENT(OUT) :: ErrMsg REAL(wp), INTENT(OUT), OPTIONAL :: y_moment(3) INTEGER :: es - CHARACTER(300) :: em + CHARACTER(1024) :: em ErrStat = CD_HFMF_OK; ErrMsg = ''; y_fair = CD_ZERO IF (PRESENT(y_moment)) y_moment = CD_ZERO IF (.NOT. self%initialized) THEN @@ -1416,7 +1416,7 @@ SUBROUTINE CD_HFMF_Curvature(self, curv_out, ErrStat, ErrMsg) INTEGER, INTENT(OUT) :: ErrStat CHARACTER(*), INTENT(OUT) :: ErrMsg INTEGER :: es - CHARACTER(300) :: em + CHARACTER(1024) :: em ErrStat = CD_HFMF_OK; ErrMsg = '' IF (.NOT. self%initialized) THEN ErrStat = CD_HFMF_BADINPUT; ErrMsg = 'CD_HFMF_Curvature: module not initialised'; RETURN @@ -1435,7 +1435,7 @@ SUBROUTINE CD_HFMF_Curvature_Exact(self, curv_out, ErrStat, ErrMsg) INTEGER, INTENT(OUT) :: ErrStat CHARACTER(*), INTENT(OUT) :: ErrMsg INTEGER :: es - CHARACTER(300) :: em + CHARACTER(1024) :: em ErrStat = CD_HFMF_OK; ErrMsg = '' IF (.NOT. self%initialized) THEN ErrStat = CD_HFMF_BADINPUT; ErrMsg = 'CD_HFMF_Curvature_Exact: module not initialised'; RETURN diff --git a/src/CableDyn_OpenFAST_Mesh.f90 b/src/CableDyn_OpenFAST_Mesh.f90 index 44c625a3..d464f2eb 100644 --- a/src/CableDyn_OpenFAST_Mesh.f90 +++ b/src/CableDyn_OpenFAST_Mesh.f90 @@ -197,7 +197,7 @@ SUBROUTINE CD_FAST_Set_PointMesh_From_Body(mesh, body_q, body_v, body_a, offsets CHARACTER(*), INTENT(OUT) :: ErrMsg INTEGER :: es - CHARACTER(240) :: em + CHARACTER(1024) :: em ErrStat = CD_FAST_MESH_OK ErrMsg = '' @@ -266,7 +266,7 @@ SUBROUTINE CD_FAST_CalcBodyWrench_From_PointMesh(mesh, body_q, offsets_body, bod CHARACTER(*), INTENT(OUT) :: ErrMsg INTEGER :: es - CHARACTER(240) :: em + CHARACTER(1024) :: em body_wrench = CD_ZERO ErrStat = CD_FAST_MESH_OK @@ -296,7 +296,7 @@ LOGICAL FUNCTION mesh_matches_module(self, mesh, ErrStat, ErrMsg) RESULT(matches CHARACTER(*), INTENT(OUT) :: ErrMsg INTEGER :: fast_stat, n_coupled - CHARACTER(240) :: fast_msg + CHARACTER(1024) :: fast_msg matches = .FALSE. ErrStat = CD_FAST_MESH_OK diff --git a/src/CableDyn_Static.f90 b/src/CableDyn_Static.f90 index 50b1140e..e3e1af9d 100644 --- a/src/CableDyn_Static.f90 +++ b/src/CableDyn_Static.f90 @@ -114,7 +114,7 @@ MODULE CableDyn_Static !! equilibrium (or the last failure), for diagnostics and fail-closed error messages. CHARACTER(64) :: seed = '' !! seed of the accepted (or last attempted) solve CHARACTER(64) :: stage = '' !! solver stage of the accepted (or last failed) solve - CHARACTER(400) :: message = '' !! human-readable outcome / failure reason + CHARACTER(560) :: message = '' !! outcome / failure reason (holds the bounded seed notes whole) INTEGER :: n_iter = 0 !! Newton iterations over every attempt REAL(wp) :: min_tension = CD_ZERO !! smallest element tension of the reported state [N] LOGICAL :: slack_branch = .FALSE. !! .TRUE. when the tension-only (slack-capable) solve was needed @@ -209,7 +209,7 @@ SUBROUTINE CD_Static_Cable_Solve(q0, elem_conn, l0, ea, tension_only, f_ext, fix ! Smallest Levenberg-Marquardt shift (relative to kappa) of the slack-capable law: keeps ! directions without any stiffness (a grounded node between slack elements) solvable. REAL(wp), PARAMETER :: LM_MU_MIN_SLACK = 1.0e-12_wp - CHARACTER(120) :: em + CHARACTER(1024) :: em ! slack-capable law: base assembly flag, compressed-branch ratio, and the second ! (compression-capable) assembly the blend needs when 0 < r < 1 LOGICAL :: law_to, reg_law, blend @@ -733,7 +733,7 @@ SUBROUTINE eval_residual(qe, Rf, sc) REAL(wp), ALLOCATABLE :: fint_e(:) REAL(wp) :: scale_load, scale_drag INTEGER :: es_e - CHARACTER(120) :: em_e + CHARACTER(1024) :: em_e ALLOCATE (fint_e(n_dof)) CALL CD_Assemble_Cable_Internal_Force(reshape3(qe, n_dof), elem_conn, l0, ea, law_to, & fint_e, es_e, em_e) @@ -1255,7 +1255,7 @@ SUBROUTINE CD_Static_Friction_Anchors(q, current, seabed_kn, anchors, ErrStat, E TYPE(CD_BathymetryType), INTENT(IN), OPTIONAL :: bathymetry INTEGER :: n_nodes, i, es REAL(wp) :: z_floor, dfdx, dfdy, normal, tangent, fvec(3), jac(3, 3), f(2), dfd(2, 2), dfc(2), curv(3) - CHARACTER(120) :: em + CHARACTER(1024) :: em ErrStat = CD_STATIC_OK ErrMsg = '' n_nodes = SIZE(q)/3 @@ -1349,7 +1349,7 @@ SUBROUTINE CD_Static_As_Laid_Reference(origin, azimuth, l0, ea, laid_tension, re INTEGER :: n_elem, e, j, nsub, es REAL(wp) :: dir(2), d, ds, step, x, y, zf, gx, gy, g, dshort, sink_j, p(3, 3), t_in(3), t_out(3), nrm(3) REAL(wp), ALLOCATABLE :: ref0(:, :) - CHARACTER(120) :: em + CHARACTER(1024) :: em ErrStat = CD_STATIC_OK ErrMsg = '' @@ -1519,7 +1519,7 @@ SUBROUTINE laid_at(k, mismatch, valid) INTEGER :: i, es_d REAL(wp) :: zf, gx, gy, g, p(3), h_s, g_s, u(3), uh REAL(wp), ALLOCATABLE :: q_sus(:) - CHARACTER(200) :: em_d + CHARACTER(1024) :: em_d valid = .FALSE. mismatch = -HUGE(CD_ONE) @@ -1555,7 +1555,7 @@ SUBROUTINE floor_at(x, y, zf, gx, gy, es_f) REAL(wp), INTENT(IN) :: x, y REAL(wp), INTENT(OUT) :: zf, gx, gy INTEGER, INTENT(OUT) :: es_f - CHARACTER(120) :: em_f + CHARACTER(1024) :: em_f es_f = 0 gx = CD_ZERO gy = CD_ZERO @@ -1658,9 +1658,13 @@ SUBROUTINE CD_Static_Line_Equilibrium(anchor, fairlead, elem_conn, l0, ea, weigh REAL(wp), ALLOCATABLE :: q_seed(:), q_try(:), q_mid(:), q_best(:), ten(:) REAL(wp) :: f_node, t_min, t_max, r_soft, r_firm, floor_a, slope_a, h_cat, g_cat LOGICAL :: has_seabed, anchor_grounded, conv, stalled, at_floor, have_seed, done, have_best - CHARACTER(200) :: em + CHARACTER(1024) :: em CHARACTER(64) :: seed_name - CHARACTER(400) :: notes + ! The seed notes of a failed solve (report%message holds them after a fixed prefix). Up to + ! seven seeds note up to three stages each, more than this holds: add_note ends the list with + ! an omission marker instead of cutting a note. + CHARACTER(480) :: notes + LOGICAL :: notes_full TYPE(CableSolverConfig) :: cfg_adm converged = .FALSE. @@ -1766,6 +1770,7 @@ SUBROUTINE CD_Static_Line_Equilibrium(anchor, fairlead, elem_conn, l0, ea, weigh END IF notes = '' + notes_full = .FALSE. q_best = CD_ZERO have_best = .FALSE. DO iorder = 1, SIZE(order) @@ -1890,12 +1895,27 @@ SUBROUTINE accept(qa, slack) END SUBROUTINE accept SUBROUTINE add_note(txt) + !! Append one seed note while the notes keep room for it and the omission marker; + !! otherwise end them with the marker, so a note is never cut. CHARACTER(*), INTENT(IN) :: txt - IF (LEN_TRIM(notes) == 0) THEN - notes = txt + CHARACTER(*), PARAMETER :: OMITTED = '; further seed notes omitted' + INTEGER :: n + IF (notes_full) RETURN + n = LEN_TRIM(notes) + IF (n == 0) THEN + IF (LEN_TRIM(txt) + LEN(OMITTED) <= LEN(notes)) THEN + notes = TRIM(txt) + RETURN + END IF + notes = OMITTED(3:) ELSE - notes = TRIM(notes)//'; '//txt + IF (n + 2 + LEN_TRIM(txt) + LEN(OMITTED) <= LEN(notes)) THEN + notes = notes(1:n)//'; '//TRIM(txt) + RETURN + END IF + notes = notes(1:n)//OMITTED END IF + notes_full = .TRUE. END SUBROUTINE add_note SUBROUTINE run_solve(qs, factors, slack_law, ratio, cfg_use, qo, ok) @@ -1907,7 +1927,7 @@ SUBROUTINE run_solve(qs, factors, slack_law, ratio, cfg_use, qo, ok) REAL(wp), INTENT(OUT) :: qo(:) LOGICAL, INTENT(OUT) :: ok INTEGER :: es_r - CHARACTER(200) :: em_r + CHARACTER(1024) :: em_r ok = .FALSE. IF (slack_law) THEN @@ -1969,7 +1989,7 @@ SUBROUTINE tension_range(qe, tmin, tmax) REAL(wp), INTENT(IN) :: qe(:) REAL(wp), INTENT(OUT) :: tmin, tmax INTEGER :: es_t - CHARACTER(200) :: em_t + CHARACTER(1024) :: em_t CALL CD_Compute_Cable_Tension(RESHAPE(qe, [3, n_nodes]), elem_conn, l0, ea, .FALSE., ten, es_t, em_t) IF (es_t /= 0) THEN tmin = -HUGE(CD_ONE) @@ -2020,7 +2040,7 @@ SUBROUTINE build_seed(which, ok) INTEGER, INTENT(IN) :: which LOGICAL, INTENT(OUT) :: ok INTEGER :: es_s, i_s - CHARACTER(200) :: em_s + CHARACTER(1024) :: em_s LOGICAL :: hang REAL(wp) :: pen @@ -2112,7 +2132,7 @@ SUBROUTINE laid_seed_from_last(ok) INTEGER :: es_r, i_r REAL(wp) :: floor_n REAL(wp), ALLOCATABLE :: q_rev(:) - CHARACTER(200) :: em_r + CHARACTER(1024) :: em_r ok = .FALSE. floor_n = seabed_floor_at(fairlead(1), fairlead(2), es_r, em_r) IF (es_r /= 0) RETURN @@ -2176,7 +2196,7 @@ SUBROUTINE drape_at(k, mismatch, valid) REAL(wp) :: hd(2), hlen, arc, d, zf, g, p(3), step, arc_prev REAL(wp), ALLOCATABLE :: q_sus(:) REAL(wp) :: h_s, g_s, u(3) - CHARACTER(200) :: em_d + CHARACTER(1024) :: em_d valid = .FALSE. mismatch = -HUGE(CD_ONE) @@ -2232,7 +2252,7 @@ SUBROUTINE fold_seed(ok) REAL(wp) :: hd(2), hlen, zp, c, arc_ap, g, e, a, dmax, total, s_node, pp(3), s_arc, d REAL(wp) :: dtab(0:NTAB), atab(0:NTAB) INTEGER :: i, j, es_f - CHARACTER(200) :: em_f + CHARACTER(1024) :: em_f ok = .FALSE. hd = fairlead(1:2) - anchor(1:2) @@ -2295,7 +2315,7 @@ SUBROUTINE seabed_slope_along(x, y, hd, g) REAL(wp), INTENT(OUT) :: g REAL(wp) :: zf, gx, gy INTEGER :: es_g - CHARACTER(200) :: em_g + CHARACTER(1024) :: em_g g = CD_ZERO IF (.NOT. PRESENT(bathymetry)) RETURN CALL CD_Bathymetry_Floor_Gradient(bathymetry, x, y, zf, gx, gy, es_g, em_g) @@ -2455,7 +2475,7 @@ SUBROUTINE CD_Static_Line_End_Forces(q, elem_conn, l0, ea, f_ext, tension_only, INTEGER :: n_dof, n_nodes, n_elem, k, e, a, b, node, es REAL(wp), ALLOCATABLE :: fint(:) REAL(wp) :: zf, gx, gy, fvec(3), jac(3, 3), curv(3), f2(6), jq2(6, 6), jv2(6, 6), va(3), vb(3), de, cn, ct, wla, wlb - CHARACTER(200) :: em + CHARACTER(1024) :: em INTEGER :: ends(2) LOGICAL :: drag_ends diff --git a/src/CableDyn_StreamWave.f90 b/src/CableDyn_StreamWave.f90 index 843ccbaa..76837338 100644 --- a/src/CableDyn_StreamWave.f90 +++ b/src/CableDyn_StreamWave.f90 @@ -56,7 +56,7 @@ SUBROUTINE CD_Stream_Solve(wave, height, period, depth, gravity, direction_deg, REAL(wp), ALLOCATABLE :: z(:), zprev(:), zprev2(:), res(:), jac(:, :), dz(:), zt(:), rt(:) REAL(wp) :: hs, ts, k0, omega, h_step, rnorm, a, h, ch LOGICAL :: ok - CHARACTER(200) :: em + CHARACTER(1024) :: em ErrStat = CD_STREAM_OK ErrMsg = '' diff --git a/src/CableDyn_Syrope.f90 b/src/CableDyn_Syrope.f90 index bd99459e..511ef818 100644 --- a/src/CableDyn_Syrope.f90 +++ b/src/CableDyn_Syrope.f90 @@ -205,7 +205,7 @@ SUBROUTINE CD_Syrope_Init(td, owc_strain, owc_tension, wc_mod, p1, p2, alpha, be td%scan_hi = owc_tension(n) BLOCK INTEGER :: k, es - CHARACTER(200) :: em, first_em + CHARACTER(1024) :: em, first_em REAL(wp) :: ws(CD_SYROPE_NWC), wt(CD_SYROPE_NWC), wsl(CD_SYROPE_NWC) first_em = '' DO k = 1, CD_SYROPE_NSCAN diff --git a/src/CableDyn_System.f90 b/src/CableDyn_System.f90 index bf5b025f..0c33d7f4 100644 --- a/src/CableDyn_System.f90 +++ b/src/CableDyn_System.f90 @@ -190,7 +190,7 @@ MODULE CableDyn_System ! parallel region so failure selection and mapped-load accumulation stay reproducible. INTEGER, ALLOCATABLE :: line_off(:), line_stat(:), line_iter(:) LOGICAL, ALLOCATABLE :: line_converged(:), line_stalled(:) - CHARACTER(160), ALLOCATABLE :: line_msg(:) + CHARACTER(1024), ALLOCATABLE :: line_msg(:) REAL(wp), ALLOCATABLE :: line_load_work(:) ! Snapshot of the COMMITTED system state (every line's q/v/a/f_ext + every point) for ! the aggregate stage-then-commit contract. The per-line q_rollback buffers CANNOT @@ -241,7 +241,7 @@ SUBROUTINE CD_Init_System_From_Models(system, models, ErrStat, ErrMsg, coupled_d TYPE(CD_SystemType) :: candidate INTEGER :: i, es, copy_stat, istat, n_local, nc - CHARACTER(200) :: em, copy_msg + CHARACTER(1024) :: em, copy_msg ErrStat = CD_SYSTEM_OK ErrMsg = '' @@ -352,7 +352,7 @@ SUBROUTINE CD_Init_System_From_Points(system, models, points, bindings, ErrStat, INTEGER, ALLOCATABLE :: map(:), pbase(:) INTEGER :: es, istat, i, pidx REAL(wp) :: md - CHARACTER(160) :: em + CHARACTER(1024) :: em CALL build_point_coupled_map(models, points, bindings, map, pbase, ErrStat, ErrMsg) IF (ErrStat /= CD_SYSTEM_OK) RETURN @@ -425,7 +425,7 @@ SUBROUTINE CD_End_System(system, ErrStat, ErrMsg) CHARACTER(*), INTENT(OUT) :: ErrMsg INTEGER :: i, es - CHARACTER(120) :: em + CHARACTER(1024) :: em IF (ALLOCATED(system%lines)) THEN DO i = 1, SIZE(system%lines) @@ -693,7 +693,7 @@ SUBROUTINE CD_Set_System_DynamicPoint_States(system, buf, ErrStat, ErrMsg) INTEGER, INTENT(OUT) :: ErrStat CHARACTER(*), INTENT(OUT) :: ErrMsg INTEGER :: i, k, es, base - CHARACTER(256) :: em + CHARACTER(1024) :: em ErrStat = CD_SYSTEM_OK ErrMsg = '' IF (.NOT. system%initialized) THEN @@ -823,7 +823,7 @@ SUBROUTINE CD_Get_System_Line_State(system, line_index, q, v, a, ErrStat, ErrMsg CHARACTER(*), INTENT(OUT) :: ErrMsg INTEGER :: es - CHARACTER(160) :: em + CHARACTER(1024) :: em q = CD_ZERO v = CD_ZERO @@ -859,7 +859,7 @@ SUBROUTINE CD_Get_System_Line_VE_Dl1(system, line_index, dl1, ErrStat, ErrMsg) CHARACTER(*), INTENT(OUT) :: ErrMsg INTEGER :: es - CHARACTER(160) :: em + CHARACTER(1024) :: em dl1 = CD_ZERO CALL validate_line_index(system, line_index, ErrStat, ErrMsg) @@ -884,7 +884,7 @@ SUBROUTINE CD_Set_System_Line_VE_Dl1(system, line_index, dl1, ErrStat, ErrMsg) CHARACTER(*), INTENT(OUT) :: ErrMsg INTEGER :: es - CHARACTER(160) :: em + CHARACTER(1024) :: em CALL validate_line_index(system, line_index, ErrStat, ErrMsg) IF (ErrStat /= CD_SYSTEM_OK) RETURN @@ -918,7 +918,7 @@ SUBROUTINE CD_Get_System_Line_Syrope_State(system, line_index, slow, tmax, ErrSt CHARACTER(*), INTENT(OUT) :: ErrMsg INTEGER :: es - CHARACTER(160) :: em + CHARACTER(1024) :: em slow = CD_ZERO tmax = CD_ZERO @@ -944,7 +944,7 @@ SUBROUTINE CD_Set_System_Line_Syrope_State(system, line_index, slow, tmax, ErrSt CHARACTER(*), INTENT(OUT) :: ErrMsg INTEGER :: es - CHARACTER(160) :: em + CHARACTER(1024) :: em CALL validate_line_index(system, line_index, ErrStat, ErrMsg) IF (ErrStat /= CD_SYSTEM_OK) RETURN @@ -976,7 +976,7 @@ SUBROUTINE CD_Get_System_Line_Friction_Anchors(system, line_index, anchors, ErrS INTEGER, INTENT(OUT) :: ErrStat CHARACTER(*), INTENT(OUT) :: ErrMsg INTEGER :: es - CHARACTER(160) :: em + CHARACTER(1024) :: em anchors = CD_ZERO CALL validate_line_index(system, line_index, ErrStat, ErrMsg) IF (ErrStat /= CD_SYSTEM_OK) RETURN @@ -998,7 +998,7 @@ SUBROUTINE CD_Set_System_Line_Friction_Anchors(system, line_index, anchors, ErrS INTEGER, INTENT(OUT) :: ErrStat CHARACTER(*), INTENT(OUT) :: ErrMsg INTEGER :: es - CHARACTER(160) :: em + CHARACTER(1024) :: em CALL validate_line_index(system, line_index, ErrStat, ErrMsg) IF (ErrStat /= CD_SYSTEM_OK) RETURN CALL CD_Set_Model_Friction_Anchors(system%lines(line_index), anchors, es, em) @@ -1020,7 +1020,7 @@ SUBROUTINE CD_Get_System_Line_Tension(system, line_index, tension, ErrStat, ErrM CHARACTER(*), INTENT(OUT) :: ErrMsg INTEGER :: es - CHARACTER(160) :: em + CHARACTER(1024) :: em tension = CD_ZERO CALL validate_line_index(system, line_index, ErrStat, ErrMsg) @@ -1044,7 +1044,7 @@ SUBROUTINE CD_Get_System_CoupledMotion(system, q_coupled, v_coupled, a_coupled, INTEGER :: i, lo, hi, nc, es, local_id, sys_id, dof, n_mapped REAL(wp), PARAMETER :: TOL = 1.0e-10_wp - CHARACTER(160) :: em + CHARACTER(1024) :: em q_coupled = CD_ZERO v_coupled = CD_ZERO @@ -1126,7 +1126,7 @@ SUBROUTINE CD_Update_System_CoupledMotion(system, q_coupled, v_coupled, a_couple INTEGER :: i, lo, hi, nc, es LOGICAL :: save_for_rollback - CHARACTER(160) :: em + CHARACTER(1024) :: em save_for_rollback = .TRUE. IF (PRESENT(caller_owns_rollback)) save_for_rollback = .NOT. caller_owns_rollback @@ -1259,7 +1259,7 @@ RECURSIVE SUBROUTINE CD_Step_System(system, dt, q_coupled, v_coupled, a_coupled, INTEGER :: i, j, lo, hi, nc, es, line_dof, sys_dof, depth, iter2, ntot, nve, nsy, lo_ve, lo_sy, ne, nfr, lo_fr INTEGER :: n_team, nel, lo_el LOGICAL :: conv2, stall2 - CHARACTER(160) :: em + CHARACTER(1024) :: em REAL(wp), ALLOCATABLE :: q0(:), v0(:), a0(:), qm(:), vm(:), am(:), qs(:), vs(:), as(:) REAL(wp), ALLOCATABLE :: dl1s(:), slows(:), tmaxs(:), frs(:, :), hmaxs(:), l0cs(:), l0dcs(:) TYPE(CD_SubstepStats), ALLOCATABLE :: subs(:) @@ -1648,7 +1648,7 @@ SUBROUTINE CD_Step_System_DynamicPoints(system, dt, converged, stalled, n_iter, REAL(wp) :: ma_blk(3, 3), k_blk(3, 3), c_blk(3, 3), rhs3(3), kv_nbr(3) LOGICAL :: solve_ok LOGICAL, ALLOCATABLE :: integ(:) - CHARACTER(160) :: em + CHARACTER(1024) :: em converged = .FALSE. stalled = .FALSE. @@ -1851,7 +1851,7 @@ SUBROUTINE point_line_end_blocks(system, point_index, ma_block, k_block, c_block CHARACTER(*), INTENT(OUT) :: ErrMsg INTEGER :: k, es REAL(wp) :: blk(3, 3), kb(3, 3), cb(3, 3), kv(3) - CHARACTER(160) :: em + CHARACTER(1024) :: em ErrStat = CD_SYSTEM_OK ErrMsg = '' ma_block = CD_ZERO @@ -1928,7 +1928,7 @@ SUBROUTINE CD_Update_System_Line_SegmentLength(system, line_index, elem, l0_new, INTEGER :: k, i, kb, es REAL(wp) :: md - CHARACTER(240) :: em + CHARACTER(1024) :: em CALL validate_line_index(system, line_index, ErrStat, ErrMsg) IF (ErrStat /= CD_SYSTEM_OK) RETURN @@ -2023,7 +2023,7 @@ SUBROUTINE recompute_point_line_mass_diag(system, point_index, ErrStat, ErrMsg) CHARACTER(*), INTENT(OUT) :: ErrMsg INTEGER :: k, es REAL(wp) :: md - CHARACTER(240) :: em + CHARACTER(1024) :: em ErrStat = CD_SYSTEM_OK ErrMsg = '' system%points(point_index)%line_mass_diag = CD_ZERO @@ -2057,7 +2057,7 @@ SUBROUTINE CD_Detach_System_LineEnds(system, fail_point_id, line_indices, reserv INTEGER :: i, k, pf, pr, es, local_base, e, nmoved REAL(wp) :: md - CHARACTER(240) :: em + CHARACTER(1024) :: em ErrStat = CD_SYSTEM_OK ErrMsg = '' @@ -2161,7 +2161,7 @@ SUBROUTINE CD_Calc_System_CoupledLoads(system, coupled_loads, ErrStat, ErrMsg) CHARACTER(*), INTENT(OUT) :: ErrMsg INTEGER :: i, lo, hi, es, n_team - CHARACTER(160) :: em + CHARACTER(1024) :: em ErrStat = CD_SYSTEM_OK ErrMsg = '' @@ -2231,7 +2231,7 @@ SUBROUTINE CD_Calc_System_CoupledKinematicDerivatives(system, dload_dq, dload_dv CHARACTER(*), INTENT(OUT) :: ErrMsg INTEGER :: i, j, k, lo, hi, nc, es, row, col - CHARACTER(160) :: em + CHARACTER(1024) :: em ErrStat = CD_SYSTEM_OK ErrMsg = '' @@ -2295,7 +2295,7 @@ SUBROUTINE CD_Calc_System_CoupledAccelDerivative(system, dload_da, ErrStat, ErrM INTEGER :: i, j, k, lo, hi, nc, es, row, col LOGICAL :: frozen - CHARACTER(160) :: em + CHARACTER(1024) :: em ErrStat = CD_SYSTEM_OK ErrMsg = '' @@ -2365,7 +2365,7 @@ SUBROUTINE CD_Recompute_System_Acceleration(system, ErrStat, ErrMsg) CHARACTER(*), INTENT(OUT) :: ErrMsg INTEGER :: i, es - CHARACTER(160) :: em + CHARACTER(1024) :: em ErrStat = CD_SYSTEM_OK ErrMsg = '' @@ -2396,7 +2396,7 @@ SUBROUTINE CD_Update_System_Line_External_Loads(system, line_index, f_ext, ErrSt CHARACTER(*), INTENT(OUT) :: ErrMsg INTEGER :: es - CHARACTER(160) :: em + CHARACTER(1024) :: em CALL validate_line_index(system, line_index, ErrStat, ErrMsg) IF (ErrStat /= CD_SYSTEM_OK) RETURN @@ -2485,7 +2485,7 @@ SUBROUTINE CD_Update_System_Line_Hydro_Fields(system, line_index, ErrStat, ErrMs REAL(wp), INTENT(IN), OPTIONAL :: buoyancy_waterline_z(:) INTEGER :: es - CHARACTER(200) :: em + CHARACTER(1024) :: em CALL validate_line_index(system, line_index, ErrStat, ErrMsg) IF (ErrStat /= CD_SYSTEM_OK) RETURN @@ -2518,7 +2518,7 @@ SUBROUTINE CD_Update_System_Line_Interior_State(system, line_index, q_interior, REAL(wp), INTENT(IN), OPTIONAL :: a_interior(:) INTEGER :: es - CHARACTER(200) :: em + CHARACTER(1024) :: em CALL validate_line_index(system, line_index, ErrStat, ErrMsg) IF (ErrStat /= CD_SYSTEM_OK) RETURN @@ -2580,7 +2580,7 @@ END FUNCTION query CHARACTER(*), INTENT(OUT) :: ErrMsg INTEGER :: es - CHARACTER(160) :: em + CHARACTER(1024) :: em n = 0 CALL validate_line_index(system, line_index, ErrStat, ErrMsg) @@ -2603,7 +2603,7 @@ SUBROUTINE validate_system_motion_shape(system, q_coupled, v_coupled, a_coupled, CHARACTER(*), INTENT(OUT) :: ErrMsg INTEGER :: n, es - CHARACTER(160) :: em + CHARACTER(1024) :: em ErrStat = CD_SYSTEM_OK ErrMsg = '' @@ -2720,7 +2720,7 @@ SUBROUTINE build_point_coupled_map(models, points, bindings, map, point_base_out INTEGER :: point_dof_base, local_base INTEGER, ALLOCATABLE :: point_base(:) LOGICAL, ALLOCATABLE :: bound(:, :), point_bound(:) - CHARACTER(160) :: em + CHARACTER(1024) :: em ErrStat = CD_SYSTEM_OK ErrMsg = '' @@ -3287,7 +3287,7 @@ SUBROUTINE CD_System_Restore(system, ErrStat, ErrMsg) IF (ALLOCATED(system%snap_l0)) THEN BLOCK INTEGER :: le, he, ne_i, es2 - CHARACTER(240) :: em2 + CHARACTER(1024) :: em2 le = 1 lo = 1 DO i = 1, system%n_lines diff --git a/src/openfast/CableDyn_OF.f90 b/src/openfast/CableDyn_OF.f90 index 07a32f3d..1947d4fc 100644 --- a/src/openfast/CableDyn_OF.f90 +++ b/src/openfast/CableDyn_OF.f90 @@ -247,7 +247,7 @@ SUBROUTINE open_native_outputs( id, root, t_start, ErrStat, ErrMsg, write_profil character(*), parameter :: RoutineName = 'CableDyn:open_native_outputs' INTEGER(IntKi) :: es, un, ic, nch, owner, ios - CHARACTER(512) :: em, iomsg + CHARACTER(ErrMsgLen) :: em, iomsg CHARACTER(ChanLen) :: hdr, unt REAL(wp) :: value LOGICAL :: write_static @@ -470,7 +470,7 @@ SUBROUTINE CD_Init(InitInp, u, p, x, xd, z, other, y, m, DTcoupling, InitOut, Er character(*), parameter :: RoutineName = 'CD_Init' INTEGER(IntKi) :: ErrStat2, es CHARACTER(ErrMsgLen) :: ErrMsg2 - CHARACTER(512) :: em + CHARACTER(ErrMsgLen) :: em INTEGER(IntKi) :: id, ncp, nlines, il, i, ndofl, nstates, ic, nch, nsuper, nglue INTEGER(IntKi) :: nreportlines, npoints, nsections, nei0, nfinite, line_id INTEGER(IntKi) :: clock_count, nT, prof_c0, prof_c1, prof_rate @@ -1264,7 +1264,7 @@ SUBROUTINE rebuild_from_checkpoint( t, u1, p, x, other, m, ErrStat, ErrMsg ) CHARACTER(2100) :: rst_deck INTEGER(IntKi) :: id, old_id, stale_id, i, es, ncp, nlines, il, ndofl, nin, k, ic, csz, koff LOGICAL :: use_extf, profile_requested, preserve_profile - CHARACTER(512) :: em + CHARACTER(ErrMsgLen) :: em INTEGER(IntKi) :: ErrStat2 CHARACTER(ErrMsgLen) :: ErrMsg2 @@ -1519,7 +1519,7 @@ SUBROUTINE CD_UpdateStates( t, n, u, t_array, p, x, xd, z, other, m, ErrStat, Er INTEGER(IntKi) :: ErrStat2, es, id, niter, iu_t, i_u INTEGER(IntKi) :: prof_c0, prof_c1, prof_rate, prof_phase0 CHARACTER(ErrMsgLen) :: ErrMsg2 - CHARACTER(512) :: em + CHARACTER(ErrMsgLen) :: em LOGICAL :: conv, stalled ErrStat = ErrID_None @@ -1728,7 +1728,7 @@ SUBROUTINE sample_wavefield( inst_e, p, m, t_sample, ErrStat, ErrMsg, at_init ) ! interpolates the current at the depth mapped with it. Only the grid check reads it, so ! it exists only until that check has warned. REAL(wp), ALLOCATABLE :: wl_sampled(:) - CHARACTER(512) :: em + CHARACTER(ErrMsgLen) :: em INTEGER(IntKi) :: ErrStat2 CHARACTER(ErrMsgLen) :: ErrMsg2 @@ -2114,7 +2114,7 @@ SUBROUTINE CD_CalcOutput( t, u, p, x, xd, z, other, y, m, ErrStat, ErrMsg ) INTEGER(IntKi) :: ErrStat2, es, id, i INTEGER(IntKi) :: prof_c0, prof_c1, prof_rate, prof_phase0 CHARACTER(ErrMsgLen) :: ErrMsg2 - CHARACTER(512) :: em + CHARACTER(ErrMsgLen) :: em REAL(wp) :: cval LOGICAL :: fresh, state_overlaid @@ -2351,7 +2351,7 @@ SUBROUTINE restore_calcoutput_probe( inst_e, m, ErrStat, ErrMsg ) INTEGER(IntKi), INTENT(OUT) :: ErrStat CHARACTER(*), INTENT(OUT) :: ErrMsg INTEGER(IntKi) :: es, ErrStat2 - CHARACTER(512) :: em + CHARACTER(ErrMsgLen) :: em CHARACTER(ErrMsgLen) :: ErrMsg2 ErrStat = ErrID_None @@ -2721,7 +2721,7 @@ SUBROUTINE probe_loads( pos, PErrStat, PErrMsg ) REAL(wp) :: q_p(3, ncp), v_p(3, ncp), a_p(3, ncp), f_p(3, ncp) REAL(wp) :: cval INTEGER(IntKi) :: es_p, ich - CHARACTER(512) :: em_p + CHARACTER(ErrMsgLen) :: em_p PErrStat = ErrID_None PErrMsg = '' @@ -2891,7 +2891,7 @@ SUBROUTINE CD_InitVars(Vars, u, p, x, y, m, inst_, Linearize, ErrStat, ErrMsg) character(*), parameter :: RoutineName = 'CD_InitVars' INTEGER(IntKi) :: ErrStat2, es CHARACTER(ErrMsgLen) :: ErrMsg2 - CHARACTER(512) :: em + CHARACTER(ErrMsgLen) :: em INTEGER(IntKi) :: il, i, j, N, ndofl, nin, ic, csz, nf, koff, nve CHARACTER(32) :: LinStr CHARACTER(ChanLen) :: whdr, wunt @@ -3364,7 +3364,7 @@ SUBROUTINE reload_interiors_ary(inst_, m, states, t_clock, ErrStat, ErrMsg) character(*), parameter :: RoutineName = 'CableDyn:reload_interiors' INTEGER(IntKi) :: es, il, ndofl, nin, k, ic, csz, koff, npd, ncd, nfl, nve - CHARACTER(512) :: em + CHARACTER(ErrMsgLen) :: em ErrStat = ErrID_None ErrMsg = '' @@ -3604,7 +3604,7 @@ SUBROUTINE reload_cable_mirrors(inst_, m, states, t_clock, torsion_only, koff, E character(*), parameter :: RoutineName = 'CableDyn:reload_cable_mirrors' INTEGER(IntKi) :: es, ic, csz - CHARACTER(512) :: em + CHARACTER(ErrMsgLen) :: em ErrStat = ErrID_None ErrMsg = '' @@ -3649,7 +3649,7 @@ INTEGER(IntKi) FUNCTION line_friction_mirror_size(inst_) RESULT(n) !! every line on a frictional seabed (0 without such lines). TYPE(CD_OF_Instance), INTENT(IN) :: inst_ INTEGER(IntKi) :: il, es - CHARACTER(256) :: em + CHARACTER(ErrMsgLen) :: em n = 0 IF (.NOT. inst_%agg%has_sys) RETURN DO il = 1, inst_%nlines @@ -3678,7 +3678,7 @@ SUBROUTINE pack_state_mirror_ary(inst_, m, states, ErrStat, ErrMsg) character(*), parameter :: RoutineName = 'CableDyn:pack_state_mirror' INTEGER(IntKi) :: es, il, ndofl, nin, k, ic, csz, koff, npd, ncd, nfl, nve - CHARACTER(512) :: em + CHARACTER(ErrMsgLen) :: em ErrStat = ErrID_None ErrMsg = '' @@ -3890,7 +3890,7 @@ SUBROUTINE build_farm_meshes( inst_e, u, y, InitInp, nT, ncp, pos, ErrStat, ErrM character(*), parameter :: RoutineName = 'CableDyn:build_farm_meshes' INTEGER(IntKi) :: es, s, J, k, nk, ErrStat2 - CHARACTER(512) :: em + CHARACTER(ErrMsgLen) :: em CHARACTER(ErrMsgLen) :: ErrMsg2 REAL(R8Ki) :: OrMatJ(3,3), OrientIdent(3,3), refp(3), ptfmJ(6), ploc(3) LOGICAL :: hasp @@ -4075,7 +4075,7 @@ SUBROUTINE release_instance( k, ErrStat, ErrMsg ) INTEGER(IntKi), OPTIONAL, INTENT(OUT) :: ErrStat CHARACTER(*), OPTIONAL, INTENT(OUT) :: ErrMsg INTEGER(IntKi) :: es, ErrStat2 - CHARACTER(512) :: em + CHARACTER(ErrMsgLen) :: em CHARACTER(ErrMsgLen) :: ErrMsg2 IF (PRESENT(ErrStat)) ErrStat = ErrID_None IF (PRESENT(ErrMsg)) ErrMsg = '' diff --git a/tests/data/msg_anchor_below_seabed.dat b/tests/data/msg_anchor_below_seabed.dat new file mode 100644 index 00000000..46040133 --- /dev/null +++ b/tests/data/msg_anchor_below_seabed.dat @@ -0,0 +1,35 @@ +--------------------- CableDyn Input File --- +msg_anchor_below_seabed +--------------------- LINE TYPES --- +TypeName Diam MassDenInAir EA BA EI Cd_n Cd_t Ca_n Ca_t +(-) (m) (kg/m) (N) (-) (Nm2) (-) (-) (-) (-) +chain 0.216 286.56 1229760000 -1 0 1.37 0.64 1 0 +--------------------- POINTS --- +ID Type X Y Z Mass Vol CdA Ca +(-) (-) (m) (m) (m) (kg) (m3) (m2) (-) +1 Coupled 0 0 -10 0 0 0 0 +2 Fixed 450 0 -100.01 0 0 0 0 +--------------------- LINES --- +ID NodeA NodeB Outputs +(-) (-) (-) (-) +1 1 2 pt +--------------------- SECTIONS --- +LineID LineType Length NumSegs +(-) (-) (m) (-) +1 chain 520 52 +--------------------- OPTIONS --- +9.80665 g +1025.0 rhoW +100.0 WtrDpth +100000.0 kBot +1.0e4 cBot +--------------------- OUTPUTS --- +"FairTen1" +"AnchTen1" +"Point1Fx" +"Point1Fy" +"Point1Fz" +"Point2Fx" +"Point2Fy" +"Point2Fz" +--------------------- need this line --- diff --git a/tests/data/msg_coarse_section.dat b/tests/data/msg_coarse_section.dat new file mode 100644 index 00000000..053e37da --- /dev/null +++ b/tests/data/msg_coarse_section.dat @@ -0,0 +1,37 @@ +--------------------- CableDyn Input File --- +msg_coarse_section +--------------------- LINE TYPES --- +TypeName Diam MassDenInAir EA BA EI Cd_n Cd_t Ca_n Ca_t +(-) (m) (kg/m) (N) (-) (Nm2) (-) (-) (-) (-) +chain 0.216 286.56 1229760000 -1 0 1.37 0.64 1 0 +--------------------- POINTS --- +ID Type X Y Z Mass Vol CdA Ca +(-) (-) (m) (m) (m) (kg) (m3) (m2) (-) +1 Coupled 0 0 -10 0 0 0 0 +2 Fixed 450 0 -100 0 0 0 0 +--------------------- LINES --- +ID NodeA NodeB Outputs +(-) (-) (-) (-) +1 1 2 pt +--------------------- SECTIONS --- +LineID LineType Length NumSegs +(-) (-) (m) (-) +1 chain 100 1 +1 chain 320 1000 +1 chain 100 2 +--------------------- OPTIONS --- +9.80665 g +1025.0 rhoW +100.0 WtrDpth +100000.0 kBot +1.0e4 cBot +--------------------- OUTPUTS --- +"FairTen1" +"AnchTen1" +"Point1Fx" +"Point1Fy" +"Point1Fz" +"Point2Fx" +"Point2Fy" +"Point2Fz" +--------------------- need this line --- diff --git a/tests/data/msg_mixed_coarse_strain.dat b/tests/data/msg_mixed_coarse_strain.dat new file mode 100644 index 00000000..05b0e99a --- /dev/null +++ b/tests/data/msg_mixed_coarse_strain.dat @@ -0,0 +1,59 @@ +--------------------- CableDyn Input File --- +msg_mixed_coarse_strain +--------------------- LINE TYPES --- +TypeName Diam MassDenInAir EA BA EI Cd_n Cd_t Ca_n Ca_t +(-) (m) (kg/m) (N) (-) (Nm2) (-) (-) (-) (-) +chain 0.216 286.56 1229760000 -1 0 1.37 0.64 1 0 +pc 0.16 36.7 469000000 -1 19900 1.2 0.1 1 0 +buoy 0.5 170.666793 469000000 -1 19900 1.2 0.1 1 0 +--------------------- POINTS --- +ID Type X Y Z Mass Vol CdA Ca +(-) (-) (m) (m) (m) (kg) (m3) (m2) (-) +1 Coupled 0 0 -14 0 0 0 0 +2 Fixed 830 0 -200 0 0 0 0 +3 Fixed -415 719 -200 0 0 0 0 +4 Fixed -300 -50 -200 0 0 0 0 +--------------------- LINES --- +ID NodeA NodeB Outputs +(-) (-) (-) (-) +1 1 2 - +2 1 3 - +3 1 4 - +--------------------- SECTIONS --- +LineID LineType Length NumSegs +(-) (-) (m) (-) +1 chain 150 1 +1 chain 700 70 +2 chain 850 85 +3 pc 180 180 +3 buoy 80 80 +3 pc 150 150 +--------------------- OPTIONS --- +9.80665 g +1025.0 rhoW +200.0 WtrDpth +100000.0 kBot +1.0e4 cBot +0.05 dtM +0.0 TMax +0.0001 maxStrain +--------------------- OUTPUTS --- +"FairTen1" +"AnchTen1" +"FairTen2" +"AnchTen2" +"FairTen3" +"AnchTen3" +"Point1Fx" +"Point1Fy" +"Point1Fz" +"Point2Fx" +"Point2Fy" +"Point2Fz" +"Point3Fx" +"Point3Fy" +"Point3Fz" +"Point4Fx" +"Point4Fy" +"Point4Fz" +--------------------- need this line --- diff --git a/tests/data/msg_mixed_connect_coupled_cable.dat b/tests/data/msg_mixed_connect_coupled_cable.dat new file mode 100644 index 00000000..26620fca --- /dev/null +++ b/tests/data/msg_mixed_connect_coupled_cable.dat @@ -0,0 +1,64 @@ +--------------------- CableDyn Input File --- +msg_mixed_connect_coupled_cable +--------------------- LINE TYPES --- +TypeName Diam MassDenInAir EA BA EI Cd_n Cd_t Ca_n Ca_t +(-) (m) (kg/m) (N) (-) (Nm2) (-) (-) (-) (-) +chain 0.216 286.56 1229760000 -1 0 1.37 0.64 1 0 +pc 0.16 36.7 469000000 -1 19900 1.2 0.1 1 0 +buoy 0.5 170.666793 469000000 -1 19900 1.2 0.1 1 0 +--------------------- POINTS --- +ID Type X Y Z Mass Vol CdA Ca +(-) (-) (m) (m) (m) (kg) (m3) (m2) (-) +1 Coupled 0 0 -14 0 0 0 0 +2 Fixed 830 0 -200 0 0 0 0 +3 Fixed -415 719 -200 0 0 0 0 +4 Fixed -300 -50 -200 0 0 0 0 +5 Connect 400 0 -150 8000 0 0 0 +--------------------- LINES --- +ID NodeA NodeB Outputs +(-) (-) (-) (-) +1 1 5 - +2 5 2 - +3 1 4 - +--------------------- SECTIONS --- +LineID LineType Length NumSegs +(-) (-) (m) (-) +1 chain 450 45 +2 chain 420 42 +3 pc 180 180 +3 buoy 80 80 +3 pc 150 150 +--------------------- OPTIONS --- +9.80665 g +1025.0 rhoW +200.0 WtrDpth +100000.0 kBot +1.0e4 cBot +0.05 dtM +0.0 TMax +--------------------- OUTPUTS --- +"FairTen1" +"AnchTen1" +"FairTen2" +"AnchTen2" +"FairTen3" +"AnchTen3" +"Point1Fx" +"Point1Fy" +"Point1Fz" +"Point2Fx" +"Point2Fy" +"Point2Fz" +"Point3Fx" +"Point3Fy" +"Point3Fz" +"Point4Fx" +"Point4Fy" +"Point4Fz" +"Point5Fx" +"Point5Fy" +"Point5Fz" +"Point5px" +"Point5py" +"Point5pz" +--------------------- need this line --- diff --git a/tests/data/msg_mixed_current.dat b/tests/data/msg_mixed_current.dat new file mode 100644 index 00000000..e74f01da --- /dev/null +++ b/tests/data/msg_mixed_current.dat @@ -0,0 +1,58 @@ +--------------------- CableDyn Input File --- +msg_mixed_current +--------------------- LINE TYPES --- +TypeName Diam MassDenInAir EA BA EI Cd_n Cd_t Ca_n Ca_t +(-) (m) (kg/m) (N) (-) (Nm2) (-) (-) (-) (-) +chain 0.216 286.56 1229760000 -1 0 1.37 0.64 1 0 +pc 0.16 36.7 469000000 -1 19900 1.2 0.1 1 0 +buoy 0.5 170.666793 469000000 -1 19900 1.2 0.1 1 0 +--------------------- POINTS --- +ID Type X Y Z Mass Vol CdA Ca +(-) (-) (m) (m) (m) (kg) (m3) (m2) (-) +1 Coupled 0 0 -14 0 0 0 0 +2 Fixed 830 0 -200 0 0 0 0 +3 Fixed -415 719 -200 0 0 0 0 +4 Fixed -300 -50 -200 0 0 0 0 +--------------------- LINES --- +ID NodeA NodeB Outputs +(-) (-) (-) (-) +1 1 2 - +2 1 3 - +3 1 4 - +--------------------- SECTIONS --- +LineID LineType Length NumSegs +(-) (-) (m) (-) +1 chain 850 85 +2 chain 850 85 +3 pc 180 180 +3 buoy 80 80 +3 pc 150 150 +--------------------- OPTIONS --- +9.80665 g +1025.0 rhoW +200.0 WtrDpth +100000.0 kBot +1.0e4 cBot +0.05 dtM +0.0 TMax +uniform 0.5 0 0 current +--------------------- OUTPUTS --- +"FairTen1" +"AnchTen1" +"FairTen2" +"AnchTen2" +"FairTen3" +"AnchTen3" +"Point1Fx" +"Point1Fy" +"Point1Fz" +"Point2Fx" +"Point2Fy" +"Point2Fz" +"Point3Fx" +"Point3Fy" +"Point3Fz" +"Point4Fx" +"Point4Fy" +"Point4Fz" +--------------------- need this line --- diff --git a/tests/data/msg_net_buoyant_ei0.dat b/tests/data/msg_net_buoyant_ei0.dat new file mode 100644 index 00000000..1069272a --- /dev/null +++ b/tests/data/msg_net_buoyant_ei0.dat @@ -0,0 +1,35 @@ +--------------------- CableDyn Input File --- +msg_net_buoyant_ei0 +--------------------- LINE TYPES --- +TypeName Diam MassDenInAir EA BA EI Cd_n Cd_t Ca_n Ca_t +(-) (m) (kg/m) (N) (-) (Nm2) (-) (-) (-) (-) +neutral 0.17 23.2654100 200000000 -1 0 1.2 0.1 1 0 +--------------------- POINTS --- +ID Type X Y Z Mass Vol CdA Ca +(-) (-) (m) (m) (m) (kg) (m3) (m2) (-) +1 Coupled 0 0 -10 0 0 0 0 +2 Fixed 450 0 -100 0 0 0 0 +--------------------- LINES --- +ID NodeA NodeB Outputs +(-) (-) (-) (-) +1 1 2 pt +--------------------- SECTIONS --- +LineID LineType Length NumSegs +(-) (-) (m) (-) +1 neutral 520 52 +--------------------- OPTIONS --- +9.80665 g +1025.0 rhoW +100.0 WtrDpth +100000.0 kBot +1.0e4 cBot +--------------------- OUTPUTS --- +"FairTen1" +"AnchTen1" +"Point1Fx" +"Point1Fy" +"Point1Fz" +"Point2Fx" +"Point2Fy" +"Point2Fz" +--------------------- need this line --- diff --git a/tests/data/msg_pliant_connect_end_b.dat b/tests/data/msg_pliant_connect_end_b.dat new file mode 100644 index 00000000..08dfab34 --- /dev/null +++ b/tests/data/msg_pliant_connect_end_b.dat @@ -0,0 +1,56 @@ +--------------------- CableDyn Input File --- +msg_pliant_connect_end_b +--------------------- LINE TYPES --- +TypeName Diam MassDenInAir EA BA EI Cd_n Cd_t Ca_n Ca_t +(-) (m) (kg/m) (N) (-) (Nm2) (-) (-) (-) (-) +pc 0.16 36.7 469000000 -1 19900 1.2 0.1 1 0 +buoy 0.5 170.666793 469000000 -1 19900 1.2 0.1 1 0 +chainS 0.1368 114.9424 493270400 -1 0 1.37 0.64 1 0 +--------------------- POINTS --- +ID Type X Y Z Mass Vol CdA Ca +(-) (-) (m) (m) (m) (kg) (m3) (m2) (-) +1 Coupled 0 0 -20 0 0 0 0 +2 Connect 250 0 -150 0 0 0 0 +3 Fixed 400 0 -200 0 0 0 0 +4 Fixed 260 0 -200 0 0 0 0 +--------------------- LINES --- +ID NodeA NodeB Outputs +(-) (-) (-) (-) +1 1 2 - +2 2 3 - +3 2 4 - +--------------------- SECTIONS --- +LineID LineType Length NumSegs +(-) (-) (m) (-) +1 pc 180 180 +1 buoy 80 80 +2 pc 200 200 +3 chainS 45 20 +--------------------- OPTIONS --- +9.80665 g +1025.0 rhoW +200.0 WtrDpth +100000.0 kBot +1.0e4 cBot +0.05 dtM +0.0 TMax +--------------------- OUTPUTS --- +"FairTen1" +"AnchTen1" +"FairTen2" +"AnchTen2" +"FairTen3" +"AnchTen3" +"Point2Fx" +"Point2Fy" +"Point2Fz" +"Point2px" +"Point2py" +"Point2pz" +"Point3Fx" +"Point3Fy" +"Point3Fz" +"Point4Fx" +"Point4Fy" +"Point4Fz" +--------------------- need this line --- diff --git a/tests/data/msg_shared_line.dat b/tests/data/msg_shared_line.dat new file mode 100644 index 00000000..e1315fc7 --- /dev/null +++ b/tests/data/msg_shared_line.dat @@ -0,0 +1,35 @@ +--------------------- CableDyn Input File --- +msg_shared_line +--------------------- LINE TYPES --- +TypeName Diam MassDenInAir EA BA EI Cd_n Cd_t Ca_n Ca_t +(-) (m) (kg/m) (N) (-) (Nm2) (-) (-) (-) (-) +wire 0.1 50 900000000 -1 0 1.2 0.008 1 0 +--------------------- POINTS --- +ID Type X Y Z Mass Vol CdA Ca +(-) (-) (m) (m) (m) (kg) (m3) (m2) (-) +1 Coupled 0 0 -15 0 0 0 0 +2 Coupled 800 0 -15 0 0 0 0 +--------------------- LINES --- +ID NodeA NodeB Outputs +(-) (-) (-) (-) +1 1 2 pt +--------------------- SECTIONS --- +LineID LineType Length NumSegs +(-) (-) (m) (-) +1 wire 900 90 +--------------------- OPTIONS --- +9.80665 g +1025.0 rhoW +200.0 WtrDpth +100000.0 kBot +1.0e4 cBot +--------------------- OUTPUTS --- +"FairTen1" +"AnchTen1" +"Point1Fx" +"Point1Fy" +"Point1Fz" +"Point2Fx" +"Point2Fy" +"Point2Fz" +--------------------- need this line --- diff --git a/tests/data/msg_shared_line_finite_ei.dat b/tests/data/msg_shared_line_finite_ei.dat new file mode 100644 index 00000000..54324710 --- /dev/null +++ b/tests/data/msg_shared_line_finite_ei.dat @@ -0,0 +1,35 @@ +--------------------- CableDyn Input File --- +msg_shared_line_finite_ei +--------------------- LINE TYPES --- +TypeName Diam MassDenInAir EA BA EI Cd_n Cd_t Ca_n Ca_t +(-) (m) (kg/m) (N) (-) (Nm2) (-) (-) (-) (-) +wire 0.1 50 900000000 -1 10000 1.2 0.008 1 0 +--------------------- POINTS --- +ID Type X Y Z Mass Vol CdA Ca +(-) (-) (m) (m) (m) (kg) (m3) (m2) (-) +1 Coupled 0 0 -15 0 0 0 0 +2 Coupled 800 0 -15 0 0 0 0 +--------------------- LINES --- +ID NodeA NodeB Outputs +(-) (-) (-) (-) +1 1 2 pt +--------------------- SECTIONS --- +LineID LineType Length NumSegs +(-) (-) (m) (-) +1 wire 900 90 +--------------------- OPTIONS --- +9.80665 g +1025.0 rhoW +200.0 WtrDpth +100000.0 kBot +1.0e4 cBot +--------------------- OUTPUTS --- +"FairTen1" +"AnchTen1" +"Point1Fx" +"Point1Fy" +"Point1Fz" +"Point2Fx" +"Point2Fy" +"Point2Fz" +--------------------- need this line --- diff --git a/tests/data/msg_static_strain.dat b/tests/data/msg_static_strain.dat new file mode 100644 index 00000000..c64428c4 --- /dev/null +++ b/tests/data/msg_static_strain.dat @@ -0,0 +1,35 @@ +--------------------- CableDyn Input File --- +msg_static_strain +--------------------- LINE TYPES --- +TypeName Diam MassDenInAir EA BA EI Cd_n Cd_t Ca_n Ca_t +(-) (m) (kg/m) (N) (-) (Nm2) (-) (-) (-) (-) +chain 0.216 286.56 1229760000 -1 0 1.37 0.64 1 0 +--------------------- POINTS --- +ID Type X Y Z Mass Vol CdA Ca +(-) (-) (m) (m) (m) (kg) (m3) (m2) (-) +1 Coupled 0 0 -10 0 0 0 0 +2 Fixed 450 0 -100 0 0 0 0 +--------------------- LINES --- +ID NodeA NodeB Outputs +(-) (-) (-) (-) +1 1 2 pt +--------------------- SECTIONS --- +LineID LineType Length NumSegs +(-) (-) (m) (-) +1 chain 229.4558781 46 +--------------------- OPTIONS --- +9.80665 g +1025.0 rhoW +100.0 WtrDpth +100000.0 kBot +1.0e4 cBot +--------------------- OUTPUTS --- +"FairTen1" +"AnchTen1" +"Point1Fx" +"Point1Fy" +"Point1Fz" +"Point2Fx" +"Point2Fy" +"Point2Fz" +--------------------- need this line --- diff --git a/tests/data/msg_tensile_safety_motion.txt b/tests/data/msg_tensile_safety_motion.txt new file mode 100644 index 00000000..07b0e02f --- /dev/null +++ b/tests/data/msg_tensile_safety_motion.txt @@ -0,0 +1,346 @@ +# time id x y z vx vy vz ax ay az +0.000000 1 5.0000000000e+00 0.0000000000e+00 -1.4000000000e+01 0.0000000000e+00 0.0000000000e+00 0.0000000000e+00 0.0000000000e+00 0.0000000000e+00 0.0000000000e+00 +0.025000 1 5.0000000000e+00 0.0000000000e+00 -1.3999999944e+01 0.0000000000e+00 0.0000000000e+00 9.0178347426e-06 0.0000000000e+00 0.0000000000e+00 1.0791875902e-03 +0.050000 1 5.0000000000e+00 0.0000000000e+00 -1.3999999103e+01 0.0000000000e+00 0.0000000000e+00 7.1541205409e-05 0.0000000000e+00 0.0000000000e+00 4.2679788790e-03 +0.075000 1 5.0000000000e+00 0.0000000000e+00 -1.3999995489e+01 0.0000000000e+00 0.0000000000e+00 2.3934890270e-04 0.0000000000e+00 0.0000000000e+00 9.4884210092e-03 +0.100000 1 5.0000000000e+00 0.0000000000e+00 -1.3999985843e+01 0.0000000000e+00 0.0000000000e+00 5.6219367406e-04 0.0000000000e+00 0.0000000000e+00 1.6656440931e-02 +0.125000 1 5.0000000000e+00 0.0000000000e+00 -1.3999965690e+01 0.0000000000e+00 0.0000000000e+00 1.0876535691e-03 0.0000000000e+00 0.0000000000e+00 2.5682194750e-02 +0.150000 1 5.0000000000e+00 0.0000000000e+00 -1.3999929394e+01 0.0000000000e+00 0.0000000000e+00 1.8609921150e-03 0.0000000000e+00 0.0000000000e+00 3.6470424618e-02 +0.175000 1 5.0000000000e+00 0.0000000000e+00 -1.3999870217e+01 0.0000000000e+00 0.0000000000e+00 2.9250274991e-03 0.0000000000e+00 0.0000000000e+00 4.8920822328e-02 +0.200000 1 5.0000000000e+00 0.0000000000e+00 -1.3999780384e+01 0.0000000000e+00 0.0000000000e+00 4.3200109175e-03 0.0000000000e+00 0.0000000000e+00 6.2928398803e-02 +0.225000 1 5.0000000000e+00 0.0000000000e+00 -1.3999651145e+01 0.0000000000e+00 0.0000000000e+00 6.0835142251e-03 0.0000000000e+00 0.0000000000e+00 7.8383858639e-02 +0.250000 1 5.0000000000e+00 0.0000000000e+00 -1.3999472846e+01 0.0000000000e+00 0.0000000000e+00 8.2503270044e-03 0.0000000000e+00 0.0000000000e+00 9.5173978882e-02 +0.275000 1 5.0000000000e+00 0.0000000000e+00 -1.3999235001e+01 0.0000000000e+00 0.0000000000e+00 1.0852363148e-02 0.0000000000e+00 0.0000000000e+00 1.1318199122e-01 +0.300000 1 5.0000000000e+00 0.0000000000e+00 -1.3998926359e+01 0.0000000000e+00 0.0000000000e+00 1.3918577029e-02 0.0000000000e+00 0.0000000000e+00 1.3228796675e-01 +0.325000 1 5.0000000000e+00 0.0000000000e+00 -1.3998534987e+01 0.0000000000e+00 0.0000000000e+00 1.7474889317e-02 0.0000000000e+00 0.0000000000e+00 1.5236920254e-01 +0.350000 1 5.0000000000e+00 0.0000000000e+00 -1.3998048339e+01 0.0000000000e+00 0.0000000000e+00 2.1544122468e-02 0.0000000000e+00 0.0000000000e+00 1.7330060916e-01 +0.375000 1 5.0000000000e+00 0.0000000000e+00 -1.3997453341e+01 0.0000000000e+00 0.0000000000e+00 2.6145945911e-02 0.0000000000e+00 0.0000000000e+00 1.9495509834e-01 +0.400000 1 5.0000000000e+00 0.0000000000e+00 -1.3996736466e+01 0.0000000000e+00 0.0000000000e+00 3.1296830914e-02 0.0000000000e+00 0.0000000000e+00 2.1720397005e-01 +0.425000 1 5.0000000000e+00 0.0000000000e+00 -1.3995883813e+01 0.0000000000e+00 0.0000000000e+00 3.7010015117e-02 0.0000000000e+00 0.0000000000e+00 2.3991729813e-01 +0.450000 1 5.0000000000e+00 0.0000000000e+00 -1.3994881195e+01 0.0000000000e+00 0.0000000000e+00 4.3295476679e-02 0.0000000000e+00 0.0000000000e+00 2.6296431381e-01 +0.475000 1 5.0000000000e+00 0.0000000000e+00 -1.3993714214e+01 0.0000000000e+00 0.0000000000e+00 5.0159917971e-02 0.0000000000e+00 0.0000000000e+00 2.8621378621e-01 +0.500000 1 5.0000000000e+00 0.0000000000e+00 -1.3992368345e+01 0.0000000000e+00 0.0000000000e+00 5.7606758748e-02 0.0000000000e+00 0.0000000000e+00 3.0953439921e-01 +0.525000 1 5.0000000000e+00 0.0000000000e+00 -1.3990829020e+01 0.0000000000e+00 0.0000000000e+00 6.5636138680e-02 0.0000000000e+00 0.0000000000e+00 3.3279512392e-01 +0.550000 1 5.0000000000e+00 0.0000000000e+00 -1.3989081709e+01 0.0000000000e+00 0.0000000000e+00 7.4244929139e-02 0.0000000000e+00 0.0000000000e+00 3.5586558601e-01 +0.575000 1 5.0000000000e+00 0.0000000000e+00 -1.3987111998e+01 0.0000000000e+00 0.0000000000e+00 8.3426754092e-02 0.0000000000e+00 0.0000000000e+00 3.7861642723e-01 +0.600000 1 5.0000000000e+00 0.0000000000e+00 -1.3984905675e+01 0.0000000000e+00 0.0000000000e+00 9.3172019957e-02 0.0000000000e+00 0.0000000000e+00 4.0091966045e-01 +0.625000 1 5.0000000000e+00 0.0000000000e+00 -1.3982448807e+01 0.0000000000e+00 0.0000000000e+00 1.0346795424e-01 0.0000000000e+00 0.0000000000e+00 4.2264901753e-01 +0.650000 1 5.0000000000e+00 0.0000000000e+00 -1.3979727820e+01 0.0000000000e+00 0.0000000000e+00 1.1429865279e-01 0.0000000000e+00 0.0000000000e+00 4.4368028942e-01 +0.675000 1 5.0000000000e+00 0.0000000000e+00 -1.3976729575e+01 0.0000000000e+00 0.0000000000e+00 1.2564513543e-01 0.0000000000e+00 0.0000000000e+00 4.6389165785e-01 +0.700000 1 5.0000000000e+00 0.0000000000e+00 -1.3973441447e+01 0.0000000000e+00 0.0000000000e+00 1.3748540977e-01 0.0000000000e+00 0.0000000000e+00 4.8316401803e-01 +0.725000 1 5.0000000000e+00 0.0000000000e+00 -1.3969851397e+01 0.0000000000e+00 0.0000000000e+00 1.4979454302e-01 0.0000000000e+00 0.0000000000e+00 5.0138129176e-01 +0.750000 1 5.0000000000e+00 0.0000000000e+00 -1.3965948044e+01 0.0000000000e+00 0.0000000000e+00 1.6254474140e-01 0.0000000000e+00 0.0000000000e+00 5.1843073044e-01 +0.775000 1 5.0000000000e+00 0.0000000000e+00 -1.3961720738e+01 0.0000000000e+00 0.0000000000e+00 1.7570543711e-01 0.0000000000e+00 0.0000000000e+00 5.3420320740e-01 +0.800000 1 5.0000000000e+00 0.0000000000e+00 -1.3957159627e+01 0.0000000000e+00 0.0000000000e+00 1.8924338240e-01 0.0000000000e+00 0.0000000000e+00 5.4859349915e-01 +0.825000 1 5.0000000000e+00 0.0000000000e+00 -1.3952255723e+01 0.0000000000e+00 0.0000000000e+00 2.0312275054e-01 0.0000000000e+00 0.0000000000e+00 5.6150055495e-01 +0.850000 1 5.0000000000e+00 0.0000000000e+00 -1.3947000963e+01 0.0000000000e+00 0.0000000000e+00 2.1730524338e-01 0.0000000000e+00 0.0000000000e+00 5.7282775436e-01 +0.875000 1 5.0000000000e+00 0.0000000000e+00 -1.3941388273e+01 0.0000000000e+00 0.0000000000e+00 2.3175020521e-01 0.0000000000e+00 0.0000000000e+00 5.8248315227e-01 +0.900000 1 5.0000000000e+00 0.0000000000e+00 -1.3935411623e+01 0.0000000000e+00 0.0000000000e+00 2.4641474257e-01 0.0000000000e+00 0.0000000000e+00 5.9037971104e-01 +0.925000 1 5.0000000000e+00 0.0000000000e+00 -1.3929066081e+01 0.0000000000e+00 0.0000000000e+00 2.6125384969e-01 0.0000000000e+00 0.0000000000e+00 5.9643551949e-01 +0.950000 1 5.0000000000e+00 0.0000000000e+00 -1.3922347866e+01 0.0000000000e+00 0.0000000000e+00 2.7622053926e-01 0.0000000000e+00 0.0000000000e+00 6.0057399818e-01 +0.975000 1 5.0000000000e+00 0.0000000000e+00 -1.3915254397e+01 0.0000000000e+00 0.0000000000e+00 2.9126597814e-01 0.0000000000e+00 0.0000000000e+00 6.0272409086e-01 +1.000000 1 5.0000000000e+00 0.0000000000e+00 -1.3907784332e+01 0.0000000000e+00 0.0000000000e+00 3.0633962766e-01 0.0000000000e+00 0.0000000000e+00 6.0282044178e-01 +1.025000 1 5.0000000000e+00 0.0000000000e+00 -1.3899937614e+01 0.0000000000e+00 0.0000000000e+00 3.2138938827e-01 0.0000000000e+00 0.0000000000e+00 6.0080355849e-01 +1.050000 1 5.0000000000e+00 0.0000000000e+00 -1.3891715507e+01 0.0000000000e+00 0.0000000000e+00 3.3636174792e-01 0.0000000000e+00 0.0000000000e+00 5.9661996009e-01 +1.075000 1 5.0000000000e+00 0.0000000000e+00 -1.3883120628e+01 0.0000000000e+00 0.0000000000e+00 3.5120193411e-01 0.0000000000e+00 0.0000000000e+00 5.9022231057e-01 +1.100000 1 5.0000000000e+00 0.0000000000e+00 -1.3874156977e+01 0.0000000000e+00 0.0000000000e+00 3.6585406898e-01 0.0000000000e+00 0.0000000000e+00 5.8156953719e-01 +1.125000 1 5.0000000000e+00 0.0000000000e+00 -1.3864829965e+01 0.0000000000e+00 0.0000000000e+00 3.8026132726e-01 0.0000000000e+00 0.0000000000e+00 5.7062693371e-01 +1.150000 1 5.0000000000e+00 0.0000000000e+00 -1.3855146432e+01 0.0000000000e+00 0.0000000000e+00 3.9436609650e-01 0.0000000000e+00 0.0000000000e+00 5.5736624837e-01 +1.175000 1 5.0000000000e+00 0.0000000000e+00 -1.3845114666e+01 0.0000000000e+00 0.0000000000e+00 4.0811013946e-01 0.0000000000e+00 0.0000000000e+00 5.4176575659e-01 +1.200000 1 5.0000000000e+00 0.0000000000e+00 -1.3834744420e+01 0.0000000000e+00 0.0000000000e+00 4.2143475794e-01 0.0000000000e+00 0.0000000000e+00 5.2381031830e-01 +1.225000 1 5.0000000000e+00 0.0000000000e+00 -1.3824046915e+01 0.0000000000e+00 0.0000000000e+00 4.3428095802e-01 0.0000000000e+00 0.0000000000e+00 5.0349141988e-01 +1.250000 1 5.0000000000e+00 0.0000000000e+00 -1.3813034851e+01 0.0000000000e+00 0.0000000000e+00 4.4658961608e-01 0.0000000000e+00 0.0000000000e+00 4.8080720078e-01 +1.275000 1 5.0000000000e+00 0.0000000000e+00 -1.3801722406e+01 0.0000000000e+00 0.0000000000e+00 4.5830164524e-01 0.0000000000e+00 0.0000000000e+00 4.5576246480e-01 +1.300000 1 5.0000000000e+00 0.0000000000e+00 -1.3790125232e+01 0.0000000000e+00 0.0000000000e+00 4.6935816203e-01 0.0000000000e+00 0.0000000000e+00 4.2836867612e-01 +1.325000 1 5.0000000000e+00 0.0000000000e+00 -1.3778260448e+01 0.0000000000e+00 0.0000000000e+00 4.7970065265e-01 0.0000000000e+00 0.0000000000e+00 3.9864394024e-01 +1.350000 1 5.0000000000e+00 0.0000000000e+00 -1.3766146633e+01 0.0000000000e+00 0.0000000000e+00 4.8927113860e-01 0.0000000000e+00 0.0000000000e+00 3.6661296981e-01 +1.375000 1 5.0000000000e+00 0.0000000000e+00 -1.3753803802e+01 0.0000000000e+00 0.0000000000e+00 4.9801234130e-01 0.0000000000e+00 0.0000000000e+00 3.3230703576e-01 +1.400000 1 5.0000000000e+00 0.0000000000e+00 -1.3741253397e+01 0.0000000000e+00 0.0000000000e+00 5.0586784529e-01 0.0000000000e+00 0.0000000000e+00 2.9576390356e-01 +1.425000 1 5.0000000000e+00 0.0000000000e+00 -1.3728518253e+01 0.0000000000e+00 0.0000000000e+00 5.1278225959e-01 0.0000000000e+00 0.0000000000e+00 2.5702775521e-01 +1.450000 1 5.0000000000e+00 0.0000000000e+00 -1.3715622578e+01 0.0000000000e+00 0.0000000000e+00 5.1870137707e-01 0.0000000000e+00 0.0000000000e+00 2.1614909683e-01 +1.475000 1 5.0000000000e+00 0.0000000000e+00 -1.3702591919e+01 0.0000000000e+00 0.0000000000e+00 5.2357233119e-01 0.0000000000e+00 0.0000000000e+00 1.7318465245e-01 +1.500000 1 5.0000000000e+00 0.0000000000e+00 -1.3689453125e+01 0.0000000000e+00 0.0000000000e+00 5.2734375000e-01 0.0000000000e+00 0.0000000000e+00 1.2819724397e-01 +1.525000 1 5.0000000000e+00 0.0000000000e+00 -1.3676234309e+01 0.0000000000e+00 0.0000000000e+00 5.2996590696e-01 0.0000000000e+00 0.0000000000e+00 8.1255657894e-02 +1.550000 1 5.0000000000e+00 0.0000000000e+00 -1.3662964807e+01 0.0000000000e+00 0.0000000000e+00 5.3139086821e-01 0.0000000000e+00 0.0000000000e+00 3.2434498891e-02 +1.575000 1 5.0000000000e+00 0.0000000000e+00 -1.3649675126e+01 0.0000000000e+00 0.0000000000e+00 5.3157263613e-01 0.0000000000e+00 0.0000000000e+00 -1.8185969194e-02 +1.600000 1 5.0000000000e+00 0.0000000000e+00 -1.3636396902e+01 0.0000000000e+00 0.0000000000e+00 5.3046728864e-01 0.0000000000e+00 0.0000000000e+00 -7.0519994699e-02 +1.625000 1 5.0000000000e+00 0.0000000000e+00 -1.3623162836e+01 0.0000000000e+00 0.0000000000e+00 5.2803311414e-01 0.0000000000e+00 0.0000000000e+00 -1.2447652136e-01 +1.650000 1 5.0000000000e+00 0.0000000000e+00 -1.3610006648e+01 0.0000000000e+00 0.0000000000e+00 5.2423074175e-01 0.0000000000e+00 0.0000000000e+00 -1.7995938303e-01 +1.675000 1 5.0000000000e+00 0.0000000000e+00 -1.3596963009e+01 0.0000000000e+00 0.0000000000e+00 5.1902326648e-01 0.0000000000e+00 0.0000000000e+00 -2.3686750939e-01 +1.700000 1 5.0000000000e+00 0.0000000000e+00 -1.3584067481e+01 0.0000000000e+00 0.0000000000e+00 5.1237636915e-01 0.0000000000e+00 0.0000000000e+00 -2.9509514222e-01 +1.725000 1 5.0000000000e+00 0.0000000000e+00 -1.3571356450e+01 0.0000000000e+00 0.0000000000e+00 5.0425843080e-01 0.0000000000e+00 0.0000000000e+00 -3.5453206185e-01 +1.750000 1 5.0000000000e+00 0.0000000000e+00 -1.3558867059e+01 0.0000000000e+00 0.0000000000e+00 4.9464064127e-01 0.0000000000e+00 0.0000000000e+00 -4.1506382309e-01 +1.775000 1 5.0000000000e+00 0.0000000000e+00 -1.3546637133e+01 0.0000000000e+00 0.0000000000e+00 4.8349710181e-01 0.0000000000e+00 0.0000000000e+00 -4.7657200030e-01 +1.800000 1 5.0000000000e+00 0.0000000000e+00 -1.3534705110e+01 0.0000000000e+00 0.0000000000e+00 4.7080492143e-01 0.0000000000e+00 0.0000000000e+00 -5.3893444102e-01 +1.825000 1 5.0000000000e+00 0.0000000000e+00 -1.3523109959e+01 0.0000000000e+00 0.0000000000e+00 4.5654430682e-01 0.0000000000e+00 0.0000000000e+00 -6.0202552763e-01 +1.850000 1 5.0000000000e+00 0.0000000000e+00 -1.3511891104e+01 0.0000000000e+00 0.0000000000e+00 4.4069864564e-01 0.0000000000e+00 0.0000000000e+00 -6.6571644640e-01 +1.875000 1 5.0000000000e+00 0.0000000000e+00 -1.3501088347e+01 0.0000000000e+00 0.0000000000e+00 4.2325458295e-01 0.0000000000e+00 0.0000000000e+00 -7.2987546353e-01 +1.900000 1 5.0000000000e+00 0.0000000000e+00 -1.3490741780e+01 0.0000000000e+00 0.0000000000e+00 4.0420209075e-01 0.0000000000e+00 0.0000000000e+00 -7.9436820744e-01 +1.925000 1 5.0000000000e+00 0.0000000000e+00 -1.3480891702e+01 0.0000000000e+00 0.0000000000e+00 3.8353453029e-01 0.0000000000e+00 0.0000000000e+00 -8.5905795686e-01 +1.950000 1 5.0000000000e+00 0.0000000000e+00 -1.3471578540e+01 0.0000000000e+00 0.0000000000e+00 3.6124870719e-01 0.0000000000e+00 0.0000000000e+00 -9.2380593399e-01 +1.975000 1 5.0000000000e+00 0.0000000000e+00 -1.3462842751e+01 0.0000000000e+00 0.0000000000e+00 3.3734491910e-01 0.0000000000e+00 0.0000000000e+00 -9.8847160223e-01 +2.000000 1 5.0000000000e+00 0.0000000000e+00 -1.3454724746e+01 0.0000000000e+00 0.0000000000e+00 3.1182699595e-01 0.0000000000e+00 0.0000000000e+00 -1.0529129679e+00 +2.025000 1 5.0000000000e+00 0.0000000000e+00 -1.3447264792e+01 0.0000000000e+00 0.0000000000e+00 2.8470233254e-01 0.0000000000e+00 0.0000000000e+00 -1.1169868851e+00 +2.050000 1 5.0000000000e+00 0.0000000000e+00 -1.3440502928e+01 0.0000000000e+00 0.0000000000e+00 2.5598191353e-01 0.0000000000e+00 0.0000000000e+00 -1.1805493635e+00 +2.075000 1 5.0000000000e+00 0.0000000000e+00 -1.3434478874e+01 0.0000000000e+00 0.0000000000e+00 2.2568033067e-01 0.0000000000e+00 0.0000000000e+00 -1.2434558779e+00 +2.100000 1 5.0000000000e+00 0.0000000000e+00 -1.3429231937e+01 0.0000000000e+00 0.0000000000e+00 1.9381579226e-01 0.0000000000e+00 0.0000000000e+00 -1.3055616798e+00 +2.125000 1 5.0000000000e+00 0.0000000000e+00 -1.3424800928e+01 0.0000000000e+00 0.0000000000e+00 1.6041012490e-01 0.0000000000e+00 0.0000000000e+00 -1.3667221089e+00 +2.150000 1 5.0000000000e+00 0.0000000000e+00 -1.3421224063e+01 0.0000000000e+00 0.0000000000e+00 1.2548876729e-01 0.0000000000e+00 0.0000000000e+00 -1.4267929055e+00 +2.175000 1 5.0000000000e+00 0.0000000000e+00 -1.3418538879e+01 0.0000000000e+00 0.0000000000e+00 8.9080756404e-02 0.0000000000e+00 0.0000000000e+00 -1.4856305225e+00 +2.200000 1 5.0000000000e+00 0.0000000000e+00 -1.3416782143e+01 0.0000000000e+00 0.0000000000e+00 5.1218705734e-02 0.0000000000e+00 0.0000000000e+00 -1.5430924358e+00 +2.225000 1 5.0000000000e+00 0.0000000000e+00 -1.3415989760e+01 0.0000000000e+00 0.0000000000e+00 1.1938775864e-02 0.0000000000e+00 0.0000000000e+00 -1.5990374537e+00 +2.250000 1 5.0000000000e+00 0.0000000000e+00 -1.3416196690e+01 0.0000000000e+00 0.0000000000e+00 -2.8719362675e-02 0.0000000000e+00 0.0000000000e+00 -1.6533260232e+00 +2.275000 1 5.0000000000e+00 0.0000000000e+00 -1.3417436855e+01 0.0000000000e+00 0.0000000000e+00 -7.0712574186e-02 0.0000000000e+00 0.0000000000e+00 -1.7058205343e+00 +2.300000 1 5.0000000000e+00 0.0000000000e+00 -1.3419743057e+01 0.0000000000e+00 0.0000000000e+00 -1.1399431014e-01 0.0000000000e+00 0.0000000000e+00 -1.7563856204e+00 +2.325000 1 5.0000000000e+00 0.0000000000e+00 -1.3423146893e+01 0.0000000000e+00 0.0000000000e+00 -1.5851466898e-01 0.0000000000e+00 0.0000000000e+00 -1.8048884541e+00 +2.350000 1 5.0000000000e+00 0.0000000000e+00 -1.3427678670e+01 0.0000000000e+00 0.0000000000e+00 -2.0422046324e-01 0.0000000000e+00 0.0000000000e+00 -1.8511990394e+00 +2.375000 1 5.0000000000e+00 0.0000000000e+00 -1.3433367326e+01 0.0000000000e+00 0.0000000000e+00 -2.5105529395e-01 0.0000000000e+00 0.0000000000e+00 -1.8951904980e+00 +2.400000 1 5.0000000000e+00 0.0000000000e+00 -1.3440240349e+01 0.0000000000e+00 0.0000000000e+00 -2.9895963206e-01 0.0000000000e+00 0.0000000000e+00 -1.9367393495e+00 +2.425000 1 5.0000000000e+00 0.0000000000e+00 -1.3448323700e+01 0.0000000000e+00 0.0000000000e+00 -3.4787090687e-01 0.0000000000e+00 0.0000000000e+00 -1.9757257860e+00 +2.450000 1 5.0000000000e+00 0.0000000000e+00 -1.3457641740e+01 0.0000000000e+00 0.0000000000e+00 -3.9772360117e-01 0.0000000000e+00 0.0000000000e+00 -2.0120339393e+00 +2.475000 1 5.0000000000e+00 0.0000000000e+00 -1.3468217156e+01 0.0000000000e+00 0.0000000000e+00 -4.4844935300e-01 0.0000000000e+00 0.0000000000e+00 -2.0455521409e+00 +2.500000 1 5.0000000000e+00 0.0000000000e+00 -1.3480070891e+01 0.0000000000e+00 0.0000000000e+00 -4.9997706383e-01 0.0000000000e+00 0.0000000000e+00 -2.0761731734e+00 +2.525000 1 5.0000000000e+00 0.0000000000e+00 -1.3493222078e+01 0.0000000000e+00 0.0000000000e+00 -5.5223301288e-01 0.0000000000e+00 0.0000000000e+00 -2.1037945148e+00 +2.550000 1 5.0000000000e+00 0.0000000000e+00 -1.3507687976e+01 0.0000000000e+00 0.0000000000e+00 -6.0514097744e-01 0.0000000000e+00 0.0000000000e+00 -2.1283185725e+00 +2.575000 1 5.0000000000e+00 0.0000000000e+00 -1.3523483906e+01 0.0000000000e+00 0.0000000000e+00 -6.5862235900e-01 0.0000000000e+00 0.0000000000e+00 -2.1496529088e+00 +2.600000 1 5.0000000000e+00 0.0000000000e+00 -1.3540623199e+01 0.0000000000e+00 0.0000000000e+00 -7.1259631476e-01 0.0000000000e+00 0.0000000000e+00 -2.1677104560e+00 +2.625000 1 5.0000000000e+00 0.0000000000e+00 -1.3559117136e+01 0.0000000000e+00 0.0000000000e+00 -7.6697989452e-01 0.0000000000e+00 0.0000000000e+00 -2.1824097220e+00 +2.650000 1 5.0000000000e+00 0.0000000000e+00 -1.3578974900e+01 0.0000000000e+00 0.0000000000e+00 -8.2168818250e-01 0.0000000000e+00 0.0000000000e+00 -2.1936749840e+00 +2.675000 1 5.0000000000e+00 0.0000000000e+00 -1.3600203529e+01 0.0000000000e+00 0.0000000000e+00 -8.7663444391e-01 0.0000000000e+00 0.0000000000e+00 -2.2014364728e+00 +2.700000 1 5.0000000000e+00 0.0000000000e+00 -1.3622807869e+01 0.0000000000e+00 0.0000000000e+00 -9.3173027592e-01 0.0000000000e+00 0.0000000000e+00 -2.2056305442e+00 +2.725000 1 5.0000000000e+00 0.0000000000e+00 -1.3646790540e+01 0.0000000000e+00 0.0000000000e+00 -9.8688576286e-01 0.0000000000e+00 0.0000000000e+00 -2.2061998395e+00 +2.750000 1 5.0000000000e+00 0.0000000000e+00 -1.3672151894e+01 0.0000000000e+00 0.0000000000e+00 -1.0420096352e+00 0.0000000000e+00 0.0000000000e+00 -2.2030934335e+00 +2.775000 1 5.0000000000e+00 0.0000000000e+00 -1.3698889988e+01 0.0000000000e+00 0.0000000000e+00 -1.0970094322e+00 0.0000000000e+00 0.0000000000e+00 -2.1962669706e+00 +2.800000 1 5.0000000000e+00 0.0000000000e+00 -1.3727000553e+01 0.0000000000e+00 0.0000000000e+00 -1.1517916675e+00 0.0000000000e+00 0.0000000000e+00 -2.1856827877e+00 +2.825000 1 5.0000000000e+00 0.0000000000e+00 -1.3756476973e+01 0.0000000000e+00 0.0000000000e+00 -1.2062619982e+00 0.0000000000e+00 0.0000000000e+00 -2.1713100245e+00 +2.850000 1 5.0000000000e+00 0.0000000000e+00 -1.3787310262e+01 0.0000000000e+00 0.0000000000e+00 -1.2603253956e+00 0.0000000000e+00 0.0000000000e+00 -2.1531247206e+00 +2.875000 1 5.0000000000e+00 0.0000000000e+00 -1.3819489055e+01 0.0000000000e+00 0.0000000000e+00 -1.3138863196e+00 0.0000000000e+00 0.0000000000e+00 -2.1311098994e+00 +2.900000 1 5.0000000000e+00 0.0000000000e+00 -1.3852999592e+01 0.0000000000e+00 0.0000000000e+00 -1.3668488933e+00 0.0000000000e+00 0.0000000000e+00 -2.1052556382e+00 +2.925000 1 5.0000000000e+00 0.0000000000e+00 -1.3887825713e+01 0.0000000000e+00 0.0000000000e+00 -1.4191170807e+00 0.0000000000e+00 0.0000000000e+00 -2.0755591248e+00 +2.950000 1 5.0000000000e+00 0.0000000000e+00 -1.3923948859e+01 0.0000000000e+00 0.0000000000e+00 -1.4705948650e+00 0.0000000000e+00 0.0000000000e+00 -2.0420247003e+00 +2.975000 1 5.0000000000e+00 0.0000000000e+00 -1.3961348071e+01 0.0000000000e+00 0.0000000000e+00 -1.5211864272e+00 0.0000000000e+00 0.0000000000e+00 -2.0046638880e+00 +3.000000 1 5.0000000000e+00 0.0000000000e+00 -1.4000000000e+01 0.0000000000e+00 0.0000000000e+00 -1.5707963268e+00 0.0000000000e+00 0.0000000000e+00 -1.9634954085e+00 +3.025000 1 5.0000000000e+00 0.0000000000e+00 -1.4039878916e+01 0.0000000000e+00 0.0000000000e+00 -1.6193296811e+00 0.0000000000e+00 0.0000000000e+00 -1.9185451800e+00 +3.050000 1 5.0000000000e+00 0.0000000000e+00 -1.4080956728e+01 0.0000000000e+00 0.0000000000e+00 -1.6666923451e+00 0.0000000000e+00 0.0000000000e+00 -1.8698463056e+00 +3.075000 1 5.0000000000e+00 0.0000000000e+00 -1.4123203001e+01 0.0000000000e+00 0.0000000000e+00 -1.7127910911e+00 0.0000000000e+00 0.0000000000e+00 -1.8174390459e+00 +3.100000 1 5.0000000000e+00 0.0000000000e+00 -1.4166584982e+01 0.0000000000e+00 0.0000000000e+00 -1.7575337870e+00 0.0000000000e+00 0.0000000000e+00 -1.7613707778e+00 +3.125000 1 5.0000000000e+00 0.0000000000e+00 -1.4211067632e+01 0.0000000000e+00 0.0000000000e+00 -1.8008295733e+00 0.0000000000e+00 0.0000000000e+00 -1.7016959390e+00 +3.150000 1 5.0000000000e+00 0.0000000000e+00 -1.4256613657e+01 0.0000000000e+00 0.0000000000e+00 -1.8425890392e+00 0.0000000000e+00 0.0000000000e+00 -1.6384759591e+00 +3.175000 1 5.0000000000e+00 0.0000000000e+00 -1.4303183549e+01 0.0000000000e+00 0.0000000000e+00 -1.8827243960e+00 0.0000000000e+00 0.0000000000e+00 -1.5717791763e+00 +3.200000 1 5.0000000000e+00 0.0000000000e+00 -1.4350735626e+01 0.0000000000e+00 0.0000000000e+00 -1.9211496491e+00 0.0000000000e+00 0.0000000000e+00 -1.5016807415e+00 +3.225000 1 5.0000000000e+00 0.0000000000e+00 -1.4399226080e+01 0.0000000000e+00 0.0000000000e+00 -1.9577807663e+00 0.0000000000e+00 0.0000000000e+00 -1.4282625071e+00 +3.250000 1 5.0000000000e+00 0.0000000000e+00 -1.4448609030e+01 0.0000000000e+00 0.0000000000e+00 -1.9925358446e+00 0.0000000000e+00 0.0000000000e+00 -1.3516129046e+00 +3.275000 1 5.0000000000e+00 0.0000000000e+00 -1.4498836574e+01 0.0000000000e+00 0.0000000000e+00 -2.0253352723e+00 0.0000000000e+00 0.0000000000e+00 -1.2718268074e+00 +3.300000 1 5.0000000000e+00 0.0000000000e+00 -1.4549858853e+01 0.0000000000e+00 0.0000000000e+00 -2.0561018888e+00 0.0000000000e+00 0.0000000000e+00 -1.1890053816e+00 +3.325000 1 5.0000000000e+00 0.0000000000e+00 -1.4601624107e+01 0.0000000000e+00 0.0000000000e+00 -2.0847611395e+00 0.0000000000e+00 0.0000000000e+00 -1.1032559238e+00 +3.350000 1 5.0000000000e+00 0.0000000000e+00 -1.4654078749e+01 0.0000000000e+00 0.0000000000e+00 -2.1112412269e+00 0.0000000000e+00 0.0000000000e+00 -1.0146916867e+00 +3.375000 1 5.0000000000e+00 0.0000000000e+00 -1.4707167433e+01 0.0000000000e+00 0.0000000000e+00 -2.1354732576e+00 0.0000000000e+00 0.0000000000e+00 -9.2343169253e-01 +3.400000 1 5.0000000000e+00 0.0000000000e+00 -1.4760833129e+01 0.0000000000e+00 0.0000000000e+00 -2.1573913837e+00 0.0000000000e+00 0.0000000000e+00 -8.2960053518e-01 +3.425000 1 5.0000000000e+00 0.0000000000e+00 -1.4815017197e+01 0.0000000000e+00 0.0000000000e+00 -2.1769329396e+00 0.0000000000e+00 0.0000000000e+00 -7.3332817020e-01 +3.450000 1 5.0000000000e+00 0.0000000000e+00 -1.4869659475e+01 0.0000000000e+00 0.0000000000e+00 -2.1940385732e+00 0.0000000000e+00 0.0000000000e+00 -6.3474969441e-01 +3.475000 1 5.0000000000e+00 0.0000000000e+00 -1.4924698359e+01 0.0000000000e+00 0.0000000000e+00 -2.2086523721e+00 0.0000000000e+00 0.0000000000e+00 -5.3400511469e-01 +3.500000 1 5.0000000000e+00 0.0000000000e+00 -1.4980070891e+01 0.0000000000e+00 0.0000000000e+00 -2.2207219825e+00 0.0000000000e+00 0.0000000000e+00 -4.3123910654e-01 +3.525000 1 5.0000000000e+00 0.0000000000e+00 -1.5035712850e+01 0.0000000000e+00 0.0000000000e+00 -2.2301987235e+00 0.0000000000e+00 0.0000000000e+00 -3.2660076289e-01 +3.550000 1 5.0000000000e+00 0.0000000000e+00 -1.5091558845e+01 0.0000000000e+00 0.0000000000e+00 -2.2370376939e+00 0.0000000000e+00 0.0000000000e+00 -2.2024333368e-01 +3.575000 1 5.0000000000e+00 0.0000000000e+00 -1.5147542410e+01 0.0000000000e+00 0.0000000000e+00 -2.2411978729e+00 0.0000000000e+00 0.0000000000e+00 -1.1232395641e-01 +3.600000 1 5.0000000000e+00 0.0000000000e+00 -1.5203596105e+01 0.0000000000e+00 0.0000000000e+00 -2.2426422141e+00 0.0000000000e+00 0.0000000000e+00 -3.0033784888e-03 +3.625000 1 5.0000000000e+00 0.0000000000e+00 -1.5259651613e+01 0.0000000000e+00 0.0000000000e+00 -2.2413377316e+00 0.0000000000e+00 0.0000000000e+00 1.0755432835e-01 +3.650000 1 5.0000000000e+00 0.0000000000e+00 -1.5315639844e+01 0.0000000000e+00 0.0000000000e+00 -2.2372555800e+00 0.0000000000e+00 0.0000000000e+00 2.1918206099e-01 +3.675000 1 5.0000000000e+00 0.0000000000e+00 -1.5371491038e+01 0.0000000000e+00 0.0000000000e+00 -2.2303711263e+00 0.0000000000e+00 0.0000000000e+00 3.3170998463e-01 +3.700000 1 5.0000000000e+00 0.0000000000e+00 -1.5427134877e+01 0.0000000000e+00 0.0000000000e+00 -2.2206640141e+00 0.0000000000e+00 0.0000000000e+00 4.4496583877e-01 +3.725000 1 5.0000000000e+00 0.0000000000e+00 -1.5482500582e+01 0.0000000000e+00 0.0000000000e+00 -2.2081182209e+00 0.0000000000e+00 0.0000000000e+00 5.5877524891e-01 +3.750000 1 5.0000000000e+00 0.0000000000e+00 -1.5537517034e+01 0.0000000000e+00 0.0000000000e+00 -2.1927221064e+00 0.0000000000e+00 0.0000000000e+00 6.7296204335e-01 +3.775000 1 5.0000000000e+00 0.0000000000e+00 -1.5592112873e+01 0.0000000000e+00 0.0000000000e+00 -2.1744684539e+00 0.0000000000e+00 0.0000000000e+00 7.8734857451e-01 +3.800000 1 5.0000000000e+00 0.0000000000e+00 -1.5646216619e+01 0.0000000000e+00 0.0000000000e+00 -2.1533545030e+00 0.0000000000e+00 0.0000000000e+00 9.0175604424e-01 +3.825000 1 5.0000000000e+00 0.0000000000e+00 -1.5699756776e+01 0.0000000000e+00 0.0000000000e+00 -2.1293819739e+00 0.0000000000e+00 0.0000000000e+00 1.0160048324e+00 +3.850000 1 5.0000000000e+00 0.0000000000e+00 -1.5752661947e+01 0.0000000000e+00 0.0000000000e+00 -2.1025570846e+00 0.0000000000e+00 0.0000000000e+00 1.1299148284e+00 +3.875000 1 5.0000000000e+00 0.0000000000e+00 -1.5804860949e+01 0.0000000000e+00 0.0000000000e+00 -2.0728905581e+00 0.0000000000e+00 0.0000000000e+00 1.2433057641e+00 +3.900000 1 5.0000000000e+00 0.0000000000e+00 -1.5856282920e+01 0.0000000000e+00 0.0000000000e+00 -2.0403976228e+00 0.0000000000e+00 0.0000000000e+00 1.3559975496e+00 +3.925000 1 5.0000000000e+00 0.0000000000e+00 -1.5906857439e+01 0.0000000000e+00 0.0000000000e+00 -2.0050980035e+00 0.0000000000e+00 0.0000000000e+00 1.4678106081e+00 +3.950000 1 5.0000000000e+00 0.0000000000e+00 -1.5956514632e+01 0.0000000000e+00 0.0000000000e+00 -1.9670159048e+00 0.0000000000e+00 0.0000000000e+00 1.5785662127e+00 +3.975000 1 5.0000000000e+00 0.0000000000e+00 -1.6005185285e+01 0.0000000000e+00 0.0000000000e+00 -1.9261799850e+00 0.0000000000e+00 0.0000000000e+00 1.6880868211e+00 +4.000000 1 5.0000000000e+00 0.0000000000e+00 -1.6052800957e+01 0.0000000000e+00 0.0000000000e+00 -1.8826233227e+00 0.0000000000e+00 0.0000000000e+00 1.7961964110e+00 +4.025000 1 5.0000000000e+00 0.0000000000e+00 -1.6099294089e+01 0.0000000000e+00 0.0000000000e+00 -1.8363833749e+00 0.0000000000e+00 0.0000000000e+00 1.9027208121e+00 +4.050000 1 5.0000000000e+00 0.0000000000e+00 -1.6144598112e+01 0.0000000000e+00 0.0000000000e+00 -1.7875019260e+00 0.0000000000e+00 0.0000000000e+00 2.0074880369e+00 +4.075000 1 5.0000000000e+00 0.0000000000e+00 -1.6188647556e+01 0.0000000000e+00 0.0000000000e+00 -1.7360250293e+00 0.0000000000e+00 0.0000000000e+00 2.1103286081e+00 +4.100000 1 5.0000000000e+00 0.0000000000e+00 -1.6231378153e+01 0.0000000000e+00 0.0000000000e+00 -1.6820029406e+00 0.0000000000e+00 0.0000000000e+00 2.2110758823e+00 +4.125000 1 5.0000000000e+00 0.0000000000e+00 -1.6272726945e+01 0.0000000000e+00 0.0000000000e+00 -1.6254900427e+00 0.0000000000e+00 0.0000000000e+00 2.3095663699e+00 +4.150000 1 5.0000000000e+00 0.0000000000e+00 -1.6312632384e+01 0.0000000000e+00 0.0000000000e+00 -1.5665447632e+00 0.0000000000e+00 0.0000000000e+00 2.4056400490e+00 +4.175000 1 5.0000000000e+00 0.0000000000e+00 -1.6351034432e+01 0.0000000000e+00 0.0000000000e+00 -1.5052294835e+00 0.0000000000e+00 0.0000000000e+00 2.4991406754e+00 +4.200000 1 5.0000000000e+00 0.0000000000e+00 -1.6387874659e+01 0.0000000000e+00 0.0000000000e+00 -1.4416104408e+00 0.0000000000e+00 0.0000000000e+00 2.5899160853e+00 +4.225000 1 5.0000000000e+00 0.0000000000e+00 -1.6423096338e+01 0.0000000000e+00 0.0000000000e+00 -1.3757576222e+00 0.0000000000e+00 0.0000000000e+00 2.6778184914e+00 +4.250000 1 5.0000000000e+00 0.0000000000e+00 -1.6456644538e+01 0.0000000000e+00 0.0000000000e+00 -1.3077446520e+00 0.0000000000e+00 0.0000000000e+00 2.7627047723e+00 +4.275000 1 5.0000000000e+00 0.0000000000e+00 -1.6488466211e+01 0.0000000000e+00 0.0000000000e+00 -1.2376486709e+00 0.0000000000e+00 0.0000000000e+00 2.8444367534e+00 +4.300000 1 5.0000000000e+00 0.0000000000e+00 -1.6518510283e+01 0.0000000000e+00 0.0000000000e+00 -1.1655502096e+00 0.0000000000e+00 0.0000000000e+00 2.9228814795e+00 +4.325000 1 5.0000000000e+00 0.0000000000e+00 -1.6546727732e+01 0.0000000000e+00 0.0000000000e+00 -1.0915330546e+00 0.0000000000e+00 0.0000000000e+00 2.9979114783e+00 +4.350000 1 5.0000000000e+00 0.0000000000e+00 -1.6573071670e+01 0.0000000000e+00 0.0000000000e+00 -1.0156841079e+00 0.0000000000e+00 0.0000000000e+00 3.0694050147e+00 +4.375000 1 5.0000000000e+00 0.0000000000e+00 -1.6597497420e+01 0.0000000000e+00 0.0000000000e+00 -9.3809324072e-01 0.0000000000e+00 0.0000000000e+00 3.1372463344e+00 +4.400000 1 5.0000000000e+00 0.0000000000e+00 -1.6619962588e+01 0.0000000000e+00 0.0000000000e+00 -8.5885314093e-01 0.0000000000e+00 0.0000000000e+00 3.2013258971e+00 +4.425000 1 5.0000000000e+00 0.0000000000e+00 -1.6640427128e+01 0.0000000000e+00 0.0000000000e+00 -7.7805915488e-01 0.0000000000e+00 0.0000000000e+00 3.2615405990e+00 +4.450000 1 5.0000000000e+00 0.0000000000e+00 -1.6658853411e+01 0.0000000000e+00 0.0000000000e+00 -6.9580912387e-01 0.0000000000e+00 0.0000000000e+00 3.3177939826e+00 +4.475000 1 5.0000000000e+00 0.0000000000e+00 -1.6675206284e+01 0.0000000000e+00 0.0000000000e+00 -6.1220321545e-01 0.0000000000e+00 0.0000000000e+00 3.3699964359e+00 +4.500000 1 5.0000000000e+00 0.0000000000e+00 -1.6689453125e+01 0.0000000000e+00 0.0000000000e+00 -5.2734375000e-01 0.0000000000e+00 0.0000000000e+00 3.4180653777e+00 +4.525000 1 5.0000000000e+00 0.0000000000e+00 -1.6701563894e+01 0.0000000000e+00 0.0000000000e+00 -4.4133502269e-01 0.0000000000e+00 0.0000000000e+00 3.4619254305e+00 +4.550000 1 5.0000000000e+00 0.0000000000e+00 -1.6711511183e+01 0.0000000000e+00 0.0000000000e+00 -3.5428312142e-01 0.0000000000e+00 0.0000000000e+00 3.5015085806e+00 +4.575000 1 5.0000000000e+00 0.0000000000e+00 -1.6719270254e+01 0.0000000000e+00 0.0000000000e+00 -2.6629574084e-01 0.0000000000e+00 0.0000000000e+00 3.5367543234e+00 +4.600000 1 5.0000000000e+00 0.0000000000e+00 -1.6724819083e+01 0.0000000000e+00 0.0000000000e+00 -1.7748199299e-01 0.0000000000e+00 0.0000000000e+00 3.5676097954e+00 +4.625000 1 5.0000000000e+00 0.0000000000e+00 -1.6728138387e+01 0.0000000000e+00 0.0000000000e+00 -8.7952214725e-02 0.0000000000e+00 0.0000000000e+00 3.5940298915e+00 +4.650000 1 5.0000000000e+00 0.0000000000e+00 -1.6729211655e+01 0.0000000000e+00 0.0000000000e+00 2.1822275394e-03 0.0000000000e+00 0.0000000000e+00 3.6159773676e+00 +4.675000 1 5.0000000000e+00 0.0000000000e+00 -1.6728025171e+01 0.0000000000e+00 0.0000000000e+00 9.2809135461e-02 0.0000000000e+00 0.0000000000e+00 3.6334229279e+00 +4.700000 1 5.0000000000e+00 0.0000000000e+00 -1.6724568034e+01 0.0000000000e+00 0.0000000000e+00 1.8381567844e-01 0.0000000000e+00 0.0000000000e+00 3.6463452978e+00 +4.725000 1 5.0000000000e+00 0.0000000000e+00 -1.6718832167e+01 0.0000000000e+00 0.0000000000e+00 2.7508859487e-01 0.0000000000e+00 0.0000000000e+00 3.6547312801e+00 +4.750000 1 5.0000000000e+00 0.0000000000e+00 -1.6710812330e+01 0.0000000000e+00 0.0000000000e+00 3.6651439463e-01 0.0000000000e+00 0.0000000000e+00 3.6585757962e+00 +4.775000 1 5.0000000000e+00 0.0000000000e+00 -1.6700506120e+01 0.0000000000e+00 0.0000000000e+00 4.5797956240e-01 0.0000000000e+00 0.0000000000e+00 3.6578819116e+00 +4.800000 1 5.0000000000e+00 0.0000000000e+00 -1.6687913969e+01 0.0000000000e+00 0.0000000000e+00 5.4937076142e-01 0.0000000000e+00 0.0000000000e+00 3.6526608446e+00 +4.825000 1 5.0000000000e+00 0.0000000000e+00 -1.6673039139e+01 0.0000000000e+00 0.0000000000e+00 6.4057503723e-01 0.0000000000e+00 0.0000000000e+00 3.6429319596e+00 +4.850000 1 5.0000000000e+00 0.0000000000e+00 -1.6655887711e+01 0.0000000000e+00 0.0000000000e+00 7.3148002107e-01 0.0000000000e+00 0.0000000000e+00 3.6287227437e+00 +4.875000 1 5.0000000000e+00 0.0000000000e+00 -1.6636468563e+01 0.0000000000e+00 0.0000000000e+00 8.2197413251e-01 0.0000000000e+00 0.0000000000e+00 3.6100687671e+00 +4.900000 1 5.0000000000e+00 0.0000000000e+00 -1.6614793350e+01 0.0000000000e+00 0.0000000000e+00 9.1194678085e-01 0.0000000000e+00 0.0000000000e+00 3.5870136270e+00 +4.925000 1 5.0000000000e+00 0.0000000000e+00 -1.6590876481e+01 0.0000000000e+00 0.0000000000e+00 1.0012885649e+00 0.0000000000e+00 0.0000000000e+00 3.5596088755e+00 +4.950000 1 5.0000000000e+00 0.0000000000e+00 -1.6564735080e+01 0.0000000000e+00 0.0000000000e+00 1.0898914709e+00 0.0000000000e+00 0.0000000000e+00 3.5279139309e+00 +4.975000 1 5.0000000000e+00 0.0000000000e+00 -1.6536388952e+01 0.0000000000e+00 0.0000000000e+00 1.1776490676e+00 0.0000000000e+00 0.0000000000e+00 3.4919959728e+00 +5.000000 1 5.0000000000e+00 0.0000000000e+00 -1.6505860543e+01 0.0000000000e+00 0.0000000000e+00 1.2644566991e+00 0.0000000000e+00 0.0000000000e+00 3.4519298207e+00 +5.025000 1 5.0000000000e+00 0.0000000000e+00 -1.6473174890e+01 0.0000000000e+00 0.0000000000e+00 1.3502116743e+00 0.0000000000e+00 0.0000000000e+00 3.4077977971e+00 +5.050000 1 5.0000000000e+00 0.0000000000e+00 -1.6438359570e+01 0.0000000000e+00 0.0000000000e+00 1.4348134520e+00 0.0000000000e+00 0.0000000000e+00 3.3596895743e+00 +5.075000 1 5.0000000000e+00 0.0000000000e+00 -1.6401444647e+01 0.0000000000e+00 0.0000000000e+00 1.5181638232e+00 0.0000000000e+00 0.0000000000e+00 3.3077020056e+00 +5.100000 1 5.0000000000e+00 0.0000000000e+00 -1.6362462606e+01 0.0000000000e+00 0.0000000000e+00 1.6001670879e+00 0.0000000000e+00 0.0000000000e+00 3.2519389405e+00 +5.125000 1 5.0000000000e+00 0.0000000000e+00 -1.6321448294e+01 0.0000000000e+00 0.0000000000e+00 1.6807302280e+00 0.0000000000e+00 0.0000000000e+00 3.1925110253e+00 +5.150000 1 5.0000000000e+00 0.0000000000e+00 -1.6278438848e+01 0.0000000000e+00 0.0000000000e+00 1.7597630739e+00 0.0000000000e+00 0.0000000000e+00 3.1295354882e+00 +5.175000 1 5.0000000000e+00 0.0000000000e+00 -1.6233473620e+01 0.0000000000e+00 0.0000000000e+00 1.8371784670e+00 0.0000000000e+00 0.0000000000e+00 3.0631359099e+00 +5.200000 1 5.0000000000e+00 0.0000000000e+00 -1.6186594104e+01 0.0000000000e+00 0.0000000000e+00 1.9128924148e+00 0.0000000000e+00 0.0000000000e+00 2.9934419792e+00 +5.225000 1 5.0000000000e+00 0.0000000000e+00 -1.6137843851e+01 0.0000000000e+00 0.0000000000e+00 1.9868242410e+00 0.0000000000e+00 0.0000000000e+00 2.9205892356e+00 +5.250000 1 5.0000000000e+00 0.0000000000e+00 -1.6087268387e+01 0.0000000000e+00 0.0000000000e+00 2.0588967277e+00 0.0000000000e+00 0.0000000000e+00 2.8447187970e+00 +5.275000 1 5.0000000000e+00 0.0000000000e+00 -1.6034915124e+01 0.0000000000e+00 0.0000000000e+00 2.1290362521e+00 0.0000000000e+00 0.0000000000e+00 2.7659770750e+00 +5.300000 1 5.0000000000e+00 0.0000000000e+00 -1.5980833266e+01 0.0000000000e+00 0.0000000000e+00 2.1971729145e+00 0.0000000000e+00 0.0000000000e+00 2.6845154772e+00 +5.325000 1 5.0000000000e+00 0.0000000000e+00 -1.5925073720e+01 0.0000000000e+00 0.0000000000e+00 2.2632406598e+00 0.0000000000e+00 0.0000000000e+00 2.6004900965e+00 +5.350000 1 5.0000000000e+00 0.0000000000e+00 -1.5867688993e+01 0.0000000000e+00 0.0000000000e+00 2.3271773905e+00 0.0000000000e+00 0.0000000000e+00 2.5140613898e+00 +5.375000 1 5.0000000000e+00 0.0000000000e+00 -1.5808733094e+01 0.0000000000e+00 0.0000000000e+00 2.3889250713e+00 0.0000000000e+00 0.0000000000e+00 2.4253938438e+00 +5.400000 1 5.0000000000e+00 0.0000000000e+00 -1.5748261432e+01 0.0000000000e+00 0.0000000000e+00 2.4484298262e+00 0.0000000000e+00 0.0000000000e+00 2.3346556314e+00 +5.425000 1 5.0000000000e+00 0.0000000000e+00 -1.5686330708e+01 0.0000000000e+00 0.0000000000e+00 2.5056420257e+00 0.0000000000e+00 0.0000000000e+00 2.2420182568e+00 +5.450000 1 5.0000000000e+00 0.0000000000e+00 -1.5622998814e+01 0.0000000000e+00 0.0000000000e+00 2.5605163659e+00 0.0000000000e+00 0.0000000000e+00 2.1476561917e+00 +5.475000 1 5.0000000000e+00 0.0000000000e+00 -1.5558324714e+01 0.0000000000e+00 0.0000000000e+00 2.6130119378e+00 0.0000000000e+00 0.0000000000e+00 2.0517465019e+00 +5.500000 1 5.0000000000e+00 0.0000000000e+00 -1.5492368345e+01 0.0000000000e+00 0.0000000000e+00 2.6630922876e+00 0.0000000000e+00 0.0000000000e+00 1.9544684661e+00 +5.525000 1 5.0000000000e+00 0.0000000000e+00 -1.5425190494e+01 0.0000000000e+00 0.0000000000e+00 2.7107254670e+00 0.0000000000e+00 0.0000000000e+00 1.8560031863e+00 +5.550000 1 5.0000000000e+00 0.0000000000e+00 -1.5356852694e+01 0.0000000000e+00 0.0000000000e+00 2.7558840740e+00 0.0000000000e+00 0.0000000000e+00 1.7565331919e+00 +5.575000 1 5.0000000000e+00 0.0000000000e+00 -1.5287417104e+01 0.0000000000e+00 0.0000000000e+00 2.7985452834e+00 0.0000000000e+00 0.0000000000e+00 1.6562420367e+00 +5.600000 1 5.0000000000e+00 0.0000000000e+00 -1.5216946395e+01 0.0000000000e+00 0.0000000000e+00 2.8386908675e+00 0.0000000000e+00 0.0000000000e+00 1.5553138909e+00 +5.625000 1 5.0000000000e+00 0.0000000000e+00 -1.5145503639e+01 0.0000000000e+00 0.0000000000e+00 2.8763072062e+00 0.0000000000e+00 0.0000000000e+00 1.4539331278e+00 +5.650000 1 5.0000000000e+00 0.0000000000e+00 -1.5073152188e+01 0.0000000000e+00 0.0000000000e+00 2.9113852870e+00 0.0000000000e+00 0.0000000000e+00 1.3522839065e+00 +5.675000 1 5.0000000000e+00 0.0000000000e+00 -1.4999955564e+01 0.0000000000e+00 0.0000000000e+00 2.9439206941e+00 0.0000000000e+00 0.0000000000e+00 1.2505497515e+00 +5.700000 1 5.0000000000e+00 0.0000000000e+00 -1.4925977342e+01 0.0000000000e+00 0.0000000000e+00 2.9739135877e+00 0.0000000000e+00 0.0000000000e+00 1.1489131293e+00 +5.725000 1 5.0000000000e+00 0.0000000000e+00 -1.4851281035e+01 0.0000000000e+00 0.0000000000e+00 3.0013686720e+00 0.0000000000e+00 0.0000000000e+00 1.0475550232e+00 +5.750000 1 5.0000000000e+00 0.0000000000e+00 -1.4775929982e+01 0.0000000000e+00 0.0000000000e+00 3.0262951528e+00 0.0000000000e+00 0.0000000000e+00 9.4665450776e-01 +5.775000 1 5.0000000000e+00 0.0000000000e+00 -1.4699987236e+01 0.0000000000e+00 0.0000000000e+00 3.0487066843e+00 0.0000000000e+00 0.0000000000e+00 8.4638832215e-01 +5.800000 1 5.0000000000e+00 0.0000000000e+00 -1.4623515456e+01 0.0000000000e+00 0.0000000000e+00 3.0686213057e+00 0.0000000000e+00 0.0000000000e+00 7.4693044505e-01 +5.825000 1 5.0000000000e+00 0.0000000000e+00 -1.4546576793e+01 0.0000000000e+00 0.0000000000e+00 3.0860613667e+00 0.0000000000e+00 0.0000000000e+00 6.4845167047e-01 +5.850000 1 5.0000000000e+00 0.0000000000e+00 -1.4469232789e+01 0.0000000000e+00 0.0000000000e+00 3.1010534427e+00 0.0000000000e+00 0.0000000000e+00 5.5111918617e-01 +5.875000 1 5.0000000000e+00 0.0000000000e+00 -1.4391544266e+01 0.0000000000e+00 0.0000000000e+00 3.1136282394e+00 0.0000000000e+00 0.0000000000e+00 4.5509615515e-01 +5.900000 1 5.0000000000e+00 0.0000000000e+00 -1.4313571232e+01 0.0000000000e+00 0.0000000000e+00 3.1238204866e+00 0.0000000000e+00 0.0000000000e+00 3.6054130130e-01 +5.925000 1 5.0000000000e+00 0.0000000000e+00 -1.4235372776e+01 0.0000000000e+00 0.0000000000e+00 3.1316688230e+00 0.0000000000e+00 0.0000000000e+00 2.6760849984e-01 +5.950000 1 5.0000000000e+00 0.0000000000e+00 -1.4157006971e+01 0.0000000000e+00 0.0000000000e+00 3.1372156688e+00 0.0000000000e+00 0.0000000000e+00 1.7644637357e-01 +5.975000 1 5.0000000000e+00 0.0000000000e+00 -1.4078530788e+01 0.0000000000e+00 0.0000000000e+00 3.1405070904e+00 0.0000000000e+00 0.0000000000e+00 8.7197895666e-02 +6.000000 1 5.0000000000e+00 0.0000000000e+00 -1.4000000000e+01 0.0000000000e+00 0.0000000000e+00 3.1415926536e+00 0.0000000000e+00 0.0000000000e+00 8.0578529591e-16 +6.025000 1 5.0000000000e+00 0.0000000000e+00 -1.3921469155e+01 0.0000000000e+00 0.0000000000e+00 3.1405161083e+00 0.0000000000e+00 0.0000000000e+00 -8.6118708075e-02 +6.050000 1 5.0000000000e+00 0.0000000000e+00 -1.3842992131e+01 0.0000000000e+00 0.0000000000e+00 3.1372872100e+00 0.0000000000e+00 0.0000000000e+00 -1.7217839469e-01 +6.075000 1 5.0000000000e+00 0.0000000000e+00 -1.3764622713e+01 0.0000000000e+00 0.0000000000e+00 3.1319081719e+00 0.0000000000e+00 0.0000000000e+00 -2.5812007883e-01 +6.100000 1 5.0000000000e+00 0.0000000000e+00 -1.3686414610e+01 0.0000000000e+00 0.0000000000e+00 3.1243826803e+00 0.0000000000e+00 0.0000000000e+00 -3.4388486037e-01 +6.125000 1 5.0000000000e+00 0.0000000000e+00 -1.3608421423e+01 0.0000000000e+00 0.0000000000e+00 3.1147158929e+00 0.0000000000e+00 0.0000000000e+00 -4.2941396040e-01 +6.150000 1 5.0000000000e+00 0.0000000000e+00 -1.3530696605e+01 0.0000000000e+00 0.0000000000e+00 3.1029144348e+00 0.0000000000e+00 0.0000000000e+00 -5.1464876155e-01 +6.175000 1 5.0000000000e+00 0.0000000000e+00 -1.3453293424e+01 0.0000000000e+00 0.0000000000e+00 3.0889863942e+00 0.0000000000e+00 0.0000000000e+00 -5.9953084814e-01 +6.200000 1 5.0000000000e+00 0.0000000000e+00 -1.3376264928e+01 0.0000000000e+00 0.0000000000e+00 3.0729413166e+00 0.0000000000e+00 0.0000000000e+00 -6.8400204624e-01 +6.225000 1 5.0000000000e+00 0.0000000000e+00 -1.3299663908e+01 0.0000000000e+00 0.0000000000e+00 3.0547901985e+00 0.0000000000e+00 0.0000000000e+00 -7.6800446351e-01 +6.250000 1 5.0000000000e+00 0.0000000000e+00 -1.3223542865e+01 0.0000000000e+00 0.0000000000e+00 3.0345454798e+00 0.0000000000e+00 0.0000000000e+00 -8.5148052888e-01 +6.275000 1 5.0000000000e+00 0.0000000000e+00 -1.3147953966e+01 0.0000000000e+00 0.0000000000e+00 3.0122210352e+00 0.0000000000e+00 0.0000000000e+00 -9.3437303202e-01 +6.300000 1 5.0000000000e+00 0.0000000000e+00 -1.3072949017e+01 0.0000000000e+00 0.0000000000e+00 2.9878321647e+00 0.0000000000e+00 0.0000000000e+00 -1.0166251626e+00 +6.325000 1 5.0000000000e+00 0.0000000000e+00 -1.2998579422e+01 0.0000000000e+00 0.0000000000e+00 2.9613955834e+00 0.0000000000e+00 0.0000000000e+00 -1.0981805490e+00 +6.350000 1 5.0000000000e+00 0.0000000000e+00 -1.2924896151e+01 0.0000000000e+00 0.0000000000e+00 2.9329294094e+00 0.0000000000e+00 0.0000000000e+00 -1.1789832973e+00 +6.375000 1 5.0000000000e+00 0.0000000000e+00 -1.2851949703e+01 0.0000000000e+00 0.0000000000e+00 2.9024531521e+00 0.0000000000e+00 0.0000000000e+00 -1.2589780294e+00 +6.400000 1 5.0000000000e+00 0.0000000000e+00 -1.2779790071e+01 0.0000000000e+00 0.0000000000e+00 2.8699876985e+00 0.0000000000e+00 0.0000000000e+00 -1.3381099209e+00 +6.425000 1 5.0000000000e+00 0.0000000000e+00 -1.2708466710e+01 0.0000000000e+00 0.0000000000e+00 2.8355552986e+00 0.0000000000e+00 0.0000000000e+00 -1.4163247386e+00 +6.450000 1 5.0000000000e+00 0.0000000000e+00 -1.2638028501e+01 0.0000000000e+00 0.0000000000e+00 2.7991795507e+00 0.0000000000e+00 0.0000000000e+00 -1.4935688781e+00 +6.475000 1 5.0000000000e+00 0.0000000000e+00 -1.2568523719e+01 0.0000000000e+00 0.0000000000e+00 2.7608853850e+00 0.0000000000e+00 0.0000000000e+00 -1.5697894001e+00 +6.500000 1 5.0000000000e+00 0.0000000000e+00 -1.2500000000e+01 0.0000000000e+00 0.0000000000e+00 2.7206990464e+00 0.0000000000e+00 0.0000000000e+00 -1.6449340668e+00 +6.525000 1 5.0000000000e+00 0.0000000000e+00 -1.2432504306e+01 0.0000000000e+00 0.0000000000e+00 2.6786480765e+00 0.0000000000e+00 0.0000000000e+00 -1.7189513780e+00 +6.550000 1 5.0000000000e+00 0.0000000000e+00 -1.2366082895e+01 0.0000000000e+00 0.0000000000e+00 2.6347612950e+00 0.0000000000e+00 0.0000000000e+00 -1.7917906057e+00 +6.575000 1 5.0000000000e+00 0.0000000000e+00 -1.2300781289e+01 0.0000000000e+00 0.0000000000e+00 2.5890687798e+00 0.0000000000e+00 0.0000000000e+00 -1.8634018296e+00 +6.600000 1 5.0000000000e+00 0.0000000000e+00 -1.2236644243e+01 0.0000000000e+00 0.0000000000e+00 2.5416018462e+00 0.0000000000e+00 0.0000000000e+00 -1.9337359710e+00 +6.625000 1 5.0000000000e+00 0.0000000000e+00 -1.2173715713e+01 0.0000000000e+00 0.0000000000e+00 2.4923930256e+00 0.0000000000e+00 0.0000000000e+00 -2.0027448263e+00 +6.650000 1 5.0000000000e+00 0.0000000000e+00 -1.2112038827e+01 0.0000000000e+00 0.0000000000e+00 2.4414760433e+00 0.0000000000e+00 0.0000000000e+00 -2.0703811004e+00 +6.675000 1 5.0000000000e+00 0.0000000000e+00 -1.2051655855e+01 0.0000000000e+00 0.0000000000e+00 2.3888857953e+00 0.0000000000e+00 0.0000000000e+00 -2.1365984387e+00 +6.700000 1 5.0000000000e+00 0.0000000000e+00 -1.1992608181e+01 0.0000000000e+00 0.0000000000e+00 2.3346583243e+00 0.0000000000e+00 0.0000000000e+00 -2.2013514591e+00 +6.725000 1 5.0000000000e+00 0.0000000000e+00 -1.1934936273e+01 0.0000000000e+00 0.0000000000e+00 2.2788307951e+00 0.0000000000e+00 0.0000000000e+00 -2.2645957833e+00 +6.750000 1 5.0000000000e+00 0.0000000000e+00 -1.1878679656e+01 0.0000000000e+00 0.0000000000e+00 2.2214414691e+00 0.0000000000e+00 0.0000000000e+00 -2.3262880665e+00 +6.775000 1 5.0000000000e+00 0.0000000000e+00 -1.1823876887e+01 0.0000000000e+00 0.0000000000e+00 2.1625296781e+00 0.0000000000e+00 0.0000000000e+00 -2.3863860282e+00 +6.800000 1 5.0000000000e+00 0.0000000000e+00 -1.1770565524e+01 0.0000000000e+00 0.0000000000e+00 2.1021357972e+00 0.0000000000e+00 0.0000000000e+00 -2.4448484801e+00 +6.825000 1 5.0000000000e+00 0.0000000000e+00 -1.1718782103e+01 0.0000000000e+00 0.0000000000e+00 2.0403012175e+00 0.0000000000e+00 0.0000000000e+00 -2.5016353549e+00 +6.850000 1 5.0000000000e+00 0.0000000000e+00 -1.1668562116e+01 0.0000000000e+00 0.0000000000e+00 1.9770683173e+00 0.0000000000e+00 0.0000000000e+00 -2.5567077338e+00 +6.875000 1 5.0000000000e+00 0.0000000000e+00 -1.1619939979e+01 0.0000000000e+00 0.0000000000e+00 1.9124804332e+00 0.0000000000e+00 0.0000000000e+00 -2.6100278730e+00 +6.900000 1 5.0000000000e+00 0.0000000000e+00 -1.1572949017e+01 0.0000000000e+00 0.0000000000e+00 1.8465818305e+00 0.0000000000e+00 0.0000000000e+00 -2.6615592294e+00 +6.925000 1 5.0000000000e+00 0.0000000000e+00 -1.1527621434e+01 0.0000000000e+00 0.0000000000e+00 1.7794176729e+00 0.0000000000e+00 0.0000000000e+00 -2.7112664861e+00 +6.950000 1 5.0000000000e+00 0.0000000000e+00 -1.1483988296e+01 0.0000000000e+00 0.0000000000e+00 1.7110339913e+00 0.0000000000e+00 0.0000000000e+00 -2.7591155762e+00 +6.975000 1 5.0000000000e+00 0.0000000000e+00 -1.1442079507e+01 0.0000000000e+00 0.0000000000e+00 1.6414776524e+00 0.0000000000e+00 0.0000000000e+00 -2.8050737062e+00 +7.000000 1 5.0000000000e+00 0.0000000000e+00 -1.1401923789e+01 0.0000000000e+00 0.0000000000e+00 1.5707963268e+00 0.0000000000e+00 0.0000000000e+00 -2.8491093789e+00 +7.025000 1 5.0000000000e+00 0.0000000000e+00 -1.1363548662e+01 0.0000000000e+00 0.0000000000e+00 1.4990384558e+00 0.0000000000e+00 0.0000000000e+00 -2.8911924143e+00 +7.050000 1 5.0000000000e+00 0.0000000000e+00 -1.1326980427e+01 0.0000000000e+00 0.0000000000e+00 1.4262532188e+00 0.0000000000e+00 0.0000000000e+00 -2.9312939708e+00 +7.075000 1 5.0000000000e+00 0.0000000000e+00 -1.1292244147e+01 0.0000000000e+00 0.0000000000e+00 1.3524904990e+00 0.0000000000e+00 0.0000000000e+00 -2.9693865649e+00 +7.100000 1 5.0000000000e+00 0.0000000000e+00 -1.1259363627e+01 0.0000000000e+00 0.0000000000e+00 1.2778008498e+00 0.0000000000e+00 0.0000000000e+00 -3.0054440898e+00 +7.125000 1 5.0000000000e+00 0.0000000000e+00 -1.1228361402e+01 0.0000000000e+00 0.0000000000e+00 1.2022354598e+00 0.0000000000e+00 0.0000000000e+00 -3.0394418334e+00 +7.150000 1 5.0000000000e+00 0.0000000000e+00 -1.1199258721e+01 0.0000000000e+00 0.0000000000e+00 1.1258461176e+00 0.0000000000e+00 0.0000000000e+00 -3.0713564954e+00 +7.175000 1 5.0000000000e+00 0.0000000000e+00 -1.1172075527e+01 0.0000000000e+00 0.0000000000e+00 1.0486851767e+00 0.0000000000e+00 0.0000000000e+00 -3.1011662030e+00 +7.200000 1 5.0000000000e+00 0.0000000000e+00 -1.1146830451e+01 0.0000000000e+00 0.0000000000e+00 9.7080551936e-01 0.0000000000e+00 0.0000000000e+00 -3.1288505263e+00 +7.225000 1 5.0000000000e+00 0.0000000000e+00 -1.1123540795e+01 0.0000000000e+00 0.0000000000e+00 8.9226052043e-01 0.0000000000e+00 0.0000000000e+00 -3.1543904917e+00 +7.250000 1 5.0000000000e+00 0.0000000000e+00 -1.1102222521e+01 0.0000000000e+00 0.0000000000e+00 8.1310401070e-01 0.0000000000e+00 0.0000000000e+00 -3.1777685954e+00 +7.275000 1 5.0000000000e+00 0.0000000000e+00 -1.1082890239e+01 0.0000000000e+00 0.0000000000e+00 7.3339024010e-01 0.0000000000e+00 0.0000000000e+00 -3.1989688153e+00 +7.300000 1 5.0000000000e+00 0.0000000000e+00 -1.1065557198e+01 0.0000000000e+00 0.0000000000e+00 6.5317384047e-01 0.0000000000e+00 0.0000000000e+00 -3.2179766217e+00 +7.325000 1 5.0000000000e+00 0.0000000000e+00 -1.1050235277e+01 0.0000000000e+00 0.0000000000e+00 5.7250978811e-01 0.0000000000e+00 0.0000000000e+00 -3.2347789877e+00 +7.350000 1 5.0000000000e+00 0.0000000000e+00 -1.1036934978e+01 0.0000000000e+00 0.0000000000e+00 4.9145336614e-01 0.0000000000e+00 0.0000000000e+00 -3.2493643977e+00 +7.375000 1 5.0000000000e+00 0.0000000000e+00 -1.1025665416e+01 0.0000000000e+00 0.0000000000e+00 4.1006012658e-01 0.0000000000e+00 0.0000000000e+00 -3.2617228558e+00 +7.400000 1 5.0000000000e+00 0.0000000000e+00 -1.1016434314e+01 0.0000000000e+00 0.0000000000e+00 3.2838585229e-01 0.0000000000e+00 0.0000000000e+00 -3.2718458918e+00 +7.425000 1 5.0000000000e+00 0.0000000000e+00 -1.1009247999e+01 0.0000000000e+00 0.0000000000e+00 2.4648651875e-01 0.0000000000e+00 0.0000000000e+00 -3.2797265682e+00 +7.450000 1 5.0000000000e+00 0.0000000000e+00 -1.1004111396e+01 0.0000000000e+00 0.0000000000e+00 1.6441825565e-01 0.0000000000e+00 0.0000000000e+00 -3.2853594838e+00 +7.475000 1 5.0000000000e+00 0.0000000000e+00 -1.1001028025e+01 0.0000000000e+00 0.0000000000e+00 8.2237308497e-02 0.0000000000e+00 0.0000000000e+00 -3.2887407781e+00 +7.500000 1 5.0000000000e+00 0.0000000000e+00 -1.1000000000e+01 0.0000000000e+00 0.0000000000e+00 3.7521301453e-15 0.0000000000e+00 0.0000000000e+00 -3.2898681337e+00 +7.525000 1 5.0000000000e+00 0.0000000000e+00 -1.1001028025e+01 0.0000000000e+00 0.0000000000e+00 -8.2237308497e-02 0.0000000000e+00 0.0000000000e+00 -3.2887407781e+00 +7.550000 1 5.0000000000e+00 0.0000000000e+00 -1.1004111396e+01 0.0000000000e+00 0.0000000000e+00 -1.6441825565e-01 0.0000000000e+00 0.0000000000e+00 -3.2853594838e+00 +7.575000 1 5.0000000000e+00 0.0000000000e+00 -1.1009247999e+01 0.0000000000e+00 0.0000000000e+00 -2.4648651875e-01 0.0000000000e+00 0.0000000000e+00 -3.2797265682e+00 +7.600000 1 5.0000000000e+00 0.0000000000e+00 -1.1016434314e+01 0.0000000000e+00 0.0000000000e+00 -3.2838585229e-01 0.0000000000e+00 0.0000000000e+00 -3.2718458918e+00 +7.625000 1 5.0000000000e+00 0.0000000000e+00 -1.1025665416e+01 0.0000000000e+00 0.0000000000e+00 -4.1006012658e-01 0.0000000000e+00 0.0000000000e+00 -3.2617228558e+00 +7.650000 1 5.0000000000e+00 0.0000000000e+00 -1.1036934978e+01 0.0000000000e+00 0.0000000000e+00 -4.9145336614e-01 0.0000000000e+00 0.0000000000e+00 -3.2493643977e+00 +7.675000 1 5.0000000000e+00 0.0000000000e+00 -1.1050235277e+01 0.0000000000e+00 0.0000000000e+00 -5.7250978811e-01 0.0000000000e+00 0.0000000000e+00 -3.2347789877e+00 +7.700000 1 5.0000000000e+00 0.0000000000e+00 -1.1065557198e+01 0.0000000000e+00 0.0000000000e+00 -6.5317384047e-01 0.0000000000e+00 0.0000000000e+00 -3.2179766217e+00 +7.725000 1 5.0000000000e+00 0.0000000000e+00 -1.1082890239e+01 0.0000000000e+00 0.0000000000e+00 -7.3339024010e-01 0.0000000000e+00 0.0000000000e+00 -3.1989688153e+00 +7.750000 1 5.0000000000e+00 0.0000000000e+00 -1.1102222521e+01 0.0000000000e+00 0.0000000000e+00 -8.1310401070e-01 0.0000000000e+00 0.0000000000e+00 -3.1777685954e+00 +7.775000 1 5.0000000000e+00 0.0000000000e+00 -1.1123540795e+01 0.0000000000e+00 0.0000000000e+00 -8.9226052043e-01 0.0000000000e+00 0.0000000000e+00 -3.1543904917e+00 +7.800000 1 5.0000000000e+00 0.0000000000e+00 -1.1146830451e+01 0.0000000000e+00 0.0000000000e+00 -9.7080551936e-01 0.0000000000e+00 0.0000000000e+00 -3.1288505263e+00 +7.825000 1 5.0000000000e+00 0.0000000000e+00 -1.1172075527e+01 0.0000000000e+00 0.0000000000e+00 -1.0486851767e+00 0.0000000000e+00 0.0000000000e+00 -3.1011662030e+00 +7.850000 1 5.0000000000e+00 0.0000000000e+00 -1.1199258721e+01 0.0000000000e+00 0.0000000000e+00 -1.1258461176e+00 0.0000000000e+00 0.0000000000e+00 -3.0713564954e+00 +7.875000 1 5.0000000000e+00 0.0000000000e+00 -1.1228361402e+01 0.0000000000e+00 0.0000000000e+00 -1.2022354598e+00 0.0000000000e+00 0.0000000000e+00 -3.0394418334e+00 +7.900000 1 5.0000000000e+00 0.0000000000e+00 -1.1259363627e+01 0.0000000000e+00 0.0000000000e+00 -1.2778008498e+00 0.0000000000e+00 0.0000000000e+00 -3.0054440898e+00 +7.925000 1 5.0000000000e+00 0.0000000000e+00 -1.1292244147e+01 0.0000000000e+00 0.0000000000e+00 -1.3524904990e+00 0.0000000000e+00 0.0000000000e+00 -2.9693865649e+00 +7.950000 1 5.0000000000e+00 0.0000000000e+00 -1.1326980427e+01 0.0000000000e+00 0.0000000000e+00 -1.4262532188e+00 0.0000000000e+00 0.0000000000e+00 -2.9312939708e+00 +7.975000 1 5.0000000000e+00 0.0000000000e+00 -1.1363548662e+01 0.0000000000e+00 0.0000000000e+00 -1.4990384558e+00 0.0000000000e+00 0.0000000000e+00 -2.8911924143e+00 +8.000000 1 5.0000000000e+00 0.0000000000e+00 -1.1401923789e+01 0.0000000000e+00 0.0000000000e+00 -1.5707963268e+00 0.0000000000e+00 0.0000000000e+00 -2.8491093789e+00 +8.025000 1 5.0000000000e+00 0.0000000000e+00 -1.1442079507e+01 0.0000000000e+00 0.0000000000e+00 -1.6414776524e+00 0.0000000000e+00 0.0000000000e+00 -2.8050737062e+00 +8.050000 1 5.0000000000e+00 0.0000000000e+00 -1.1483988296e+01 0.0000000000e+00 0.0000000000e+00 -1.7110339913e+00 0.0000000000e+00 0.0000000000e+00 -2.7591155762e+00 +8.075000 1 5.0000000000e+00 0.0000000000e+00 -1.1527621434e+01 0.0000000000e+00 0.0000000000e+00 -1.7794176729e+00 0.0000000000e+00 0.0000000000e+00 -2.7112664861e+00 +8.100000 1 5.0000000000e+00 0.0000000000e+00 -1.1572949017e+01 0.0000000000e+00 0.0000000000e+00 -1.8465818305e+00 0.0000000000e+00 0.0000000000e+00 -2.6615592294e+00 +8.125000 1 5.0000000000e+00 0.0000000000e+00 -1.1619939979e+01 0.0000000000e+00 0.0000000000e+00 -1.9124804332e+00 0.0000000000e+00 0.0000000000e+00 -2.6100278730e+00 +8.150000 1 5.0000000000e+00 0.0000000000e+00 -1.1668562116e+01 0.0000000000e+00 0.0000000000e+00 -1.9770683173e+00 0.0000000000e+00 0.0000000000e+00 -2.5567077338e+00 +8.175000 1 5.0000000000e+00 0.0000000000e+00 -1.1718782103e+01 0.0000000000e+00 0.0000000000e+00 -2.0403012175e+00 0.0000000000e+00 0.0000000000e+00 -2.5016353549e+00 +8.200000 1 5.0000000000e+00 0.0000000000e+00 -1.1770565524e+01 0.0000000000e+00 0.0000000000e+00 -2.1021357972e+00 0.0000000000e+00 0.0000000000e+00 -2.4448484801e+00 +8.225000 1 5.0000000000e+00 0.0000000000e+00 -1.1823876887e+01 0.0000000000e+00 0.0000000000e+00 -2.1625296781e+00 0.0000000000e+00 0.0000000000e+00 -2.3863860282e+00 +8.250000 1 5.0000000000e+00 0.0000000000e+00 -1.1878679656e+01 0.0000000000e+00 0.0000000000e+00 -2.2214414691e+00 0.0000000000e+00 0.0000000000e+00 -2.3262880665e+00 +8.275000 1 5.0000000000e+00 0.0000000000e+00 -1.1934936273e+01 0.0000000000e+00 0.0000000000e+00 -2.2788307951e+00 0.0000000000e+00 0.0000000000e+00 -2.2645957833e+00 +8.300000 1 5.0000000000e+00 0.0000000000e+00 -1.1992608181e+01 0.0000000000e+00 0.0000000000e+00 -2.3346583243e+00 0.0000000000e+00 0.0000000000e+00 -2.2013514591e+00 +8.325000 1 5.0000000000e+00 0.0000000000e+00 -1.2051655855e+01 0.0000000000e+00 0.0000000000e+00 -2.3888857953e+00 0.0000000000e+00 0.0000000000e+00 -2.1365984387e+00 +8.350000 1 5.0000000000e+00 0.0000000000e+00 -1.2112038827e+01 0.0000000000e+00 0.0000000000e+00 -2.4414760433e+00 0.0000000000e+00 0.0000000000e+00 -2.0703811004e+00 +8.375000 1 5.0000000000e+00 0.0000000000e+00 -1.2173715713e+01 0.0000000000e+00 0.0000000000e+00 -2.4923930256e+00 0.0000000000e+00 0.0000000000e+00 -2.0027448263e+00 +8.400000 1 5.0000000000e+00 0.0000000000e+00 -1.2236644243e+01 0.0000000000e+00 0.0000000000e+00 -2.5416018462e+00 0.0000000000e+00 0.0000000000e+00 -1.9337359710e+00 +8.425000 1 5.0000000000e+00 0.0000000000e+00 -1.2300781289e+01 0.0000000000e+00 0.0000000000e+00 -2.5890687798e+00 0.0000000000e+00 0.0000000000e+00 -1.8634018296e+00 +8.450000 1 5.0000000000e+00 0.0000000000e+00 -1.2366082895e+01 0.0000000000e+00 0.0000000000e+00 -2.6347612950e+00 0.0000000000e+00 0.0000000000e+00 -1.7917906057e+00 +8.475000 1 5.0000000000e+00 0.0000000000e+00 -1.2432504306e+01 0.0000000000e+00 0.0000000000e+00 -2.6786480765e+00 0.0000000000e+00 0.0000000000e+00 -1.7189513780e+00 +8.500000 1 5.0000000000e+00 0.0000000000e+00 -1.2500000000e+01 0.0000000000e+00 0.0000000000e+00 -2.7206990464e+00 0.0000000000e+00 0.0000000000e+00 -1.6449340668e+00 +8.525000 1 5.0000000000e+00 0.0000000000e+00 -1.2568523719e+01 0.0000000000e+00 0.0000000000e+00 -2.7608853850e+00 0.0000000000e+00 0.0000000000e+00 -1.5697894001e+00 +8.550000 1 5.0000000000e+00 0.0000000000e+00 -1.2638028501e+01 0.0000000000e+00 0.0000000000e+00 -2.7991795507e+00 0.0000000000e+00 0.0000000000e+00 -1.4935688781e+00 +8.575000 1 5.0000000000e+00 0.0000000000e+00 -1.2708466710e+01 0.0000000000e+00 0.0000000000e+00 -2.8355552986e+00 0.0000000000e+00 0.0000000000e+00 -1.4163247386e+00 +8.600000 1 5.0000000000e+00 0.0000000000e+00 -1.2779790071e+01 0.0000000000e+00 0.0000000000e+00 -2.8699876985e+00 0.0000000000e+00 0.0000000000e+00 -1.3381099209e+00 diff --git a/tests/data/msg_tensile_safety_truncated.dat b/tests/data/msg_tensile_safety_truncated.dat new file mode 100644 index 00000000..1831358c --- /dev/null +++ b/tests/data/msg_tensile_safety_truncated.dat @@ -0,0 +1,35 @@ +--------------------- CableDyn Input File ------------------------------------ +msg_tensile_safety_truncated +--------------------- LINE TYPES --------------------------------------- +TypeName Diam MassDenInAir EA BA EI Cd_n Cd_t Ca_n Ca_t +(-) (m) (kg/m) (N) (N-s/-) (N-m^2) (-) (-) (-) (-) +bare 0.16 36.7 469000000.0 0.0 19900.0 1.2 0.1 1.0 0.0 +buoy 0.29 59.53 469000000.0 0.0 19900.0 1.2 0.1 1.0 0.0 +--------------------- POINTS --------------------------------------- +ID Type X Y Z Mass Vol CdA Ca +(-) (-) (m) (m) (m) (kg) (m^3) (m^2) (-) +1 Coupled 5.0 0.0 -14.0 0 0 0 0 +2 Fixed 125.0 0.0 -80.0 0 0 0 0 +--------------------- LINES --------------------------------------- +ID NodeA NodeB Outputs +(-) (-) (-) (-) +1 1 2 - +--------------------- SECTIONS --------------------------------------- +LineID LineType Length NumSegs +(-) (-) (m) (-) +1 bare 68.114 28 +1 buoy 50.0 20 +1 bare 52.101 16 +--------------------- OPTIONS --------------------------------------- +0.025 dtM +8.6 TMax +80.0 WtrDpth +msg_tensile_safety_motion.txt motionFile +dynamic_solver 1.0e-4 1.0e-14 100 12 +True tensile_safety +--------------------- OUTPUTS --------------------------------------- +"FairTen1" +"AnchTen1" +"TDP1s" +"Curv1N25" +--------------------- need this line ----------------------------------- diff --git a/tests/data/msg_weightless_ei0.dat b/tests/data/msg_weightless_ei0.dat new file mode 100644 index 00000000..6d2b18ee --- /dev/null +++ b/tests/data/msg_weightless_ei0.dat @@ -0,0 +1,35 @@ +--------------------- CableDyn Input File --- +msg_weightless_ei0 +--------------------- LINE TYPES --- +TypeName Diam MassDenInAir EA BA EI Cd_n Cd_t Ca_n Ca_t +(-) (m) (kg/m) (N) (-) (Nm2) (-) (-) (-) (-) +neutral 0.17 23.2654570 200000000 -1 0 1.2 0.1 1 0 +--------------------- POINTS --- +ID Type X Y Z Mass Vol CdA Ca +(-) (-) (m) (m) (m) (kg) (m3) (m2) (-) +1 Coupled 0 0 -10 0 0 0 0 +2 Fixed 450 0 -100 0 0 0 0 +--------------------- LINES --- +ID NodeA NodeB Outputs +(-) (-) (-) (-) +1 1 2 pt +--------------------- SECTIONS --- +LineID LineType Length NumSegs +(-) (-) (m) (-) +1 neutral 520 52 +--------------------- OPTIONS --- +9.80665 g +1025.0 rhoW +100.0 WtrDpth +100000.0 kBot +1.0e4 cBot +--------------------- OUTPUTS --- +"FairTen1" +"AnchTen1" +"Point1Fx" +"Point1Fy" +"Point1Fz" +"Point2Fx" +"Point2Fy" +"Point2Fz" +--------------------- need this line --- diff --git a/tests/data/msg_weightless_finite_ei.dat b/tests/data/msg_weightless_finite_ei.dat new file mode 100644 index 00000000..facd0da4 --- /dev/null +++ b/tests/data/msg_weightless_finite_ei.dat @@ -0,0 +1,37 @@ +--------------------- CableDyn Input File --- +msg_weightless_finite_ei +--------------------- LINE TYPES --- +TypeName Diam MassDenInAir EA BA EI Cd_n Cd_t Ca_n Ca_t +(-) (m) (kg/m) (N) (-) (Nm2) (-) (-) (-) (-) +neut 0.2 32.2013247 100000000 -1 10000 1.2 0.1 1 0 +--------------------- POINTS --- +ID Type X Y Z Mass Vol CdA Ca +(-) (-) (m) (m) (m) (kg) (m3) (m2) (-) +1 Coupled 0 0 -20 0 0 0 0 +2 Fixed 80 0 -100 0 0 0 0 +--------------------- LINES --- +ID NodeA NodeB Outputs +(-) (-) (-) (-) +1 1 2 pt +--------------------- SECTIONS --- +LineID LineType Length NumSegs +(-) (-) (m) (-) +1 neut 120 120 +--------------------- OPTIONS --- +9.80665 g +1025.0 rhoW +200.0 WtrDpth +100000.0 kBot +1.0e4 cBot +0.05 dtM +0.0 TMax +--------------------- OUTPUTS --- +"FairTen1" +"AnchTen1" +"Point1Fx" +"Point1Fy" +"Point1Fz" +"Point2Fx" +"Point2Fy" +"Point2Fz" +--------------------- need this line --- diff --git a/tests/test_hermite_cable_control.f90 b/tests/test_hermite_cable_control.f90 index 8de7669a..1f05ac03 100644 --- a/tests/test_hermite_cable_control.f90 +++ b/tests/test_hermite_cable_control.f90 @@ -235,10 +235,20 @@ SUBROUTINE check_model_contract() CALL require(unchanged(a, ref) .AND. same_bits(a%l0_dot, ref%l0_dot) .AND. same_bits(a%q, ref%q) .AND. & same_bits(a%v, ref%v) .AND. same_bits(a%a, ref%a) .AND. same_bits2(a%fr_anchor, ref%fr_anchor), & 'A: restore brings back the lengths, rates, caches and state bit for bit') + ! Restore clears the carried Newton factor and the cached committed force, which ref still + ! holds. Where a step stops depends on the factor's age, so a restart is exact only with + ! tangent reuse off; and ref's next step would take its committed force from the cache + ! while a evaluates it afresh. Both models march with reuse off from an uncached + ! committed force, so they take the same path. + a%tangent_reuse = .FALSE. + ref%tangent_reuse = .FALSE. + ref%fc_valid = .FALSE. DO k = 1, 3 CALL CD_HermiteCable_Dyn_Step(a, DT, 50, 1.0e-10_wp, es, em) CALL CD_HermiteCable_Dyn_Step(ref, DT, 50, 1.0e-10_wp, es, em) END DO + WRITE (*, '(A,ES10.3,A,ES10.3)') ' A: restored vs untouched after 3 steps, max |dq| ', & + MAXVAL(ABS(a%q - ref%q)), ', max |dv| ', MAXVAL(ABS(a%v - ref%v)) CALL require(es == CD_HCDYN_OK .AND. same_bits(a%q, ref%q) .AND. same_bits(a%v, ref%v), & 'A: the restored model marches bit-identically to an untouched copy') CALL CD_HermiteCable_Dyn_End(ref) From b8594fdd363a59cc81a09c692f4c183fcf36661f Mon Sep 17 00:00:00 2001 From: Jae Hoon Seo Date: Tue, 20 Oct 2026 16:05:13 +0900 Subject: [PATCH 22/31] fix: seabed contact for clump points and buoys; note EI = 0 folds (#28) Free and Connect points and Point3 buoys had no seabed contact of their own, so a heavy clump sank into the seabed (a 50 t clump 2.8 m). A point with Mass or Vol now rests on a footprint A = V^(2/3) with the line contact law, in the point static equilibrium and in the monolithic, staggered, OpenFAST and C API point steps; the contact is frictionless. Only clump_weight_free_point.dat among the examples changes. OpenFAST linearisation of a deck with a Point3 buoy fails closed by name. A tension-only line whose grounded run a current or a falling seabed carries past its anchor, where it folds back with zero tension, now gets a note naming the fold, its cause and the remedy that fits the deck's static friction; the finite-EI run-past-anchor note follows the same rule. The notes number segments and nodes from End A as the output channels do. No result changes apart from the point contact. Signed-off-by: Jae Hoon Seo --- CHANGELOG.md | 42 +- CMakeLists.txt | 80 +++ doc/driver_format.md | 11 +- doc/openfast.rst | 8 +- doc/options.rst | 9 +- doc/theory.rst | 95 +++- doc/troubleshooting.rst | 29 +- examples/clump_weight_free_point.dat | 9 +- src/CableDyn_DeckDriver.f90 | 594 ++++++++++++++++++-- src/CableDyn_Model.f90 | 68 +++ src/CableDyn_OpenFAST_Aggregate.f90 | 16 +- src/CableDyn_System.f90 | 92 ++- src/openfast/CableDyn_OF.f90 | 28 +- tests/check_fold_layout.py | 92 +++ tests/data/ei0_aslaid_behind_anchor.dat | 34 ++ tests/data/ei0_clump_no_fold.dat | 35 ++ tests/data/ei0_fold_slope.dat | 29 + tests/data/ei0_fold_slope_aslaid.dat | 33 ++ tests/data/ei0_fold_slope_bathy.txt | 27 + tests/data/ei0_fold_turn_current.dat | 32 ++ tests/data/ei0_hairpin_current.dat | 32 ++ tests/data/ei0_hairpin_current_friction.dat | 33 ++ tests/data/fei_hairpin_current.dat | 37 ++ tests/test_point_seabed_contact.f90 | 442 +++++++++++++++ tests/test_shared_anchor.f90 | 24 +- tests/test_statics_robustness.py | 10 +- 26 files changed, 1867 insertions(+), 74 deletions(-) create mode 100644 tests/check_fold_layout.py create mode 100644 tests/data/ei0_aslaid_behind_anchor.dat create mode 100644 tests/data/ei0_clump_no_fold.dat create mode 100644 tests/data/ei0_fold_slope.dat create mode 100644 tests/data/ei0_fold_slope_aslaid.dat create mode 100644 tests/data/ei0_fold_slope_bathy.txt create mode 100644 tests/data/ei0_fold_turn_current.dat create mode 100644 tests/data/ei0_hairpin_current.dat create mode 100644 tests/data/ei0_hairpin_current_friction.dat create mode 100644 tests/data/fei_hairpin_current.dat create mode 100644 tests/test_point_seabed_contact.f90 diff --git a/CHANGELOG.md b/CHANGELOG.md index 5da378e2..0d3639aa 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -99,7 +99,8 @@ All notable changes to CableDyn are recorded in this file. The format follows tension, or that of its viscoelastic or Syrope law) at one step exceeds four times its own one step before and after, ten times the largest tension anywhere on the line one step before and after, and the largest tension of the initial state. The first spike of a line is reported as - a warning, once per line, and the run summary counts them. The run ends with a note when a + a warning, once per line, naming its segment from End A as `.Line.t.out` numbers it, and + the run summary counts them. The run ends with a note when a taut segment turned by more than 1° in one solver step (with `ei0_substeps auto`, see Changed, 1.1 times the larger of 1° and `ei0_substep_angle`; the sub-steps of a sub-stepped or recovered step count as steps; the mean and standard deviation of the tension err by about @@ -183,6 +184,28 @@ All notable changes to CableDyn are recorded in this file. The format follows still reject `CONTROL`. A zero command, with a `DeltaLdot` of either sign, leaves the run bit-identical to an uncontrolled one, and a checkpoint restart continues bit-identically. See the manual's deck format page (CONTROL). +- A note when the static layout of an `EI = 0` line folds back on the seabed (a hairpin), the + twin of the finite-EI note. A current toward the anchor or a seabed falling past it can carry + the grounded run of a tension-only line past its anchor where no seabed friction holds it, + and it folds back with zero tension at the fold: a 2 m/s current carried a chain 20 m past its + anchor, a 5° slope 24 m, without a word. The equilibrium is kept, and one note per line names + the fold (the distance past the anchor, or a turn above 150° of the grounded run at a deck + node, numbered from End A as the node channels), its cause + (a deck current on the line, a seabed steeper than 0.5° at the fold, or a slack run) and the + remedy that fits the deck's static friction: `frictionMu` against a current, + `staticsFriction asLaid` on a slope (with the default `staticsFriction none` the static solve + applies friction against a deck current only), or a shorter line where friction already acts + or the route rejects it; a run without `dtM` and `TMax` is told that friction needs them, + since the static-only line solve carries none. A run that the `staticsFriction asLaid` + reference itself lays past its end (laid from the lower end along `layAzimuth`) is not + noted, nor is a near-vertical line (horizontal span under a tenth of the water depth) past + its end. The finite-EI note on a run past its anchor, which named "seabed friction or a + shorter line" whatever the deck, now names the same cause and remedy by the same rule and + skips the same as-laid run. It is printed on the static, `TMax = 0`, point-system and + multibody routes and in the OpenFAST initialisation report, which now also prints the + initialisation notes of finite-EI cables, and returned in the line report of the OpenFAST + aggregate. No example deck prints it, and no result changes. See the manual's theory page + (EI = 0 path) and Troubleshooting. ### Changed @@ -635,6 +658,23 @@ All notable changes to CableDyn are recorded in this file. The format follows OPTION); an anchor below the seabed by more than the tolerance gives the depth, the tolerance rule, and the Z to use. These messages change no acceptance rule. +- `Free` and `Connect` points (clump weights, buoys) and `Point3` buoys now have their own + seabed contact. Until now only the end nodes of the attached lines held a point on the + seabed, over their tributary length, so a heavy clump sank silently into it: a 50 t clump + between two polyester lines ended 2.8 m below the seabed, a 20 t clump on chain 1.0 m. A + point with `Mass` or `Vol` (a `Point3` buoy: its BODY `Mass` and `Vol`) now rests on a + footprint `A = V^(2/3)` (`V` = `Vol`, or `Mass`/7850 kg/m³ for a clump declared by its mass + alone), the face area of a cube of its volume, with the line contact law, stiffness `kBot·A` + and damping `cBot·A`, along the surface normal on a bathymetry, in the point static + equilibrium (which does not place a `Point3` buoy) and in the monolithic, staggered and + OpenFAST/C API point steps. The 50 t clump now rests 0.95 m deep (its weight alone presses + its 3.44 m² footprint in by 1.43 m) and the 20 t clump 0.67 m. The point routes still reject + `frictionMu`, so the contact is frictionless. Formal OpenFAST linearisation of a deck with a + `Point3` buoy now fails closed by name, like a deck with Rigid6 bodies or rods: its + quasi-static re-solve held the buoy at its deck position. Results change only where a point touches the seabed: of the examples only + `clump_weight_free_point.dat`, whose clump now rests 4.7 cm deep instead of 6.6 cm and whose + anchor tension falls from 186 kN to 92 kN; decks whose points stay clear of the seabed give + identical output. See the manual's theory page (Seabed contact). - The development environment (`environment.yml`) excludes OpenBLAS 0.3.34, which caused the access violation in the modal analysis tests listed under Known issues for 0.1.1. On AMD Zen 4 and Zen 5 CPUs that expose AVX-512, OpenBLAS 0.3.34 enlarges the GEMM blocking, diff --git a/CMakeLists.txt b/CMakeLists.txt index a4c6c0e6..e86a8a0b 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -986,6 +986,14 @@ target_link_libraries(test_deck_massless_connect PRIVATE cabledyn_core) add_test(NAME deck_massless_connect COMMAND test_deck_massless_connect WORKING_DIRECTORY ${CMAKE_BINARY_DIR}) set_tests_properties(deck_massless_connect PROPERTIES LABELS "fortran;driver;integration;dynamic") +# Seabed contact of Free/Connect points: a clump weight rests on its own footprint in the +# statics and stays at rest in the monolithic and staggered marches, on a flat and a sloped +# seabed; the fold note of an EI = 0 line reaches the OpenFAST aggregate's line report. +add_executable(test_point_seabed_contact tests/test_point_seabed_contact.f90) +target_link_libraries(test_point_seabed_contact PRIVATE cabledyn_core) +add_test(NAME point_seabed_contact COMMAND test_point_seabed_contact WORKING_DIRECTORY ${CMAKE_BINARY_DIR}) +set_tests_properties(point_seabed_contact PROPERTIES LABELS "fortran;driver;integration;dynamic;static") + add_executable(test_openfast_shell tests/test_openfast_shell.f90) target_link_libraries(test_openfast_shell PRIVATE cabledyn_core) add_test(NAME openfast_shell COMMAND test_openfast_shell) @@ -2098,6 +2106,78 @@ add_test(NAME driver_advisories -DSEABED_DECK=${CMAKE_CURRENT_SOURCE_DIR}/examples/chain_catenary_shallow_30m.dat -P ${CMAKE_CURRENT_SOURCE_DIR}/tests/check_driver_advisories.cmake) set_tests_properties(driver_advisories PROPERTIES LABELS "fortran;driver;integration") +# The fold note of an EI = 0 line, once per folded line and never on a usual layout: a current +# that pushes the grounded run 20 m past its anchor (TMax = 0, the line-model route), a seabed +# sloping down past the anchor (static run over a bathymetry), each with the remedy that fits +# the deck's friction, and no note on a grounded chain that does not fold, on the same current +# deck with frictionMu, on the same slope with as-laid friction, on a run the deck itself lays +# past its anchor (staticsFriction asLaid along layAzimuth), or on two lines through a clump +# resting on the seabed. +add_test(NAME driver_ei0_fold_note_current + COMMAND ${CMAKE_COMMAND} -DDRIVER=$ -DEXPECT_RC=0 + "-DARGS=${CMAKE_CURRENT_SOURCE_DIR}/tests/data/ei0_hairpin_current.dat|hairpin" + "-DONCE=Note: line 1: the static layout carries the grounded run 20\\.[0-9]+ m past its anchor, where it folds back;the current drives the run along the seabed, which holds it only by friction" + "-DMUST_MATCH=seabed friction \\(frictionMu\\) or a shorter line prevents it" + -DWORKDIR=${CMAKE_CURRENT_BINARY_DIR}/driver_ei0_fold_note_current + -P ${CMAKE_CURRENT_SOURCE_DIR}/tests/check_driver_output.cmake) +set_tests_properties(driver_ei0_fold_note_current PROPERTIES LABELS "fortran;driver;integration;static") +add_test(NAME driver_ei0_fold_note_slope + COMMAND ${CMAKE_COMMAND} -DDRIVER=$ -DEXPECT_RC=0 + "-DARGS=${CMAKE_CURRENT_SOURCE_DIR}/tests/data/ei0_fold_slope.dat|slope" + "-DONCE=Note: line 1: the static layout carries the grounded run 2[0-9]\\.[0-9]+ m past its anchor, where it folds back;the seabed slope drives the run downhill" + "-DMUST_MATCH=frictionMu with staticsFriction asLaid, which need dtM and TMax: the static-only solve carries no seabed friction\\) or a shorter line prevents it" + -DWORKDIR=${CMAKE_CURRENT_BINARY_DIR}/driver_ei0_fold_note_slope + -P ${CMAKE_CURRENT_SOURCE_DIR}/tests/check_driver_output.cmake) +set_tests_properties(driver_ei0_fold_note_slope PROPERTIES LABELS "fortran;driver;integration;static") +# ... and a fold of the grounded run onto itself between two grounded ends, named at its deck +# node (driver_ei0_fold_layouts checks that it is the node of the fold). +add_test(NAME driver_ei0_fold_note_turn + COMMAND ${CMAKE_COMMAND} -DDRIVER=$ -DEXPECT_RC=0 + "-DARGS=${CMAKE_CURRENT_SOURCE_DIR}/tests/data/ei0_fold_turn_current.dat|turn" + "-DONCE=Note: line 1: the static layout folds the grounded run back on itself \\(a 180 deg turn at node 49, a hairpin\\);the current drives the run along the seabed, which holds it only by friction" + "-DMUST_MATCH=seabed friction \\(frictionMu\\) or a shorter line prevents it" + "-DMUST_NOT=past its anchor" + -DWORKDIR=${CMAKE_CURRENT_BINARY_DIR}/driver_ei0_fold_note_turn + -P ${CMAKE_CURRENT_SOURCE_DIR}/tests/check_driver_output.cmake) +set_tests_properties(driver_ei0_fold_note_turn PROPERTIES LABELS "fortran;driver;integration;static") +foreach(_deck IN ITEMS examples/chain_catenary_shallow_30m tests/data/ei0_hairpin_current_friction + tests/data/ei0_fold_slope_aslaid tests/data/ei0_aslaid_behind_anchor + tests/data/ei0_clump_no_fold) + get_filename_component(_name "${_deck}" NAME) + if(_name STREQUAL "chain_catenary_shallow_30m") + set(_test driver_ei0_no_fold_note) + else() + set(_test driver_ei0_no_fold_note_${_name}) + endif() + add_test(NAME ${_test} + COMMAND ${CMAKE_COMMAND} -DDRIVER=$ -DEXPECT_RC=0 + "-DARGS=${CMAKE_CURRENT_SOURCE_DIR}/${_deck}.dat|${_name}" + "-DONCE=converged run written" + "-DMUST_NOT=folds back|a hairpin" + -DWORKDIR=${CMAKE_CURRENT_BINARY_DIR}/${_test} + -P ${CMAKE_CURRENT_SOURCE_DIR}/tests/check_driver_output.cmake) + set_tests_properties(${_test} PROPERTIES LABELS "fortran;driver;integration;static") +endforeach() +# The finite-EI twin of the current note: the same cause and remedy (fold_cause_remedy). +add_test(NAME driver_fei_fold_note_current + COMMAND ${CMAKE_COMMAND} -DDRIVER=$ -DEXPECT_RC=0 + "-DARGS=${CMAKE_CURRENT_SOURCE_DIR}/tests/data/fei_hairpin_current.dat|fei_hairpin" + "-DONCE=Note: line 1: the static layout carries the grounded run [0-9.]+ m past its anchor, where it folds back;the current drives the run along the seabed, which holds it only by friction" + "-DMUST_MATCH=seabed friction \\(frictionMu\\) or a shorter line prevents it" + -DWORKDIR=${CMAKE_CURRENT_BINARY_DIR}/driver_fei_fold_note_current + -P ${CMAKE_CURRENT_SOURCE_DIR}/tests/check_driver_output.cmake) +set_tests_properties(driver_fei_fold_note_current PROPERTIES LABELS "fortran;driver;integration;static") +# ... and the layouts behind those notes: the frictionless current carries the run past its +# anchor, frictionMu holds it short of the note threshold, and the as-laid run the note skips +# does lie past the anchor (so the no-note tests cannot pass on a layout that never got there). +if(Python3_Interpreter_FOUND) + add_test(NAME driver_ei0_fold_layouts + COMMAND ${Python3_EXECUTABLE} ${CMAKE_CURRENT_SOURCE_DIR}/tests/check_fold_layout.py + $ ${CMAKE_CURRENT_SOURCE_DIR}/tests/data) + set_tests_properties(driver_ei0_fold_layouts PROPERTIES + LABELS "python;driver;integration;static" + ENVIRONMENT "${_cabledyn_python_test_environment}") +endif() # A clamped finite-EI cable with a buoyant section on a Rigid6 body: the body static solve # holds the objects at their deck poses, warns once, and reports no balanced clamped end loads. add_test(NAME driver_clamped_buoyant_held diff --git a/doc/driver_format.md b/doc/driver_format.md index e5240eef..7e336172 100644 --- a/doc/driver_format.md +++ b/doc/driver_format.md @@ -621,7 +621,12 @@ A POINTS row has 9 columns, `ID Type X Y Z Mass Vol CdA Ca`, or the short 5-colu For dynamic `Connect`/`Free` points, `Mass` is inertial mass and `(rhoW·Vol − Mass)·g` is a constant vertical load. A `Mass = 0` junction is accepted; it moves with the end-node mass of its lines. `CdA` adds lumped drag and `Ca` lumped added mass in EI = 0 dynamic runs with uniform or -profile current or deck waves. `Connect`/`Free` points require `dtM`/`TMax` in the +profile current or deck waves. A `Connect`/`Free` point with `Mass` or `Vol` (a clump weight or +a buoy) has its own seabed contact, the line contact law with stiffness `kBot·A` and damping +`cBot·A` over the footprint `A = V^(2/3)`, where `V = Vol`, or `Mass/7850` (solid steel) when +`Vol = 0`; a point with neither has none. A `Point3` buoy has the same contact over the footprint +of its BODY `Mass`/`Vol` (see the theory manual, Seabed contact). +`Connect`/`Free` points require `dtM`/`TMax` in the standalone driver. Non-zero `Mass`/`Vol`/`CdA`/`Ca` on `Fixed`, `Coupled`, `Vessel`, `Body`, `RodA/B`, or `Turbine` points is rejected. @@ -1041,8 +1046,8 @@ syntax form. The most frequently edited keywords are: | `rhoW` / `WtrDnsty` | water density [kg/m³] | 1025.0 | | `WtrDpth` | water depth [m]; seabed plane z = −WtrDpth. Omit for a suspended or taut line with no bottom contact | none | | `bathymetryFile` / `bathymetry_file` / `seafloorFile` | structured bathymetry file (rows `x y depth`); mutually exclusive with `WtrDpth`. Supported for static EI = 0, independent-line EI = 0 dynamic, EI = 0 `Connect`/`Free` point-system line contact, cubic-Hermite finite-EI dynamic with held or prescribed-translation ends, free/fixed rod dynamic, and Rigid6 dynamic decks | none | -| `kBot` | seabed penalty stiffness base [Pa/m = N/m³], scaled per line node and rod contact station by diameter × tributary length, and by a fixed 1 m² reference area at a Rigid6 reference point (only with `WtrDpth`/`bathymetryFile`) | 1.0e5 | -| `cBot` | seabed normal damping base [Pa·s/m = N·s/m³], scaled like `kBot`; active only on contacting nodes moving downward | 1.0e4 | +| `kBot` | seabed penalty stiffness base [Pa/m = N/m³], scaled per line node and rod contact station by diameter × tributary length, at a Free/Connect point with Mass or Vol and a Point3 buoy by its footprint `V^(2/3)` (`V` = Vol, or Mass/7850), and by a fixed 1 m² reference area at a Rigid6 reference point (only with `WtrDpth`/`bathymetryFile`) | 1.0e5 | +| `cBot` | seabed normal damping base [Pa·s/m = N·s/m³], scaled like `kBot` (also over a point footprint); active only on contacting nodes and points moving downward | 1.0e4 | | `bodyIC` | `static`: free `Rigid6` bodies and free rods, with `Free`/`Connect` points, start at their static equilibrium; `deck`: they start at their deck pose (for example a free-decay test) | `static` | | `frictionMu` / `mu` | isotropic seabed friction coefficient: stick-slip springs on line nodes (held by the static solve too in a deck current, from the still-water laid shape, or toward the as-laid position with `staticsFriction asLaid`), regularised kinetic friction on rods and bodies; requires `WtrDpth` or `bathymetryFile`, and `dtM`/`TMax` in the standalone driver. Rejected on some routes (decks with `Connect`/`Free` points, `Point3` buoys or `FAILURE` rows, and body or rod decks off the default monolithic march); see the [OPTIONS reference](options.rst) | 0 | | `frictionMuAxial` / `frictionMuLateral` | anisotropic line friction: the coefficients along and across the local line axis (OrcaFlex axial/normal); an omitted one takes `frictionMu`; both positive or both zero; rods and bodies use the lateral one | `frictionMu` | diff --git a/doc/openfast.rst b/doc/openfast.rst index 09e82172..dad65c98 100644 --- a/doc/openfast.rst +++ b/doc/openfast.rst @@ -178,7 +178,8 @@ Before trusting a run, confirm in the console: #. the ``dtM`` line and the model inventory (``Created CableDyn model: ... line object(s)``); #. for every line, the converged fairlead effective tension, force vector, inclination, declination, and azimuth at the static equilibrium — printed unconditionally, whether or not - ``OUTPUTS`` is present; + ``OUTPUTS`` is present — followed by the line's static-initialisation notes, if any + (``Note: line ...``, for example a folded ``EI = 0`` layout; see :doc:`troubleshooting`); #. ``Requested CableDyn OUTPUTS at t = 0 s``, the deck's channels in the first output row. With SeaState waves or current the header adds ``SeaState kinematics at t = 0``: the equilibrium is solved before the kinematics act, so a line-end tension at t = 0 can differ slightly from the @@ -328,8 +329,9 @@ without an auxiliary process: the ``.lin`` matrices in the ``.fst`` ``OutFmt``; to compare them with MoorDyn's ``D - C A^-1 B``, use a full-precision format such as ``"ES24.15E3"``, because the usual 4-digit format cannot resolve that reduction. A deck with - Rigid6 bodies or rods is rejected at initialisation: the quasi-static reduction would hold - them at their deck pose instead of re-solving their equilibrium. + Rigid6 bodies, rods or ``Point3`` buoys is rejected at initialisation: the quasi-static + reduction would hold them at their deck pose instead of re-solving their equilibrium (a + ``Free`` point with the buoy's ``Mass``, ``Vol``, ``CdA`` and ``Ca`` is re-solved). * **FAST.Farm** selects CableDyn with ``Mod_SharedMooring = 5`` for shared lines and connections. Gravity, water density, depth, and ``TMax`` are host-owned and must agree across turbines, otherwise initialisation fails. diff --git a/doc/options.rst b/doc/options.rst index a257318a..12acbe91 100644 --- a/doc/options.rst +++ b/doc/options.rst @@ -89,14 +89,17 @@ Environment and seabed - real, Pa/m (N/m³) - ``1.0e5`` - finite, > 0 when a seabed is present. Mapped to each line node and rod contact station by - local diameter × tributary length; a Rigid6 reference point uses a fixed 1 m² area + local diameter × tributary length; a Free/Connect point with Mass or Vol, and a Point3 + buoy, over its footprint (Vol, or Mass/7850 kg/m³, to the power 2/3); a Rigid6 reference + point uses a fixed 1 m² area - both - ``1.0e5 kBot`` * - ``cBot`` / ``cb`` - real, Pa·s/m (N·s/m³) - ``1.0e4`` - - finite, ≥ 0 when a seabed is present; scaled like ``kBot`` and acts only on contacted - nodes moving downward + - finite, ≥ 0 when a seabed is present; scaled like ``kBot`` (per line node and rod contact + station, and over the footprint of a Free/Connect point with Mass or Vol or a Point3 + buoy) and acts only on contacting nodes and points moving downward - both - ``1.0e4 cBot`` * - ``frictionMu`` / ``mu`` / ``frictionCoefficient`` diff --git a/doc/theory.rst b/doc/theory.rst index 5f9d41e8..a75319ba 100644 --- a/doc/theory.rst +++ b/doc/theory.rst @@ -1070,6 +1070,33 @@ component :math:`w\sin\theta` per unit length, and a run pushed down the slope i is compressed there. On the Hermite path the contact acts on the nodal position DOFs only, not on the tangent DOFs. +**Free and Connect points.** A clump weight or a buoy (a ``Free`` or ``Connect`` point with +``Mass`` or ``Vol``, or a ``Point3`` buoy, whose ``Body`` attachment point steps as a free +point with the BODY ``Mass`` and ``Vol``) has its own seabed contact, the line law above with +the stiffness :math:`k_p = k_\text{Bot} A` and the damping :math:`c_p = c_\text{Bot} A` over its +contact footprint + +.. math:: + + A = V^{2/3}, \qquad V = \begin{cases} \text{Vol}, & \text{Vol} > 0, \\ + \text{Mass}/\rho_s, & \text{otherwise}, \end{cases} + +the face area of a cube of the point's volume, CableDyn's own area-equivalent of a compact +body (a point carries no shape), with :math:`\rho_s = 7850\ \mathrm{kg/m^3}`: a clump declared +by its mass alone, its buoyancy left out, takes the volume of solid steel of that mass. A point +with neither (a massless line junction) has no footprint. Without it only the end nodes of the +attached lines held a point on the bed, over their tributary length: a 50 t clump between two +polyester lines (``kBot = 1e5``) sank 2.8 m into the seabed; on its 3.44 m² footprint it rests +0.95 m deep, within the 1.43 m that its weight alone would press it in, and the lines no longer +hang it from the seabed. The contact acts along the surface normal of a sloped or rounded +bathymetry, in the point static equilibrium and in the monolithic and staggered point steps +alike (in the staggered step its stiffness and damping are linearly implicit, like the end +blocks of the attached lines), so a grounded point starts at rest. A ``Point3`` buoy is not +placed by the static solve (it starts at its deck position) but carries the same contact in +every march, the monolithic and staggered steps and the coupled point step of the OpenFAST +aggregate and the C API. The contact is frictionless: the point routes reject ``frictionMu``. A +point clear of the seabed sees exactly no contact load, and its results are unchanged. + Static equilibrium ------------------ @@ -1135,8 +1162,47 @@ march) enters the static equilibrium as Morison drag on the line at rest, so the offset is part of the initial condition. ``Connect`` and ``Free`` points are then placed at their static force balance: a trust-region Newton iteration on the point positions whose residual sums the attached lines' end forces (each line re-solved for the moving ends), the -point's weight and buoyancy, and its current drag. It is the rigid-body equilibrium solve -described under *Rigid-body initial condition* below, with points as the only unknowns. +point's weight and buoyancy, its current drag, and its own seabed contact (see Seabed +contact above). It is the rigid-body equilibrium solve described under *Rigid-body initial +condition* below, with points as the only unknowns. + +A tension-only line on a seabed that does not hold it can reach a folded (hairpin) +equilibrium: a current toward the anchor, or a seabed falling past it, drives the grounded run +beyond the anchor, and the run folds back to it with zero tension at the fold; a slack line can +likewise be laid out and back. The equilibrium is kept, and the driver prints one note per such +line, on every ``EI = 0`` route (static, ``TMax = 0`` and the dynamic initial condition, the +point and multibody systems, and the OpenFAST aggregate, whose line report returns it and whose +OpenFAST initialisation report prints it): ``the static layout carries the grounded run ... m +past its anchor, where it folds back (a hairpin)`` when grounded nodes lie more than 1 % of the +horizontal span plus 0.5 m beyond a grounded end whose other end is suspended, measured along +the horizontal chord (the criterion of the finite-EI note below; only for a horizontal span of +at least a tenth of the water depth at that end, or of the height of the other end above it if +that is larger, so that a near-vertical line, whose side away from its other end is not +defined, is left to the next test), or ``the static layout folds the grounded run back on +itself (a ... deg turn at node ...)`` when the run turns by more than 150° +at a node whose two neighbours are also grounded (within 5 cm of the floor); the node is the +deck node, numbered as the ```` of the node channels (1 = End A; an ``EI = 0`` line is never +refined, so its deck nodes are its mesh nodes). The note names the +cause: a deck current acting on the line (a current profile that vanishes at the seabed still +pulls the run through the suspended span), a seabed steeper than 0.5° at the fold, or neither +(a slack run). Its remedy follows the deck's static friction. Without ``frictionMu``: friction +against a current, or friction toward the as-laid position (``staticsFriction asLaid``) on a +slope, since with the default ``staticsFriction none`` the static solve applies friction against +a deck current only. With ``frictionMu`` and ``staticsFriction none`` on a slope: +``staticsFriction asLaid``. With friction that already acts and still does not hold the run, or +on a deck whose route rejects ``frictionMu`` (``Connect``/``Free`` points, ``Point3`` buoys) or +``staticsFriction asLaid`` (the multibody march): a shorter line. A run without ``dtM`` and +``TMax`` takes the static-only line solve, which carries no seabed friction at all, so there +the note adds that friction needs ``dtM`` and ``TMax`` (``TMax = 0`` for the statics alone). +Under ``staticsFriction asLaid`` no note is made when the as-laid reference itself (the line +laid on the seabed from its lower end, the anchor or the fairlead when that is lower, along +``layAzimuth`` or by default toward the other end, over its length) reaches past the grounded +end by more than the threshold above: the deck lays the run there, for example from the anchor +away from the fairlead, or from a lower fairlead toward the anchor and beyond it. The same rule +and the same causes and remedies apply to the finite-EI note below. The note never changes a +result. No +example deck and no ``EI = 0`` line of the statics test matrices prints it except the folded +layouts it describes. Hermite path ~~~~~~~~~~~~ @@ -1289,7 +1355,14 @@ seeded with the CableDyn shape converge to the same layout, and a dynamic run fr rest and returns to it after a disturbance. The standalone driver prints a note when the grounded run of the static layout lies past its anchor (``the static layout carries the grounded run ... m past its anchor``), because the layout differs from the usual one and a -real seabed with friction, or a shorter line, would not reach it. When the 3D solve also +real seabed with friction, or a shorter line, would not reach it. The note names the same +cause and remedy as the ``EI = 0`` fold note above (one rule for both): the finite-EI static +solve also applies ``frictionMu`` against a deck current under ``staticsFriction none``, so +``frictionMu`` answers a current and ``staticsFriction asLaid`` a slope, and a shorter line +remains where that friction already acts or the route rejects it (the multibody march rejects +``asLaid``, and a deck with ``Connect``/``Free`` points or ``Point3`` buoys ``frictionMu``). +Under ``asLaid`` no note is made when the as-laid reference itself, the line laid from its +lower end along ``layAzimuth``, reaches past the anchor. When the 3D solve also fails, the solve stops with the diagnosis (the element-mean compression, where it sits, and its height above the seabed) and suggests ``frictionMu``; neither the pseudo-arclength continuation of the planar path @@ -1787,15 +1860,19 @@ Deck ``POINTS``, ``BODIES``, and ``RODS`` records follow the MoorDyn object mode - **Fixed, coupled, and vessel points** prescribe the position, velocity, and acceleration of line ends. - **Free points** (``Point3`` buoys, clump weights, connectors) have three translational DOFs. - Each carries its weight and buoyancy :math:`(\rho V - m)\,g\,\mathbf{e}_z`, point loads, and, + Each carries its weight and buoyancy :math:`(\rho V - m)\,g\,\mathbf{e}_z`, point loads, its + own seabed contact (with ``Mass`` or ``Vol``, see Seabed contact above), and, while below the surface, lumped Morison terms :math:`\tfrac{1}{2}\rho\,C_dA\,\lvert\mathbf{u}_r\rvert\mathbf{u}_r + \rho V(1 + C_a)\,\dot{\mathbf{u}}_f` with added mass :math:`\rho V C_a`. Points are advanced around the implicit line step with implicit-Euler kinematics, and the attached line ends' own blocks are linearly implicit: the structural mass diagonal, the Morison added-mass block, and the end-segment elastic tangent - and axial damping. A light or massless connector is therefore stable at any - :math:`\Delta t`, including under added mass that exceeds the structural mass, and the end - segments impose no :math:`\sqrt{k_\text{line}/m_\text{point}}` limit. The coupling to the + and axial damping, and so is the point's own seabed contact (its stiffness + :math:`k_\text{Bot} A` and damping :math:`c_\text{Bot} A`). A light or massless connector is + therefore stable at any :math:`\Delta t`, including under added mass that exceeds the + structural mass, and neither the end segments nor the footprint impose a + :math:`\sqrt{k/m_\text{point}}` limit, so the sub-step estimate of the explicit object march + (below) leaves the points out. The coupling to the first interior node, drag, and seabed contact at the end node stay at the step-start state; the step fails with a named error if a point's motion becomes non-finite. - **Rigid6 bodies** have six DOFs, a diagonal inertia about the centre of gravity, and the @@ -2039,7 +2116,9 @@ the added mass changes as it crosses. A finite-EI cable on a body or rod of the whose end force the march returns explicitly, adds the directional spring above with :math:`k_a = 1/\sum l_0/EA` and its current end tension. The normal seabed damping and the regularised friction (a damper :math:`\mu N/\sqrt{v^2 + v_\text{reg}^2}`, :math:`\mu N/v_\text{reg}` -at rest) are applied implicitly, the friction as that secant coefficient, so they set no limit; +at rest) are applied implicitly, the friction as that secant coefficient, so they set no limit, +nor does the seabed contact of a ``Free``/``Connect`` point or a Point3 buoy, which its point +step treats as linearly implicit (see Free points above), so the estimate leaves it out; the monolithic scheme carries the contact and the hydrostatics in its Jacobian, and its accuracy sub-steps (above) leave them out. A step that would need more than 256 sub-steps is warned about once per run. The estimate omits the line-end inertia and the coupling between diff --git a/doc/troubleshooting.rst b/doc/troubleshooting.rst index cc83934a..587f693f 100644 --- a/doc/troubleshooting.rst +++ b/doc/troubleshooting.rst @@ -648,11 +648,28 @@ Warnings and notes that do not stop a run over one or two periods, as ``examples/data/lozon/generate_gomex80_heave.py`` does. * - ``Note: line ...: the static layout carries the grounded run ... m past its anchor, where it folds back (a hairpin) ...`` - - a very strong current on a frictionless seabed has pushed the line past its anchor, and - it folds back to it (see :doc:`theory`). The layout is a valid, stable equilibrium of the - deck as written, but not the usual one. If the real seabed holds the line, declare - ``frictionMu``; otherwise check the line length and the current, and inspect - ``.static.out`` before using the layout. + - a current, or a seabed sloping down past the anchor, has pushed the grounded run past its + anchor where no seabed friction holds it, and it folds back to it (see :doc:`theory`). + The layout is a valid, stable equilibrium of the deck as written, but not the usual one. + Check the line length, the current and the seabed, and inspect + ``.static.out`` before using the layout. The note, finite-EI or ``EI = 0``, + names the cause (the current, the slope, or on an ``EI = 0`` line neither: a slack line + laid out and back, which a shorter line removes) and the remedy that fits the deck: with + the default ``staticsFriction none`` the static solve applies ``frictionMu`` against a + deck current only, so a current points to ``frictionMu`` and a slope to + ``staticsFriction asLaid``, which holds the run toward its as-laid position; a run without + ``dtM`` and ``TMax`` has no seabed friction in its static solve at all; where friction + already acts, or the deck's route rejects it (``frictionMu`` beside ``Connect``/``Free`` + points or ``Point3`` buoys, ``asLaid`` on the multibody march), it points to a shorter + line. A run that the ``staticsFriction asLaid`` reference itself lays past the anchor is + the deck's own layout and is not noted. + * - ``Note: line ...: the static layout folds the grounded run back on itself (a ... deg turn + at node ..., a hairpin) ...`` + - an ``EI = 0`` line whose grounded run turns back by more than 150° at a node, away from + its ends (for example a slack line whose excess length the static solve lays out and back + on the seabed). The node is a deck node, numbered as the ```` of the node channels + (1 = End A). As above, the layout is an equilibrium of the deck as written; check the + line length before using it. * - ``Note: line ...: the equilibrium in the current is held in the vertical plane of the line; it is unstable out of that plane ...`` - in a current along the plane of the line the static state is a planar equilibrium that a @@ -709,7 +726,7 @@ Warnings and notes that do not stop a run * - ``Warning: line ...: segment ... carried ... N at t = ... s for a single step, ... times the largest tension on the line one step before and after`` - a non-physical tension spike: the tension of one segment (elastic, viscoelastic or - Syrope) rose and fell within one step to ten times anything the line carried one step + Syrope; numbered from End A, as in ``.Line.t.out``) rose and fell within one step to ten times anything the line carried one step before and after, which no physical snap or tension wave does. It is the signature of an under-resolved slack–taut transition integrated without energy control, for example with diff --git a/examples/clump_weight_free_point.dat b/examples/clump_weight_free_point.dat index 7ecc37a1..dbedac6c 100644 --- a/examples/clump_weight_free_point.dat +++ b/examples/clump_weight_free_point.dat @@ -1,9 +1,12 @@ --------------------- CableDyn Input File ------------------------------------ CableDyn driver deck -- chain with a clump weight at a Free line end, dynamic run -- A single chain hangs from a fairlead at the surface down to a heavy clump weight modelled as a --- Free point (a 1-line terminal): Mass 20 t, Vol 1 m^3, so a net downward load (Mass - rhoW*Vol)*g --- pulls the line end down and sets the pretension. Free points carry Mass/Vol only on the dynamic --- point-system path, so the deck sets dtM/TMax; the static IC seeds the march, held here for 2 s. +-- Free point (a 1-line terminal): Mass 20 t, Vol 1 m^3, a net downward load (Mass - rhoW*Vol)*g of +-- 186 kN. The 250 m chain reaches the 250 m seabed, so the clump rests on it below the fairlead, on +-- its own footprint Vol^(2/3) = 1 m^2 (kBot*A = 2e6 N/m), about 5 cm deep: the seabed carries half +-- its net weight and the chain the other half (AnchTen 92 kN). Free points carry Mass/Vol only on +-- the dynamic point-system path, so the deck sets dtM/TMax; the static IC seeds the march, held +-- here for 2 s. -- Chain: R4 studless 155 mm, volume-equivalent diam 0.2791 m, dry mass 480.93 kg/m, EA 2.058e9 N. --------------------- LINE TYPES --------------------------------------- TypeName Diam MassDenInAir EA BA/-zeta EI Cd_n Cd_t Ca_n Ca_t diff --git a/src/CableDyn_DeckDriver.f90 b/src/CableDyn_DeckDriver.f90 index a72d2fac..9a71baeb 100644 --- a/src/CableDyn_DeckDriver.f90 +++ b/src/CableDyn_DeckDriver.f90 @@ -65,7 +65,7 @@ MODULE CableDyn_DeckDriver CD_Get_System_CoupledMotion, CD_Update_System_Point_States, & CD_Calc_System_CoupledLoads, CD_Step_System, CD_Step_System_DynamicPoints, & CD_Step_System_Junction, CD_System_Junction_Rewind, CD_System_Point_Base, & - CD_System_Point_Environment, & + CD_System_Point_Environment, CD_System_Point_Seabed, & CD_Calc_System_CoupledAccelDerivative, & CD_Detach_System_LineEnds, & CD_SYSTEM_OK, CD_POINT_FIXED, CD_POINT_COUPLED, CD_POINT_FREE, CD_POINT_CONNECT, & @@ -132,7 +132,8 @@ MODULE CableDyn_DeckDriver CD_Morison_Drag_Element_Load, & CD_Morison_Drag_Element_Force, CD_Froude_Krylov_Element_Load, & CD_Froude_Krylov_Element_Force, CD_HYDRO_OK - USE CableDyn_SeabedContact, ONLY: CD_Seabed_Normal_Law, CD_Seabed_Contact_Gate + USE CableDyn_SeabedContact, ONLY: CD_Seabed_Normal_Law, CD_Seabed_Normal_Contact, CD_Seabed_Contact_Gate, & + CD_SEABED_CONTACT_BLEND USE CableDyn_Modal, ONLY: CD_Modal_Bar_Band, CD_Modal_Hermite_Band, CD_Modal_Solve_Band, & CD_Modal_Write_Header, CD_Modal_Write_Line, CD_MODAL_OK USE CableDyn_StreamWave, ONLY: CD_StreamWaveType, CD_Stream_Solve, CD_Stream_Kinematics @@ -298,6 +299,14 @@ MODULE CableDyn_DeckDriver REAL(wp), PARAMETER :: MAX_WAVE_SAMPLES = 1.0e6_wp ! a wave record above this many samples prints a setup-time note before its O(N^2) reduction INTEGER, PARAMETER :: LONG_WAVE_RECORD = 100000 + ! The static seabed friction a route accepts, for the remedy of a fold note (fold_cause_remedy): + ! none (decks with Connect/Free points or Point3 buoys reject frictionMu), frictionMu but not + ! staticsFriction asLaid (the multibody march), both (line decks), or both only with dtM and + ! TMax (the static-only line solve, which carries no seabed friction). + INTEGER, PARAMETER :: FOLD_FRICTION_NONE = 0, FOLD_FRICTION_NO_AS_LAID = 1, FOLD_FRICTION_FULL = 2, & + FOLD_FRICTION_NEEDS_MARCH = 3 + ! A fold note names the seabed slope as a cause above this gradient, TAN(0.5 deg). + REAL(wp), PARAMETER :: FOLD_SLOPE_MIN = 8.7268677907587893e-3_wp ! real_value_defect classes of an input number INTEGER, PARAMETER :: REAL_OK = 0, REAL_NONFINITE = 1, REAL_SUBNORMAL = 2 ! Admissible input magnitudes (documented in driver_format.md, "Admissible input ranges"). @@ -369,6 +378,9 @@ MODULE CableDyn_DeckDriver REAL(wp) :: turb_local(3) = CD_ZERO REAL(wp) :: body_offset(3) = CD_ZERO REAL(wp) :: mass = CD_ZERO, vol = CD_ZERO, cda = CD_ZERO, ca = CD_ZERO + ! the Body attachment of a Point3 BODY: stepped as a Free point with the BODY Mass/Vol/CdA/Ca + ! (copied into mass, vol, cda, ca above), its seabed contact included + LOGICAL :: point3 = .FALSE. INTEGER :: deck_line = 0 ! deck file line of the row, for error messages END TYPE @@ -975,9 +987,11 @@ MODULE CableDyn_DeckDriver REAL(wp) :: fair_declination = CD_ZERO REAL(wp) :: fair_azimuth = CD_ZERO LOGICAL :: force_is_total = .TRUE. - ! Static-initialisation notes of the line (finite-EI compression, mesh refinement, accepted - ! residual floor; the static strain note of any line), one per text line (append_note_line); - ! empty when there is nothing to report. It holds a whole cable note (1024) and a strain note. + ! Static-initialisation notes of the line, one per text line (append_note_line): those of a + ! finite-EI line (compression, mesh refinement, accepted residual floor, a run past its + ! anchor), the fold note of an EI = 0 line (ei0_fold_note) and the static strain note of any + ! line; empty when there is nothing to report. It holds a whole cable note (1024) and a + ! strain note. CHARACTER(2048) :: note = '' END TYPE CD_LineInitSummary @@ -1069,6 +1083,8 @@ MODULE CableDyn_DeckDriver ! `sys` each mooring step. Populated only when the deck declares RODs (has_rod). LOGICAL :: has_rod = .FALSE. TYPE(CD_RodRuntimeType) :: rod + ! Point3 buoys: stepped as Free points of the EI=0 system, but not placed by the static solve + LOGICAL :: has_point3 = .FALSE. ! Range graphs (LINES flag r, standalone only) and the touchdown references of the ! TDP channels, keyed by deck line id and fixed at the converged initial state. TYPE(CD_RangeSet) :: ranges @@ -1355,6 +1371,15 @@ SUBROUTINE init_deck_system_from_parsed(types, points, lines, sections, opts, sy sys_points(i)%cda = pts(i)%cda sys_points(i)%ca = pts(i)%ca sys_points(i)%force = [CD_ZERO, CD_ZERO, (opts%rhoW*pts(i)%vol - pts(i)%mass)*opts%g] + ! a deck Free/Connect point's own seabed contact over its footprint (point_contact_area), + ! with the line contact coefficients kBot and cBot per unit area, and so a Point3 buoy's, + ! which is the Free point of its Body attachment with the BODY Mass/Vol. Rigid6 body + ! and rod attachment points also step as system Free points, but their object carries + ! the contact. + IF (TRIM(pts(i)%ptype) == 'free' .OR. TRIM(pts(i)%ptype) == 'connect' .OR. pts(i)%point3) THEN + sys_points(i)%seabed_k = opts%kbot*point_contact_area(pts(i)) + sys_points(i)%seabed_c = opts%cbot*point_contact_area(pts(i)) + END IF END DO IF (nres > 0) THEN maxid = 0 @@ -1586,7 +1611,7 @@ END SUBROUTINE init_one_finite_model RECURSIVE SUBROUTINE build_one_hermite_cable(ln, sections, types, points, opts, dt, cable, coupled_node, & ErrStat, ErrMsg, standalone_controls, bathymetry, & - fairlead_orientation, init_note, coarse_pass) + fairlead_orientation, init_note, coarse_pass, fold_support) !! Build one COUPLED cubic-Hermite lazy-wave cable (CD_HFMF) from a finite-EI deck !! LINE -- the production Hermite bending path shared by the coupled route and !! standalone and coupled finite-EI dynamics, including flat/structured seabed contact. @@ -1614,6 +1639,9 @@ RECURSIVE SUBROUTINE build_one_hermite_cable(ln, sections, types, points, opts, CHARACTER(*), INTENT(OUT), OPTIONAL :: init_note ! Set on the coarsened build of coarse_current_first (see there): no further coarsening. LOGICAL, INTENT(IN), OPTIONAL :: coarse_pass + ! The static seabed friction the calling route accepts (FOLD_FRICTION_*, default + ! FOLD_FRICTION_FULL), for the remedy of the note on a run past the anchor. + INTEGER, INTENT(IN), OPTIONAL :: fold_support INTEGER, ALLOCATABLE :: conn(:, :), fixed_dofs(:), dynamic_fixed_dofs(:) REAL(wp), ALLOCATABLE :: l0(:), ea(:), mpl(:), diam(:), ei(:), gas_in(:), gj_in(:), i_rt_in(:), i_rn_in(:) @@ -4187,39 +4215,75 @@ END SUBROUTINE fine_mesh_note SUBROUTINE anchor_overshoot_note() !! Note a static layout whose grounded run lies beyond the anchor, on the side away !! from the fairlead: the line is carried past its anchor and folds back to it (a - !! hairpin). A strong current on a frictionless seabed holds such an equilibrium; it - !! is reported so that it is not mistaken for the usual layout. Node 1 is the anchor - !! and q_static is in the solve frame, where anchor and fairlead are also given. + !! hairpin). A current or a seabed slope where no seabed friction holds the run reaches + !! such an equilibrium; it is reported so that it is not mistaken for the usual layout, + !! with the cause and remedy of the EI = 0 fold note (fold_cause_remedy, with the route's + !! fold_support). Node 1 is the anchor and q_static is in the solve frame, where anchor + !! and fairlead are also given (a rotation of the global frame by frame_cs). Under + !! staticsFriction asLaid no note is made when the as-laid reference itself reaches past + !! the anchor (as_laid_reference_past): the deck lays the run there. REAL(wp), PARAMETER :: GROUNDED_TOL = 0.05_wp - REAL(wp) :: e_h(2), span, past, floor_z, xg, yg, pos(3) - INTEGER :: k, esb + REAL(wp) :: e_h(2), span, past, d, floor_z, xg, yg, pos(3), gx, gy, slope_at + REAL(wp) :: z_nodes(SIZE(q_static)/6) + INTEGER :: k, esb, support CHARACTER(1024) :: emb + CHARACTER(200) :: cause + CHARACTER(320) :: remedy + support = FOLD_FRICTION_FULL + IF (PRESENT(fold_support)) support = fold_support span = NORM2(fairlead(1:2) - anchor(1:2)) IF (span <= 1.0e-9_wp*MAX(CD_ONE, SUM(l0))) RETURN e_h = (fairlead(1:2) - anchor(1:2))/span + IF (as_laid .AND. support == FOLD_FRICTION_FULL) THEN + ! the reference is laid from the lower end: the fairlead when it lies below the anchor + IF (fairlead(3) < anchor(3)) THEN + d = as_laid_reference_past(opts, ln%id, to_global(fairlead(1:2)), to_global(anchor(1:2)), & + to_global(anchor(1:2)), to_global(e_h), SUM(l0)) + ELSE + d = as_laid_reference_past(opts, ln%id, to_global(anchor(1:2)), to_global(fairlead(1:2)), & + to_global(anchor(1:2)), to_global(e_h), SUM(l0)) + END IF + IF (d > 0.01_wp*span + 0.5_wp) RETURN + END IF past = CD_ZERO + slope_at = CD_ZERO DO k = 1, SIZE(q_static)/6 pos = q_static(6*(k - 1) + 1:6*(k - 1) + 3) + z_nodes(k) = pos(3) floor_z = contact_z + gx = CD_ZERO + gy = CD_ZERO IF (PRESENT(bathymetry)) THEN IF (.NOT. bathymetry_flat) THEN xg = frame_cs(1)*pos(1) - frame_cs(2)*pos(2) yg = frame_cs(2)*pos(1) + frame_cs(1)*pos(2) - CALL CD_Bathymetry_Floor(bathymetry, xg, yg, floor_z, esb, emb) + CALL CD_Bathymetry_Floor_Gradient(bathymetry, xg, yg, floor_z, gx, gy, esb, emb) IF (esb /= CD_BATHY_OK) RETURN END IF END IF IF (pos(3) > floor_z + GROUNDED_TOL) CYCLE - past = MAX(past, -DOT_PRODUCT(pos(1:2) - anchor(1:2), e_h)) + d = -DOT_PRODUCT(pos(1:2) - anchor(1:2), e_h) + IF (d > past) THEN + past = d + slope_at = SQRT(gx*gx + gy*gy) + END IF END DO IF (past <= 0.01_wp*span + 0.5_wp) RETURN + CALL fold_cause_remedy(opts, deck_current_on_line(opts, z_nodes), slope_at > FOLD_SLOPE_MIN, support, & + cause, remedy) WRITE (note_text, '(A,I0,A,F0.2,A)') 'line ', ln%id, ': the static layout carries the grounded run ', & - past, ' m past its anchor, where it folds back (a hairpin); a strong current on a frictionless '// & - 'seabed can hold this equilibrium, but check that it is the intended layout (seabed friction or '// & - 'a shorter line prevents it)' + past, ' m past its anchor, where it folds back (a hairpin); '//TRIM(cause)//'. Check that it is the '// & + 'intended layout ('//TRIM(remedy)//')' CALL report_note(note_text) END SUBROUTINE anchor_overshoot_note + PURE FUNCTION to_global(v) RESULT(g) + !! A horizontal vector of the solve frame in the global frame (frame_cs, a rotation). + REAL(wp), INTENT(IN) :: v(2) + REAL(wp) :: g(2) + g = [frame_cs(1)*v(1) - frame_cs(2)*v(2), frame_cs(2)*v(1) + frame_cs(1)*v(2)] + END FUNCTION to_global + SUBROUTINE report_note(text) !! One initialisation note: printed on a standalone run, appended to init_note. CHARACTER(*), INTENT(IN) :: text @@ -6607,6 +6671,7 @@ SUBROUTINE CD_Init_Deck_Aggregate(deck_path, dt, agg, ErrStat, ErrMsg, env_gravi END IF agg%has_sys = .TRUE. END IF + agg%has_point3 = n_point3 > 0 ! Coupled Rigid6 runtime: build the body states + retain the deck options/points the ! per-step marcher needs (scope validated above -- pure EI=0, non-farm; CdA/Ca only with a ! host fluid field). @@ -6670,10 +6735,14 @@ SUBROUTINE CD_Init_Deck_Aggregate(deck_path, dt, agg, ErrStat, ErrMsg, env_gravi IF (opts%has_bathymetry_file) THEN CALL build_one_hermite_cable(lines(i), sections, types, points, opts, dt, agg%cables(c), cn, es, em, & bathymetry=bathymetry, fairlead_orientation=fairlead_dcm, & - init_note=agg%cable_note(c)) + init_note=agg%cable_note(c), & + fold_support=MERGE(FOLD_FRICTION_NONE, FOLD_FRICTION_FULL, & + deck_has_dynamic_points(points))) ELSE CALL build_one_hermite_cable(lines(i), sections, types, points, opts, dt, agg%cables(c), cn, es, em, & - fairlead_orientation=fairlead_dcm, init_note=agg%cable_note(c)) + fairlead_orientation=fairlead_dcm, init_note=agg%cable_note(c), & + fold_support=MERGE(FOLD_FRICTION_NONE, FOLD_FRICTION_FULL, & + deck_has_dynamic_points(points))) END IF IF (es /= CD_DECKDRV_OK) THEN ErrStat = es @@ -6720,6 +6789,22 @@ SUBROUTINE CD_Init_Deck_Aggregate(deck_path, dt, agg, ErrStat, ErrMsg, env_gravi IF (ErrStat /= CD_DECKDRV_OK) THEN CALL CD_End_Deck_Aggregate(agg); RETURN END IF + ! the static fold note of each EI = 0 line (the finite-EI cables carry their own notes), + ! appended to the notes the line already has; the system rejects frictionMu beside + ! Connect/Free, Point3, body or rod points + IF (agg%has_sys) THEN + BLOCK + CHARACTER(1024) :: fold_note + DO c = 1, SIZE(lines) + IF (agg%line_is_cable(lines(c)%id)) CYCLE + CALL ei0_fold_note(lines(c), points, opts, agg%sys%lines(agg%line_obj_index(lines(c)%id))%q, & + fold_note, model=agg%sys%lines(agg%line_obj_index(lines(c)%id)), & + friction_support=MERGE(FOLD_FRICTION_NONE, FOLD_FRICTION_FULL, & + deck_has_dynamic_points(points))) + IF (LEN_TRIM(fold_note) > 0) CALL append_note_line(agg%init_lines(c)%note, fold_note) + END DO + END BLOCK + END IF ! A static strain above the note level is named in the line's initialisation note (every route that ! prints the notes of this summary shows it), and the standalone mixed route -- the caller that ! asks for the range graphs -- also warns about coarse sections, as the single-topology driver does. @@ -7319,6 +7404,7 @@ SUBROUTINE CD_End_Deck_Aggregate(agg) agg%has_rigid6 = .FALSE. CALL CD_Rod_End(agg%rod) agg%has_rod = .FALSE. + agg%has_point3 = .FALSE. CALL CD_Range_End(agg%ranges) agg%gravity = CD_ZERO agg%rho_water = CD_ZERO @@ -7612,7 +7698,8 @@ SUBROUTINE run_deck_driver(deck_path, out_root, converged, ErrStat, ErrMsg) IF (opts%has_bathymetry_file) CALL CD_End_Bathymetry(bathymetry) RETURN END IF - CALL collect_system_init_summaries(lines, points, point_system, init_summaries, ErrStat, ErrMsg) + CALL collect_system_init_summaries(lines, points, point_system, init_summaries, ErrStat, ErrMsg, & + opts=opts) IF (ErrStat /= CD_DECKDRV_OK) THEN CALL CD_End_System(point_system, es, em) IF (opts%has_bathymetry_file) CALL CD_End_Bathymetry(bathymetry) @@ -7646,7 +7733,8 @@ SUBROUTINE run_deck_driver(deck_path, out_root, converged, ErrStat, ErrMsg) IF (opts%has_bathymetry_file) CALL CD_End_Bathymetry(bathymetry) RETURN END IF - CALL collect_system_init_summaries(lines, points, point_system, init_summaries, ErrStat, ErrMsg) + CALL collect_system_init_summaries(lines, points, point_system, init_summaries, ErrStat, ErrMsg, & + opts=opts) IF (ErrStat /= CD_DECKDRV_OK) THEN CALL CD_End_System(point_system, es, em) IF (opts%has_bathymetry_file) CALL CD_End_Bathymetry(bathymetry) @@ -7680,7 +7768,8 @@ SUBROUTINE run_deck_driver(deck_path, out_root, converged, ErrStat, ErrMsg) IF (opts%has_bathymetry_file) CALL CD_End_Bathymetry(bathymetry) RETURN END IF - CALL collect_system_init_summaries(lines, points, point_system, init_summaries, ErrStat, ErrMsg) + CALL collect_system_init_summaries(lines, points, point_system, init_summaries, ErrStat, ErrMsg, & + opts=opts) IF (ErrStat /= CD_DECKDRV_OK) THEN CALL CD_End_System(point_system, es, em) IF (opts%has_bathymetry_file) CALL CD_End_Bathymetry(bathymetry) @@ -7702,7 +7791,7 @@ SUBROUTINE run_deck_driver(deck_path, out_root, converged, ErrStat, ErrMsg) IF (opts%has_bathymetry_file) CALL CD_End_Bathymetry(bathymetry) RETURN END IF - CALL collect_model_init_summaries(lines, points, models, init_summaries, ErrStat, ErrMsg) + CALL collect_model_init_summaries(lines, points, models, init_summaries, ErrStat, ErrMsg, opts=opts) IF (ErrStat /= CD_DECKDRV_OK) THEN CALL end_models(models) IF (opts%has_bathymetry_file) CALL CD_End_Bathymetry(bathymetry) @@ -7771,6 +7860,15 @@ SUBROUTINE run_deck_driver(deck_path, out_root, converged, ErrStat, ErrMsg) IF (converged) THEN CALL collect_raw_init_summaries(lines, points, ne, q_all, q_off, ten_all, ten_off, init_summaries, & end_ten=end_all, end_force=end_vec) + BLOCK + CHARACTER(1024) :: fold_note + DO li = 1, nl + IF (line_is_finite_ei(lines(li), types, sections)) CYCLE + CALL ei0_fold_note(lines(li), points, opts, q_all(q_off(li) + 1:q_off(li + 1)), fold_note, & + bathymetry=bathymetry, friction_support=FOLD_FRICTION_NEEDS_MARCH) + IF (LEN_TRIM(fold_note) > 0) CALL append_note_line(init_summaries(li)%note, fold_note) + END DO + END BLOCK CALL print_deck_init_report(deck_path, lines, points, sections, n_finite, init_summaries, & types=types, opts=opts) IF (.NOT. (opts%has_wtrdpth .OR. opts%has_bathymetry_file)) & @@ -9787,6 +9885,309 @@ SUBROUTINE warn_line_below_anchor(lines, points, sections, q_all, q_off) END DO END SUBROUTINE warn_line_below_anchor + SUBROUTINE ei0_fold_note(ln, points, opts, q, note, model, bathymetry, friction_support) + !! Initialisation note for an EI = 0 line whose static layout folds its grounded run back + !! on itself (a hairpin), the twin of the finite-EI anchor_overshoot_note: a current or a + !! seabed slope drives the run past its anchor where no seabed friction holds it, or a + !! slack run that carries no tension is laid out and back. Such a layout is an equilibrium + !! of the tension-only line and is kept; the note names it so that it is not mistaken for + !! the usual one. q is the line's static state in the internal node order (node 1 = End B). + !! A node is grounded within GROUNDED_TOL of the floor: model's floor when model is + !! present, otherwise the deck's (bathymetry, else WtrDpth). The layout folds when + !! (a) the grounded run lies beyond a grounded line end whose other end is suspended, on + !! the side away from that other end, by more than 1 % of the horizontal span plus + !! 0.5 m (anchor_overshoot_note); only for a horizontal span of at least SPAN_MIN_FRAC + !! of the water depth at that end (or of the height of the other end above it), so + !! that the direction away from the other end is well defined; or + !! (b) the run turns by more than FOLD_TURN_DEG at a node whose neighbours are grounded too. + !! The cause (a deck current on the line, a seabed steeper than 0.5 deg at the + !! fold, or a slack run) and the remedy come from fold_cause_remedy, shared with the + !! finite-EI note; friction_support (FOLD_FRICTION_*, default FOLD_FRICTION_FULL) is the + !! static seabed friction the route accepts. Under staticsFriction asLaid no note is made + !! when the as-laid reference itself reaches past the grounded end (as_laid_reference_past): + !! the deck lays the run there. + !! note is empty otherwise, and on a line without a floor. + TYPE(DeckLine), INTENT(IN) :: ln + TYPE(DeckPoint), INTENT(IN) :: points(:) + TYPE(DeckOptions), INTENT(IN) :: opts + REAL(wp), INTENT(IN) :: q(:) + CHARACTER(*), INTENT(OUT) :: note + TYPE(CD_ModelType), INTENT(IN), OPTIONAL :: model + TYPE(CD_BathymetryType), INTENT(IN), OPTIONAL :: bathymetry + INTEGER, INTENT(IN), OPTIONAL :: friction_support + REAL(wp), PARAMETER :: GROUNDED_TOL = 0.05_wp, FOLD_TURN_DEG = 150.0_wp + REAL(wp), PARAMETER :: SPAN_MIN_FRAC = 0.1_wp + LOGICAL, ALLOCATABLE :: grounded(:) + REAL(wp), ALLOCATABLE :: slope(:), zfl(:), znode(:) + REAL(wp) :: total, span, e_h(2), past, past_e, d, u1(3), u2(3), l1, l2, turn, turn_max, zf, dfdx, dfdy + INTEGER :: n, k, ie, k_end, k_oth, k_past, k_turn, k_at, k_lay, end_id, jp, support + LOGICAL :: has_floor, by_current, by_slope, as_laid + CHARACTER(200) :: what, cause + CHARACTER(320) :: remedy + + note = '' + support = FOLD_FRICTION_FULL + IF (PRESENT(friction_support)) support = friction_support + as_laid = opts%has_friction .AND. opts%static_friction == CD_STATIC_FRICTION_AS_LAID .AND. & + support == FOLD_FRICTION_FULL + n = SIZE(q)/3 + IF (n < 3) RETURN + ALLOCATE (grounded(n), slope(n), zfl(n), znode(n)) + DO k = 1, n + CALL floor_at(q(3*k - 2), q(3*k - 1), has_floor, zf, dfdx, dfdy) + IF (.NOT. has_floor) RETURN + grounded(k) = q(3*k) <= zf + GROUNDED_TOL + slope(k) = SQRT(dfdx*dfdx + dfdy*dfdy) + zfl(k) = zf + znode(k) = q(3*k) + END DO + IF (COUNT(grounded) < 2) RETURN + total = CD_ZERO + DO k = 1, n - 1 + total = total + NORM2(q(3*k + 1:3*k + 3) - q(3*k - 2:3*k)) + END DO + ! (a) the grounded run beyond a grounded end (node 1 is End B, node n End A) + past = CD_ZERO + k_past = 0 + k_at = 0 + end_id = 0 + DO ie = 1, 2 + k_end = MERGE(1, n, ie == 1) + k_oth = MERGE(n, 1, ie == 1) + ! A grounded end below a suspended span: the span pulls the run toward the other end, so + ! on a frictionless seabed a run past the end is folded back to it. (Between two + ! grounded ends a slack run may bow behind an end without folding; (b) covers those.) + IF (.NOT. grounded(k_end) .OR. grounded(k_oth)) CYCLE + span = NORM2(q(3*k_oth - 2:3*k_oth - 1) - q(3*k_end - 2:3*k_end - 1)) + ! a near-vertical line has no well-defined side away from its other end + IF (span < SPAN_MIN_FRAC*MAX(-zfl(k_end), q(3*k_oth) - q(3*k_end)) .OR. & + span <= 1.0e-6_wp*MAX(CD_ONE, total)) CYCLE + e_h = (q(3*k_oth - 2:3*k_oth - 1) - q(3*k_end - 2:3*k_end - 1))/span + ! staticsFriction asLaid holds the run toward its as-laid position: where that reference + ! itself reaches past this end, the deck lays the run there (as_laid_reference_past) + IF (as_laid) THEN + k_lay = MERGE(n, 1, q(3*n) < q(3)) + IF (as_laid_reference_past(opts, ln%id, q(3*k_lay - 2:3*k_lay - 1), & + q(3*(n + 1 - k_lay) - 2:3*(n + 1 - k_lay) - 1), & + q(3*k_end - 2:3*k_end - 1), e_h, total) > 0.01_wp*span + 0.5_wp) RETURN + END IF + past_e = CD_ZERO + DO k = 1, n + IF (.NOT. grounded(k)) CYCLE + d = -DOT_PRODUCT(q(3*k - 2:3*k - 1) - q(3*k_end - 2:3*k_end - 1), e_h) + IF (d > past_e) THEN + past_e = d + k_at = k + END IF + END DO + IF (past_e > 0.01_wp*span + 0.5_wp .AND. past_e > past) THEN + past = past_e + k_past = k_at + end_id = MERGE(ln%nodeB, ln%nodeA, ie == 1) + END IF + END DO + ! (b) a fold of the grounded run onto itself + turn_max = CD_ZERO + k_turn = 0 + DO k = 2, n - 1 + IF (.NOT. ALL(grounded(k - 1:k + 1))) CYCLE + u1 = q(3*k - 2:3*k) - q(3*k - 5:3*k - 3) + u2 = q(3*k + 1:3*k + 3) - q(3*k - 2:3*k) + l1 = NORM2(u1) + l2 = NORM2(u2) + IF (l1 <= 1.0e-9_wp*MAX(CD_ONE, total) .OR. l2 <= 1.0e-9_wp*MAX(CD_ONE, total)) CYCLE + turn = ACOS(MAX(-CD_ONE, MIN(CD_ONE, DOT_PRODUCT(u1, u2)/(l1*l2))))*CD_RAD2DEG + IF (turn > turn_max) THEN + turn_max = turn + k_turn = k + END IF + END DO + IF (k_past == 0 .AND. turn_max <= FOLD_TURN_DEG) RETURN + IF (k_past > 0) THEN + jp = find_point(points, end_id) + IF (jp > 0) THEN + IF (TRIM(points(jp)%ptype) == 'fixed') THEN + WRITE (what, '(A,F0.2,A)') 'the static layout carries the grounded run ', past, & + ' m past its anchor, where it folds back (a hairpin)' + ELSE + WRITE (what, '(A,F0.2,A,I0,A)') 'the static layout carries the grounded run ', past, & + ' m past its end at point ', end_id, ', where it folds back (a hairpin)' + END IF + ELSE + WRITE (what, '(A,F0.2,A)') 'the static layout carries the grounded run ', past, & + ' m past its end, where it folds back (a hairpin)' + END IF + k_at = k_past + ELSE + WRITE (what, '(A,I0,A,I0,A)') 'the static layout folds the grounded run back on itself (a ', & + NINT(turn_max), ' deg turn at node ', n + 1 - k_turn, ', a hairpin)' + k_at = k_turn + END IF + ! the cause: a deck current on the line (its drag on the suspended span pulls the run as + ! well as the drag on the run itself, so a profile still at the seabed counts), a seabed + ! sloping at the fold, or neither (a slack run) + by_current = deck_current_on_line(opts, znode) + by_slope = slope(k_at) > FOLD_SLOPE_MIN + CALL fold_cause_remedy(opts, by_current, by_slope, support, cause, remedy) + note = 'line '//TRIM(int_to_str(ln%id))//': '//TRIM(what)//'; '//TRIM(cause)//'. Check that it is the '// & + 'intended layout ('//TRIM(remedy)//')' + + CONTAINS + + SUBROUTINE floor_at(x, y, ok, z, gx, gy) + !! The floor elevation and gradient at (x, y); ok is .FALSE. without a floor (or on a + !! failed bathymetry query, where no note is made). + REAL(wp), INTENT(IN) :: x, y + LOGICAL, INTENT(OUT) :: ok + REAL(wp), INTENT(OUT) :: z, gx, gy + LOGICAL :: ready + INTEGER :: esb + CHARACTER(160) :: emb + ok = .FALSE. + z = CD_ZERO + gx = CD_ZERO + gy = CD_ZERO + IF (PRESENT(model)) THEN + IF (.NOT. model%has_seabed) RETURN + IF (model%has_bathymetry) THEN + CALL CD_Bathymetry_Floor_Gradient(model%bathymetry, x, y, z, gx, gy, esb, emb) + ok = esb == CD_BATHY_OK + ELSE + z = model%seabed_z_floor + ok = .TRUE. + END IF + RETURN + END IF + ready = .FALSE. + IF (PRESENT(bathymetry)) ready = CD_Bathymetry_Is_Initialized(bathymetry) + IF (ready) THEN + CALL CD_Bathymetry_Floor_Gradient(bathymetry, x, y, z, gx, gy, esb, emb) + ok = esb == CD_BATHY_OK + ELSE IF (opts%has_wtrdpth) THEN + z = -opts%wtrdpth + ok = .TRUE. + END IF + END SUBROUTINE floor_at + END SUBROUTINE ei0_fold_note + + SUBROUTINE add_model_fold_notes(lines, points, opts, models, summaries, friction_support) + !! ei0_fold_note of every EI = 0 line model (index-aligned with lines), appended to the notes + !! of its summary; friction_support as in ei0_fold_note. + TYPE(DeckLine), INTENT(IN) :: lines(:) + TYPE(DeckPoint), INTENT(IN) :: points(:) + TYPE(DeckOptions), INTENT(IN) :: opts + TYPE(CD_ModelType), INTENT(IN) :: models(:) + TYPE(CD_LineInitSummary), INTENT(INOUT) :: summaries(:) + INTEGER, INTENT(IN) :: friction_support + INTEGER :: i + CHARACTER(1024) :: fold_note + DO i = 1, MIN(SIZE(lines), SIZE(models), SIZE(summaries)) + IF (.NOT. ALLOCATED(models(i)%q)) CYCLE + CALL ei0_fold_note(lines(i), points, opts, models(i)%q, fold_note, model=models(i), & + friction_support=friction_support) + IF (LEN_TRIM(fold_note) > 0) CALL append_note_line(summaries(i)%note, fold_note) + END DO + END SUBROUTINE add_model_fold_notes + + LOGICAL FUNCTION deck_current_on_line(opts, z) RESULT(on) + !! Whether the deck current is non-zero at any of the node elevations z: its drag on the + !! suspended span pulls a grounded run as well as its drag on the run itself, so a current + !! profile that vanishes at the seabed still counts. + TYPE(DeckOptions), INTENT(IN) :: opts + REAL(wp), INTENT(IN) :: z(:) + REAL(wp) :: u(3) + INTEGER :: k, es + CHARACTER(512) :: em + on = .FALSE. + IF (.NOT. opts%has_current) RETURN + DO k = 1, SIZE(z) + u = deck_current_velocity(opts, z(k), es, em) + IF (es /= CD_HYDRO_OK) CYCLE + IF (NORM2(u) > CD_ZERO) THEN + on = .TRUE. + RETURN + END IF + END DO + END FUNCTION deck_current_on_line + + SUBROUTINE fold_cause_remedy(opts, by_current, by_slope, support, cause, remedy) + !! The cause and the remedy named by a note on a grounded run folded past its end (the + !! EI = 0 ei0_fold_note and the finite-EI anchor_overshoot_note). The cause is the deck + !! current, the seabed slope at the fold, both, or neither (a slack run). The remedy + !! follows the deck's static seabed friction and support, the friction the route accepts + !! (FOLD_FRICTION_*): with staticsFriction none the static solve applies frictionMu against + !! a deck current only, so frictionMu answers a current and staticsFriction asLaid a slope; + !! where that friction already acts, or the route rejects it, a shorter line remains; the + !! static-only line solve carries no friction at all, so there friction needs dtM and TMax. + TYPE(DeckOptions), INTENT(IN) :: opts + LOGICAL, INTENT(IN) :: by_current, by_slope + INTEGER, INTENT(IN) :: support + CHARACTER(*), INTENT(OUT) :: cause, remedy + LOGICAL :: as_laid + as_laid = opts%has_friction .AND. opts%static_friction == CD_STATIC_FRICTION_AS_LAID + IF (by_current .AND. by_slope) THEN + cause = 'the current and the seabed slope drive the run along the seabed, which holds it only by friction' + ELSE IF (by_current) THEN + cause = 'the current drives the run along the seabed, which holds it only by friction' + ELSE IF (by_slope) THEN + cause = 'the seabed slope drives the run downhill, which the seabed holds only by friction' + ELSE + cause = 'the run carries no tension, so nothing sets its layout on the seabed' + END IF + IF (.NOT. (by_current .OR. by_slope)) THEN + remedy = 'a shorter line prevents it' + ELSE IF (support == FOLD_FRICTION_NEEDS_MARCH .AND. by_slope) THEN + remedy = 'seabed friction toward the as-laid position (frictionMu with staticsFriction asLaid, which need '// & + 'dtM and TMax: the static-only solve carries no seabed friction) or a shorter line prevents it' + ELSE IF (support == FOLD_FRICTION_NEEDS_MARCH) THEN + remedy = 'seabed friction (frictionMu, which needs dtM and TMax: the static-only solve carries no seabed '// & + 'friction) or a shorter line prevents it' + ELSE IF (support == FOLD_FRICTION_NONE) THEN + remedy = 'a shorter line prevents it; seabed friction (frictionMu) is not supported on this deck' + ELSE IF (as_laid .AND. support == FOLD_FRICTION_FULL) THEN + remedy = 'a shorter line prevents it; the as-laid seabed friction (staticsFriction asLaid) does not hold '// & + 'the run there' + ELSE IF (by_slope .AND. support == FOLD_FRICTION_FULL .AND. opts%has_friction) THEN + remedy = 'staticsFriction asLaid or a shorter line prevents it; with staticsFriction none the static solve '// & + 'applies frictionMu against a deck current only' + ELSE IF (by_slope .AND. support == FOLD_FRICTION_FULL) THEN + remedy = 'seabed friction toward the as-laid position (frictionMu with staticsFriction asLaid) or a shorter '// & + 'line prevents it' + ELSE IF (by_slope) THEN + remedy = 'a shorter line prevents it; the static solve of this deck applies seabed friction against a deck '// & + 'current only' + ELSE IF (opts%has_friction) THEN + remedy = 'a shorter line prevents it; frictionMu does not hold the run against this current' + ELSE + remedy = 'seabed friction (frictionMu) or a shorter line prevents it' + END IF + END SUBROUTINE fold_cause_remedy + + REAL(wp) FUNCTION as_laid_reference_past(opts, line_id, lay_xy, other_xy, end_xy, e_h, laid_len) RESULT(past) + !! How far [m] the staticsFriction asLaid reference of a line reaches past one of its ends, + !! on the side away from the other end: the line laid on the seabed from its lower end + !! lay_xy (the anchor, or the fairlead when that is lower; other_xy is the other end) along + !! layAzimuth, by default toward the other end, over its length laid_len. end_xy is the + !! end tested and e_h the unit horizontal direction from it toward the line's other end; + !! global coordinates. The laid run is straight in plan, so its farthest point past the end + !! is one of its two ends; on a sloped seabed its plan length is shorter than laid_len, so + !! the distance is an upper bound. Zero for a reference that stays on the near side. + TYPE(DeckOptions), INTENT(IN) :: opts + INTEGER, INTENT(IN) :: line_id + REAL(wp), INTENT(IN) :: lay_xy(2), other_xy(2), end_xy(2), e_h(2), laid_len + REAL(wp), ALLOCATABLE :: lay_az + REAL(wp) :: laid_t, dir(2), h + CALL line_static_friction(opts, line_id, lay_az, laid_t) + IF (ALLOCATED(lay_az)) THEN + dir = [COS(lay_az), SIN(lay_az)] + ELSE + h = NORM2(other_xy - lay_xy) + dir = [CD_ONE, CD_ZERO] + IF (h > 1.0e-9_wp*MAX(CD_ONE, laid_len)) dir = (other_xy - lay_xy)/h + END IF + past = MAX(CD_ZERO, -DOT_PRODUCT(lay_xy - end_xy, e_h), -DOT_PRODUCT(lay_xy + laid_len*dir - end_xy, e_h)) + END FUNCTION as_laid_reference_past + SUBROUTINE solve_one_line(ln, sections, types, points, opts, q, tension, converged, ErrStat, ErrMsg, bathymetry, & end_ten, end_force) !! Solve one EI=0 line (Fixed anchor -> Coupled/held fairlead) built from its ordered @@ -14877,6 +15278,7 @@ SUBROUTINE finalize_checks(types, bodies, rod_types, rods, points, lines, sectio points(i)%vol = bodies(body_idx)%vol points(i)%cda = bodies(body_idx)%cda points(i)%ca = bodies(body_idx)%ca + points(i)%point3 = TRIM(bodies(body_idx)%btype) == 'point3' CYCLE ELSE IF (is_rod_point_type(points(i)%ptype)) THEN CALL parse_rod_point_type(points(i)%ptype, rod_id, idx) @@ -18292,7 +18694,11 @@ SUBROUTINE write_multibody_dynamic_out(deck_path, out_root, channels, types, bod CALL init_deck_system_from_parsed(types, pc, sys_lines, sections, opts, mb%system, ErrStat, ErrMsg, & bathymetry=bathymetry) IF (ErrStat /= CD_DECKDRV_OK) RETURN - CALL collect_system_init_summaries(sys_lines, points, mb%system, sum_sys, ErrStat, ErrMsg) + ! frictionMu is rejected beside Connect/Free points and Point3 buoys, and staticsFriction asLaid + ! on every multibody deck + CALL collect_system_init_summaries(sys_lines, points, mb%system, sum_sys, ErrStat, ErrMsg, opts=opts, & + friction_support=MERGE(FOLD_FRICTION_NONE, FOLD_FRICTION_NO_AS_LAID, & + deck_has_non_rigid6_dynamic_points(points, bodies))) IF (ErrStat /= CD_DECKDRV_OK) GOTO 900 ELSE ALLOCATE (sum_sys(0)) @@ -18353,14 +18759,18 @@ SUBROUTINE write_multibody_dynamic_out(deck_path, out_root, channels, types, bod lnc%endconn_ez_ref(:, 1) = dclamp CALL build_one_hermite_cable(lnc, sections, types, pc, opts, opts%dtM, mb%cables(c), node, & ErrStat, ErrMsg, standalone_controls=.TRUE., bathymetry=bathymetry, & - fairlead_orientation=TRANSPOSE(rclamp)) + fairlead_orientation=TRANSPOSE(rclamp), & + fold_support=MERGE(FOLD_FRICTION_NONE, FOLD_FRICTION_NO_AS_LAID, & + deck_has_non_rigid6_dynamic_points(points, bodies))) END BLOCK ! re-stepped inside the outer Newton of the monolithic step: its end loads must be ! converged well inside the junction tolerance mb%cables(c)%tol = MIN(mb%cables(c)%tol, CLAMPED_CABLE_TOL) ELSE CALL build_one_hermite_cable(cab_lines(c), sections, types, pc, opts, opts%dtM, mb%cables(c), node, & - ErrStat, ErrMsg, standalone_controls=.TRUE., bathymetry=bathymetry) + ErrStat, ErrMsg, standalone_controls=.TRUE., bathymetry=bathymetry, & + fold_support=MERGE(FOLD_FRICTION_NONE, FOLD_FRICTION_NO_AS_LAID, & + deck_has_non_rigid6_dynamic_points(points, bodies))) END IF IF (ErrStat /= CD_DECKDRV_OK) GOTO 900 END DO @@ -19889,6 +20299,8 @@ SUBROUTINE mb_imp_group_residual(mb, points, opts, g, time, res, ErrStat, ErrMsg INTEGER :: lo, hi, idx, nc, k, ir, base, n INTEGER, ALLOCATABLE :: kids(:) REAL(wp) :: fx(3), mx(3), m6b(6, 6), rhsb(6), x6(6), fenv(3), meff, arm(3), z6(6) + REAL(wp) :: fsea(3), ksea(3, 3), csea(3, 3) + LOGICAL :: sea_contact REAL(wp), ALLOCATABLE :: m6c(:, :, :), rhsc(:, :), pinw(:, :), rc(:, :), wc(:, :), amat(:, :), bvec(:), xg(:) ErrStat = CD_DECKDRV_OK @@ -19958,7 +20370,19 @@ SUBROUTINE mb_imp_group_residual(mb, points, opts, g, time, res, ErrStat, ErrMsg CALL fail_solve(ErrStat, ErrMsg, 'Free/Connect point load failed: '//TRIM(ErrMsg)); RETURN END IF ErrStat = CD_DECKDRV_OK - res(lo:hi) = meff*mb%pt_af(idx)%a - (mb%pt_af(idx)%force + fenv + mb%loads(base + 1:base + 3)) + ! the point's own seabed contact at the alpha-level state (the finite-difference + ! Jacobian of this residual carries its stiffness and damping) + CALL CD_System_Point_Seabed(mb%system, idx, mb%pt_af(idx)%q, mb%pt_af(idx)%v, sea_contact, fsea, ksea, & + csea, ErrStat, ErrMsg) + IF (ErrStat /= CD_SYSTEM_OK) THEN + CALL fail_solve(ErrStat, ErrMsg, 'Free/Connect point seabed contact failed: '//TRIM(ErrMsg)); RETURN + END IF + ErrStat = CD_DECKDRV_OK + IF (sea_contact) THEN + res(lo:hi) = meff*mb%pt_af(idx)%a - (mb%pt_af(idx)%force + fenv + fsea + mb%loads(base + 1:base + 3)) + ELSE + res(lo:hi) = meff*mb%pt_af(idx)%a - (mb%pt_af(idx)%force + fenv + mb%loads(base + 1:base + 3)) + END IF END SELECT CONTAINS SUBROUTINE cable_load(kind, obj, f, m) @@ -23036,6 +23460,7 @@ SUBROUTINE own_loads(xs, fk, mk, cen, sc_out, good) INTEGER :: kk, es_l, ib CHARACTER(1024) :: em_l TYPE(DeckRod) :: rg + LOGICAL :: ok_sea good = .FALSE. sc_out = TINY(CD_ONE)**0.25_wp @@ -23123,6 +23548,11 @@ SUBROUTINE own_loads(xs, fk, mk, cen, sc_out, good) END IF fk(:, kk) = fk(:, kk) + 0.5_wp*opts%rhoW*pts(idx(kk))%cda*NORM2(u)*u END IF + ! the point's own seabed contact (a grounded clump weight), as in the dynamics + CALL deck_point_seabed_force(pts(idx(kk))%pos, point_contact_area(pts(idx(kk))), opts, f2, ok_sea, & + ErrStat, ErrMsg, bathymetry) + IF (ErrStat /= CD_DECKDRV_OK) RETURN + IF (ok_sea) fk(:, kk) = fk(:, kk) + f2 END SELECT END DO ! the extra (clamped-end correction) loads, at their points carried by the objects @@ -24059,7 +24489,9 @@ SUBROUTINE hermite_end_loads(jl, fm, km, rot) IF (opts%dtM > CD_ZERO) dtb = opts%dtM CALL build_one_hermite_cable(lnc, sections, types, pc, opts, dtb, cab, node, ErrStat, ErrMsg, & standalone_controls=.TRUE., bathymetry=bathymetry, & - fairlead_orientation=TRANSPOSE(rclamp), init_note=note) + fairlead_orientation=TRANSPOSE(rclamp), init_note=note, & + fold_support=MERGE(FOLD_FRICTION_NONE, FOLD_FRICTION_NO_AS_LAID, & + deck_has_non_rigid6_dynamic_points(points, bodies))) IF (ErrStat == CD_DECKDRV_OK) THEN CALL CD_HFMF_CalcOutput(cab, fm(1:3), es, em, y_moment=fm(4:6)) IF (es /= CD_HFMF_OK) CALL fail_solve(ErrStat, ErrMsg, 'finite-EI LINE '//TRIM(int_to_str(lnc%id))// & @@ -26122,6 +26554,74 @@ SUBROUTINE deck_seabed_floor_at(x, y, opts, has_floor, z_floor, ErrStat, ErrMsg, END IF END SUBROUTINE deck_seabed_floor_at + PURE REAL(wp) FUNCTION point_contact_area(pt) RESULT(area) + !! Seabed contact footprint [m^2] of a Free/Connect point or a Point3 buoy (a clump weight + !! or a buoy): the face area of a cube of the point's volume, V^(2/3), CableDyn's own + !! area-equivalent of a compact body, with V the displaced volume Vol or, for a point + !! declared with Mass only (a clump weight whose buoyancy is left out), the volume of + !! solid steel of that mass, Mass/7850 kg/m^3. A point with neither (a massless line + !! junction) has no footprint: its lines' end nodes carry its contact. + TYPE(DeckPoint), INTENT(IN) :: pt + REAL(wp), PARAMETER :: STEEL_DENSITY = 7850.0_wp + REAL(wp) :: vol + area = CD_ZERO + vol = pt%vol + IF (.NOT. (vol > CD_ZERO)) vol = pt%mass/STEEL_DENSITY + IF (vol > CD_ZERO) area = vol**(2.0_wp/3.0_wp) + END FUNCTION point_contact_area + + SUBROUTINE deck_point_seabed_force(pos, area, opts, force, in_contact, ErrStat, ErrMsg, bathymetry) + !! Static seabed reaction on a Free/Connect point at pos with contact footprint area: the + !! line nodes' normal penalty law (C1 touchdown blend, along the surface normal on a + !! slope, with the bathymetry crease rounding) with stiffness kBot*area, the static twin of + !! CD_System_Point_Seabed (no velocity, so no damping). in_contact is .FALSE., with force + !! exactly zero, without a seabed or footprint or clear of the floor. + REAL(wp), INTENT(IN) :: pos(3), area + TYPE(DeckOptions), INTENT(IN) :: opts + REAL(wp), INTENT(OUT) :: force(3) + LOGICAL, INTENT(OUT) :: in_contact + INTEGER, INTENT(OUT) :: ErrStat + CHARACTER(*), INTENT(OUT) :: ErrMsg + TYPE(CD_BathymetryType), INTENT(IN), OPTIONAL :: bathymetry + REAL(wp) :: z_floor, dfdx, dfdy, curv(3), gap, kp, normal, tangent, jac3(3, 3) + LOGICAL :: bathy_ready + INTEGER :: es + CHARACTER(160) :: em + + force = CD_ZERO + in_contact = .FALSE. + ErrStat = CD_DECKDRV_OK + ErrMsg = '' + kp = opts%kbot*area + IF (.NOT. (kp > CD_ZERO)) RETURN + bathy_ready = .FALSE. + IF (PRESENT(bathymetry)) bathy_ready = CD_Bathymetry_Is_Initialized(bathymetry) + dfdx = CD_ZERO + dfdy = CD_ZERO + curv = CD_ZERO + IF (bathy_ready) THEN + CALL CD_Bathymetry_Floor_Gradient(bathymetry, pos(1), pos(2), z_floor, dfdx, dfdy, es, em, & + crease_curvature=curv) + IF (es /= CD_BATHY_OK) THEN + CALL fail_solve(ErrStat, ErrMsg, 'point seabed contact: bathymetry query failed: '//TRIM(em)) + RETURN + END IF + ELSE IF (opts%has_wtrdpth) THEN + z_floor = -opts%wtrdpth + ELSE + RETURN + END IF + gap = z_floor - pos(3) + IF (gap <= -CD_SEABED_CONTACT_BLEND*SQRT(CD_ONE + dfdx*dfdx + dfdy*dfdy)) RETURN + IF (ABS(dfdx) > CD_ZERO .OR. ABS(dfdy) > CD_ZERO .OR. ANY(ABS(curv) > CD_ZERO)) THEN + CALL CD_Seabed_Normal_Contact(gap, dfdx, dfdy, kp, force, jac3, curvature=curv) + ELSE + CALL CD_Seabed_Normal_Law(gap, kp, normal, tangent) + force(3) = normal + END IF + in_contact = .TRUE. + END SUBROUTINE deck_point_seabed_force + SUBROUTINE rigid6_wet_fraction(body, opts, time, phi, ErrStat, ErrMsg) !! Submerged fraction phi of a Rigid6 body. bodyWetting sphere (default): an equivalent !! sphere of the body volume, r_e = (3 V/(4 pi))^(1/3), centred at the centre of buoyancy, @@ -27971,12 +28471,14 @@ INTEGER FUNCTION audited_line_id(lines, i) RESULT(id) END FUNCTION audited_line_id SUBROUTINE warn_line_spike(model, line_id) - !! The once-per-line warning of the run audit's first implausible tension spike. + !! The once-per-line warning of the run audit's first implausible tension spike. The + !! segment is numbered in deck order, from End A, as the segment tension outputs and the + !! fold note's nodes are (audit_spike_elem is in internal order, End B first). TYPE(CD_ModelType), INTENT(IN) :: model INTEGER, INTENT(IN) :: line_id INTEGER :: ios WRITE (output_unit, '(A,I0,A,I0,A,ES10.3,A,F10.3,A,F0.1,A)', IOSTAT=ios) ' Warning: line ', line_id, & - ': segment ', model%audit_spike_elem, ' carried ', model%audit_spike_tension, ' N at t =', & + ': segment ', model%n_elem + 1 - model%audit_spike_elem, ' carried ', model%audit_spike_tension, ' N at t =', & model%audit_spike_time, ' s for a single step, ', model%audit_spike_ratio, & ' times the largest tension on the line one step before and after: a non-physical tension spike '// & '(an under-resolved slack-taut transition). Check the result with a smaller dtM (doc: troubleshooting).' @@ -31655,13 +32157,15 @@ SUBROUTINE collect_raw_init_summaries(lines, points, ne, q_all, q_off, ten_all, END DO END SUBROUTINE collect_raw_init_summaries - SUBROUTINE collect_model_init_summaries(lines, points, models, summaries, ErrStat, ErrMsg) + SUBROUTINE collect_model_init_summaries(lines, points, models, summaries, ErrStat, ErrMsg, opts) TYPE(DeckLine), INTENT(IN) :: lines(:) TYPE(DeckPoint), INTENT(IN) :: points(:) TYPE(CD_ModelType), INTENT(IN) :: models(:) TYPE(CD_LineInitSummary), ALLOCATABLE, INTENT(OUT) :: summaries(:) INTEGER, INTENT(OUT) :: ErrStat CHARACTER(*), INTENT(OUT) :: ErrMsg + !! opts (optional): add each line's static fold note (ei0_fold_note) + TYPE(DeckOptions), INTENT(IN), OPTIONAL :: opts TYPE(ModelOutputWorkspace) :: work INTEGER :: i, es REAL(wp) :: tension, declination, azimuth, f_first(3), fair_force(3) @@ -31687,15 +32191,21 @@ SUBROUTINE collect_model_init_summaries(lines, points, models, summaries, ErrSta END IF CALL set_init_summary(lines(i)%id, tension, declination, azimuth, summaries(i), fair_force=fair_force) END DO + IF (PRESENT(opts)) CALL add_model_fold_notes(lines, points, opts, models, summaries, FOLD_FRICTION_FULL) END SUBROUTINE collect_model_init_summaries - SUBROUTINE collect_system_init_summaries(lines, points, system, summaries, ErrStat, ErrMsg) + SUBROUTINE collect_system_init_summaries(lines, points, system, summaries, ErrStat, ErrMsg, opts, friction_support) TYPE(DeckLine), INTENT(IN) :: lines(:) TYPE(DeckPoint), INTENT(IN) :: points(:) TYPE(CD_SystemType), INTENT(IN) :: system TYPE(CD_LineInitSummary), ALLOCATABLE, INTENT(OUT) :: summaries(:) INTEGER, INTENT(OUT) :: ErrStat CHARACTER(*), INTENT(OUT) :: ErrMsg + !! opts (optional): add each line's static fold note (ei0_fold_note), with the route's + !! friction_support (default FOLD_FRICTION_NONE: a system of Connect/Free, Point3, body or + !! rod points, whose deck rejects frictionMu) + TYPE(DeckOptions), INTENT(IN), OPTIONAL :: opts + INTEGER, INTENT(IN), OPTIONAL :: friction_support TYPE(ModelOutputWorkspace) :: work INTEGER :: i, es REAL(wp) :: tension, declination, azimuth, f_first(3), fair_force(3) @@ -31721,6 +32231,13 @@ SUBROUTINE collect_system_init_summaries(lines, points, system, summaries, ErrSt END IF CALL set_init_summary(lines(i)%id, tension, declination, azimuth, summaries(i), fair_force=fair_force) END DO + IF (PRESENT(opts)) THEN + IF (PRESENT(friction_support)) THEN + CALL add_model_fold_notes(lines, points, opts, system%lines, summaries, friction_support) + ELSE + CALL add_model_fold_notes(lines, points, opts, system%lines, summaries, FOLD_FRICTION_NONE) + END IF + END IF END SUBROUTINE collect_system_init_summaries SUBROUTINE collect_finite_init_summaries(lines, points, models, summaries, ErrStat, ErrMsg) @@ -31785,7 +32302,7 @@ SUBROUTINE print_deck_init_report(deck_path, lines, points, sections, n_finite, TYPE(CD_LineInitSummary), INTENT(IN) :: summaries(:) TYPE(DeckLineType), INTENT(IN), OPTIONAL :: types(:) TYPE(DeckOptions), INTENT(IN), OPTIONAL :: opts - INTEGER :: i + INTEGER :: i, a, b REAL(wp) :: f_incl CHARACTER(1024) :: strain_note @@ -31813,6 +32330,19 @@ SUBROUTINE print_deck_init_report(deck_path, lines, points, sections, n_finite, WRITE (error_unit, '(A,F9.3,A,F9.3,A,F9.3,A)') ' line tangent: inclination=', & summaries(i)%fair_inclination, ' deg, declination=', summaries(i)%fair_declination, & ' deg, azimuth=', summaries(i)%fair_azimuth, ' deg' + ! the line's static-initialisation notes (ei0_fold_note), one per text line + IF (LEN_TRIM(summaries(i)%note) > 0) THEN + a = 1 + DO + b = INDEX(summaries(i)%note(a:), NEW_LINE('a')) + IF (b == 0) THEN + WRITE (error_unit, '(A)') ' Note: '//TRIM(summaries(i)%note(a:))//'.' + EXIT + END IF + WRITE (error_unit, '(A)') ' Note: '//summaries(i)%note(a:a + b - 2)//'.' + a = a + b + END DO + END IF IF (PRESENT(types) .AND. PRESENT(opts)) THEN CALL static_strain_note(summaries(i)%line_id, summaries(i)%fair_tension, sections, types, opts, strain_note) IF (LEN_TRIM(strain_note) > 0) WRITE (error_unit, '(A)') ' Note: '//TRIM(strain_note)//'.' diff --git a/src/CableDyn_Model.f90 b/src/CableDyn_Model.f90 index 8bb49c75..10554bec 100644 --- a/src/CableDyn_Model.f90 +++ b/src/CableDyn_Model.f90 @@ -25,6 +25,7 @@ MODULE CableDyn_Model USE CableDyn_Line, ONLY: CD_Nodal_Seabed_Stiffness USE CableDyn_CableElem, ONLY: CD_Compute_Cable_Element USE CableDyn_SeabedContact, ONLY: CD_Seabed_Normal_Law, CD_Seabed_Normal_Contact, CD_Seabed_Contact_Gate, & + CD_SEABED_CONTACT_BLEND, & CD_Seabed_Friction_Stick_Slip, CD_Seabed_Friction_Aniso, & CD_Seabed_Friction_Mu_Dir, CD_FRICTION_STICK_SLIP USE CableDyn_Bathymetry, ONLY: CD_BathymetryType, CD_Init_Bathymetry, CD_Bathymetry_Is_Initialized, & @@ -95,6 +96,7 @@ MODULE CableDyn_Model PUBLIC :: CD_Get_Model_EndNodeMassDiag PUBLIC :: CD_Get_Model_EndNodeAddedMass PUBLIC :: CD_Get_Model_EndNodeTangent + PUBLIC :: CD_Model_Seabed_Point_Load PUBLIC :: CD_Set_Model_EndQuery PUBLIC :: CD_Get_Model_EndQuery PUBLIC :: CD_Update_Model_SegmentLength @@ -7993,6 +7995,72 @@ SUBROUTINE seabed_normal_velocity_gradient(model, x, y, z, vel, node, dn_dv, Err dn_dv = dn_dvn*nvec END SUBROUTINE seabed_normal_velocity_gradient + SUBROUTINE CD_Model_Seabed_Point_Load(model, x, vel, k_n, c_n, in_contact, force, jac_q, jac_v, ErrStat, ErrMsg) + !! The line's own nodal seabed law evaluated for a point that is not one of its nodes (a + !! Free/Connect point the line is attached to): normal stiffness k_n [N/m] and one-sided + !! normal damping c_n [N.s/m] against this model's floor (flat or bathymetry, along the + !! surface normal on a slope, with the crease rounding), exactly as a line node with those + !! coefficients. force is the seabed load on the point, jac_q = -d(force)/dq and + !! jac_v = -d(force)/dv its residual tangents. in_contact is .FALSE. (and every output + !! exactly zero) when the model has no seabed or the point is clear of the contact. + TYPE(CD_ModelType), INTENT(IN) :: model + REAL(wp), INTENT(IN) :: x(3), vel(3), k_n, c_n + LOGICAL, INTENT(OUT) :: in_contact + REAL(wp), INTENT(OUT) :: force(3), jac_q(3, 3), jac_v(3, 3) + INTEGER, INTENT(OUT) :: ErrStat + CHARACTER(*), INTENT(OUT) :: ErrMsg + REAL(wp) :: z_floor, dfdx, dfdy, curv(3), gap, normal, tangent, gap_n, vn, nvec(3) + REAL(wp) :: damp_force, damp_dgap, damp_dvz + LOGICAL :: sloped + INTEGER :: a, b + + in_contact = .FALSE. + force = CD_ZERO + jac_q = CD_ZERO + jac_v = CD_ZERO + ErrStat = CD_MODEL_OK + ErrMsg = '' + IF (.NOT. model%has_seabed) RETURN + IF (.NOT. (k_n > CD_ZERO .OR. c_n > CD_ZERO)) RETURN + IF (model%has_bathymetry) THEN + CALL model_floor_gradient(model, x(1), x(2), z_floor, dfdx, dfdy, ErrStat, ErrMsg, curvature=curv) + IF (ErrStat /= CD_MODEL_OK) RETURN + ELSE + z_floor = model%seabed_z_floor + dfdx = CD_ZERO + dfdy = CD_ZERO + curv = CD_ZERO + END IF + gap = z_floor - x(3) + ! The normal penetration is the vertical one over s >= 1, so a point more than the + ! touchdown blend above the floor (vertically) is clear of every term below. + IF (gap <= -CD_SEABED_CONTACT_BLEND*SQRT(CD_ONE + dfdx*dfdx + dfdy*dfdy)) RETURN + IF (ABS(dfdx) > CD_ZERO .OR. ABS(dfdy) > CD_ZERO .OR. ANY(ABS(curv) > CD_ZERO)) THEN + CALL CD_Seabed_Normal_Contact(gap, dfdx, dfdy, k_n, force, jac_q, curvature=curv) + ELSE + CALL CD_Seabed_Normal_Law(gap, k_n, normal, tangent) + force(3) = normal + jac_q(3, 3) = tangent + END IF + IF (c_n > CD_ZERO) THEN + CALL node_contact_normal(model, x(1), x(2), x(3), vel, gap_n, vn, nvec, sloped, ErrStat, ErrMsg) + IF (ErrStat /= CD_MODEL_OK) THEN + force = CD_ZERO + jac_q = CD_ZERO + RETURN + END IF + CALL seabed_normal_damping_terms(gap_n, vn, c_n, damp_force, damp_dgap, damp_dvz) + force = force + damp_force*nvec + DO b = 1, 3 + DO a = 1, 3 + jac_q(a, b) = jac_q(a, b) + damp_dgap*nvec(a)*nvec(b) + jac_v(a, b) = -damp_dvz*nvec(a)*nvec(b) + END DO + END DO + END IF + in_contact = .TRUE. + END SUBROUTINE CD_Model_Seabed_Point_Load + PURE SUBROUTINE seabed_normal_damping_terms(gap, vz, c_n, force, dforce_dgap, dforce_dvz) !! One-sided normal seabed damping at normal penetration gap and normal velocity vz !! (vertical on a level floor): force = -c_n*gate(gap)*vz for vz < 0. diff --git a/src/CableDyn_OpenFAST_Aggregate.f90 b/src/CableDyn_OpenFAST_Aggregate.f90 index a7ffb3ba..e60e5abf 100644 --- a/src/CableDyn_OpenFAST_Aggregate.f90 +++ b/src/CableDyn_OpenFAST_Aggregate.f90 @@ -96,6 +96,7 @@ MODULE CableDyn_OpenFAST_Aggregate PUBLIC :: CD_AGG_NDynamicPoints PUBLIC :: CD_AGG_HasRigid6 PUBLIC :: CD_AGG_HasRod + PUBLIC :: CD_AGG_HasPoint3 PUBLIC :: CD_AGG_Rigid6_MirrorSize, CD_AGG_Get_Rigid6_States, CD_AGG_Set_Rigid6_States PUBLIC :: CD_AGG_Rod_MirrorSize, CD_AGG_Get_Rod_States, CD_AGG_Set_Rod_States PUBLIC :: CD_AGG_Refresh_PointMesh @@ -215,6 +216,8 @@ MODULE CableDyn_OpenFAST_Aggregate ! Coupled Rigid6 bodies (pure EI=0 deck): the opaque runtime the facade marches over the ! EI=0 system each mooring step, in place of the plain moving step. has_rigid6 selects the ! body-march branch; the runtime's own snapshot buffer joins the aggregate snapshot/restore. + ! Point3 buoys among the Free points of the EI=0 system (CD_AGG_HasPoint3). + LOGICAL :: has_point3 = .FALSE. LOGICAL :: has_rigid6 = .FALSE. TYPE(CD_Rigid6RuntimeType) :: rigid6 ! Coupled rigid RODS: the rod twin of the Rigid6 runtime above. has_rod selects the rod-march @@ -374,6 +377,7 @@ SUBROUTINE CD_AGG_Init_From_Deck(self, deck_path, dt, ErrStat, ErrMsg, env_gravi candidate%has_rigid6 = parts%has_rigid6 IF (parts%has_rigid6) candidate%rigid6 = parts%rigid6 candidate%has_rod = parts%has_rod + candidate%has_point3 = parts%has_point3 IF (parts%has_rod) candidate%rod = parts%rod candidate%nhost_rod = 0 IF (parts%has_rod) candidate%nhost_rod = CD_Rod_NHost(candidate%rod) @@ -1981,6 +1985,7 @@ SUBROUTINE CD_AGG_End(self, ErrStat, ErrMsg) self%has_rigid6 = .FALSE. CALL CD_Rod_End(self%rod) self%has_rod = .FALSE. + self%has_point3 = .FALSE. CALL CD_Range_End(self%ranges) self%nhost_rod = 0 self%nhost_body = 0 @@ -2034,7 +2039,8 @@ END SUBROUTINE CD_AGG_GetInitMetadata SUBROUTINE CD_AGG_GetInitLine(self, i, line_id, tension, force, inclination, declination, azimuth, ErrStat, ErrMsg, & note) !! Return one line's unconditional converged-static fairlead result in deck order, and - !! (optional note) the static-initialisation notes of a finite-EI line ('' if none). + !! (optional note) its static-initialisation notes, one per text line: those of a finite-EI + !! cable, or the fold note of an EI = 0 line ('' if none). TYPE(CD_AGG_ModuleType), INTENT(IN) :: self INTEGER, INTENT(IN) :: i INTEGER, INTENT(OUT) :: line_id @@ -2587,6 +2593,14 @@ LOGICAL FUNCTION CD_AGG_HasRod(self) RESULT(has) has = self%has_rod .AND. CD_Rod_NRods(self%rod) > 0 END FUNCTION CD_AGG_HasRod + LOGICAL FUNCTION CD_AGG_HasPoint3(self) RESULT(has) + !! True iff the deck has a Point3 buoy, which the EI=0 system steps as a Free point but + !! the static solve does not place: it starts, and a static re-solve holds it, at its deck + !! position. + TYPE(CD_AGG_ModuleType), INTENT(IN) :: self + has = self%has_point3 + END FUNCTION CD_AGG_HasPoint3 + INTEGER FUNCTION CD_AGG_Rigid6_MirrorSize(self) RESULT(n) !! Reals the checkpoint mirror must reserve for the aggregate's Rigid6 bodies (0 if none). TYPE(CD_AGG_ModuleType), INTENT(IN) :: self diff --git a/src/CableDyn_System.f90 b/src/CableDyn_System.f90 index 0c33d7f4..b34ef6de 100644 --- a/src/CableDyn_System.f90 +++ b/src/CableDyn_System.f90 @@ -20,6 +20,7 @@ MODULE CableDyn_System CD_Model_Has_Friction, CD_Get_Model_Friction_Anchors, CD_Set_Model_Friction_Anchors, & CD_Get_Model_EndNodeMassDiag, CD_Get_Model_EndNodeAddedMass, & CD_Get_Model_EndNodeTangent, CD_Set_Model_EndQuery, CD_Get_Model_EndQuery, & + CD_Model_Seabed_Point_Load, & CD_Update_Model_SegmentLength, CD_ModelControlSaveType, CD_Save_Model_Control, & CD_Restore_Model_Control, & CD_Update_Model_CoupledMotion, CD_Update_Model_Interior_State, CD_Step_Model, & @@ -97,6 +98,7 @@ MODULE CableDyn_System PUBLIC :: CD_System_Junction_Rewind PUBLIC :: CD_System_Point_Base PUBLIC :: CD_System_Point_Environment + PUBLIC :: CD_System_Point_Seabed PUBLIC :: CD_Detach_System_LineEnds PUBLIC :: CD_Update_System_Line_SegmentLength PUBLIC :: CD_Save_System_Line_Control, CD_Restore_System_Line_Control @@ -152,6 +154,13 @@ MODULE CableDyn_System REAL(wp) :: fluid_acceleration(3) = CD_ZERO REAL(wp) :: waterline_z = CD_ZERO REAL(wp) :: fluid_density = CD_ZERO + ! Seabed contact of a Free/Connect point (a clump weight or a grounded buoy): normal + ! stiffness seabed_k = kBot*A [N/m] and one-sided normal damping seabed_c = cBot*A + ! [N.s/m] over its contact footprint A, applied with the line nodes' contact law + ! against the floor of a line bound to the point (CD_System_Point_Seabed). Zero: no + ! contact (the default, and every point not built from a deck footprint). + REAL(wp) :: seabed_k = CD_ZERO + REAL(wp) :: seabed_c = CD_ZERO END TYPE CD_SystemPointType TYPE :: CD_LineEndpointBinding @@ -1623,6 +1632,66 @@ SUBROUTINE CD_System_Point_Environment(point, point_velocity, force, effective_m CALL point_environment_force(point, point_velocity, force, effective_mass, ErrStat, ErrMsg) END SUBROUTINE CD_System_Point_Environment + SUBROUTINE CD_System_Point_Seabed(system, point_index, q, v, in_contact, force, jac_q, jac_v, ErrStat, ErrMsg) + !! Seabed contact load of system point point_index at position q and velocity v: the line + !! nodes' normal contact law (CD_Model_Seabed_Point_Load) with the point's own stiffness + !! seabed_k and damping seabed_c, against the floor of the first bound line that has a + !! seabed, else of any line of the system (every line of a deck shares the deck's floor). + !! jac_q = -d(force)/dq and jac_v = -d(force)/dv. in_contact is .FALSE., with every output + !! exactly zero, for a point without a footprint, in a system without a seabed, or clear of + !! the floor. + TYPE(CD_SystemType), INTENT(IN) :: system + INTEGER, INTENT(IN) :: point_index + REAL(wp), INTENT(IN) :: q(3), v(3) + LOGICAL, INTENT(OUT) :: in_contact + REAL(wp), INTENT(OUT) :: force(3), jac_q(3, 3), jac_v(3, 3) + INTEGER, INTENT(OUT) :: ErrStat + CHARACTER(*), INTENT(OUT) :: ErrMsg + INTEGER :: k, li, es + CHARACTER(160) :: em + + in_contact = .FALSE. + force = CD_ZERO + jac_q = CD_ZERO + jac_v = CD_ZERO + ErrStat = CD_SYSTEM_OK + ErrMsg = '' + IF (.NOT. ALLOCATED(system%points) .OR. .NOT. ALLOCATED(system%bindings)) RETURN + IF (point_index < 1 .OR. point_index > SIZE(system%points)) RETURN + IF (.NOT. (system%points(point_index)%seabed_k > CD_ZERO .OR. system%points(point_index)%seabed_c > CD_ZERO)) & + RETURN + IF (.NOT. ALLOCATED(system%lines)) RETURN + ! the floor of a bound line, or of any line of the system for a point whose lines have all + ! been detached (a line failure): a clump left without lines still rests on the seabed + li = 0 + DO k = 1, SIZE(system%bindings) + IF (system%bindings(k)%point_id /= system%points(point_index)%id) CYCLE + IF (system%bindings(k)%line_index < 1 .OR. system%bindings(k)%line_index > SIZE(system%lines)) CYCLE + IF (.NOT. system%lines(system%bindings(k)%line_index)%has_seabed) CYCLE + li = system%bindings(k)%line_index + EXIT + END DO + IF (li == 0) THEN + DO k = 1, SIZE(system%lines) + IF (.NOT. system%lines(k)%has_seabed) CYCLE + li = k + EXIT + END DO + END IF + IF (li == 0) RETURN + CALL CD_Model_Seabed_Point_Load(system%lines(li), q, v, system%points(point_index)%seabed_k, & + system%points(point_index)%seabed_c, in_contact, force, jac_q, jac_v, es, em) + IF (es /= CD_MODEL_OK) THEN + in_contact = .FALSE. + force = CD_ZERO + jac_q = CD_ZERO + jac_v = CD_ZERO + WRITE (ErrMsg, '(A,I0,A)') 'CableDyn_System: seabed contact of point ', system%points(point_index)%id, & + ' failed: '//TRIM(em) + ErrStat = system_status_from_model(es) + END IF + END SUBROUTINE CD_System_Point_Seabed + INTEGER FUNCTION CD_System_Point_Base(system, point_index) RESULT(base) !! Zero-based coupled-DOF offset of system point point_index (-1 when unbound). TYPE(CD_SystemType), INTENT(IN) :: system @@ -1646,7 +1715,8 @@ SUBROUTINE CD_Step_System_DynamicPoints(system, dt, converged, stalled, n_iter, INTEGER :: p, base, es, k REAL(wp) :: ma_blk(3, 3), k_blk(3, 3), c_blk(3, 3), rhs3(3), kv_nbr(3) - LOGICAL :: solve_ok + REAL(wp) :: sea_f(3), sea_k(3, 3), sea_c(3, 3) + LOGICAL :: solve_ok, sea_contact LOGICAL, ALLOCATABLE :: integ(:) CHARACTER(1024) :: em @@ -1798,6 +1868,19 @@ SUBROUTINE CD_Step_System_DynamicPoints(system, dt, converged, stalled, n_iter, MATMUL(ma_blk, system%a_work(base + 1:base + 3)) - & dt*(MATMUL(k_blk, system%v_work(base + 1:base + 3)) - kv_nbr) ma_blk = ma_blk + dt*c_blk + dt*dt*k_blk + ! The point's own seabed contact, linearised about the step start like the end + ! blocks: F(q+, v+) = F - K (dt v + dt^2 a+) - C dt a+ (K = -dF/dq, C = -dF/dv), so + ! a light point on a stiff footprint does not bounce. Nothing is added off the floor. + CALL CD_System_Point_Seabed(system, p, system%q_work(base + 1:base + 3), system%v_work(base + 1:base + 3), & + sea_contact, sea_f, sea_k, sea_c, es, em) + IF (es /= CD_SYSTEM_OK) THEN + CALL restore_failed_dynamic_points(system, system%point_rollback, es, em, ErrStat, ErrMsg) + RETURN + END IF + IF (sea_contact) THEN + rhs3 = rhs3 + sea_f - dt*MATMUL(sea_k, system%v_work(base + 1:base + 3)) + ma_blk = ma_blk + dt*sea_c + dt*dt*sea_k + END IF DO k = 1, 3 ma_blk(k, k) = ma_blk(k, k) + system%point_mass_work(p) END DO @@ -2866,7 +2949,8 @@ SUBROUTINE validate_points(points, ErrStat, ErrMsg) CD_All_Finite(points(i)%a) .AND. CD_All_Finite(points(i)%force) .AND. & CD_Is_Finite(points(i)%mass) .AND. & CD_Is_Finite(points(i)%volume) .AND. CD_Is_Finite(points(i)%cda) .AND. & - CD_Is_Finite(points(i)%ca))) THEN + CD_Is_Finite(points(i)%ca) .AND. CD_Is_Finite(points(i)%seabed_k) .AND. & + CD_Is_Finite(points(i)%seabed_c))) THEN CALL fail(ErrStat, ErrMsg, 'point state and load properties must be finite') RETURN END IF @@ -2883,6 +2967,10 @@ SUBROUTINE validate_points(points, ErrStat, ErrMsg) CALL fail(ErrStat, ErrMsg, 'point volume, CdA, and Ca must be non-negative') RETURN END IF + IF (points(i)%seabed_k < CD_ZERO .OR. points(i)%seabed_c < CD_ZERO) THEN + CALL fail(ErrStat, ErrMsg, 'point seabed contact stiffness and damping must be non-negative') + RETURN + END IF DO j = i + 1, SIZE(points) IF (points(j)%id == points(i)%id) THEN CALL fail(ErrStat, ErrMsg, 'point ids must be unique') diff --git a/src/openfast/CableDyn_OF.f90 b/src/openfast/CableDyn_OF.f90 index 1947d4fc..8cab4b7d 100644 --- a/src/openfast/CableDyn_OF.f90 +++ b/src/openfast/CableDyn_OF.f90 @@ -77,7 +77,7 @@ MODULE CableDyn CD_AGG_Snapshot, CD_AGG_Restore, & CD_AGG_NMovingPoints, CD_AGG_NDynamicPoints, CD_AGG_Refresh_PointMesh, & CD_AGG_NFailures, CD_AGG_Get_Substep_Counts, & - CD_AGG_HasRigid6, CD_AGG_HasRod, & + CD_AGG_HasRigid6, CD_AGG_HasRod, CD_AGG_HasPoint3, & CD_AGG_Rigid6_MirrorSize, CD_AGG_Get_Rigid6_States, & CD_AGG_Set_Rigid6_States, & CD_AGG_Rod_MirrorSize, CD_AGG_Get_Rod_States, CD_AGG_Set_Rod_States, & @@ -482,7 +482,8 @@ SUBROUTINE CD_Init(InitInp, u, p, x, xd, z, other, y, m, DTcoupling, InitOut, Er REAL(wp) :: fair_ten, fair_force(3), fair_incl, fair_decl, fair_azi, force_incl LOGICAL :: has_dtm, has_ptfm, use_extf CHARACTER(ChanLen) :: chan_hdr, chan_unt - CHARACTER(1024) :: native_root + CHARACTER(1024) :: native_root, init_note + INTEGER(IntKi) :: note_at, note_end REAL(wp), PARAMETER :: DTM_DEFAULT = 0.1_wp ErrStat = ErrID_None @@ -740,6 +741,15 @@ SUBROUTINE CD_Init(InitInp, u, p, x, xd, z, other, y, m, DTcoupling, InitOut, Er '(linearize a deck without BODIES/RODS).', ErrStat, ErrMsg, RoutineName ) RETURN END IF + ! A Point3 buoy steps as a Free point, but the static solve holds it at its deck position: + ! each perturbed re-solve would leave it there and omit its compliance as well. + IF (InitInp%Linearize .AND. CD_AGG_HasPoint3( Inst(id)%agg )) THEN + CALL SetErrStat( ErrID_Fatal, 'CableDyn mooring module: formal OpenFAST linearization '// & + 'with Point3 buoys is not supported; the quasi-static reduction holds a '// & + 'Point3 buoy at its deck position instead of re-solving its equilibrium '// & + '(model the buoy as a Free point to linearize).', ErrStat, ErrMsg, RoutineName ) + RETURN + END IF IF (InitInp%Linearize .AND. Inst(id)%agg%ncable > 0) THEN DO ic = 1, Inst(id)%agg%ncable ! a line restrained in torsion returns a torque moment that turns with the platform @@ -1167,7 +1177,7 @@ SUBROUTINE CD_Init(InitInp, u, p, x, xd, z, other, y, m, DTcoupling, InitOut, Er CALL WrScr( ' Fairlead convention: force is on End A toward End B; inclinations are signed below horizontal.' ) DO il = 1, nreportlines CALL CD_AGG_GetInitLine( Inst(id)%agg, il, line_id, fair_ten, fair_force, fair_incl, fair_decl, & - fair_azi, es, em ) + fair_azi, es, em, note=init_note ) IF (es /= CD_AGG_OK) THEN CALL SetErrStat( ErrID_Fatal, 'CableDyn mooring module: '//TRIM(em), ErrStat, ErrMsg, RoutineName ) RETURN @@ -1184,6 +1194,18 @@ SUBROUTINE CD_Init(InitInp, u, p, x, xd, z, other, y, m, DTcoupling, InitOut, Er CALL WrScr( ' line tangent: inclination='//TRIM(Num2LStr(REAL(fair_incl, DbKi)))// & ' deg, declination='//TRIM(Num2LStr(REAL(fair_decl, DbKi)))// & ' deg, azimuth='//TRIM(Num2LStr(REAL(fair_azi, DbKi)))//' deg' ) + ! The line's static-initialisation notes (a folded EI = 0 layout, the notes of a + ! finite-EI cable), one per text line, as the standalone driver prints them. + note_at = 1 + DO WHILE (LEN_TRIM(init_note(note_at:)) > 0) + note_end = INDEX(init_note(note_at:), NEW_LINE('a')) + IF (note_end == 0) THEN + CALL WrScr( ' Note: '//TRIM(init_note(note_at:))//'.' ) + EXIT + END IF + CALL WrScr( ' Note: '//init_note(note_at:note_at + note_end - 2)//'.' ) + note_at = note_at + note_end + END DO END DO CALL WrScr( ' CableDyn initialization completed.' ) diff --git a/tests/check_fold_layout.py b/tests/check_fold_layout.py new file mode 100644 index 00000000..24ddf626 --- /dev/null +++ b/tests/check_fold_layout.py @@ -0,0 +1,92 @@ +# SPDX-License-Identifier: Apache-2.0 +"""The layouts behind the EI = 0 fold-note tests (driver_ei0_fold_note_* in CMakeLists.txt). + +Those tests check that a note is printed or not; this one checks that the static layouts are +the ones the notes are about, so that a silent no-note test cannot pass on a layout that never +reached past its anchor. The anchor of each chain is at x = 450 m, its fairlead at x = 0, and +the note threshold is 1 % of the 450 m span plus 0.5 m, so a grounded node past the anchor by +more than 5 m (x > 455 m) is a run carried past it: + +* ei0_hairpin_current.dat (a 2 m/s current, frictionless seabed): the run reaches past the + anchor, and the driver notes it; +* ei0_hairpin_current_friction.dat (the same with frictionMu 0.5): friction holds the run + short of the threshold, so there is nothing to note; +* ei0_aslaid_behind_anchor.dat (staticsFriction asLaid, layAzimuth 0, away from the + fairlead): the run does lie past the anchor, laid there by the deck, which the note skips; +* ei0_fold_turn_current.dat (both ends grounded, the current along the line): the run folds + back on itself, and the node the note names is the deck node of the fold (the farthest + node downstream, numbered from End A as the node channels). + +Usage: check_fold_layout.py +""" + +import pathlib +import re +import subprocess +import sys +import tempfile + +ANCHOR_X = 450.0 +THRESHOLD = 0.01 * 450.0 + 0.5 +FLOOR_Z = -100.0 +GROUNDED_TOL = 0.05 +NODES = 53 + + +def node_positions(exe, deck, stderr=None): + """The static x and z of every node of line 1 (deck node 1 = End A ... 53 = End B); the + driver's stderr is appended to the list stderr when one is given.""" + text = deck.read_text(encoding="utf-8") + head = text.split("--------------------- OUTPUTS")[0] + channels = [f"L1N{k}px" for k in range(1, NODES + 1)] + [f"L1N{k}pz" for k in range(1, NODES + 1)] + body = head + "--------------------- OUTPUTS ---\n" + "\n".join(channels) + "\n--------------------- END ---\n" + with tempfile.TemporaryDirectory() as tmp: + path = pathlib.Path(tmp) / deck.name + path.write_text(body, encoding="utf-8", newline="\n") + run = subprocess.run([exe, str(path), "layout"], cwd=tmp, capture_output=True, text=True) + if run.returncode != 0: + raise SystemExit(f"{deck.name}: driver failed ({run.returncode}):\n{run.stdout}\n{run.stderr}") + if stderr is not None: + stderr.append(run.stderr) + rows = (pathlib.Path(tmp) / "layout.out").read_text(encoding="utf-8").splitlines() + values = [float(v) for v in rows[2].split()[1:]] + return values[:NODES], values[NODES:] + + +def farthest_grounded_x(exe, deck): + xs, zs = node_positions(exe, deck) + grounded = [x for x, z in zip(xs, zs) if z <= FLOOR_Z + GROUNDED_TOL] + if not grounded: + raise SystemExit(f"{deck.name}: no grounded node") + return max(grounded) + + +def main(): + exe, data = str(pathlib.Path(sys.argv[1]).resolve()), pathlib.Path(sys.argv[2]).resolve() + failures = [] + x = farthest_grounded_x(exe, data / "ei0_hairpin_current.dat") + print(f"frictionless current: grounded run reaches x = {x:.3f} m") + if not x > ANCHOR_X + THRESHOLD: + failures.append("the frictionless current deck does not carry the run past its anchor") + x = farthest_grounded_x(exe, data / "ei0_hairpin_current_friction.dat") + print(f"current with frictionMu: grounded run reaches x = {x:.3f} m") + if not x <= ANCHOR_X + THRESHOLD: + failures.append("frictionMu does not hold the run short of its anchor") + x = farthest_grounded_x(exe, data / "ei0_aslaid_behind_anchor.dat") + print(f"as laid behind the anchor: grounded run reaches x = {x:.3f} m") + if not x > ANCHOR_X + THRESHOLD: + failures.append("the as-laid run does not lie past its anchor, so the skipped note is not exercised") + err = [] + xs, _ = node_positions(exe, data / "ei0_fold_turn_current.dat", err) + fold = max(range(NODES), key=lambda k: xs[k]) + 1 + named = re.search(r"deg turn at node (\d+), a hairpin", err[0]) + print(f"fold on itself: the run turns at deck node {fold}, the note names node {named.group(1) if named else None}") + if named is None or int(named.group(1)) != fold: + failures.append("the turn note does not name the deck node of the fold") + for f in failures: + print("FAIL: " + f) + return 1 if failures else 0 + + +if __name__ == "__main__": + sys.exit(main()) diff --git a/tests/data/ei0_aslaid_behind_anchor.dat b/tests/data/ei0_aslaid_behind_anchor.dat new file mode 100644 index 00000000..08443ad3 --- /dev/null +++ b/tests/data/ei0_aslaid_behind_anchor.dat @@ -0,0 +1,34 @@ +--------------------- CableDyn Input File ------------------------------------ +A chain laid from its anchor away from the fairlead (layAzimuth 0, the fairlead lies along 180 deg) and held there by as-laid seabed friction: the deck lays the run past the anchor, so no fold note +--------------------- LINE TYPES --------------------------------------------- +TypeName Diam MassDenInAir EA BA EI Cd_n Cd_t Ca_n Ca_t +(-) (m) (kg/m) (N) (-) (Nm2) (-) (-) (-) (-) +chain 0.216 286.56 1.22976e9 -1 0 1.37 0.64 1 0 +--------------------- POINTS ------------------------------------------------- +ID Type X Y Z +(-) (-) (m) (m) (m) +1 Coupled 0.0 0.0 -10.0 +2 Fixed 450.0 0.0 -100.0 +--------------------- LINES -------------------------------------------------- +ID NodeA NodeB Outputs +(-) (-) (-) (-) +1 1 2 - +--------------------- SECTIONS ----------------------------------------------- +LineID LineType Length NumSegs +(-) (-) (m) (-) +1 chain 520.0 52 +--------------------- OPTIONS ------------------------------------------------ +9.80665 g +1025.0 rhoW +100.0 WtrDpth +1.0e5 kBot +1.0e4 cBot +0.5 frictionMu +asLaid staticsFriction +0.0 layAzimuth +0.05 dtM +0.0 TMax +--------------------- OUTPUTS ------------------------------------------------ +FairTen1 +AnchTen1 +--------------------- END ---------------------------------------------------- diff --git a/tests/data/ei0_clump_no_fold.dat b/tests/data/ei0_clump_no_fold.dat new file mode 100644 index 00000000..0c121c6c --- /dev/null +++ b/tests/data/ei0_clump_no_fold.dat @@ -0,0 +1,35 @@ +--------------------- CableDyn Input File ------------------------------------ +A 50 t clump weight resting on the seabed between two polyester lines, each line grounded at the clump: no line folds (no note) +--------------------- LINE TYPES --------------------------------------------- +TypeName Diam MassDenInAir EA BA EI Cd_n Cd_t Ca_n Ca_t +(-) (m) (kg/m) (N) (-) (Nm2) (-) (-) (-) (-) +poly 0.172 31.916 200000000 -1 0 1.2 0.008 1 0 +--------------------- POINTS ------------------------------------------------- +ID Type X Y Z Mass Vol CdA Ca +(-) (-) (m) (m) (m) (kg) (m3) (m2) (-) +1 Coupled 0 0 -10 0 0 0 0 +2 Fixed 800 0 -200 0 0 0 0 +3 Connect 450 0 -190 50000 0 0 0 +--------------------- LINES -------------------------------------------------- +ID NodeA NodeB Outputs +(-) (-) (-) (-) +1 1 3 - +2 3 2 - +--------------------- SECTIONS ----------------------------------------------- +LineID LineType Length NumSegs +(-) (-) (m) (-) +1 poly 520 52 +2 poly 360 36 +--------------------- OPTIONS ------------------------------------------------ +9.80665 g +1025.0 rhoW +200.0 WtrDpth +1.0e5 kBot +1.0e4 cBot +0.05 dtM +0.0 TMax +--------------------- OUTPUTS ------------------------------------------------ +FairTen1 +AnchTen1 +Point3pz +--------------------- END ---------------------------------------------------- diff --git a/tests/data/ei0_fold_slope.dat b/tests/data/ei0_fold_slope.dat new file mode 100644 index 00000000..436e7e3d --- /dev/null +++ b/tests/data/ei0_fold_slope.dat @@ -0,0 +1,29 @@ +--------------------- CableDyn Input File ------------------------------------ +Chain on a 5 deg frictionless slope falling past its anchor: the grounded run slides 24 m past the anchor and folds back (noted) +--------------------- LINE TYPES --------------------------------------------- +TypeName Diam MassDenInAir EA BA EI Cd_n Cd_t Ca_n Ca_t +(-) (m) (kg/m) (N) (-) (Nm2) (-) (-) (-) (-) +chain 0.216 286.56 1.22976e9 -1 0 1.37 0.64 1 0 +--------------------- POINTS ------------------------------------------------- +ID Type X Y Z +(-) (-) (m) (m) (m) +1 Coupled 0.0 0.0 -10.0 +2 Fixed 450.0 0.0 -300.0 +--------------------- LINES -------------------------------------------------- +ID NodeA NodeB Outputs +(-) (-) (-) (-) +1 1 2 - +--------------------- SECTIONS ----------------------------------------------- +LineID LineType Length NumSegs +(-) (-) (m) (-) +1 chain 700.0 70 +--------------------- OPTIONS ------------------------------------------------ +9.80665 g +1025.0 rhoW +ei0_fold_slope_bathy.txt bathymetryFile +1.0e5 kBot +1.0e4 cBot +--------------------- OUTPUTS ------------------------------------------------ +FairTen1 +AnchTen1 +--------------------- END ---------------------------------------------------- diff --git a/tests/data/ei0_fold_slope_aslaid.dat b/tests/data/ei0_fold_slope_aslaid.dat new file mode 100644 index 00000000..7007f882 --- /dev/null +++ b/tests/data/ei0_fold_slope_aslaid.dat @@ -0,0 +1,33 @@ +--------------------- CableDyn Input File ------------------------------------ +The chain of ei0_fold_slope.dat held by as-laid seabed friction: mu = 0.5 exceeds tan(5 deg), so the run rests where it was laid and does not fold (no note) +--------------------- LINE TYPES --------------------------------------------- +TypeName Diam MassDenInAir EA BA EI Cd_n Cd_t Ca_n Ca_t +(-) (m) (kg/m) (N) (-) (Nm2) (-) (-) (-) (-) +chain 0.216 286.56 1.22976e9 -1 0 1.37 0.64 1 0 +--------------------- POINTS ------------------------------------------------- +ID Type X Y Z +(-) (-) (m) (m) (m) +1 Coupled 0.0 0.0 -10.0 +2 Fixed 450.0 0.0 -300.0 +--------------------- LINES -------------------------------------------------- +ID NodeA NodeB Outputs +(-) (-) (-) (-) +1 1 2 - +--------------------- SECTIONS ----------------------------------------------- +LineID LineType Length NumSegs +(-) (-) (m) (-) +1 chain 700.0 70 +--------------------- OPTIONS ------------------------------------------------ +9.80665 g +1025.0 rhoW +ei0_fold_slope_bathy.txt bathymetryFile +1.0e5 kBot +1.0e4 cBot +0.5 frictionMu +asLaid staticsFriction +0.05 dtM +0.0 TMax +--------------------- OUTPUTS ------------------------------------------------ +FairTen1 +AnchTen1 +--------------------- END ---------------------------------------------------- diff --git a/tests/data/ei0_fold_slope_bathy.txt b/tests/data/ei0_fold_slope_bathy.txt new file mode 100644 index 00000000..4b3d924b --- /dev/null +++ b/tests/data/ei0_fold_slope_bathy.txt @@ -0,0 +1,27 @@ +# x y depth: a plane falling 5 deg toward +x, depth = 260.630101 + tan(5 deg) x +-300.0 -300.0 234.383502 +-300.0 300.0 234.383502 +-200.0 -300.0 243.132369 +-200.0 300.0 243.132369 +-100.0 -300.0 251.881235 +-100.0 300.0 251.881235 +0.0 -300.0 260.630101 +0.0 300.0 260.630101 +100.0 -300.0 269.378968 +100.0 300.0 269.378968 +200.0 -300.0 278.127834 +200.0 300.0 278.127834 +300.0 -300.0 286.876700 +300.0 300.0 286.876700 +400.0 -300.0 295.625567 +400.0 300.0 295.625567 +500.0 -300.0 304.374433 +500.0 300.0 304.374433 +600.0 -300.0 313.123300 +600.0 300.0 313.123300 +700.0 -300.0 321.872166 +700.0 300.0 321.872166 +800.0 -300.0 330.621032 +800.0 300.0 330.621032 +900.0 -300.0 339.369899 +900.0 300.0 339.369899 diff --git a/tests/data/ei0_fold_turn_current.dat b/tests/data/ei0_fold_turn_current.dat new file mode 100644 index 00000000..5a38544e --- /dev/null +++ b/tests/data/ei0_fold_turn_current.dat @@ -0,0 +1,32 @@ +--------------------- CableDyn Input File ------------------------------------ +Slack chain between two grounded ends, a 2 m/s current along it on a frictionless seabed: the run folds back on itself at a deck node (noted) +--------------------- LINE TYPES --------------------------------------------- +TypeName Diam MassDenInAir EA BA EI Cd_n Cd_t Ca_n Ca_t +(-) (m) (kg/m) (N) (-) (Nm2) (-) (-) (-) (-) +chain 0.216 286.56 1.22976e9 -1 0 1.37 0.64 1 0 +--------------------- POINTS ------------------------------------------------- +ID Type X Y Z +(-) (-) (m) (m) (m) +1 Coupled 0.0 0.0 -100.0 +2 Fixed 450.0 0.0 -100.0 +--------------------- LINES -------------------------------------------------- +ID NodeA NodeB Outputs +(-) (-) (-) (-) +1 1 2 - +--------------------- SECTIONS ----------------------------------------------- +LineID LineType Length NumSegs +(-) (-) (m) (-) +1 chain 520.0 52 +--------------------- OPTIONS ------------------------------------------------ +9.80665 g +1025.0 rhoW +100.0 WtrDpth +1.0e5 kBot +1.0e4 cBot +0.05 dtM +0.0 TMax +uniform 2.0 0 0 current +--------------------- OUTPUTS ------------------------------------------------ +FairTen1 +AnchTen1 +--------------------- END ---------------------------------------------------- diff --git a/tests/data/ei0_hairpin_current.dat b/tests/data/ei0_hairpin_current.dat new file mode 100644 index 00000000..4dd89a1f --- /dev/null +++ b/tests/data/ei0_hairpin_current.dat @@ -0,0 +1,32 @@ +--------------------- CableDyn Input File ------------------------------------ +Chain pushed 20 m past its anchor by a 2 m/s current along its plane on a frictionless seabed (a hairpin, noted) +--------------------- LINE TYPES --------------------------------------------- +TypeName Diam MassDenInAir EA BA EI Cd_n Cd_t Ca_n Ca_t +(-) (m) (kg/m) (N) (-) (Nm2) (-) (-) (-) (-) +chain 0.216 286.56 1.22976e9 -1 0 1.37 0.64 1 0 +--------------------- POINTS ------------------------------------------------- +ID Type X Y Z +(-) (-) (m) (m) (m) +1 Coupled 0.0 0.0 -10.0 +2 Fixed 450.0 0.0 -100.0 +--------------------- LINES -------------------------------------------------- +ID NodeA NodeB Outputs +(-) (-) (-) (-) +1 1 2 - +--------------------- SECTIONS ----------------------------------------------- +LineID LineType Length NumSegs +(-) (-) (m) (-) +1 chain 520.0 52 +--------------------- OPTIONS ------------------------------------------------ +9.80665 g +1025.0 rhoW +100.0 WtrDpth +1.0e5 kBot +1.0e4 cBot +0.05 dtM +0.0 TMax +uniform 2.0 0 0 current +--------------------- OUTPUTS ------------------------------------------------ +FairTen1 +AnchTen1 +--------------------- END ---------------------------------------------------- diff --git a/tests/data/ei0_hairpin_current_friction.dat b/tests/data/ei0_hairpin_current_friction.dat new file mode 100644 index 00000000..389d04e9 --- /dev/null +++ b/tests/data/ei0_hairpin_current_friction.dat @@ -0,0 +1,33 @@ +--------------------- CableDyn Input File ------------------------------------ +The chain of ei0_hairpin_current.dat on a seabed with friction: frictionMu holds the grounded run in the 2 m/s current, so it does not fold (no note) +--------------------- LINE TYPES --------------------------------------------- +TypeName Diam MassDenInAir EA BA EI Cd_n Cd_t Ca_n Ca_t +(-) (m) (kg/m) (N) (-) (Nm2) (-) (-) (-) (-) +chain 0.216 286.56 1.22976e9 -1 0 1.37 0.64 1 0 +--------------------- POINTS ------------------------------------------------- +ID Type X Y Z +(-) (-) (m) (m) (m) +1 Coupled 0.0 0.0 -10.0 +2 Fixed 450.0 0.0 -100.0 +--------------------- LINES -------------------------------------------------- +ID NodeA NodeB Outputs +(-) (-) (-) (-) +1 1 2 - +--------------------- SECTIONS ----------------------------------------------- +LineID LineType Length NumSegs +(-) (-) (m) (-) +1 chain 520.0 52 +--------------------- OPTIONS ------------------------------------------------ +9.80665 g +1025.0 rhoW +100.0 WtrDpth +1.0e5 kBot +1.0e4 cBot +0.5 frictionMu +0.05 dtM +0.0 TMax +uniform 2.0 0 0 current +--------------------- OUTPUTS ------------------------------------------------ +FairTen1 +AnchTen1 +--------------------- END ---------------------------------------------------- diff --git a/tests/data/fei_hairpin_current.dat b/tests/data/fei_hairpin_current.dat new file mode 100644 index 00000000..88e6e97c --- /dev/null +++ b/tests/data/fei_hairpin_current.dat @@ -0,0 +1,37 @@ +--------------------- CableDyn Input File --------------------------- +Finite-EI lazy wave carried 2 m past its anchor by a 1.9 m/s current on a frictionless seabed (the cable statics matrix case CUR_1013; noted) +--------------------- LINE TYPES ------------------------------------ +TypeName Diam MassDenInAir EA BA EI Cd_n Cd_t Ca_n Ca_t +(-) (m) (kg/m) (N) (-) (N-m2) (-) (-) (-) (-) +bare 0.1784650716 82.63060908 255233842 0 25945.91551 1.2 0.1 1 0 +buoy 0.4710966462 88.94142595 255233842 0 40205.41756 1.2 0.1 1 0 +--------------------- POINTS ---------------------------------------- +ID Type X Y Z +(-) (-) (m) (m) (m) +1 Coupled 0 0 -13.08348484 +2 Fixed 41.77649681 0 -42.543 +--------------------- LINES ----------------------------------------- +ID NodeA NodeB Outputs +(-) (-) (-) (-) +1 1 2 - +--------------------- SECTIONS -------------------------------------- +LineID LineType Length NumSegs +(-) (-) (m) (-) +1 bare 20.5504 2 +1 buoy 7.3589 1 +1 bare 35.1167 4 +--------------------- OPTIONS --------------------------------------- +9.80665 g +1025.0 rhoW +42.543 WtrDpth +3e+06 kBot +1.0e4 cBot +0.05 dtM +0.0 TMax +False adaptive_mesh +True tensile_safety +uniform 1.906 0.0 0.0 current +--------------------- OUTPUTS --------------------------------------- +"FairTen1" +"AnchTen1" +--------------------- need this line -------------------------------- diff --git a/tests/test_point_seabed_contact.f90 b/tests/test_point_seabed_contact.f90 new file mode 100644 index 00000000..bcd7c056 --- /dev/null +++ b/tests/test_point_seabed_contact.f90 @@ -0,0 +1,442 @@ +! File: tests/test_point_seabed_contact.f90 +! SPDX-License-Identifier: Apache-2.0 +! Copyright (c) 2026 Jae Hoon Seo, SMI Lab, Inha University +PROGRAM test_point_seabed_contact + !! Seabed contact of Free/Connect points, and the fold note of EI = 0 lines. + !! + !! A 50 t clump weight (Mass only, Vol = 0) joins two polyester lines on the seabed. Its + !! footprint is A = (Mass/7850)^(2/3) (the volume of solid steel of that mass), so its own + !! contact has the stiffness kBot*A. Without it only the two line end nodes held the clump + !! and it sank 2.8 m below the seabed. Checked on every route that steps the point: + !! * the static equilibrium (TMax = 0, multibody march): the clump rests within the + !! penetration of its own footprint, 0 < pen <= W/(kBot*A), and its contact reaction + !! kBot*A*pen balances its weight with the line forces on it (Point

Fz); + !! * the dynamic march, monolithic and staggered (the point system step), from that + !! equilibrium: the clump stays at rest; + !! * the OpenFAST aggregate (the coupled point step): the clump stays at rest; + !! * a sloped structured seabed: the clump rests on the bathymetry, also at rest in the + !! staggered and monolithic marches (the monolithic residual along the surface normal); + !! * a Point3 buoy of the same mass (a BODY whose Body attachment is the system Free + !! point; the static solve does not place it) set at the clump's static position: it + !! stays at rest in the staggered and monolithic marches and the aggregate step, which + !! it would not without its own footprint; + !! * a buoy tethered 4 m above the seabed: its contact is inactive, so its line forces + !! balance its net buoyancy exactly and it stays at rest. + !! An EI = 0 line pushed past its anchor by a current on a frictionless seabed (a hairpin) + !! is kept and named by a note; through the OpenFAST aggregate the note is returned with + !! the line's initialisation report (CD_AGG_GetInitLine). + USE CableDyn_Precision, ONLY: wp + USE CableDyn_DeckDriver, ONLY: CD_Run_Deck_Driver, CD_DECKDRV_OK + USE CableDyn_OpenFAST_Aggregate, ONLY: CD_AGG_ModuleType, CD_AGG_Init_From_Deck, CD_AGG_GetInitLine, & + CD_AGG_EvalChannel, CD_AGG_GetMovingPointMesh, CD_AGG_Step_Moving, & + CD_AGG_CalcOutput, CD_AGG_End, CD_AGG_OK + USE, INTRINSIC :: IEEE_ARITHMETIC, ONLY: IEEE_IS_FINITE + IMPLICIT NONE + + REAL(wp), PARAMETER :: G = 9.80665_wp, KBOT = 1.0e5_wp, MASS = 50000.0_wp, STEEL = 7850.0_wp + ! columns of the .out rows: Time, FairTen1, AnchTen1, FairTen2, AnchTen2, Point3Fx/Fy/Fz, Point3px/py/pz + INTEGER, PARAMETER :: NCOL = 11 + INTEGER :: failures + REAL(wp) :: area, k_clump, w_clump + ! the clump's static position on the flat seabed (case_flat_static), where the Point3 buoy is set + REAL(wp) :: eq_x = 0.0_wp, eq_z = 0.0_wp + LOGICAL :: have_eq = .FALSE. + CHARACTER(160) :: p3_body + + failures = 0 + area = (MASS/STEEL)**(2.0_wp/3.0_wp) + k_clump = KBOT*area + w_clump = MASS*G + + CALL case_flat_static() + CALL case_flat_march('monolithic') + CALL case_flat_march('staggered') + CALL case_slope('staggered') + CALL case_slope('monolithic') + CALL case_flat_aggregate('point_seabed_agg.dat', 'aggregate clump', '') + IF (have_eq) THEN + WRITE (p3_body, '(A,ES24.16,A,ES24.16,A)') '1 Point3 ', eq_x, ' 0.0 ', eq_z, ' 0 0 0 50000 0 0 0 0 0 0' + CALL case_point3_march('staggered') + CALL case_point3_march('monolithic') + CALL case_flat_aggregate('point_seabed_p3_agg.dat', 'aggregate Point3 buoy', TRIM(p3_body)) + ELSE + CALL require(.FALSE., 'Point3 buoy: no clump equilibrium to start from') + END IF + CALL case_clear_buoy() + CALL case_fold_note_aggregate() + + IF (failures /= 0) THEN + WRITE (*, '(A,I0,A)') 'test_point_seabed_contact: ', failures, ' failure(s)' + ERROR STOP 1 + END IF + WRITE (*, '(A)') 'test_point_seabed_contact: all checks passed' + +CONTAINS + + SUBROUTINE case_flat_static() + REAL(wp), ALLOCATABLE :: rows(:, :) + REAL(wp) :: pen, residual + INTEGER :: es + LOGICAL :: conv + CHARACTER(512) :: em + + CALL write_clump_deck('point_seabed_flat_static.dat', '0.0', '', .FALSE.) + CALL CD_Run_Deck_Driver('point_seabed_flat_static.dat', 'point_seabed_flat_static', conv, es, em) + CALL require(es == CD_DECKDRV_OK .AND. conv, 'flat static: run: '//TRIM(em)) + IF (es /= CD_DECKDRV_OK) RETURN + CALL read_rows('point_seabed_flat_static.out', rows) + IF (SIZE(rows, 2) < 1) THEN + CALL require(.FALSE., 'flat static: no output row') + RETURN + END IF + pen = -200.0_wp - rows(11, 1) + WRITE (*, '(A,F8.4,A,F8.4,A)') ' flat seabed: clump ', pen, ' m below the seabed (footprint limit ', & + w_clump/k_clump, ' m)' + ! base behaviour: 2.8 m, held by the two line end nodes only + CALL require(pen > 0.0_wp, 'flat static: the clump rests on the seabed') + CALL require(pen <= w_clump/k_clump, 'flat static: the clump rests within the penetration of its footprint') + ! weight = line forces on the point + the footprint's reaction (Point3Fz is printed to 8 digits) + residual = rows(8, 1) + k_clump*pen - w_clump + CALL require(ABS(residual) <= 1.0e-4_wp*w_clump, 'flat static: the footprint reaction kBot*A*pen balances '// & + 'the clump with its lines') + eq_x = rows(9, 1) + eq_z = rows(11, 1) + have_eq = ABS(rows(10, 1)) < 1.0e-9_wp + END SUBROUTINE case_flat_static + + SUBROUTINE case_point3_march(scheme) + !! A Point3 buoy of the clump's mass (BODY Mass 50000, Vol 0) set at the clump's static + !! position: no static solve places a Point3, so it starts there, and it stays at rest only + !! if its own footprint carries the share of its weight that the clump's did, kBot*A*pen = + !! 3.44e5 N/m * 0.95 m = 3.3e5 N (without it the buoy sinks about 2.8 m into the seabed + !! over the 2 s march, against the 1e-3 m bound here). + CHARACTER(*), INTENT(IN) :: scheme + REAL(wp), ALLOCATABLE :: rows(:, :) + INTEGER :: es + LOGICAL :: conv + CHARACTER(512) :: em + CHARACTER(64) :: root + + root = 'point_seabed_p3_'//scheme + CALL write_clump_deck(TRIM(root)//'.dat', '2.0', scheme, .FALSE., body_row=TRIM(p3_body)) + CALL CD_Run_Deck_Driver(TRIM(root)//'.dat', TRIM(root), conv, es, em) + CALL require(es == CD_DECKDRV_OK .AND. conv, 'Point3 '//scheme//' march: run: '//TRIM(em)) + IF (es /= CD_DECKDRV_OK) RETURN + CALL read_rows(TRIM(root)//'.out', rows) + CALL require(SIZE(rows, 2) > 10, 'Point3 '//scheme//' march: output rows') + IF (SIZE(rows, 2) < 2) RETURN + CALL require(ALL(IEEE_IS_FINITE(rows)), 'Point3 '//scheme//' march: finite outputs') + CALL require(ABS(rows(9, 1) - eq_x) < 1.0e-6_wp .AND. ABS(rows(11, 1) - eq_z) < 1.0e-6_wp, & + 'Point3 '//scheme//' march: the buoy starts at the clump''s static position') + WRITE (*, '(A,ES10.2,A)') ' Point3 buoy ('//scheme//'): largest drift ', & + MAXVAL(ABS(rows(9:11, :) - SPREAD(rows(9:11, 1), 2, SIZE(rows, 2)))), ' m' + CALL require(MAXVAL(ABS(rows(9:11, :) - SPREAD(rows(9:11, 1), 2, SIZE(rows, 2)))) < 1.0e-3_wp, & + 'Point3 '//scheme//' march: the buoy stays at rest on its own footprint') + END SUBROUTINE case_point3_march + + SUBROUTINE case_clear_buoy() + !! A buoy (Mass 1 t, Vol 10 m^3) tethered 4 m above the seabed by a 4 m line to an anchor + !! below it: its contact is inactive (exactly zero), so the line forces on it balance its + !! net buoyancy alone, statically and through the march. + REAL(wp), ALLOCATABLE :: rows(:, :) + REAL(wp) :: b_net + INTEGER :: es, run + LOGICAL :: conv + CHARACTER(512) :: em + CHARACTER(64) :: root + + b_net = (1025.0_wp*10.0_wp - 1000.0_wp)*G + DO run = 1, 2 + IF (run == 1) THEN + root = 'point_seabed_clear_static' + CALL write_clump_deck(TRIM(root)//'.dat', '0.0', '', .FALSE., point_row='3 Connect 450 0 -190 1000 10 0 0', & + anchor_row='2 Fixed 450 0 -200 0 0 0 0', sec2='2 poly 4 4') + ELSE + root = 'point_seabed_clear_staggered' + CALL write_clump_deck(TRIM(root)//'.dat', '2.0', 'staggered', .FALSE., & + point_row='3 Connect 450 0 -190 1000 10 0 0', anchor_row='2 Fixed 450 0 -200 0 0 0 0', & + sec2='2 poly 4 4') + END IF + CALL CD_Run_Deck_Driver(TRIM(root)//'.dat', TRIM(root), conv, es, em) + CALL require(es == CD_DECKDRV_OK .AND. conv, 'clear buoy: run: '//TRIM(em)) + IF (es /= CD_DECKDRV_OK) CYCLE + CALL read_rows(TRIM(root)//'.out', rows) + IF (SIZE(rows, 2) < 1) THEN + CALL require(.FALSE., 'clear buoy: no output row') + CYCLE + END IF + WRITE (*, '(A,F8.4,A)') ' tethered buoy: ', rows(11, 1) + 200.0_wp, ' m above the seabed' + CALL require(rows(11, 1) > -200.0_wp + 3.0_wp, 'clear buoy: the buoy is clear of the seabed') + ! Point3Fz, the line forces on the buoy, balances its net buoyancy with no seabed reaction + CALL require(ABS(rows(8, 1) + b_net) <= 1.0e-6_wp*b_net, 'clear buoy: the line forces balance the net '// & + 'buoyancy alone (no contact)') + IF (run == 2) CALL require(MAXVAL(ABS(rows(9:11, :) - SPREAD(rows(9:11, 1), 2, SIZE(rows, 2)))) < 1.0e-3_wp, & + 'clear buoy: the buoy stays at rest') + END DO + END SUBROUTINE case_clear_buoy + + SUBROUTINE case_flat_march(scheme) + CHARACTER(*), INTENT(IN) :: scheme + REAL(wp), ALLOCATABLE :: rows(:, :) + INTEGER :: es + LOGICAL :: conv + CHARACTER(512) :: em + CHARACTER(64) :: root + + root = 'point_seabed_flat_'//scheme + CALL write_clump_deck(TRIM(root)//'.dat', '2.0', scheme, .FALSE.) + CALL CD_Run_Deck_Driver(TRIM(root)//'.dat', TRIM(root), conv, es, em) + CALL require(es == CD_DECKDRV_OK .AND. conv, 'flat '//scheme//' march: run: '//TRIM(em)) + IF (es /= CD_DECKDRV_OK) RETURN + CALL read_rows(TRIM(root)//'.out', rows) + CALL require(SIZE(rows, 2) > 10, 'flat '//scheme//' march: output rows') + IF (SIZE(rows, 2) < 2) RETURN + CALL require(ALL(IEEE_IS_FINITE(rows)), 'flat '//scheme//' march: finite outputs') + CALL require(-200.0_wp - rows(11, 1) > 0.0_wp .AND. -200.0_wp - rows(11, 1) <= w_clump/k_clump, & + 'flat '//scheme//' march: the clump starts on its footprint') + CALL require(MAXVAL(ABS(rows(9:11, :) - SPREAD(rows(9:11, 1), 2, SIZE(rows, 2)))) < 1.0e-3_wp, & + 'flat '//scheme//' march: the clump stays at rest on the seabed') + END SUBROUTINE case_flat_march + + SUBROUTINE case_slope(scheme) + CHARACTER(*), INTENT(IN) :: scheme + REAL(wp), ALLOCATABLE :: rows(:, :) + REAL(wp) :: floor_z, gap, s + INTEGER :: es, u + LOGICAL :: conv + CHARACTER(512) :: em + CHARACTER(64) :: root + + ! a plane rising 2 % toward +x under the whole line, depth 200 m at x = 450 m + OPEN (NEWUNIT=u, FILE='point_seabed_slope_bathy.txt', STATUS='REPLACE', ACTION='WRITE') + WRITE (u, '(A)') '-100.0 -100.0 211.0' + WRITE (u, '(A)') '-100.0 100.0 211.0' + WRITE (u, '(A)') '900.0 -100.0 191.0' + WRITE (u, '(A)') '900.0 100.0 191.0' + CLOSE (u) + root = 'point_seabed_slope_'//scheme + CALL write_clump_deck(TRIM(root)//'.dat', '1.0', scheme, .TRUE.) + CALL CD_Run_Deck_Driver(TRIM(root)//'.dat', TRIM(root), conv, es, em) + CALL require(es == CD_DECKDRV_OK .AND. conv, 'slope '//scheme//': run: '//TRIM(em)) + IF (es /= CD_DECKDRV_OK) RETURN + CALL read_rows(TRIM(root)//'.out', rows) + CALL require(SIZE(rows, 2) > 10, 'slope '//scheme//': output rows') + IF (SIZE(rows, 2) < 2) RETURN + floor_z = -(211.0_wp - 0.02_wp*(rows(9, 1) + 100.0_wp)) + gap = floor_z - rows(11, 1) + s = SQRT(1.0_wp + 0.02_wp**2) + WRITE (*, '(A,F8.4,A)') ' sloped seabed ('//scheme//'): clump ', gap, ' m below the seabed' + ! the normal law pushes along the surface normal with k*gap/s, whose vertical part k*gap/s^2 + ! (with the lines' share) carries the weight + CALL require(gap > 0.0_wp .AND. gap <= s*s*w_clump/k_clump, 'slope '//scheme//': the clump rests on its footprint') + CALL require(MAXVAL(ABS(rows(9:11, :) - SPREAD(rows(9:11, 1), 2, SIZE(rows, 2)))) < 1.0e-3_wp, & + 'slope '//scheme//': the clump stays at rest on the sloped seabed') + END SUBROUTINE case_slope + + SUBROUTINE case_flat_aggregate(path, label, body_row) + !! The OpenFAST aggregate (the coupled point step): the clump (or the Point3 buoy of + !! body_row, when not empty) starts on its footprint and stays at rest with the fairlead + !! held. Channel 10 is Point3pz. + CHARACTER(*), INTENT(IN) :: path, label, body_row + TYPE(CD_AGG_ModuleType) :: agg + REAL(wp), PARAMETER :: DT = 0.05_wp + REAL(wp) :: r0(3, 1), v0(3, 1), a0(3, 1), l0(3, 1), z0, z, zmax_dev + INTEGER :: es, s, n_iter + LOGICAL :: cv, st + CHARACTER(512) :: em + + CALL write_clump_deck(path, '0.0', '', .FALSE., body_row=body_row) + CALL CD_AGG_Init_From_Deck(agg, path, DT, es, em) + CALL require(es == CD_AGG_OK, label//': init: '//TRIM(em)) + IF (es /= CD_AGG_OK) RETURN + CALL CD_AGG_EvalChannel(agg, 10, z0, es, em) + CALL require(es == CD_AGG_OK, label//': Point3pz: '//TRIM(em)) + CALL require(-200.0_wp - z0 > 0.0_wp .AND. -200.0_wp - z0 <= w_clump/k_clump, & + label//': it starts on its footprint') + CALL CD_AGG_GetMovingPointMesh(agg, r0, v0, a0, l0, es, em) + CALL require(es == CD_AGG_OK, label//': moving mesh: '//TRIM(em)) + v0 = 0.0_wp + a0 = 0.0_wp + zmax_dev = 0.0_wp + DO s = 1, 40 + CALL CD_AGG_Step_Moving(agg, DT, r0, v0, a0, cv, st, n_iter, es, em) + CALL require(es == CD_AGG_OK .AND. cv, label//': step: '//TRIM(em)) + IF (es /= CD_AGG_OK) EXIT + CALL CD_AGG_CalcOutput(agg, es, em) + CALL CD_AGG_EvalChannel(agg, 10, z, es, em) + zmax_dev = MAX(zmax_dev, ABS(z - z0)) + END DO + WRITE (*, '(A,ES10.2,A)') ' '//label//': largest vertical drift ', zmax_dev, ' m' + CALL require(zmax_dev < 1.0e-3_wp, label//': it stays at rest on the seabed') + CALL CD_AGG_End(agg, es, em) + END SUBROUTINE case_flat_aggregate + + SUBROUTINE case_fold_note_aggregate() + !! The hairpin of an EI = 0 line through the OpenFAST aggregate: kept, and named in the + !! line's initialisation report. + TYPE(CD_AGG_ModuleType) :: agg + INTEGER :: es, u, line_id + REAL(wp) :: ten, force(3), incl, decl, azi + CHARACTER(512) :: em + CHARACTER(1024) :: note + + OPEN (NEWUNIT=u, FILE='point_seabed_hairpin.dat', STATUS='REPLACE', ACTION='WRITE') + WRITE (u, '(A)') '--------------------- CableDyn Input File ---' + WRITE (u, '(A)') 'Chain pushed past its anchor by a 2 m/s current on a frictionless seabed' + WRITE (u, '(A)') '--------------------- LINE TYPES ---' + WRITE (u, '(A)') 'TypeName Diam MassDenInAir EA BA EI Cd_n Cd_t Ca_n Ca_t' + WRITE (u, '(A)') '(-) (m) (kg/m) (N) (-) (Nm2) (-) (-) (-) (-)' + WRITE (u, '(A)') 'chain 0.216 286.56 1229760000 -1 0 1.37 0.64 1 0' + WRITE (u, '(A)') '--------------------- POINTS ---' + WRITE (u, '(A)') 'ID Type X Y Z Mass Vol CdA Ca' + WRITE (u, '(A)') '(-) (-) (m) (m) (m) (kg) (m3) (m2) (-)' + WRITE (u, '(A)') '1 Coupled 0 0 -10 0 0 0 0' + WRITE (u, '(A)') '2 Fixed 450 0 -100 0 0 0 0' + WRITE (u, '(A)') '--------------------- LINES ---' + WRITE (u, '(A)') 'ID NodeA NodeB Outputs' + WRITE (u, '(A)') '(-) (-) (-) (-)' + WRITE (u, '(A)') '1 1 2 -' + WRITE (u, '(A)') '--------------------- SECTIONS ---' + WRITE (u, '(A)') 'LineID LineType Length NumSegs' + WRITE (u, '(A)') '(-) (-) (m) (-)' + WRITE (u, '(A)') '1 chain 520 52' + WRITE (u, '(A)') '--------------------- OPTIONS ---' + WRITE (u, '(A)') '100.0 WtrDpth' + WRITE (u, '(A)') 'uniform 2.0 0 0 current' + WRITE (u, '(A)') '--------------------- OUTPUTS ---' + WRITE (u, '(A)') 'FairTen1' + WRITE (u, '(A)') '--------------------- need this line ---' + CLOSE (u) + CALL CD_AGG_Init_From_Deck(agg, 'point_seabed_hairpin.dat', 0.05_wp, es, em) + CALL require(es == CD_AGG_OK, 'aggregate hairpin: init: '//TRIM(em)) + IF (es /= CD_AGG_OK) RETURN + CALL CD_AGG_GetInitLine(agg, 1, line_id, ten, force, incl, decl, azi, es, em, note=note) + CALL require(es == CD_AGG_OK .AND. line_id == 1, 'aggregate hairpin: init report') + CALL require(INDEX(note, 'the static layout carries the grounded run') > 0 .AND. & + INDEX(note, 'past its anchor') > 0 .AND. INDEX(note, 'the current drives the run') > 0, & + 'aggregate hairpin: the line report carries the fold note: '//TRIM(note)) + CALL CD_AGG_End(agg, es, em) + END SUBROUTINE case_fold_note_aggregate + + SUBROUTINE write_clump_deck(path, tmax, scheme, sloped, body_row, point_row, anchor_row, sec2) + !! The 50 t clump (deck point 3, Mass only) between two polyester lines on a 200 m seabed. + !! body_row (not empty): point 3 is instead the Body1 attachment of this Point3 BODY row; + !! point_row, anchor_row and sec2 replace the rows of point 3, point 2 and line 2's section. + CHARACTER(*), INTENT(IN) :: path, tmax, scheme + LOGICAL, INTENT(IN) :: sloped + CHARACTER(*), INTENT(IN), OPTIONAL :: body_row, point_row, anchor_row, sec2 + INTEGER :: u + LOGICAL :: p3 + p3 = .FALSE. + IF (PRESENT(body_row)) p3 = LEN_TRIM(body_row) > 0 + OPEN (NEWUNIT=u, FILE=path, STATUS='REPLACE', ACTION='WRITE') + WRITE (u, '(A)') '--------------------- CableDyn Input File ---' + WRITE (u, '(A)') 'Heavy clump weight resting on the seabed between two polyester lines' + WRITE (u, '(A)') '--------------------- LINE TYPES ---' + WRITE (u, '(A)') 'TypeName Diam MassDenInAir EA BA EI Cd_n Cd_t Ca_n Ca_t' + WRITE (u, '(A)') '(-) (m) (kg/m) (N) (-) (Nm2) (-) (-) (-) (-)' + WRITE (u, '(A)') 'poly 0.172 31.916 200000000 -1 0 1.2 0.008 1 0' + IF (p3) THEN + WRITE (u, '(A)') '--------------------- BODIES ---' + WRITE (u, '(A)') 'ID Type X Y Z Rot1 Rot2 Rot3 Mass Vol C33 C44 C55 CdA Ca' + WRITE (u, '(A)') '(-) (-) (m) (m) (m) (deg) (deg) (deg) (kg) (m3) (N/m) (Nm/rad) (Nm/rad) (m2) (-)' + WRITE (u, '(A)') TRIM(body_row) + END IF + WRITE (u, '(A)') '--------------------- POINTS ---' + WRITE (u, '(A)') 'ID Type X Y Z Mass Vol CdA Ca' + WRITE (u, '(A)') '(-) (-) (m) (m) (m) (kg) (m3) (m2) (-)' + WRITE (u, '(A)') '1 Coupled 0 0 -10 0 0 0 0' + IF (PRESENT(anchor_row)) THEN + WRITE (u, '(A)') anchor_row + ELSE IF (sloped) THEN + WRITE (u, '(A)') '2 Fixed 800 0 -193 0 0 0 0' + ELSE + WRITE (u, '(A)') '2 Fixed 800 0 -200 0 0 0 0' + END IF + IF (p3) THEN + WRITE (u, '(A)') '3 Body1 0 0 0 0 0 0 0' + ELSE IF (PRESENT(point_row)) THEN + WRITE (u, '(A)') point_row + ELSE + WRITE (u, '(A)') '3 Connect 450 0 -190 50000 0 0 0' + END IF + WRITE (u, '(A)') '--------------------- LINES ---' + WRITE (u, '(A)') 'ID NodeA NodeB Outputs' + WRITE (u, '(A)') '(-) (-) (-) (-)' + WRITE (u, '(A)') '1 1 3 -' + WRITE (u, '(A)') '2 3 2 -' + WRITE (u, '(A)') '--------------------- SECTIONS ---' + WRITE (u, '(A)') 'LineID LineType Length NumSegs' + WRITE (u, '(A)') '(-) (-) (m) (-)' + WRITE (u, '(A)') '1 poly 520 52' + IF (PRESENT(sec2)) THEN + WRITE (u, '(A)') sec2 + ELSE + WRITE (u, '(A)') '2 poly 360 36' + END IF + WRITE (u, '(A)') '--------------------- OPTIONS ---' + WRITE (u, '(A)') '9.80665 g' + WRITE (u, '(A)') '1025.0 rhoW' + IF (sloped) THEN + WRITE (u, '(A)') 'point_seabed_slope_bathy.txt bathymetryFile' + ELSE + WRITE (u, '(A)') '200.0 WtrDpth' + END IF + WRITE (u, '(A)') '100000.0 kBot' + WRITE (u, '(A)') '1.0e4 cBot' + WRITE (u, '(A)') '0.05 dtM' + WRITE (u, '(A)') tmax//' TMax' + IF (LEN_TRIM(scheme) > 0) WRITE (u, '(A)') scheme//' bodyScheme' + WRITE (u, '(A)') '--------------------- OUTPUTS ---' + WRITE (u, '(A)') 'FairTen1' + WRITE (u, '(A)') 'AnchTen1' + WRITE (u, '(A)') 'FairTen2' + WRITE (u, '(A)') 'AnchTen2' + WRITE (u, '(A)') 'Point3Fx' + WRITE (u, '(A)') 'Point3Fy' + WRITE (u, '(A)') 'Point3Fz' + WRITE (u, '(A)') 'Point3px' + WRITE (u, '(A)') 'Point3py' + WRITE (u, '(A)') 'Point3pz' + WRITE (u, '(A)') '--------------------- need this line ---' + CLOSE (u) + END SUBROUTINE write_clump_deck + + SUBROUTINE read_rows(path, rows) + !! The numeric rows of a driver .out file (two header lines), one column per row entry. + CHARACTER(*), INTENT(IN) :: path + REAL(wp), ALLOCATABLE, INTENT(OUT) :: rows(:, :) + REAL(wp) :: row(NCOL) + REAL(wp), ALLOCATABLE :: tmp(:, :) + INTEGER :: u, ios, n + CHARACTER(4096) :: buf + ALLOCATE (rows(NCOL, 0)) + OPEN (NEWUNIT=u, FILE=path, STATUS='OLD', ACTION='READ', IOSTAT=ios) + CALL require(ios == 0, 'open '//path) + IF (ios /= 0) RETURN + READ (u, '(A)', IOSTAT=ios) buf + READ (u, '(A)', IOSTAT=ios) buf + n = 0 + DO + READ (u, '(A)', IOSTAT=ios) buf + IF (ios /= 0) EXIT + READ (buf, *, IOSTAT=ios) row + IF (ios /= 0) EXIT + n = n + 1 + ALLOCATE (tmp(NCOL, n)) + tmp(:, 1:n - 1) = rows + tmp(:, n) = row + CALL MOVE_ALLOC(tmp, rows) + END DO + CLOSE (u) + END SUBROUTINE read_rows + + SUBROUTINE require(ok, label) + LOGICAL, INTENT(IN) :: ok + CHARACTER(*), INTENT(IN) :: label + IF (ok) RETURN + failures = failures + 1 + WRITE (*, '(A)') 'FAIL: '//TRIM(label) + END SUBROUTINE require + +END PROGRAM test_point_seabed_contact diff --git a/tests/test_shared_anchor.f90 b/tests/test_shared_anchor.f90 index d45c27ed..f7bda633 100644 --- a/tests/test_shared_anchor.f90 +++ b/tests/test_shared_anchor.f90 @@ -7,8 +7,9 @@ PROGRAM test_shared_anchor !! anchor resultant Point4F equals the sum of the three single-line decks' anchor forces !! (a Fixed anchor couples nothing) in statics and in a dynamic run with one fairlead !! driven by a motionFile, and each single-line anchor force has the AnchTen magnitude; - !! 2. a Free clump shared by the three lines: its line resultant balances its submerged - !! weight, Point4F + (rhoW V - m) g e3 = 0. + !! 2. a Free clump shared by the three lines, resting on the seabed: its line resultant and + !! its own seabed reaction (kBot A pen over its footprint A = Vol^(2/3)) balance its + !! submerged weight, Point4F + kBot A pen e3 + (rhoW V - m) g e3 = 0. !! 3. the same three fairleads written as Turbine points of a TURBINES section (reference !! position, turbine-local fairlead) and driven by per-turbine rigid-body motion records !! reproduce the Coupled-point deck. @@ -18,7 +19,7 @@ PROGRAM test_shared_anchor USE, INTRINSIC :: IEEE_ARITHMETIC, ONLY: IEEE_IS_FINITE IMPLICIT NONE - REAL(wp), PARAMETER :: RHO_W = 1025.0_wp, GRAV = 9.80665_wp + REAL(wp), PARAMETER :: RHO_W = 1025.0_wp, GRAV = 9.80665_wp, KBOT = 1.0e5_wp ! the default kBot REAL(wp), PARAMETER :: FAIR(3, 3) = RESHAPE([0.0_wp, 0.0_wp, -10.0_wp, 600.0_wp, 0.0_wp, -10.0_wp, & 300.0_wp, 519.615242_wp, -10.0_wp], [3, 3]) REAL(wp), PARAMETER :: ANCHOR(3) = [300.0_wp, 173.205081_wp, -100.0_wp] @@ -128,6 +129,7 @@ SUBROUTINE write_deck(path, which, clump, dynamic, motion) IF (which(j)) WRITE (u, '(A,I0)') 'AnchTen', j END DO WRITE (u, '(A)') 'Point4Fx Point4Fy Point4Fz Point4FH' + IF (clump) WRITE (u, '(A)') 'Point4pz' WRITE (u, '(A)') '--- end ---' CLOSE (u) END SUBROUTINE write_deck @@ -328,15 +330,21 @@ END SUBROUTINE expect_reject SUBROUTINE check_free_clump() REAL(wp), ALLOCATABLE :: d(:, :) - REAL(wp) :: w_sub, err + REAL(wp) :: w_sub, err, pen LOGICAL :: ok CALL write_deck('shared_clump.dat', [.TRUE., .TRUE., .TRUE.], .TRUE., .TRUE., .FALSE.) - CALL run('shared_clump.dat', 'shared_clump', 8, d, ok) + CALL run('shared_clump.dat', 'shared_clump', 9, d, ok) IF (.NOT. ok) RETURN w_sub = (20000.0_wp - RHO_W*2.0_wp)*GRAV - err = NORM2(d(5:7, 1) + [0.0_wp, 0.0_wp, -w_sub])/w_sub - WRITE (*, '(A,ES11.3)') 'shared Free clump: |F_lines + submerged weight|/weight = ', err - CALL require(err <= 1.0e-6_wp, 'shared free point: line resultant balances the submerged weight') + ! the clump rests on the 100 m seabed on its own footprint, (2 m^3)^(2/3) + pen = -100.0_wp - d(9, 1) + CALL require(pen > 0.0_wp .AND. pen <= w_sub/(KBOT*2.0_wp**(2.0_wp/3.0_wp)), & + 'shared free point: the clump rests on its footprint') + err = NORM2(d(5:7, 1) + [0.0_wp, 0.0_wp, KBOT*2.0_wp**(2.0_wp/3.0_wp)*MAX(pen, 0.0_wp) - w_sub])/w_sub + WRITE (*, '(A,ES11.3)') 'shared Free clump: |F_lines + seabed reaction + submerged weight|/weight = ', err + ! the depth is printed to 8 digits (1e-5 m at 100 m), and kBot A 1e-5 m is 1e-5 of the weight + CALL require(err <= 2.0e-5_wp, 'shared free point: line resultant and seabed reaction balance the '// & + 'submerged weight') END SUBROUTINE check_free_clump END PROGRAM test_shared_anchor diff --git a/tests/test_statics_robustness.py b/tests/test_statics_robustness.py index 465a8ca1..4975d085 100644 --- a/tests/test_statics_robustness.py +++ b/tests/test_statics_robustness.py @@ -607,7 +607,8 @@ def evaluate(case, exe): def check_points(case, row): - """Every Free/Connect point is at rest: the line-end forces balance its weight/buoyancy.""" + """Every Free/Connect point is at rest: the line-end forces and its own seabed contact balance its + weight/buoyancy.""" for p in case["points"]: if p["type"] not in ("Free", "Connect"): continue @@ -633,6 +634,13 @@ def check_points(case, row): if P[end][2] < zf: net[2] += 0.5 * case["kbot"] * t["d"] * l0 * (zf - P[end][2]) scale = max(scale, te) + # ... and by its own contact over its footprint A = V^(2/3) (V = Vol, or Mass/7850 kg/m^3), + # the line law along the floor normal + vol = p.get("vol", 0.0) if p.get("vol", 0.0) > 0.0 else p.get("mass", 0.0) / 7850.0 + zf, gx, gy = case["floor"](*pos[:2]) + if vol > 0.0 and pos[2] < zf: + s = math.sqrt(1.0 + gx * gx + gy * gy) + net += case["kbot"] * vol ** (2.0 / 3.0) * (zf - pos[2]) / s * np.array([-gx, -gy, 1.0]) / s check(np.linalg.norm(net) < 1e-3 * scale, "%s: point %d force balance %.3g of %.3g N" % (case["name"], p["id"], np.linalg.norm(net), scale)) From cd1aaa5b0a2f9a0271bdca2490d221272b37b48c Mon Sep 17 00:00:00 2001 From: Jae Hoon Seo Date: Tue, 20 Oct 2026 18:44:15 +0900 Subject: [PATCH 23/31] fix(statics): refine locally; robust attachment polish (#29) A finite-EI mesh too coarse for its static curvature was refined as a whole, every element split by the factor the worst one needed: a 462-element lazy wave was solved on 7392 elements in 10.0 s. The static solve now splits only the elements that need it (curvature, half the bending length, the end boundary layer, an isolated contact change) and grades the mesh around them; the deck above solves on 492 elements in 0.33 s with end tensions within 4e-7. Every deck node stays a node, so node channels still name deck nodes, and decks that do not refine give identical output. The discrete-attachment polish of a lazy wave with 25 modules in a 0.3 m/s cross current on a frictional seabed diverged at load fraction 0.125. A step that does not converge is now repeated with pseudo-transient continuation, then a residual-merit line search, and halved; the state reached must pass the smeared state's checks or the solve fails closed. The deck solves within 0.2 % of its smeared twin, and polishes that converged before take the same solves. CD_HermiteCable_Static_Solve_AutoMesh takes an optional max_elements (a lower element limit than 8192; callers are unchanged), so the test of the element-limit priorities runs on a small, well-conditioned line. Signed-off-by: Jae Hoon Seo --- CHANGELOG.md | 55 ++++ CMakeLists.txt | 13 + doc/outputs.rst | 6 +- doc/theory.rst | 44 ++- doc/troubleshooting.rst | 29 ++ src/CableDyn_DeckDriver.f90 | 424 ++++++++++++++++++++----- src/CableDyn_HermiteCableStatic.f90 | 387 ++++++++++++++++++++-- tests/test_attachment_cross_current.py | 119 +++++++ tests/test_deck_hermite_cable.f90 | 29 +- tests/test_hermite_automesh.f90 | 240 ++++++++++++++ tests/test_line_attachments.f90 | 56 +++- tests/test_openfast_aggregate.f90 | 6 +- 12 files changed, 1288 insertions(+), 120 deletions(-) create mode 100644 tests/test_attachment_cross_current.py diff --git a/CHANGELOG.md b/CHANGELOG.md index 0d3639aa..ffcd8df7 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -675,6 +675,61 @@ All notable changes to CableDyn are recorded in this file. The format follows `clump_weight_free_point.dat`, whose clump now rests 4.7 cm deep instead of 6.6 cm and whose anchor tension falls from 186 kN to 92 kN; decks whose points stay clear of the seabed give identical output. See the manual's theory page (Seabed contact). +- A finite-EI deck mesh that cannot resolve the curvature of its static equilibrium (an + element folded beyond `L0*kappa = 0.7`), and a fragile mesh under `adaptive_mesh True`, are + now refined locally instead of as a whole. The static solve had multiplied every element by + the power of two that the worst one needed, up to 16, even when only one section was coarse: + a 462-element lazy wave whose 180 m top section had two elements was solved on 7392 elements + in 10.0 s, and a 410-element lazy wave with a rigid horizontal hang-off on 6560 elements in + 9.2 s. A refinement pass now splits into 2, 4, 8 or 16 equal elements only the elements whose + `L0*kappa` exceeds 0.12 (or the stricter `adaptive_mesh` target), that are longer than half + their bending length `(EI/|w|)^(1/3)`, or, at a line end, longer than the boundary layer + `sqrt(EI/T)`, and the elements about an isolated seabed-contact change, and grades the mesh + into the neighbouring elements (no element more than twice as long as the next, unless the + deck mesh has a larger ratio there). The cap of 16 per deck element, the element limit, the + acceptance checks and the fail-closed messages are unchanged; where a pass would exceed the + element limit, the bending-length splits give way first, then the grading, and only then the + curvature, end-layer and contact splits, and a refinement that stops short of its target + names what stopped it (the cap, the element limit or the limit of 12 passes, 16 for the + axial passes). The two decks above now solve on 492 and 436 elements in 0.33 s and 0.28 s, + with end tensions within 4e-7 and 2e-6 of the whole-line refinement and nodes within 0.7 mm + and 4 mm. The lazy wave of the node-channel entry above (its top section on 4 elements) now + refines to 269 elements instead of 1136, with node tensions within 0.9 N (of 1.2 to 12 kN) + of the same line on 1560 elements of 0.25 to 0.5 m. In the finite-EI statics matrix 61 + of the 123 decks refine: their CPU time falls from 65 s to 33 s, the end tensions change by + at most 0.21 % of the line's peak end tension (a 58 m line on 2 m end elements, whose + hang-off tension moves from 1157.5 N to 1155.1 N; 1157.5 N on a mesh 16 times finer) and the + nodes by at most 6.4e-4 of the line length. In a 761-deck statics robustness campaign 57 + decks refine: they solve in 18 s instead of 63 s, with the same outcomes and notes (two no + longer need the static residual floor note), end tensions within 1e-5 of the peak end + tension and nodes within 3.2e-5 of the line length. + Decks that do not refine, including every shipped example, give identical output. On a + deck that refines, the dynamics run on the new mesh; the local refinement only splits deck + elements, so every deck node is a node of the new mesh and the node output channels still + name deck nodes (see the node-channel entry above). +- A finite-EI line with discrete buoyancy modules (`ATTACHMENTS`) in a cross current on a + frictional seabed no longer fails its static solve. The lazy wave of + `tests/data/lazy_wave_touchdown_planar_refined_att.dat` (25 modules on 2 m elements) in a + 0.3 m/s current across its plane stopped with `finite-EI static solve with discrete + ATTACHMENTS failed at load fraction 0.125 (relative residual 1.304E+02)`. The homotopy from + the smeared to the lumped modules adds the module drag, which the smeared equilibrium does + not carry, and on the frictional seabed the damped Newton update for it overshot and + diverged from the first step, even in steps of 1/64 of the load; the seed and the step size + were not the cause. A step whose damped Newton solve does not converge is now repeated from + the last converged state with pseudo-transient continuation and then with a residual-merit + line search, and halved (down to 1/1024) when neither converges. A halved step doubles + again (up to 1/8) after two consecutive converged steps of its size, and each time a + doubled step fails, the number of converged steps a doubling waits for doubles; at most 64 + load steps may fail in all. A discrete state reached this way must pass the checks the + smeared state passed (the kink limit, except on the elements beside an attachment node, + which carry its slope jump as curvature at any mesh size; the tensile contract under + `tensile_safety True`; the physical-branch audit; the stability test), or the solve fails + closed naming the check; a state that passes them is reported in a note. The deck now solves in + 1.8 s, its fairlead and anchor tensions within 0.04 % and 0.2 % of the deck with the + equivalent smeared buoyancy section; in 0.6 m/s, and on the coarse mesh, it solved before + and its results are unchanged. A polish whose Newton steps all converge takes the same + solves as before, so every other deck is unchanged. A new test (`attachment_cross_current`) + checks the four cases against their smeared twins. - The development environment (`environment.yml`) excludes OpenBLAS 0.3.34, which caused the access violation in the modal analysis tests listed under Known issues for 0.1.1. On AMD Zen 4 and Zen 5 CPUs that expose AVX-512, OpenBLAS 0.3.34 enlarges the GEMM blocking, diff --git a/CMakeLists.txt b/CMakeLists.txt index e86a8a0b..e602d2ee 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -1458,6 +1458,19 @@ if(Python3_Interpreter_FOUND) TIMEOUT 600 ENVIRONMENT "${_cabledyn_python_test_environment}") + # Discrete buoyancy modules on a lazy wave in a cross current (the attachment polish falls + # back from diverging Newton steps on the frictional seabed): the static solve converges and + # its end tensions match the equivalent smeared section. + add_test(NAME attachment_cross_current + COMMAND ${Python3_EXECUTABLE} ${CMAKE_CURRENT_SOURCE_DIR}/tests/test_attachment_cross_current.py + --exe $ + --data ${CMAKE_CURRENT_SOURCE_DIR}/tests/data + --output ${CMAKE_BINARY_DIR}/attachment_cross_current) + set_tests_properties(attachment_cross_current PROPERTIES + LABELS "python;hermite;static;robustness;attachments" + TIMEOUT 600 + ENVIRONMENT "${_cabledyn_python_test_environment}") + # Finite-EI generalised-alpha blends: force-blend dtM convergence under prescribed surge. add_test(NAME hermite_force_blend_dt COMMAND ${Python3_EXECUTABLE} ${CMAKE_CURRENT_SOURCE_DIR}/tests/test_hermite_force_blend_dt.py diff --git a/doc/outputs.rst b/doc/outputs.rst index eedcd047..989ed591 100644 --- a/doc/outputs.rst +++ b/doc/outputs.rst @@ -485,9 +485,9 @@ Node channels on a refined line ```` is always a node of the **deck** mesh. The static solve of a finite-EI line can refine its mesh (``OPTIONS adaptive_mesh``, or the automatic refinement after a failed stability test or an unresolved curvature, which a note of the initialization report names). A refinement splits -deck elements, so each deck node is a node of the refined mesh at the same unstretched arc length -from End A, and ``TenN``, ``CurvN``, ``BendMomN``, ``LN…``, -``TorqN`` and ``TwistN`` report deck node ``J`` there, on every route (standalone, +deck elements (along the whole line or only where the state needs it), so each deck node is a +node of the refined mesh at the same unstretched arc length from End A, and ``TenN``, +``CurvN``, ``BendMomN``, ``LN…``, ``TorqN`` and ``TwistN`` report deck node ``J`` there, on every route (standalone, mixed, multibody, OpenFAST and the C API ``CableDyn_EvalChannel``). ``.static.out``, the range graphs, the per-line files and the C API ``CableDyn_GetLineValues`` list every node of the refined mesh instead, and ``.elements.out`` every element. To find deck node ``J`` among them, diff --git a/doc/theory.rst b/doc/theory.rst index a75319ba..b696d11b 100644 --- a/doc/theory.rst +++ b/doc/theory.rst @@ -1276,9 +1276,28 @@ mesh-sequenced route described below first and this route as its fallback): does not converge is restarted at full ``EI``. 3. **Polish and diagnosis** on the deck mesh at the static tolerance. A residual floor above it is accepted at :math:`10^{-6}` (or, for a line on the seabed, :math:`10^{-5}`, nodes - alternating across the 1 µm contact blend) and reported. A deck mesh too coarse for the - bending length (continuation or polish failing, or an element folded beyond - :math:`L_0\kappa = 0.7`) repeats the route on a mesh refined until the elements are at most + alternating across the 1 µm contact blend) and reported. An element folded beyond + :math:`L_0\kappa = 0.7` on the deck mesh is refined locally, from the polished state, until + no element exceeds :math:`L_0\kappa = 0.35`; ``adaptive_mesh`` refines the same way, to its + own target. A refinement pass splits into :math:`2^k` equal elements every element whose + sampled :math:`L_0\kappa` exceeds 0.12 (or the requested target, when stricter), that is + longer than half its bending length :math:`(EI/|w|)^{1/3}`, or, at a line end, longer than + its boundary layer :math:`\sqrt{EI/T}`, and the elements about a node whose seabed contact + differs from both neighbours; :math:`k` is the smallest that meets the criterion, at most 4 + (16 elements per deck element). The neighbours are then split until no element is more than + twice as long as the next one (or than the ratio the deck mesh already has there) and none + is left longer than both of its neighbours with fewer splits than either (a single coarser + element between finer ones carries a spurious axial oscillation), the state is carried to + the new mesh by the Hermite interpolant of each element and polished, and the pass is + repeated on the polished state while the target is not met and an element can still be + split (at most 12 passes), within 8192 elements: a pass that would exceed them gives up the + bending-length splits first, then the grading, and only then the curvature, end-layer and + contact splits. Elements the criteria leave alone keep their deck length, so + a single coarse section costs only its own refinement (a 462-element lazy + wave whose 180 m top section has two elements: 492 elements, where refining the whole line + by the factor of its worst element gave 7392). A deck mesh too coarse for the bending length + whose continuation or polish fails, or whose folded element the local refinement does not + resolve, repeats the route on a mesh refined until the elements are at most half the bending length (when the continuation on that mesh runs out of its iteration budget, on the coarser powers of two down to twice the deck mesh); a rotationally restrained end whose boundary layer :math:`\sqrt{EI/T}` is shorter than its element, which @@ -2311,7 +2330,24 @@ the nodal tangent :math:`\mathbf{m}_j/\lvert\mathbf{m}_j\rvert` (the line's Mori and, through :math:`\mathbf{m}_j`, the position tangent exactly. 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. As the pitch :math:`p` of identical modules shrinks, the discrete equilibrium +solve is repeated with the drag of its own solution until the nodes stop moving. 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) +after two consecutive converged steps of its size; each time a doubled step fails, the number +of converged steps a doubling waits for doubles, so a homotopy that converges steadily at one +size and fails at twice it keeps advancing and tries the larger size about ten times at most. +At most 64 load steps may fail in all. A discrete state reached this way passes the kink, +tensile, physical-branch and stability checks of the smeared state before it is accepted, the +kink limit :math:`L_0\kappa \le 0.7` applied away from the attachment nodes: a lumped load +turns the line by a slope jump :math:`\theta` at its node, which the :math:`C^1` elements +beside the node carry as :math:`L_0\kappa \approx 2\theta` at any mesh size. The smeared state carries no +attachment drag, and on a frictional seabed, whose regularised friction force turns from its +sticking stiffness to its sliding capacity over a short slip, the Newton update for a +cross-flow drag can overshoot and diverge from the first step (a lazy wave with 25 modules in a +0.3 m/s cross current on 2 m elements, even in steps of 1/64), which the pseudo-transient +regularisation avoids. +As the pitch :math:`p` of identical modules shrinks, the discrete equilibrium converges to the smeared section at :math:`O(p^2)`. **Line failure.** A ``FAILURE`` row detaches a line end from its point at a prescribed time or diff --git a/doc/troubleshooting.rst b/doc/troubleshooting.rst index 587f693f..ab6092ed 100644 --- a/doc/troubleshooting.rst +++ b/doc/troubleshooting.rst @@ -576,6 +576,19 @@ but a few geometries are genuinely hard: the mesh-sequenced state is prolongated and polished there. If the message names that refined mesh as well (``still unstable on the refined mesh``), the instability is physical: check the layout, the line length and the buoyancy. +- **Discrete buoyancy modules.** ``finite-EI static solve with discrete ATTACHMENTS failed at + load fraction ...`` means the homotopy from the smeared modules to the lumped ones (see + *Discrete attachments* in :doc:`theory`) did not reach the discrete equilibrium: the damped + Newton solve of a load step did not converge, nor did its pseudo-transient and line-search + repetitions, down to steps of 1/1024 of the module loads (or 64 load steps failed in all). + The message names the load fraction of the first failed solve and the load fraction the + homotopy reached. A discrete state reached by those repetitions or smaller steps is checked as + the smeared one was; ``... the discrete equilibrium reached after a failed Newton solve ...`` + names the check it failed (the kink limit away from the attachment nodes, the tensile + contract, the physical-branch audit or the stability test), and a state that passes them is + 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. - **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. @@ -754,6 +767,22 @@ Warnings and notes that do not stop a run :math:`(EI/|w|)^{1/3}` (see :doc:`modeling`, step 5). The run uses the refined mesh, statics and dynamics alike, and its outputs have that many segments. Mesh the touchdown and section changes to that rule to keep the deck mesh. + * - ``Note: line ...: the deck mesh (... elements) could not resolve the curvature of the + equilibrium; refined to ... elements`` + - the deck mesh is too coarse for the bends of the static state. Either an element folded + beyond :math:`L_0\kappa = 0.7` (a bend shorter than the element), and the static solve + refined the mesh locally where the bend is, and where elements are longer than half the + bending length, at most 16-fold per deck element and graded into the neighbouring + elements; or the continuation or polish failed on a deck mesh with elements longer than + half the bending length :math:`(EI/|w|)^{1/3}`, and the route was repeated on the whole + line refined uniformly by a power of two, up to the factor at which every element meets + that length (or, at a rotationally + restrained end, on end elements halved toward the end down to its boundary layer). See + :doc:`theory`, Static equilibrium. The run uses the refined mesh, statics and dynamics + alike, and its profile and per-line outputs have that many segments; the refinement + only splits deck elements, so the node channels still name deck nodes (see + :ref:`outputs-refined-nodes`). Mesh the line to the bending-length rule to keep the deck + mesh. * - ``Note: line ... starts the dynamics from a static state solved in its vertical plane that is unstable out of that plane on its mesh of ... elements, the coarsest ... m long where half the bending length (EI/|w|)^(1/3) is ... m; ...`` diff --git a/src/CableDyn_DeckDriver.f90 b/src/CableDyn_DeckDriver.f90 index 9a71baeb..926b7a53 100644 --- a/src/CableDyn_DeckDriver.f90 +++ b/src/CableDyn_DeckDriver.f90 @@ -209,6 +209,8 @@ MODULE CableDyn_DeckDriver PUBLIC :: CD_Rigid6_Get_States, CD_Rigid6_Set_States PUBLIC :: DeckFailure, DeckLine, DeckPoint PUBLIC :: CD_Fire_Deck_Failures + ! Acceptance of a fallback attachment equilibrium (public for its unit test). + PUBLIC :: CD_Attachment_Discrete_Verdict PUBLIC :: CD_Check_System_Plausibility PUBLIC :: CD_Replay_Deck_Failures PUBLIC :: CD_Classify_Dynamic_Completion @@ -1670,6 +1672,8 @@ RECURSIVE SUBROUTINE build_one_hermite_cable(ln, sections, types, points, opts, INTEGER, PARAMETER :: FALLBACK_SEQUENCE_BUDGET = 2000 LOGICAL :: standalone_mode, contact_enabled, used_trivial_seed, anchor_on_flat_bed, allow_extra_sequence LOGICAL :: polish_ready + ! Set when the attachment polish needed its fallbacks (attachment_fallback_checks). + LOGICAL :: att_fell_back LOGICAL :: bathymetry_flat, require_3d_static, sym_broken, planar_unstable, saddle_kept ! A planar equilibrium in a current that is a saddle out of its plane (see route_pass). REAL(wp), ALLOCATABLE :: l0_saddle(:), ea_saddle(:), ei_saddle(:), w_saddle(:), q_saddle(:), curv_saddle(:) @@ -2094,8 +2098,9 @@ RECURSIVE SUBROUTINE build_one_hermite_cable(ln, sections, types, points, opts, ! n_cont = 8 load steps and damping = 0.7. When the deck opts in to ! adaptive_mesh AND CD_HermiteCable_Resolution_Metrics flags the mesh FRAGILE (an ! under-resolved arch/touchdown that would stall the coupled dynamic Newton), AutoMesh - ! refines by WARM-STARTED cubic-Hermite prolongation of the converged IC - ! (CD_HermiteCable_Refine_Mesh) up to CD_HC_REFINE_CAP. Prolongation -- not a + ! refines by WARM-STARTED cubic-Hermite prolongation of the converged IC, element by + ! element where the resolution screens fail (local_refinement), up to CD_HC_REFINE_CAP + ! bisection factor per deck element. Prolongation -- not a ! cold re-solve at the finer mesh -- is essential: a cold fine solve kinks (mesh-sequencing is ! the documented practice). inherit_dofs [2,5] carries the planar out-of-plane hold (y ! position + y tangent) onto inserted nodes. max_scale = 1 (adaptive_mesh off, the DEFAULT) @@ -2319,7 +2324,8 @@ RECURSIVE SUBROUTINE build_one_hermite_cable(ln, sections, types, points, opts, endconn_direction=endconn_d0_local, & endconn_mode=endconn_mode, & waterline_z=CD_ZERO, dry_buoyancy=dry_b, & - water_weight=opts%rhoW*opts%g, current=cur_obj) + water_weight=opts%rhoW*opts%g, current=cur_obj, & + local_refinement=.TRUE.) ELSE IF (contact_enabled) THEN CALL CD_HermiteCable_Static_Solve_AutoMesh(l0, ea, ei, w, q_sequence, fixed_dofs, & contact_z, CD_ZERO, 8, 80, static_tol, 0.7_wp, & @@ -2340,7 +2346,8 @@ RECURSIVE SUBROUTINE build_one_hermite_cable(ln, sections, types, points, opts, endconn_direction=endconn_d0_local, & endconn_mode=endconn_mode, & waterline_z=CD_ZERO, dry_buoyancy=dry_b, & - water_weight=opts%rhoW*opts%g, current=cur_obj) + water_weight=opts%rhoW*opts%g, current=cur_obj, & + local_refinement=.TRUE.) ELSE CALL CD_HermiteCable_Static_Solve_AutoMesh(l0, ea, ei, w, q_sequence, fixed_dofs, & contact_z, CD_ZERO, 8, 80, static_tol, 0.7_wp, & @@ -2360,7 +2367,8 @@ RECURSIVE SUBROUTINE build_one_hermite_cable(ln, sections, types, points, opts, endconn_direction=endconn_d0_local, & endconn_mode=endconn_mode, & waterline_z=CD_ZERO, dry_buoyancy=dry_b, & - water_weight=opts%rhoW*opts%g, current=cur_obj) + water_weight=opts%rhoW*opts%g, current=cur_obj, & + local_refinement=.TRUE.) END IF iters = sequence_total + adaptive_iters ELSE @@ -2389,7 +2397,8 @@ RECURSIVE SUBROUTINE build_one_hermite_cable(ln, sections, types, points, opts, endconn_direction=endconn_d0_local, & endconn_mode=endconn_mode, & waterline_z=CD_ZERO, dry_buoyancy=dry_b, & - water_weight=opts%rhoW*opts%g, current=cur_obj) + water_weight=opts%rhoW*opts%g, current=cur_obj, & + local_refinement=.TRUE.) ELSE IF (contact_enabled) THEN CALL CD_HermiteCable_Static_Solve_AutoMesh(l0, ea, ei, w, q0, fixed_dofs, contact_z, CD_ZERO, & 8, 80, static_tol, 0.7_wp, CD_HC_HKAPPA_TARGET, CD_ZERO, & @@ -2409,7 +2418,8 @@ RECURSIVE SUBROUTINE build_one_hermite_cable(ln, sections, types, points, opts, endconn_direction=endconn_d0_local, & endconn_mode=endconn_mode, & waterline_z=CD_ZERO, dry_buoyancy=dry_b, & - water_weight=opts%rhoW*opts%g, current=cur_obj) + water_weight=opts%rhoW*opts%g, current=cur_obj, & + local_refinement=.TRUE.) ELSE CALL CD_HermiteCable_Static_Solve_AutoMesh(l0, ea, ei, w, q0, fixed_dofs, -2000.0_wp, CD_ZERO, & 8, 80, static_tol, 0.7_wp, CD_HC_HKAPPA_TARGET, CD_ZERO, & @@ -2427,7 +2437,8 @@ RECURSIVE SUBROUTINE build_one_hermite_cable(ln, sections, types, points, opts, endconn_direction=endconn_d0_local, & endconn_mode=endconn_mode, & waterline_z=CD_ZERO, dry_buoyancy=dry_b, & - water_weight=opts%rhoW*opts%g, current=cur_obj) + water_weight=opts%rhoW*opts%g, current=cur_obj, & + local_refinement=.TRUE.) END IF IF (es == CD_HCSTAT_OK .OR. es == CD_HCSTAT_BADINPUT) EXIT static_attempt IF (static_tol >= COUPLED_STATIC_TOL) EXIT static_attempt @@ -2469,7 +2480,8 @@ RECURSIVE SUBROUTINE build_one_hermite_cable(ln, sections, types, points, opts, endconn_direction=endconn_d0_local, & endconn_mode=endconn_mode, & waterline_z=CD_ZERO, dry_buoyancy=dry_b, & - water_weight=opts%rhoW*opts%g, current=cur_obj) + water_weight=opts%rhoW*opts%g, current=cur_obj, & + local_refinement=.TRUE.) ELSE IF (contact_enabled) THEN CALL CD_HermiteCable_Static_Solve_AutoMesh(l0, ea, ei, w, q_coupled_tol, fixed_dofs, & contact_z, CD_ZERO, 8, 80, static_tol_target, 0.7_wp, & @@ -2488,7 +2500,8 @@ RECURSIVE SUBROUTINE build_one_hermite_cable(ln, sections, types, points, opts, endconn_direction=endconn_d0_local, & endconn_mode=endconn_mode, & waterline_z=CD_ZERO, dry_buoyancy=dry_b, & - water_weight=opts%rhoW*opts%g, current=cur_obj) + water_weight=opts%rhoW*opts%g, current=cur_obj, & + local_refinement=.TRUE.) ELSE CALL CD_HermiteCable_Static_Solve_AutoMesh(l0, ea, ei, w, q_coupled_tol, fixed_dofs, & -2000.0_wp, CD_ZERO, 8, 80, static_tol_target, 0.7_wp, & @@ -2506,7 +2519,8 @@ RECURSIVE SUBROUTINE build_one_hermite_cable(ln, sections, types, points, opts, endconn_direction=endconn_d0_local, & endconn_mode=endconn_mode, & waterline_z=CD_ZERO, dry_buoyancy=dry_b, & - water_weight=opts%rhoW*opts%g, current=cur_obj) + water_weight=opts%rhoW*opts%g, current=cur_obj, & + local_refinement=.TRUE.) END IF iters = iters + polish_iters END IF @@ -2863,7 +2877,8 @@ RECURSIVE SUBROUTINE build_one_hermite_cable(ln, sections, types, points, opts, IF (.NOT. has_att) CALL handoff_lateral_note(l0, l0_am, ea_am, ei_am, w_am, w_am, diam, dry_b, fixed_am, .FALSE.) ! Build the coarse Morison arrays, then map every per-element quantity onto the ! refined reference-arc mesh. This covers both global refinement and the local - ! axial-oscillation refinement used by tensile safety. Every child inherits the + ! refinements (the resolution screens, and the axial-oscillation refinement used by + ! tensile safety). Every child inherits the ! property of the original element containing its reference-arc midpoint. ALLOCATE (cdn(SIZE(l0)), cdt(SIZE(l0)), can(SIZE(l0)), cat(SIZE(l0))) CALL finite_hydro_arrays(ln, sections, types, diam, cdn, cdt, can, cat) @@ -2939,8 +2954,23 @@ RECURSIVE SUBROUTINE build_one_hermite_cable(ln, sections, types, points, opts, END IF CALL attachment_static_polish(l0, ea, ei, w_bare, w, diam, att_node, ln%att, q_static, fixed_dofs, & contact_enabled, contact_z, frame_cs, endconn_k, endconn_d0_local, & - endconn_mode, opts, static_tol, ErrStat, ErrMsg, bathymetry, cur_obj) + endconn_mode, opts, static_tol, ErrStat, ErrMsg, bathymetry, cur_obj, & + fell_back=att_fell_back) IF (ErrStat /= CD_DECKDRV_OK) RETURN + ! A discrete state the damped Newton solves did not reach alone (pseudo-transient + ! continuation, line search or smaller load steps) passes the acceptance checks the + ! smeared state passed above: the kink limit (away from the attachment nodes, whose + ! slope jump the elements beside them carry as curvature), the tensile contract, the + ! physical-branch audit and the stability test (CD_Attachment_Discrete_Verdict). A + ! polish whose Newton solves all converge is a small warm-started correction of an + ! accepted state and is not checked again. + IF (att_fell_back) THEN + CALL attachment_fallback_checks() + IF (ErrStat /= CD_DECKDRV_OK) RETURN + CALL report_note('line '//TRIM(int_to_str(ln%id))//': the discrete attachment equilibrium was reached '// & + 'after a failed Newton solve (pseudo-transient continuation, line search or smaller '// & + 'load steps) and passed the acceptance checks of the smeared state') + END IF ! On the final mesh, with the bare weights the polished state carries; the bending-length ! rule of the note uses the smeared section weights w. CALL handoff_lateral_note(l0, l0, ea, ei, w_bare, w, diam, opts%rhoW*opts%g*QUARTER_PI*diam**2, fixed_dofs, & @@ -3337,7 +3367,8 @@ SUBROUTINE sequenced_refined_polish(done, why) refine_non_axial=opts%adaptive_mesh, & endconn_stiffness=endconn_k, endconn_direction=endconn_d0_local, & endconn_mode=endconn_mode, waterline_z=CD_ZERO, & - dry_buoyancy=dry_r, water_weight=opts%rhoW*opts%g, current=cur_obj) + dry_buoyancy=dry_r, water_weight=opts%rhoW*opts%g, & + current=cur_obj, local_refinement=.TRUE.) ELSE IF (contact_enabled) THEN CALL CD_HermiteCable_Static_Solve_AutoMesh(l0_r, ea_r, ei_r, w_r, q_r, fixed_r, contact_z, CD_ZERO, & 8, 80, tol_r(k_tol), 0.7_wp, CD_HC_HKAPPA_TARGET, CD_ZERO, & @@ -3353,7 +3384,8 @@ SUBROUTINE sequenced_refined_polish(done, why) refine_non_axial=opts%adaptive_mesh, & endconn_stiffness=endconn_k, endconn_direction=endconn_d0_local, & endconn_mode=endconn_mode, waterline_z=CD_ZERO, & - dry_buoyancy=dry_r, water_weight=opts%rhoW*opts%g, current=cur_obj) + dry_buoyancy=dry_r, water_weight=opts%rhoW*opts%g, & + current=cur_obj, local_refinement=.TRUE.) ELSE CALL CD_HermiteCable_Static_Solve_AutoMesh(l0_r, ea_r, ei_r, w_r, q_r, fixed_r, contact_z, CD_ZERO, & 8, 80, tol_r(k_tol), 0.7_wp, CD_HC_HKAPPA_TARGET, CD_ZERO, & @@ -3368,7 +3400,8 @@ SUBROUTINE sequenced_refined_polish(done, why) refine_non_axial=opts%adaptive_mesh, & endconn_stiffness=endconn_k, endconn_direction=endconn_d0_local, & endconn_mode=endconn_mode, waterline_z=CD_ZERO, & - dry_buoyancy=dry_r, water_weight=opts%rhoW*opts%g, current=cur_obj) + dry_buoyancy=dry_r, water_weight=opts%rhoW*opts%g, & + current=cur_obj, local_refinement=.TRUE.) END IF iters = iters + it_r IF (es_r == CD_HCSTAT_OK) THEN @@ -3601,7 +3634,8 @@ SUBROUTINE symmetric_current_polish(done) endconn_direction=endconn_d0_local, & endconn_mode=endconn_mode, waterline_z=CD_ZERO, & dry_buoyancy=dry_s, water_weight=opts%rhoW*opts%g, & - current=cur_obj) + current=cur_obj, & + local_refinement=.TRUE.) ELSE CALL CD_HermiteCable_Static_Solve_AutoMesh(l0_s, ea_s, ei_s, w_s, q_s, fixed_s, -2000.0_wp, CD_ZERO, & 8, 80, tol_s(k_tol), 0.7_wp, h_t, & @@ -3616,7 +3650,8 @@ SUBROUTINE symmetric_current_polish(done) endconn_direction=endconn_d0_local, & endconn_mode=endconn_mode, waterline_z=CD_ZERO, & dry_buoyancy=dry_s, water_weight=opts%rhoW*opts%g, & - current=cur_obj) + current=cur_obj, & + local_refinement=.TRUE.) END IF iters = iters + it_s IF (es_s == CD_HCSTAT_OK) THEN @@ -3790,6 +3825,41 @@ SUBROUTINE handoff_lateral_note(l0_ref, l0_n, ea_n, ei_n, w_n, w_rule, diam_ref, CALL report_note(text_h) END SUBROUTINE handoff_lateral_note + SUBROUTINE attachment_fallback_checks() + !! Acceptance of a discrete attachment equilibrium the polish reached with its fallbacks + !! (attachment_static_polish, fell_back), on the final mesh, by + !! CD_Attachment_Discrete_Verdict: the stability test with the static constraints is + !! evaluated here (the tangent takes the bare weights; the lumped attachment loads are + !! dead loads), the rest there. Fails closed with the verdict's message. + LOGICAL :: stable_f, accepted_f + CHARACTER(1024) :: msg_f + IF (PRESENT(bathymetry) .AND. .NOT. bathymetry_flat) THEN + CALL hermite_static_stable(l0, l0, ea, ei, w_bare, diam, dry_b_final(), q_static, fixed_dofs, & + contact_enabled, contact_z, frame_cs, endconn_k, endconn_d0_local, endconn_mode, & + opts, stable_f, ErrStat, ErrMsg, bathymetry=bathymetry, cur_obj=cur_obj) + IF (ErrStat /= CD_DECKDRV_OK) RETURN + CALL CD_Attachment_Discrete_Verdict(l0, q_static, ea, ei, w, diam, endconn_mode, att_node, contact_z, & + opts%tensile_mode == CD_HCDYN_TENSILE_ERROR, stable_f, accepted_f, msg_f, & + bathymetry=bathymetry, frame_cs=frame_cs) + ELSE + CALL hermite_static_stable(l0, l0, ea, ei, w_bare, diam, dry_b_final(), q_static, fixed_dofs, & + contact_enabled, contact_z, frame_cs, endconn_k, endconn_d0_local, endconn_mode, & + opts, stable_f, ErrStat, ErrMsg, cur_obj=cur_obj) + IF (ErrStat /= CD_DECKDRV_OK) RETURN + CALL CD_Attachment_Discrete_Verdict(l0, q_static, ea, ei, w, diam, endconn_mode, att_node, contact_z, & + opts%tensile_mode == CD_HCDYN_TENSILE_ERROR, stable_f, accepted_f, msg_f) + END IF + IF (.NOT. accepted_f) THEN + CALL fail_solve(ErrStat, ErrMsg, TRIM(msg_f)); RETURN + END IF + END SUBROUTINE attachment_fallback_checks + + FUNCTION dry_b_final() RESULT(dry) + !! Dry buoyancy per length on the final mesh (as dry_b on the deck mesh). + REAL(wp), ALLOCATABLE :: dry(:) + dry = opts%rhoW*opts%g*QUARTER_PI*diam**2 + END FUNCTION dry_b_final + LOGICAL FUNCTION coarse_current_eligible() RESULT(ok) !! coarse_current_first applies to an in-plane current (in_plane_current) without !! seabed friction or attachments, on a deck build that is not itself the coarse one, @@ -3922,7 +3992,8 @@ SUBROUTINE coarse_current_first(done, fail_msg) endconn_direction=endconn_d0_local, & endconn_mode=endconn_mode, waterline_z=CD_ZERO, & dry_buoyancy=dry_b, water_weight=opts%rhoW*opts%g, & - current=cur_obj) + current=cur_obj, & + local_refinement=.TRUE.) ELSE CALL CD_HermiteCable_Static_Solve_AutoMesh(l0, ea, ei, w, q_p, fixed_3d, -2000.0_wp, CD_ZERO, & 8, 80, tol_c(k_tol), 0.7_wp, h_t, & @@ -3939,7 +4010,8 @@ SUBROUTINE coarse_current_first(done, fail_msg) endconn_direction=endconn_d0_local, & endconn_mode=endconn_mode, waterline_z=CD_ZERO, & dry_buoyancy=dry_b, water_weight=opts%rhoW*opts%g, & - current=cur_obj) + current=cur_obj, & + local_refinement=.TRUE.) END IF iters = iters + it_c IF (esc == CD_HCSTAT_OK) THEN @@ -4339,14 +4411,36 @@ END SUBROUTINE smear_attachments SUBROUTINE attachment_static_polish(l0, ea, ei, w_bare, w_smear, diam, node, att, q, fixed_dofs, & contact_enabled, contact_z, frame_cs, endconn_k, endconn_d0, endconn_mode, & - opts, tol, ErrStat, ErrMsg, bathymetry, cur_obj) - !! Homotopy from the smeared-attachment equilibrium q to the discrete one: in NSTEP - !! 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 zero to full, with the contact, dry-buoyancy, end-connection and line - !! current terms of the builder's static problem. The drag depends on the node's depth - !! (profile current) and line tangent, so the full-load solve is repeated with the drag - !! of the last solution until the solution stops moving (fixed point). + 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 + !! zero to full, with the contact, dry-buoyancy, end-connection and line current terms of + !! the builder's static problem. The drag depends on the node's depth (profile current) + !! and line tangent, so the full-load solve is repeated with the drag of the last solution + !! until the solution stops moving (fixed point). + !! + !! The 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 + !! continuation and then with a residual-merit line search; when neither converges, the + !! step is halved (down to MIN_STEP). A step doubles again (up to 1/NSTEP) once grow_after + !! consecutive steps of its size have converged; grow_after starts at 2 and doubles each + !! time a doubled step fails, so a homotopy that converges steadily at one size and fails + !! at twice it tries the larger size ever more rarely (about log2(1/MIN_STEP) times in all) + !! and still advances at the smaller size. At most MAX_FAILED_STEPS load steps may fail in + !! all, a backstop that a steady homotopy does not reach (16 failures at worst, at + !! MIN_STEP); with at most 1/MIN_STEP converged steps this bounds the polish. + !! The smeared state carries no attachment drag, and on a frictional seabed, whose + !! regularised friction force turns from its sticking stiffness to its sliding capacity + !! over a short slip, the Newton update for a cross-flow drag can overshoot far from the + !! equilibrium and diverge (even in load steps of 1/64), which the pseudo-transient + !! regularisation avoids. Once a damped Newton solve has failed, the + !! later ones get NEWTON_RETRY_ITER iterations before the fallbacks take over. A polish + !! whose damped Newton solves all converge takes exactly the solves it took before. + !! fell_back (optional out) reports that a damped Newton solve failed, so that the state + !! was reached with the fallbacks (and the caller re-runs its acceptance checks on it). + !! A failure names the load fraction of the first failed solve and, when the homotopy + !! stops, the load fraction it reached. REAL(wp), INTENT(IN) :: l0(:), ea(:), ei(:), w_bare(:), w_smear(:), diam(:), att(:, :) INTEGER, INTENT(IN) :: node(:), fixed_dofs(:), endconn_mode(2) REAL(wp), INTENT(INOUT) :: q(:) @@ -4357,14 +4451,29 @@ SUBROUTINE attachment_static_polish(l0, ea, ei, w_bare, w_smear, diam, node, att CHARACTER(*), INTENT(OUT) :: ErrMsg TYPE(CD_BathymetryType), INTENT(IN), OPTIONAL :: bathymetry TYPE(CD_HermiteStaticCurrentType), INTENT(IN), OPTIONAL :: cur_obj + LOGICAL, INTENT(OUT), OPTIONAL :: fell_back INTEGER, PARAMETER :: NSTEP = 8, MAX_FIXED_POINT = 60 + ! Smallest load-fraction step: 1/NSTEP halved seven times. Newton budget once a damped + ! Newton solve of this polish has failed (a converging one takes well under it). Budget + ! of failed load steps: each takes at most NEWTON_RETRY_ITER + 400 Newton iterations + ! (the first failed solve 600, its damped Newton solve having the full 200). + REAL(wp), PARAMETER :: MIN_STEP = 1.0_wp/1024.0_wp + 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(:) - REAL(wp) :: lam, res, change - INTEGER :: i, k, ne, step, fp - LOGICAL :: has_drag + REAL(wp) :: lam, lam_done, dlam, res, change + INTEGER :: i, k, ne, fp, n_failed, n_ok, grow_after + LOGICAL :: has_drag, converged, newton_failed, grown + ! 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 ErrStat = CD_DECKDRV_OK; ErrMsg = '' + IF (PRESENT(fell_back)) fell_back = .FALSE. + first_msg = '' + last_msg = '' + newton_failed = .FALSE. + 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 @@ -4381,29 +4490,78 @@ SUBROUTINE attachment_static_polish(l0, ea, ei, w_bare, w_smear, diam, node, att knnode(i + 1) = knnode(i + 1) + 0.5_wp*opts%kbot*diam(i)*l0(i) END DO END IF - DO step = 1, NSTEP - lam = REAL(step, wp)/REAL(NSTEP, wp) + lam_done = CD_ZERO + dlam = CD_ONE/REAL(NSTEP, wp) + n_ok = 0 + grow_after = 2 + grown = .FALSE. + DO WHILE (lam_done < CD_ONE) + lam = MIN(CD_ONE, lam_done + dlam) wl = w_bare + (CD_ONE - lam)*(w_smear - w_bare) - CALL solve_with(lam) + CALL solve_with(lam, converged) IF (ErrStat /= CD_DECKDRV_OK) RETURN + IF (converged) THEN + lam_done = lam + grown = .FALSE. + n_ok = n_ok + 1 + IF (dlam < CD_ONE/REAL(NSTEP, wp) .AND. n_ok >= grow_after) THEN + dlam = MIN(2.0_wp*dlam, CD_ONE/REAL(NSTEP, wp)) + n_ok = 0 + grown = .TRUE. + END IF + ELSE + n_failed = n_failed + 1 + ! A doubled step that fails was premature: wait twice as long before the next. + ! (Capped past the 1/MIN_STEP steps a homotopy can take.) + IF (grown) grow_after = MIN(2*grow_after, 2*NINT(CD_ONE/MIN_STEP)) + grown = .FALSE. + n_ok = 0 + dlam = 0.5_wp*dlam + IF (dlam < MIN_STEP .OR. n_failed >= MAX_FAILED_STEPS) THEN + 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') + 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') + END IF + RETURN + END IF + END IF END DO IF (.NOT. has_drag) RETURN DO fp = 1, MAX_FIXED_POINT - CALL solve_with(CD_ONE, change) + 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 + END IF IF (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') CONTAINS - SUBROUTINE solve_with(scale, dq_max) - !! One warm-started Newton solve at load fraction scale, with the attachment current - !! drag evaluated on the incoming state; dq_max is the resulting largest DOF change. + 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 + !! converge, the pseudo-transient continuation and the residual-merit line search, each + !! from the incoming state. ok reports convergence; q is updated only then, and dq_max + !! is the resulting largest DOF change. Otherwise last_msg (and, the first time, + !! first_msg) names the load fraction and the damped Newton failure. A failed drag + !! evaluation or a rejected input sets ErrStat. REAL(wp), INTENT(IN) :: scale + LOGICAL, INTENT(OUT) :: ok REAL(wp), INTENT(OUT), OPTIONAL :: dq_max - INTEGER :: it, es + INTEGER, PARAMETER :: NEWTON = 1, PSEUDO_TRANSIENT = 2, MERIT = 3 + INTEGER :: it, es, mode, max_it(3) CHARACTER(1024) :: em CHARACTER(48) :: num_buf + ok = .FALSE. + max_it = [MERGE(NEWTON_RETRY_ITER, 200, newton_failed), 200, 200] f_drag = CD_ZERO IF (has_drag) THEN CALL attachment_static_drag(q, node, att, opts, frame_cs, f_drag, es, em) @@ -4411,35 +4569,51 @@ SUBROUTINE solve_with(scale, dq_max) CALL fail_solve(ErrStat, ErrMsg, 'finite-EI static attachment drag failed: '//TRIM(em)); RETURN END IF END IF - IF (contact_enabled) THEN - CALL CD_HermiteCable_Static_Solve(l0, ea, ei, wl, q, fixed_dofs, contact_z, CD_ZERO, 1, 200, & - tol, 0.7_wp, q_out, curv, res, it, es, em, & - f_nodal=scale*(f_att + f_drag), n_buoy_steps=1, contact_kn=knnode, & - bathymetry=bathymetry, contact_frame_cs=frame_cs, & - axial_quadrature_order=opts%axial_quadrature_order, & - bending_quadrature_order=opts%bending_quadrature_order, & - endconn_stiffness=endconn_k, endconn_direction=endconn_d0, & - endconn_mode=endconn_mode, waterline_z=CD_ZERO, dry_buoyancy=dry, & - water_weight=opts%rhoW*opts%g, current=cur_obj) - ELSE - CALL CD_HermiteCable_Static_Solve(l0, ea, ei, wl, q, fixed_dofs, contact_z, CD_ZERO, 1, 200, & - tol, 0.7_wp, q_out, curv, res, it, es, em, & - f_nodal=scale*(f_att + f_drag), n_buoy_steps=1, & - axial_quadrature_order=opts%axial_quadrature_order, & - bending_quadrature_order=opts%bending_quadrature_order, & - endconn_stiffness=endconn_k, endconn_direction=endconn_d0, & - endconn_mode=endconn_mode, waterline_z=CD_ZERO, dry_buoyancy=dry, & - water_weight=opts%rhoW*opts%g, current=cur_obj) - END IF - IF (es /= CD_HCSTAT_OK .OR. .NOT. (res <= tol)) THEN - ! numbers into a local buffer: an internal WRITE into the caller's ErrMsg would abort - ! on a short buffer - WRITE (num_buf, '(F5.3,A,ES10.3)') scale, ' (relative residual ', res - ErrMsg = 'CableDyn_DeckDriver: finite-EI static solve with discrete ATTACHMENTS failed at load '// & - 'fraction '//TRIM(num_buf)//'): '//TRIM(em) - ErrStat = CD_DECKDRV_SOLVEFAIL - RETURN - END IF + DO mode = NEWTON, MERIT + IF (contact_enabled) THEN + CALL CD_HermiteCable_Static_Solve(l0, ea, ei, wl, q, fixed_dofs, contact_z, CD_ZERO, 1, max_it(mode), & + tol, 0.7_wp, q_out, curv, res, it, es, em, & + f_nodal=scale*(f_att + f_drag), n_buoy_steps=1, contact_kn=knnode, & + bathymetry=bathymetry, contact_frame_cs=frame_cs, & + axial_quadrature_order=opts%axial_quadrature_order, & + bending_quadrature_order=opts%bending_quadrature_order, & + endconn_stiffness=endconn_k, endconn_direction=endconn_d0, & + endconn_mode=endconn_mode, waterline_z=CD_ZERO, dry_buoyancy=dry, & + water_weight=opts%rhoW*opts%g, current=cur_obj, & + backtracking=mode == MERIT, merit_line_search=mode == MERIT, & + pseudo_transient=mode == PSEUDO_TRANSIENT) + ELSE + CALL CD_HermiteCable_Static_Solve(l0, ea, ei, wl, q, fixed_dofs, contact_z, CD_ZERO, 1, max_it(mode), & + tol, 0.7_wp, q_out, curv, res, it, es, em, & + f_nodal=scale*(f_att + f_drag), n_buoy_steps=1, & + axial_quadrature_order=opts%axial_quadrature_order, & + bending_quadrature_order=opts%bending_quadrature_order, & + endconn_stiffness=endconn_k, endconn_direction=endconn_d0, & + endconn_mode=endconn_mode, waterline_z=CD_ZERO, dry_buoyancy=dry, & + water_weight=opts%rhoW*opts%g, current=cur_obj, & + backtracking=mode == MERIT, merit_line_search=mode == MERIT, & + pseudo_transient=mode == PSEUDO_TRANSIENT) + END IF + IF (es == CD_HCSTAT_OK .AND. res <= tol) THEN + ok = .TRUE. + EXIT + END IF + IF (mode == NEWTON) THEN + ! numbers into a local buffer: an internal WRITE into the caller's ErrMsg would abort + ! on a short buffer + WRITE (num_buf, '(F5.3,A,ES10.3)') scale, ' (relative residual ', res + last_msg = 'finite-EI static solve with discrete ATTACHMENTS failed at load '// & + 'fraction '//TRIM(num_buf)//'): '//TRIM(em) + IF (.NOT. newton_failed) first_msg = last_msg + newton_failed = .TRUE. + IF (PRESENT(fell_back)) fell_back = .TRUE. + END IF + ! A rejected input is rejected by every update rule. + IF (es == CD_HCSTAT_BADINPUT) THEN + CALL fail_solve(ErrStat, ErrMsg, TRIM(last_msg)); RETURN + END IF + END DO + IF (.NOT. ok) RETURN IF (PRESENT(dq_max)) dq_max = MAXVAL(ABS(q_out - q)) q = q_out END SUBROUTINE solve_with @@ -4975,7 +5149,7 @@ RECURSIVE SUBROUTINE hermite_static_primary(anchor, fairlead, l0, ea, ei, w, dia END IF END IF - ! 3. caller-mesh polish, diagnosis and opt-in refinement (adaptive_mesh: uniform + ! 3. caller-mesh polish, diagnosis and opt-in refinement (adaptive_mesh: local ! refinement of a fragile resolution screen). A coarse mesh whose axial resultant ! oscillates is kept and reported by the audit. With tensile_safety True ! compression beyond the tighter of the strain band and the tension-relative band is @@ -4987,9 +5161,10 @@ RECURSIVE SUBROUTINE hermite_static_primary(anchor, fairlead, l0, ea, ei, w, dia refine_all = opts%adaptive_mesh CALL polish_with_floor() ! Safety-driven refinement: an element-localized fold on the deck mesh means the - ! mesh cannot represent the bends of this equilibrium. Refine globally (power of two, - ! capped) until max(h*kappa) is half the kink limit, whatever adaptive_mesh says; the - ! alternative is no result at all. The caller reports the refined mesh. + ! mesh cannot represent the bends of this equilibrium. Refine locally (power-of-two + ! splits of the elements that fail the resolution screens, graded into their + ! neighbours, capped) until max(h*kappa) is half the kink limit, whatever adaptive_mesh + ! says; the alternative is no result at all. The caller reports the refined mesh. IF (ErrStat == CD_HCSTAT_NOCONVERGE .AND. INDEX(ErrMsg, 'unresolved/kinked') > 0) THEN h_target = 0.5_wp*CD_HC_KINK_LIMIT @@ -5626,7 +5801,8 @@ SUBROUTINE polish(tol_polish) refine_non_axial=refine_all, & endconn_stiffness=endconn_k, endconn_direction=endconn_d0, & endconn_mode=endconn_mode, waterline_z=CD_ZERO, dry_buoyancy=dry_b, & - water_weight=opts%rhoW*opts%g, current=cur_obj) + water_weight=opts%rhoW*opts%g, current=cur_obj, & + local_refinement=.TRUE.) ELSE IF (contact_enabled) THEN CALL CD_HermiteCable_Static_Solve_AutoMesh(l0, ea, ei, w, q_cont, fixed_dofs, contact_z, CD_ZERO, & 8, 200, tol_polish, 0.7_wp, h_target, CD_ZERO, & @@ -5644,7 +5820,8 @@ SUBROUTINE polish(tol_polish) refine_non_axial=refine_all, & endconn_stiffness=endconn_k, endconn_direction=endconn_d0, & endconn_mode=endconn_mode, waterline_z=CD_ZERO, dry_buoyancy=dry_b, & - water_weight=opts%rhoW*opts%g, current=cur_obj) + water_weight=opts%rhoW*opts%g, current=cur_obj, & + local_refinement=.TRUE.) ELSE CALL CD_HermiteCable_Static_Solve_AutoMesh(l0, ea, ei, w, q_cont, fixed_dofs, contact_z, CD_ZERO, & 8, 200, tol_polish, 0.7_wp, h_target, CD_ZERO, & @@ -5660,7 +5837,8 @@ SUBROUTINE polish(tol_polish) refine_non_axial=refine_all, & endconn_stiffness=endconn_k, endconn_direction=endconn_d0, & endconn_mode=endconn_mode, waterline_z=CD_ZERO, dry_buoyancy=dry_b, & - water_weight=opts%rhoW*opts%g, current=cur_obj) + water_weight=opts%rhoW*opts%g, current=cur_obj, & + local_refinement=.TRUE.) END IF iters = iters + polish_iters END SUBROUTINE polish @@ -5834,8 +6012,97 @@ SUBROUTINE hermite_static_torsion(l0_deck, l0, ea, ei, w, diam_deck, dry_deck, q q = q_out END SUBROUTINE hermite_static_torsion - SUBROUTINE audit_hermite_static(l0, q, ea, ei, w, diam, endconn_mode, physical, message, compression_note) + SUBROUTINE CD_Attachment_Discrete_Verdict(l0, q, ea, ei, w, diam, endconn_mode, att_node, contact_z, & + tensile_error, stable, accepted, message, bathymetry, frame_cs) + !! Acceptance of a discrete attachment equilibrium that the attachment polish reached + !! with its fallbacks (pseudo-transient continuation, line search or smaller load steps), + !! on its mesh l0 with state q: the checks the smeared state passed before the polish. + !! 1. The kink limit (h*kappa <= CD_HC_KINK_LIMIT), except on the elements beside an + !! attachment node att_node: the lumped load turns the line there by a slope jump, + !! which the C1 Hermite elements beside the node carry as curvature (h*kappa of about + !! twice the jump) at any mesh size; a polish whose Newton solves converge accepts it. + !! 2. With tensile_error (tensile_safety True), no axial compression in the mesh safety + !! diagnosis (the strict, smoothed compression mode of the smeared-state check). + !! 3. The physical-branch audit (audit_hermite_static: no fold, loop or self-contact), + !! with its kink test left to 1. + !! 4. stable: the stability test with the static constraints, evaluated by the caller. + !! accepted is false when a check fails, and message names it in full. w are the section + !! weights (smeared over the attachments) of the audit's compression allowance, diam the + !! element diameters on l0. Public for its unit test. + REAL(wp), INTENT(IN) :: l0(:), q(:), ea(:), ei(:), w(:), diam(:), contact_z + INTEGER, INTENT(IN) :: endconn_mode(2), att_node(:) + LOGICAL, INTENT(IN) :: tensile_error, stable + LOGICAL, INTENT(OUT) :: accepted + CHARACTER(*), INTENT(OUT) :: message + TYPE(CD_BathymetryType), INTENT(IN), OPTIONAL :: bathymetry + REAL(wp), INTENT(IN), OPTIONAL :: frame_cs(2) + CHARACTER(*), PARAMETER :: WHAT = 'finite-EI static solve with discrete ATTACHMENTS: the discrete '// & + 'equilibrium reached after a failed Newton solve (pseudo-transient '// & + 'continuation, line search or smaller load steps) ' + TYPE(CD_HermiteResolutionType) :: diag + REAL(wp), ALLOCATABLE :: hk(:) + LOGICAL, ALLOCATABLE :: beside(:) + REAL(wp) :: hk_peak + INTEGER :: ne, e, k, es, e_peak + LOGICAL :: physical + CHARACTER(1024) :: em + accepted = .FALSE. + message = '' + ne = SIZE(l0) + ALLOCATE (hk(ne), beside(ne)) + IF (PRESENT(bathymetry) .AND. PRESENT(frame_cs)) THEN + CALL CD_HermiteCable_Resolution_Metrics(l0, q, contact_z, CD_ZERO, CD_HC_KINK_LIMIT, diag, es, em, & + bathymetry=bathymetry, contact_frame_cs=frame_cs, EA=ea, EI=ei, & + compression_mode=CD_HC_COMPRESSION_STRICT, elem_h_kappa=hk) + ELSE + CALL CD_HermiteCable_Resolution_Metrics(l0, q, contact_z, CD_ZERO, CD_HC_KINK_LIMIT, diag, es, em, & + EA=ea, EI=ei, compression_mode=CD_HC_COMPRESSION_STRICT, elem_h_kappa=hk) + END IF + IF (es /= CD_HCSTAT_OK) THEN + message = WHAT//'could not be diagnosed: '//TRIM(em); RETURN + END IF + beside = .FALSE. + DO k = 1, SIZE(att_node) + DO e = att_node(k) - 1, att_node(k) + IF (e >= 1 .AND. e <= ne) beside(e) = .TRUE. + END DO + END DO + hk_peak = CD_ZERO + e_peak = 0 + DO e = 1, ne + IF (beside(e)) CYCLE + IF (hk(e) > hk_peak) THEN + hk_peak = hk(e) + e_peak = e + END IF + END DO + IF (hk_peak > CD_HC_KINK_LIMIT) THEN + WRITE (em, '(A,ES12.5,A,ES12.5,A,I0,A)') 'is unresolved/kinked: max(h*kappa)=', hk_peak, & + ' > safety limit=', CD_HC_KINK_LIMIT, ' at element ', e_peak, ' (away from the attachment nodes)' + message = WHAT//TRIM(em); RETURN + END IF + IF (tensile_error .AND. diag%axial_compression) THEN + WRITE (em, '(A,ES12.5,A,ES12.5,A,I0,A,F8.5,A,ES12.5)') & + 'carries axial compression under tensile_safety True: element-mean axial force=', & + diag%axial_strain_min_resultant, ' N below tolerance=', diag%axial_tolerance, ' N at element ', & + diag%axial_strain_min_elem, ', xi=', diag%axial_strain_min_xi, ', strain=', diag%axial_strain_min + message = WHAT//TRIM(em); RETURN + END IF + CALL audit_hermite_static(l0, q, ea, ei, w, diam, endconn_mode, physical, em, ignore_kink=.TRUE.) + IF (.NOT. physical) THEN + message = WHAT//'is rejected: '//TRIM(em); RETURN + END IF + IF (.NOT. stable) THEN + message = WHAT//'is an unstable equilibrium (tangent stiffness not positive definite)'; RETURN + END IF + accepted = .TRUE. + END SUBROUTINE CD_Attachment_Discrete_Verdict + + SUBROUTINE audit_hermite_static(l0, q, ea, ei, w, diam, endconn_mode, physical, message, compression_note, & + ignore_kink) !! Physical-branch audit of a converged deck cable (CD_HermiteCable_Branch_Audit). + !! ignore_kink (optional, default false): accept a state that fails only the audit's kink + !! test (the last it applies), for a caller that judges the kink limit itself. !! A rotationally restrained end (Finite/Rigid connection) may turn the centreline !! against the chord heading inside its bending boundary layer, of length !! sqrt(EI/T) at the end tension; five such lengths (at most a quarter of the line) @@ -5848,6 +6115,7 @@ SUBROUTINE audit_hermite_static(l0, q, ea, ei, w, diam, endconn_mode, physical, LOGICAL, INTENT(OUT) :: physical CHARACTER(*), INTENT(OUT) :: message CHARACTER(*), INTENT(OUT), OPTIONAL :: compression_note + LOGICAL, INTENT(IN), OPTIONAL :: ignore_kink TYPE(CD_HermiteBranchAuditType) :: audit REAL(wp) :: zone(2), qe(12), t_end, total, allowance, hl_max, excess, denom LOGICAL :: report_c @@ -5881,6 +6149,9 @@ SUBROUTINE audit_hermite_static(l0, q, ea, ei, w, diam, endconn_mode, physical, RETURN END IF physical = audit%physical + IF (PRESENT(ignore_kink)) THEN + IF (ignore_kink .AND. audit%failed_check == CD_HC_AUDIT_KINK) physical = .TRUE. + END IF IF (PRESENT(compression_note)) THEN ! Mesh adequacy: a cubic-Hermite element longer than the bending length ! lambda = (EI/|w|)^(1/3) cannot follow the bends of the line (touchdown, arch, @@ -5935,6 +6206,7 @@ SUBROUTINE audit_hermite_static(l0, q, ea, ei, w, diam, endconn_mode, physical, WRITE (message, '(A,ES10.3,A,ES10.3,A,I0)') 'unresolved/kinked equilibrium: max(h*kappa)=', & audit%h_kappa_peak, ' > safety limit=', CD_HC_KINK_LIMIT, ' at element ', audit%h_kappa_elem END SELECT + IF (physical) message = '' END SUBROUTINE audit_hermite_static FUNCTION diam_on(l0_deck, l0, diam_deck) RESULT(diam) diff --git a/src/CableDyn_HermiteCableStatic.f90 b/src/CableDyn_HermiteCableStatic.f90 index 88829029..22b34085 100644 --- a/src/CableDyn_HermiteCableStatic.f90 +++ b/src/CableDyn_HermiteCableStatic.f90 @@ -5104,7 +5104,8 @@ END SUBROUTINE reject_unresolved_sequence SUBROUTINE CD_HermiteCable_Resolution_Metrics(l0, q, seabed_z, contact_band, & h_kappa_target, diag, ErrStat, ErrMsg, & - bathymetry, contact_frame_cs, EA, EI, compression_mode) + bathymetry, contact_frame_cs, EA, EI, compression_mode, & + elem_h_kappa, chatter_node) !! Diagnose the mesh resolution of a converged finite-EI static IC and recommend a global !! refinement factor. This is the preflight trigger for the adaptive mesh policy: a lazy-wave !! arch or touchdown transition resolved with too few elements carries a large h*kappa and @@ -5126,6 +5127,10 @@ SUBROUTINE CD_HermiteCable_Resolution_Metrics(l0, q, seabed_z, contact_band, & !! element force tolerance of diag%axial_compression (see the constants). !! STRICT judges the three-element mean of the element-mean axial force !! (smoothed_element_means) instead of the pointwise resultant. + !! elem_h_kappa(ne) (optional out): l0(e) * peak |kappa| of every element, the field whose + !! maximum is h_kappa_peak (the local refinement of AutoMesh marks from it). + !! chatter_node(ne+1) (optional out): every interior node whose contact state differs from + !! both of its neighbours (the nodes behind diag%contact_chatter). REAL(wp), INTENT(IN) :: l0(:), q(:), seabed_z, contact_band, h_kappa_target TYPE(CD_HermiteResolutionType), INTENT(OUT) :: diag INTEGER, INTENT(OUT) :: ErrStat @@ -5134,6 +5139,8 @@ SUBROUTINE CD_HermiteCable_Resolution_Metrics(l0, q, seabed_z, contact_band, & REAL(wp), INTENT(IN), OPTIONAL :: contact_frame_cs(2) REAL(wp), INTENT(IN), OPTIONAL :: EA(:), EI(:) INTEGER, INTENT(IN), OPTIONAL :: compression_mode + REAL(wp), INTENT(OUT), OPTIONAL :: elem_h_kappa(:) + LOGICAL, INTENT(OUT), OPTIONAL :: chatter_node(:) INTEGER :: ne, nn, e, a, es3, mode REAL(wp) :: qe(12), ke, ke_prev, hk, u_peak, z, z_floor, xg, yg, contact_cs(2), & @@ -5166,6 +5173,20 @@ SUBROUTINE CD_HermiteCable_Resolution_Metrics(l0, q, seabed_z, contact_band, & ErrStat = CD_HCSTAT_BADINPUT ErrMsg = 'CD_HermiteCable_Resolution_Metrics: q must be 6*(ne+1)'; RETURN END IF + IF (PRESENT(elem_h_kappa)) THEN + IF (SIZE(elem_h_kappa) /= ne) THEN + ErrStat = CD_HCSTAT_BADINPUT + ErrMsg = 'CD_HermiteCable_Resolution_Metrics: elem_h_kappa must have length ne'; RETURN + END IF + elem_h_kappa = CD_ZERO + END IF + IF (PRESENT(chatter_node)) THEN + IF (SIZE(chatter_node) /= nn) THEN + ErrStat = CD_HCSTAT_BADINPUT + ErrMsg = 'CD_HermiteCable_Resolution_Metrics: chatter_node must have length ne+1'; RETURN + END IF + chatter_node = .FALSE. + END IF IF (PRESENT(EA)) THEN IF (SIZE(EA) /= ne .OR. .NOT. CD_All_Finite(EA) .OR. ANY(EA < CD_ZERO)) THEN ErrStat = CD_HCSTAT_BADINPUT @@ -5248,6 +5269,7 @@ SUBROUTINE CD_HermiteCable_Resolution_Metrics(l0, q, seabed_z, contact_band, & END IF diag%kappa_peak = MAX(diag%kappa_peak, ke) hk = l0(e)*ke + IF (PRESENT(elem_h_kappa)) elem_h_kappa(e) = hk IF (hk > diag%h_kappa_peak) THEN diag%h_kappa_peak = hk diag%h_kappa_elem = e @@ -5399,6 +5421,12 @@ SUBROUTINE CD_HermiteCable_Resolution_Metrics(l0, q, seabed_z, contact_band, & EXIT END IF END DO + IF (PRESENT(chatter_node)) THEN + DO a = 2, nn - 1 + chatter_node(a) = (contact_node(a) .NEQV. contact_node(a - 1)) .AND. & + (contact_node(a) .NEQV. contact_node(a + 1)) + END DO + END IF ! Recommended global refinement: the smallest power-of-two factor that brings h_kappa_peak ! at or below the target, capped so a pathological IC cannot ask for an unbounded mesh. @@ -6129,7 +6157,7 @@ SUBROUTINE CD_HermiteCable_Static_Solve_AutoMesh(l0, EA, EI, w, seed, fixed_dofs require_tensile, refine_non_axial, endconn_stiffness, & endconn_direction, endconn_mode, waterline_z, dry_buoyancy, & compression_mode, energy_polish_in, tensile_advisory, water_weight, & - current) + current, local_refinement, max_elements) !! Solve the finite-EI static equilibrium and AUTOMATICALLY select the minimum safe mesh: the !! metric-gated mesh-economics entry. Solve at the caller's (coarse) mesh; if !! CD_HermiteCable_Resolution_Metrics flags it fragile, refine by the recommended power-of-two @@ -6166,6 +6194,24 @@ SUBROUTINE CD_HermiteCable_Static_Solve_AutoMesh(l0, EA, EI, w, seed, fixed_dofs !! energy_polish_in (optional, default false): polish the initial state and every !! prolongated refinement with the trust-region energy minimization of !! CD_HermiteCable_Static_Solve instead of the damped Newton update. + !! max_elements (optional): a lower element limit than AUTO_MAX_ELEMENTS (8192), the most + !! elements a refinement may produce; values outside [1, 8192] use 8192. It lets + !! a test reach the limit on a small, well-conditioned line. + !! local_refinement (optional, default false): refine for the curvature, end boundary-layer + !! and contact-topology screens element by element instead of globally. A + !! pass runs when the same screens fail as for the global refinement; it + !! splits into the power-of-two number of equal children that meets its + !! criterion every element whose h*kappa exceeds min(h_kappa_target, + !! CD_HC_HKAPPA_TARGET), every element longer than half its bending length + !! (EI/|w|)^(1/3), each end element for its boundary-layer ratio, and the + !! elements about an isolated contact or gap node once (local_resolution_mesh); + !! the neighbours are then split until the mesh is graded (grade). Every + !! element keeps the cumulative cap max_scale relative to its caller element, + !! the mesh keeps the element limit of the global refinement, and the split + !! elements are cubic-Hermite prolongated exactly as there. The pass repeats + !! on the re-solved state while a screen fails and an element can still be + !! split. applied_scale then reports the largest factor of any element. The + !! axial (tensile) refinement is local in either mode and unchanged. REAL(wp), INTENT(IN) :: l0(:), EA(:), EI(:), w(:), seed(:) INTEGER, INTENT(IN) :: fixed_dofs(:) REAL(wp), INTENT(IN) :: seabed_z, kn, tol, damping, h_kappa_target, contact_band @@ -6187,11 +6233,23 @@ SUBROUTINE CD_HermiteCable_Static_Solve_AutoMesh(l0, EA, EI, w, seed, fixed_dofs REAL(wp), INTENT(IN), OPTIONAL :: waterline_z, dry_buoyancy(:), water_weight TYPE(CD_HermiteStaticCurrentType), INTENT(IN), OPTIONAL :: current INTEGER, INTENT(IN), OPTIONAL :: compression_mode - LOGICAL, INTENT(IN), OPTIONAL :: energy_polish_in, tensile_advisory + LOGICAL, INTENT(IN), OPTIONAL :: energy_polish_in, tensile_advisory, local_refinement + INTEGER, INTENT(IN), OPTIONAL :: max_elements INTEGER :: ne, nn, it, scale, parent, j, es, axial_order, bending_order, local_passes, cmode LOGICAL :: energy_polish, advisory INTEGER, PARAMETER :: MAX_LOCAL_AXIAL_PASSES = 16 + ! Local resolution refinement (local_refinement): passes, the per-element level cap + ! (log2 of max_scale), every element's number of bisections from its caller element, + ! and the per-element h*kappa and isolated contact/gap nodes of the last diagnosis. + INTEGER, PARAMETER :: MAX_LOCAL_RESOLUTION_PASSES = 12 + LOGICAL :: local_mode, nothing_to_split + INTEGER :: kcap, local_res_passes, element_limit + ! What stopped the local refinement short of its targets, other than the per-element cap. + CHARACTER(160) :: local_stop + INTEGER, ALLOCATABLE :: level_out(:), level_r(:) + REAL(wp), ALLOCATABLE :: elem_hk(:) + LOGICAL, ALLOCATABLE :: chatter_nodes(:) REAL(wp), ALLOCATABLE :: l0r(:), qr(:), EAr(:), EIr(:), wr(:), qnew(:), curvnew(:) REAL(wp), ALLOCATABLE :: contact_diam_out(:), contact_diam_r(:) ! Current-mesh dry buoyancy; unallocated (an absent optional) without a free surface. @@ -6246,6 +6304,14 @@ SUBROUTINE CD_HermiteCable_Static_Solve_AutoMesh(l0, EA, EI, w, seed, fixed_dofs max_axial_stall_passes = MERGE(4, 2, cmode == CD_HC_COMPRESSION_STRICT) energy_polish = .FALSE. IF (PRESENT(energy_polish_in)) energy_polish = energy_polish_in + local_mode = .FALSE. + IF (PRESENT(local_refinement)) local_mode = local_refinement + element_limit = AUTO_MAX_ELEMENTS + IF (PRESENT(max_elements)) THEN + IF (max_elements >= 1 .AND. max_elements < AUTO_MAX_ELEMENTS) element_limit = max_elements + END IF + local_res_passes = 0 + local_stop = '' IF (max_scale < 1) THEN ErrStat = CD_HCSTAT_BADINPUT; ErrMsg = 'CD_HermiteCable_Static_Solve_AutoMesh: max_scale >= 1 required'; RETURN @@ -6281,6 +6347,12 @@ SUBROUTINE CD_HermiteCable_Static_Solve_AutoMesh(l0, EA, EI, w, seed, fixed_dofs ErrStat = CD_HCSTAT_BADINPUT ErrMsg = 'CD_HermiteCable_Static_Solve_AutoMesh: l0/EA/EI/w/seed sizes inconsistent'; RETURN END IF + kcap = 0 + DO WHILE (2_I8**(kcap + 1) <= INT(max_scale, I8)) + kcap = kcap + 1 + END DO + ALLOCATE (level_out(ne)) + level_out = 0 axial_budget = MAX(max_scale, CD_HC_REFINE_CAP) IF (axial_budget > HUGE(axial_budget)/ne) THEN axial_budget = HUGE(axial_budget) @@ -6324,15 +6396,7 @@ SUBROUTINE CD_HermiteCable_Static_Solve_AutoMesh(l0, EA, EI, w, seed, fixed_dofs END IF ! Diagnose; refine and re-solve while fragile and under the cap. - IF (PRESENT(bathymetry)) THEN - CALL CD_HermiteCable_Resolution_Metrics(l0_out, q_out, seabed_z, contact_band, h_kappa_target, & - diag_out, es, ErrMsg, bathymetry=bathymetry, & - contact_frame_cs=contact_cs, EA=EA_out, EI=EI_out, & - compression_mode=cmode) - ELSE - CALL CD_HermiteCable_Resolution_Metrics(l0_out, q_out, seabed_z, contact_band, h_kappa_target, & - diag_out, es, ErrMsg, EA=EA_out, EI=EI_out, compression_mode=cmode) - END IF + CALL diagnose(es) IF (es /= CD_HCSTAT_OK) THEN ErrStat = es; RETURN END IF @@ -6346,8 +6410,16 @@ SUBROUTINE CD_HermiteCable_Static_Solve_AutoMesh(l0, EA, EI, w, seed, fixed_dofs (diag_out%axial_strain_min_elem == SIZE(l0_out) .AND. & diag_out%axial_strain_min_xi >= CD_ONE - 1.0e-6_wp)) end_res_prev = diag_out%axial_strain_min_resultant + ! A local resolution pass runs while an element can still be split (local_resolution_mesh + ! says when none can), at most MAX_LOCAL_RESOLUTION_PASSES times, and in the local mode an + ! axial pass at most MAX_LOCAL_AXIAL_PASSES times (applied_scale, the largest factor of + ! any element there, need not grow with every pass); the global passes, and the axial + ! passes of the global mode, keep their cumulative-factor bound. DO WHILE (needs_refinement .AND. & - (applied_scale < max_scale .OR. (local_axial .AND. local_passes < MAX_LOCAL_AXIAL_PASSES))) + ((local_axial .AND. local_passes < MAX_LOCAL_AXIAL_PASSES) .OR. & + (.NOT. local_mode .AND. applied_scale < max_scale) .OR. & + (.NOT. local_axial .AND. local_mode .AND. kcap > 0 .AND. & + local_res_passes < MAX_LOCAL_RESOLUTION_PASSES))) ! A signed axial oscillation is local, usually at a section interface or the ! touchdown transition. Split every offending element and its immediate ! neighbours rather than multiplying the whole installed line. Curvature or @@ -6370,20 +6442,33 @@ SUBROUTINE CD_HermiteCable_Static_Solve_AutoMesh(l0, EA, EI, w, seed, fixed_dofs END IF END IF scale = 2 + IF (es == CD_HCSTAT_OK) THEN + ALLOCATE (level_r(SIZE(l0r))) + DO j = 1, SIZE(l0r) + level_r(j) = level_out(parent_map(j)) + MERGE(1, 0, axial_marks(parent_map(j))) + END DO + END IF + ELSE IF (local_mode) THEN + ! Split the elements whose screen fails, graded into their neighbours. + local_res_passes = local_res_passes + 1 + CALL local_resolution_mesh(nothing_to_split, es, emloc) + IF (es == CD_HCSTAT_OK .AND. nothing_to_split) EXIT + scale = 2 ELSE ! Mesh-scale contact chatter can report rec_scale = 1 (a topology signal), so ! force at least one doubling; never exceed the cumulative cap. scale = MAX(2, diag_out%rec_scale) - DO WHILE ((applied_scale*scale > max_scale .OR. SIZE(l0_out)*scale > AUTO_MAX_ELEMENTS) .AND. scale > 1) + DO WHILE ((applied_scale*scale > max_scale .OR. SIZE(l0_out)*scale > element_limit) .AND. scale > 1) scale = scale/2 END DO IF (scale < 2) EXIT CALL CD_HermiteCable_Refine_Mesh(l0_out, q_out, fixed_out, scale, l0r, qr, fixedr, es, emloc, & inherit_dofs=inherit_dofs) IF (es == CD_HCSTAT_OK) THEN - ALLOCATE (parent_map(SIZE(l0r))) + ALLOCATE (parent_map(SIZE(l0r)), level_r(SIZE(l0r))) DO j = 1, SIZE(l0r) parent_map(j) = (j - 1)/scale + 1 + level_r(j) = level_out(parent_map(j)) + NINT(LOG(REAL(scale, wp))/LOG(2.0_wp)) END DO END IF END IF @@ -6453,21 +6538,18 @@ SUBROUTINE CD_HermiteCable_Static_Solve_AutoMesh(l0, EA, EI, w, seed, fixed_dofs CALL MOVE_ALLOC(qnew, q_out) CALL MOVE_ALLOC(curvnew, curv_out) DEALLOCATE (qr) - IF (local_axial) THEN + CALL MOVE_ALLOC(level_r, level_out) + IF (local_mode) THEN + ! The largest factor of any element from its caller element (an axial pass splits + ! only the marked elements, so it raises the factor of those alone). + applied_scale = MAX(applied_scale, MIN(max_scale, 2**MIN(MAXVAL(level_out), 30))) + ELSE IF (local_axial) THEN applied_scale = MIN(max_scale, applied_scale*scale) ELSE applied_scale = applied_scale*scale END IF - IF (PRESENT(bathymetry)) THEN - CALL CD_HermiteCable_Resolution_Metrics(l0_out, q_out, seabed_z, contact_band, h_kappa_target, & - diag_out, es, ErrMsg, bathymetry=bathymetry, & - contact_frame_cs=contact_cs, EA=EA_out, EI=EI_out, & - compression_mode=cmode) - ELSE - CALL CD_HermiteCable_Resolution_Metrics(l0_out, q_out, seabed_z, contact_band, h_kappa_target, & - diag_out, es, ErrMsg, EA=EA_out, EI=EI_out, compression_mode=cmode) - END IF + CALL diagnose(es) IF (es /= CD_HCSTAT_OK) THEN ErrStat = es; RETURN END IF @@ -6504,6 +6586,14 @@ SUBROUTINE CD_HermiteCable_Static_Solve_AutoMesh(l0, EA, EI, w, seed, fixed_dofs EXIT END IF END DO + ! In the local mode, name a pass limit that stopped the refinement (the element limit is + ! named by local_resolution_mesh; a refinement that stops at the per-element cap keeps + ! the cap wording below). + IF (local_mode .AND. LEN_TRIM(local_stop) == 0 .AND. local_res_passes >= MAX_LOCAL_RESOLUTION_PASSES) & + WRITE (local_stop, '(A,I0,A)', IOSTAT=wios) 'the limit of ', MAX_LOCAL_RESOLUTION_PASSES, & + ' refinement passes was reached' + IF (local_mode .AND. LEN_TRIM(axial_stop) == 0 .AND. local_passes >= MAX_LOCAL_AXIAL_PASSES) & + WRITE (axial_stop, '(A,I0,A)', IOSTAT=wios) 'the limit of ', MAX_LOCAL_AXIAL_PASSES, ' passes was reached' ! A residual-converged, element-localized fold is not a usable equilibrium. ! Enforce this numerical-safety bound for every AutoMesh caller, including @@ -6518,6 +6608,7 @@ SUBROUTINE CD_HermiteCable_Static_Solve_AutoMesh(l0, EA, EI, w, seed, fixed_dofs 'CD_HermiteCable_Static_Solve_AutoMesh: unresolved/kinked equilibrium: max(h*kappa)=', & diag_out%h_kappa_peak, ' > safety limit=', CD_HC_KINK_LIMIT, & ' at element ', diag_out%h_kappa_elem + IF (LEN_TRIM(local_stop) > 0) wbuf = TRIM(wbuf)//' (local refinement stopped: '//TRIM(local_stop)//')' ErrMsg = wbuf RETURN END IF @@ -6535,6 +6626,13 @@ SUBROUTINE CD_HermiteCable_Static_Solve_AutoMesh(l0, EA, EI, w, seed, fixed_dofs ' N below tolerance=', diag_out%axial_tolerance, ' N at element ', & diag_out%axial_strain_min_elem, ', xi=', diag_out%axial_strain_min_xi, & ', strain=', diag_out%axial_strain_min + ELSE IF (LEN_TRIM(local_stop) > 0) THEN + WRITE (wbuf, '(A,ES12.5,A,ES12.5,A,I0,A,F8.5,A,ES12.5)', IOSTAT=wios) & + 'CD_HermiteCable_Static_Solve_AutoMesh: local refinement stopped ('//TRIM(local_stop)// & + ') with compressive axial resultant=', diag_out%axial_strain_min_resultant, & + ' N below tolerance=', diag_out%axial_tolerance, ' N at element ', & + diag_out%axial_strain_min_elem, ', xi=', diag_out%axial_strain_min_xi, & + ', strain=', diag_out%axial_strain_min ELSE WRITE (wbuf, '(A,I0,A,ES12.5,A,ES12.5,A,I0,A,F8.5,A,ES12.5)', IOSTAT=wios) & 'CD_HermiteCable_Static_Solve_AutoMesh: refinement cap ', max_scale, & @@ -6564,11 +6662,19 @@ SUBROUTINE CD_HermiteCable_Static_Solve_AutoMesh(l0, EA, EI, w, seed, fixed_dofs (diag_out%h_kappa_peak > h_kappa_target .OR. diag_out%contact_chatter)) THEN ErrStat = CD_HCSTAT_NOCONVERGE wbuf = '' - WRITE (wbuf, '(A,I0,A,ES12.5,A,ES12.5,A,L1,A,I0)', IOSTAT=wios) & - 'CD_HermiteCable_Static_Solve_AutoMesh: refinement cap ', max_scale, & - ' exhausted with unresolved h*kappa=', diag_out%h_kappa_peak, ' (target ', h_kappa_target, & - '), contact chatter=', diag_out%contact_chatter, & - ', contact islands=', diag_out%n_islands + IF (LEN_TRIM(local_stop) > 0) THEN + WRITE (wbuf, '(A,ES12.5,A,ES12.5,A,L1,A,I0)', IOSTAT=wios) & + 'CD_HermiteCable_Static_Solve_AutoMesh: local refinement stopped ('//TRIM(local_stop)// & + ') with unresolved h*kappa=', diag_out%h_kappa_peak, ' (target ', h_kappa_target, & + '), contact chatter=', diag_out%contact_chatter, & + ', contact islands=', diag_out%n_islands + ELSE + WRITE (wbuf, '(A,I0,A,ES12.5,A,ES12.5,A,L1,A,I0)', IOSTAT=wios) & + 'CD_HermiteCable_Static_Solve_AutoMesh: refinement cap ', max_scale, & + ' exhausted with unresolved h*kappa=', diag_out%h_kappa_peak, ' (target ', h_kappa_target, & + '), contact chatter=', diag_out%contact_chatter, & + ', contact islands=', diag_out%n_islands + END IF ErrMsg = wbuf RETURN END IF @@ -6634,11 +6740,232 @@ LOGICAL FUNCTION refinable(dg) !! topology, and for an unresolved end boundary layer only while the remaining !! refinement cap can still bring h/sqrt(EI/T) to its target. TYPE(CD_HermiteResolutionType), INTENT(IN) :: dg + IF (local_mode) THEN + ! As below, with the factor still open to the end element of the larger ratio (on + ! the caller mesh exactly the global test, so the same meshes refine). + refinable = dg%h_kappa_peak > h_kappa_target .OR. dg%contact_chatter .OR. & + (dg%boundary_unresolved .AND. & + dg%boundary_ratio_peak <= CD_HC_BOUNDARY_TARGET*REAL(max_scale, wp)/ & + 2.0_wp**MERGE(level_out(1), level_out(SIZE(level_out)), & + dg%hop_boundary_ratio >= dg%end_boundary_ratio)) + RETURN + END IF refinable = dg%h_kappa_peak > h_kappa_target .OR. dg%contact_chatter .OR. & (dg%boundary_unresolved .AND. & dg%boundary_ratio_peak <= CD_HC_BOUNDARY_TARGET*REAL(max_scale, wp)/REAL(applied_scale, wp)) END FUNCTION refinable + INTEGER FUNCTION end_layer_levels(ratio, level) RESULT(k) + !! Bisections of an end element (at level bisections from its caller element) that bring + !! its boundary-layer ratio h/sqrt(EI/T) to CD_HC_BOUNDARY_TARGET, within the cap; zero + !! when the ratio is met. A layer the cap cannot reach is an accuracy limit (reported by + !! diag%boundary_unresolved) that does not by itself start a pass (refinable), but a + !! pass that runs refines it as far as the cap allows -- as the global factor rec_scale + !! does. + REAL(wp), INTENT(IN) :: ratio + INTEGER, INTENT(IN) :: level + k = 0 + IF (.NOT. (ratio > CD_HC_BOUNDARY_TARGET*(CD_ONE + 1.0e-10_wp))) RETURN + DO WHILE (ratio > CD_HC_BOUNDARY_TARGET*2.0_wp**k*(CD_ONE + 1.0e-10_wp) .AND. level + k < kcap) + k = k + 1 + END DO + END FUNCTION end_layer_levels + + SUBROUTINE diagnose(esx) + !! Resolution diagnosis of the current mesh and state (diag_out); in local mode also the + !! per-element h*kappa and the isolated contact/gap nodes the local refinement marks from. + INTEGER, INTENT(OUT) :: esx + IF (local_mode) THEN + IF (ALLOCATED(elem_hk)) DEALLOCATE (elem_hk, chatter_nodes) + ALLOCATE (elem_hk(SIZE(l0_out)), chatter_nodes(SIZE(l0_out) + 1)) + IF (PRESENT(bathymetry)) THEN + CALL CD_HermiteCable_Resolution_Metrics(l0_out, q_out, seabed_z, contact_band, h_kappa_target, & + diag_out, esx, ErrMsg, bathymetry=bathymetry, & + contact_frame_cs=contact_cs, EA=EA_out, EI=EI_out, & + compression_mode=cmode, elem_h_kappa=elem_hk, & + chatter_node=chatter_nodes) + ELSE + CALL CD_HermiteCable_Resolution_Metrics(l0_out, q_out, seabed_z, contact_band, h_kappa_target, & + diag_out, esx, ErrMsg, EA=EA_out, EI=EI_out, & + compression_mode=cmode, elem_h_kappa=elem_hk, & + chatter_node=chatter_nodes) + END IF + ELSE IF (PRESENT(bathymetry)) THEN + CALL CD_HermiteCable_Resolution_Metrics(l0_out, q_out, seabed_z, contact_band, h_kappa_target, & + diag_out, esx, ErrMsg, bathymetry=bathymetry, & + contact_frame_cs=contact_cs, EA=EA_out, EI=EI_out, & + compression_mode=cmode) + ELSE + CALL CD_HermiteCable_Resolution_Metrics(l0_out, q_out, seabed_z, contact_band, h_kappa_target, & + diag_out, esx, ErrMsg, EA=EA_out, EI=EI_out, compression_mode=cmode) + END IF + END SUBROUTINE diagnose + + SUBROUTINE local_resolution_mesh(none, esx, emx) + !! The locally refined mesh of a local resolution pass, in l0r/qr/fixedr with parent_map + !! (the current element each new one lies in) and level_r. Levels needed per element: + !! h*kappa -- the smallest k with h*kappa / 2^k <= min(h_kappa_target, + !! CD_HC_HKAPPA_TARGET). A pass runs only while the caller's target fails, + !! but it refines every element to the accuracy target (a looser caller + !! target, such as the safety-driven half kink limit, would leave the bends + !! of a locally refined line at a much coarser resolution than the global + !! factor, which refines every element by the factor of the worst one); + !! bending -- the smallest k with h / 2^k <= half the bending length (EI/|w|)^(1/3), + !! the element-length rule of the finite-EI meshing guide: an element longer + !! than that cannot follow a bend (a grounded run over an uneven bed, a + !! touchdown) whose curvature it therefore does not show, and on such a mesh + !! a planar state can read as unstable out of its plane; + !! end layer -- end_layer_levels of each end element (as far as the cap allows); + !! contact -- one level on the two elements at an isolated contact or gap node and + !! one more on each side; + !! each limited to kcap bisections from the caller element. The levels are then graded: + !! an element is split further while it is longer than max(2, its length ratio to the + !! neighbour before the pass) times that neighbour's new length. A pass that would exceed + !! the element limit (element_limit) gives up first the bending-length levels (one + !! level at a time, graded), then the grading, and only then takes one level less of the + !! h*kappa, end-layer and contact needs at a time: those name a bend or a boundary layer + !! the state shows, where the bending-length rule is a mesh-quality rule. none is set + !! when no element can be split. + LOGICAL, INTENT(OUT) :: none + INTEGER, INTENT(OUT) :: esx + CHARACTER(*), INTENT(OUT) :: emx + INTEGER, ALLOCATABLE :: base(:), bend(:), need(:), need_n(:), lev_c(:), lev_n(:), par_c(:), par_n(:) + INTEGER, ALLOCATABLE :: fix_c(:), fix_n(:) + REAL(wp), ALLOCATABLE :: l0_c(:), q_c(:), l0_n(:), q_n(:) + LOGICAL, ALLOCATABLE :: split(:) + INTEGER :: nec, e, a, k, red + INTEGER(I8) :: n_new + REAL(wp) :: hk_local, half_bend + LOGICAL :: fits + none = .TRUE. + esx = CD_HCSTAT_OK + emx = '' + nec = SIZE(l0_out) + ! base: the h*kappa, end-layer and contact needs; bend: the bending-length needs. + ALLOCATE (base(nec), bend(nec), need(nec)) + hk_local = MIN(h_kappa_target, CD_HC_HKAPPA_TARGET) + base = 0 + bend = 0 + DO e = 1, nec + IF (.NOT. (elem_hk(e) > hk_local)) CYCLE + k = 0 + DO WHILE (elem_hk(e) > hk_local*2.0_wp**k .AND. level_out(e) + k < kcap) + k = k + 1 + END DO + base(e) = MAX(base(e), k) + END DO + DO e = 1, nec + IF (.NOT. (EI_out(e) > CD_ZERO .AND. ABS(w_out(e)) > CD_ZERO)) CYCLE + half_bend = 0.5_wp*(EI_out(e)/ABS(w_out(e)))**(CD_ONE/3.0_wp) + k = 0 + DO WHILE (l0_out(e) > half_bend*2.0_wp**k*(CD_ONE + 1.0e-12_wp) .AND. level_out(e) + k < kcap) + k = k + 1 + END DO + bend(e) = k + END DO + base(1) = MAX(base(1), end_layer_levels(diag_out%hop_boundary_ratio, level_out(1))) + base(nec) = MAX(base(nec), end_layer_levels(diag_out%end_boundary_ratio, level_out(nec))) + DO a = 2, nec + IF (.NOT. chatter_nodes(a)) CYCLE + DO e = MAX(1, a - 2), MIN(nec, a + 1) + IF (level_out(e) < kcap) base(e) = MAX(base(e), 1) + END DO + END DO + IF (ALL(base == 0) .AND. ALL(bend == 0)) RETURN + ! Within the element limit: the bending-length levels go first, then the grading, then + ! the other needs a level at a time (the first try is the whole graded need). + fits = .FALSE. + DO red = 0, MAXVAL(bend) + need = MAX(base, bend - red) + CALL grade(need) + n_new = SUM(2_I8**need) + fits = n_new <= INT(element_limit, I8) + IF (fits) EXIT + END DO + DO red = 0, MAXVAL(base) + IF (fits) EXIT + need = MAX(base - red, 0) + n_new = SUM(2_I8**need) + fits = n_new <= INT(element_limit, I8) + END DO + IF (.NOT. fits .OR. ALL(need == 0)) THEN + ! A need was given up to the limit (with no need at all the early return above names + ! the per-element cap). + WRITE (local_stop, '(A,I0,A)') 'the element limit ', element_limit, ' was reached' + RETURN + END IF + none = .FALSE. + + ! Bisect level by level: the children of a split cubic-Hermite element carry the same + ! cubic, so k bisections are the 2^k-fold uniform prolongation of the element. + l0_c = l0_out + q_c = q_out + fix_c = fixed_out + lev_c = level_out + ALLOCATE (par_c(nec)) + par_c = [(e, e=1, nec)] + DO WHILE (ANY(need > 0)) + split = need > 0 + CALL refine_marked_elements(l0_c, q_c, fix_c, split, l0_n, q_n, fix_n, par_n, esx, emx, inherit_dofs) + IF (esx /= CD_HCSTAT_OK) RETURN + ALLOCATE (need_n(SIZE(l0_n)), lev_n(SIZE(l0_n))) + DO e = 1, SIZE(l0_n) + need_n(e) = need(par_n(e)) - MERGE(1, 0, split(par_n(e))) + lev_n(e) = lev_c(par_n(e)) + MERGE(1, 0, split(par_n(e))) + par_n(e) = par_c(par_n(e)) + END DO + CALL MOVE_ALLOC(l0_n, l0_c) + CALL MOVE_ALLOC(q_n, q_c) + CALL MOVE_ALLOC(fix_n, fix_c) + CALL MOVE_ALLOC(par_n, par_c) + CALL MOVE_ALLOC(need_n, need) + CALL MOVE_ALLOC(lev_n, lev_c) + END DO + CALL MOVE_ALLOC(l0_c, l0r) + CALL MOVE_ALLOC(q_c, qr) + CALL MOVE_ALLOC(fix_c, fixedr) + CALL MOVE_ALLOC(par_c, parent_map) + CALL MOVE_ALLOC(lev_c, level_r) + END SUBROUTINE local_resolution_mesh + + SUBROUTINE grade(need) + !! Raise need until no element of the refined mesh is longer than max(2, its length + !! ratio to the neighbour on the current mesh) times that neighbour's refined length, + !! within the per-element cap, and no element left longer than both of its neighbours + !! is split fewer times (from its caller element) than both: such an element is split + !! until it is no longer than the longer neighbour or as often as the less split one. + !! (A single coarser element between finer ones carries a spurious axial oscillation + !! and can read as a compressed stretch.) + INTEGER, INTENT(INOUT) :: need(:) + LOGICAL :: changed + INTEGER :: e, side, f, g, lm + REAL(wp) :: allow, lnb + changed = .TRUE. + DO WHILE (changed) + changed = .FALSE. + DO e = 2, SIZE(need) - 1 + lm = MIN(level_out(e - 1) + need(e - 1), level_out(e + 1) + need(e + 1), kcap) + lnb = MAX(l0_out(e - 1)/2.0_wp**need(e - 1), l0_out(e + 1)/2.0_wp**need(e + 1)) + DO WHILE (l0_out(e)/2.0_wp**need(e) > lnb*(CD_ONE + 1.0e-12_wp) .AND. level_out(e) + need(e) < lm) + need(e) = need(e) + 1 + changed = .TRUE. + END DO + END DO + DO e = 1, SIZE(need) - 1 + DO side = 0, 1 + f = e + side + g = e + 1 - side + allow = MAX(2.0_wp, l0_out(f)/l0_out(g))*(CD_ONE + 1.0e-12_wp) + DO WHILE (l0_out(f)/2.0_wp**need(f) > allow*l0_out(g)/2.0_wp**need(g) .AND. & + level_out(f) + need(f) < kcap) + need(f) = need(f) + 1 + changed = .TRUE. + END DO + END DO + END DO + END DO + END SUBROUTINE grade + SUBROUTINE solve_level(l0x, EAx, EIx, wx, seedx, fixedx, diamx, dryx, qx, curvx, resx, itx, esx, emx, polish) REAL(wp), INTENT(IN) :: l0x(:), EAx(:), EIx(:), wx(:), seedx(:) INTEGER, INTENT(IN) :: fixedx(:) diff --git a/tests/test_attachment_cross_current.py b/tests/test_attachment_cross_current.py new file mode 100644 index 00000000..29305eee --- /dev/null +++ b/tests/test_attachment_cross_current.py @@ -0,0 +1,119 @@ +#!/usr/bin/env python3 +# SPDX-License-Identifier: Apache-2.0 +# Copyright (c) 2026 Jae Hoon Seo, SMI Lab, Inha University +"""Discrete buoyancy modules on a lazy wave in a cross current, against the smeared section. + +The lazy-wave power cable of ``tests/data/lazy_wave_touchdown_planar_{refined,coarse}_att.dat`` +(25 discrete buoyancy modules at a 4 m pitch, rigid end connections, seabed friction 0.35) is +put in a uniform current across its vertical plane. The static solve reaches the discrete +equilibrium from the smeared one by a homotopy in the module loads and drag; on the refined +mesh in 0.3 m/s its damped Newton steps diverge on the frictional seabed, and the polish must +fall back to its regularised solves rather than fail (its note naming that path is required). + +Every deck must solve (exit 0), and its line-end tensions must agree with the deck that +replaces the modules by the equivalent smeared section (the same submerged weight, displaced +volume and normal drag per metre over the stretch the modules cover): FairTen within 1 % and +AnchTen within 2 % of the smeared values. + +usage: test_attachment_cross_current.py --exe --data --output

+""" + +from __future__ import annotations + +import argparse +import math +import re +import subprocess +import sys +from pathlib import Path + +# 25 modules at a 4 m pitch from 80 m to 176 m: the smeared stretch runs from 78 m to 178 m. +MODULES, PITCH, M_MOD, V_MOD, CDA_MOD = 25, 4.0, 91.32, 0.18378, 1.392 +BARE_D, BARE_M, BARE_CDN, BARE_CDT = 0.16, 36.70, 1.2, 0.1 +FAIR_TOL, ANCH_TOL = 0.01, 0.02 +CASES = [("refined", 0.3), ("refined", 0.6), ("coarse", 0.3), ("coarse", 0.6)] +# The case whose polish takes the fallback path; its note says so (and that the state passed +# the acceptance checks of the smeared state). +FALLBACK_CASE = "refined_0.3" +FALLBACK_NOTE = "was reached after a failed Newton solve" + + +def with_current(text: str, speed: float) -> str: + """The deck in a uniform current of the given speed across its plane, with AnchTen output.""" + text = re.sub(r"^(0\.0 TMax)$", r"\1\nuniform 0.0 %g 0.0 current" % speed, text, count=1, flags=re.M) + return re.sub(r"^FairTen4$", "FairTen4\nAnchTen4", text, count=1, flags=re.M) + + +def smeared(text: str) -> str: + """The deck with the modules replaced by the equivalent smeared section over 78-178 m.""" + span = MODULES * PITCH + area = math.pi / 4.0 * BARE_D**2 + MODULES * V_MOD / span + d_eq = math.sqrt(4.0 * area / math.pi) + m_eq = BARE_M + MODULES * M_MOD / span + cdn = (BARE_CDN * BARE_D + MODULES * CDA_MOD / span) / d_eq + cdt = BARE_CDT * BARE_D / d_eq + text = re.sub(r"^-+ ATTACHMENTS -+\n(?:(?!-{10}).*\n)*", "", text, count=1, flags=re.M) + bare = re.search(r"^bare .*$", text, re.M).group(0) + f = bare.split() + buoy = " ".join(["buoy", "%.6f" % d_eq, "%.4f" % m_eq] + f[3:10] + ["%.6f" % cdn, "%.6f" % cdt] + f[12:]) + text = text.replace(bare, bare + "\n" + buoy, 1) + rows = re.findall(r"^4 bare \S+ \d+$", text, re.M) + h = [float(r.split()[2]) / int(r.split()[3]) for r in rows] + new = ["4 bare 78.0 %d" % round(78.0 / h[0]), "4 buoy 100.0 %d" % round(100.0 / h[1]), + "4 bare 422.0 %d" % round(422.0 / h[2])] + for old, row in zip(rows, new): + text = text.replace(old, row, 1) + return text + + +def run(exe: str, deck: Path) -> tuple[int, dict, str]: + p = subprocess.run([exe, deck.name, "o"], cwd=deck.parent, capture_output=True, text=True, timeout=600) + row = {} + out = deck.parent / "o.out" + if p.returncode == 0 and out.exists(): + lines = [ln for ln in out.read_text().splitlines() if not ln.startswith("#")] + row = dict(zip(lines[0].split(), (float(v) for v in lines[1].split()))) + return p.returncode, row, p.stdout + p.stderr + + +def main() -> int: + ap = argparse.ArgumentParser() + ap.add_argument("--exe", required=True) + ap.add_argument("--data", required=True) + ap.add_argument("--output", required=True) + a = ap.parse_args() + exe = str(Path(a.exe).resolve()) + failures = [] + for mesh, speed in CASES: + base = (Path(a.data) / ("lazy_wave_touchdown_planar_%s_att.dat" % mesh)).read_text() + name = "%s_%g" % (mesh, speed) + results = {} + for kind, text in (("discrete", with_current(base, speed)), ("smeared", smeared(with_current(base, speed)))): + d = Path(a.output) / name / kind + d.mkdir(parents=True, exist_ok=True) + (d / "deck.dat").write_text(text) + rc, row, log = run(exe, d / "deck.dat") + if rc != 0 or "FairTen4" not in row: + failures.append("%s %s: exit %d\n%s" % (name, kind, rc, log[-2000:])) + if kind == "discrete" and name == FALLBACK_CASE and FALLBACK_NOTE not in log: + failures.append("%s: the polish did not report its fallback path" % name) + results[kind] = row + if all("FairTen4" in r for r in results.values()): + disc, smr = results["discrete"], results["smeared"] + dfair = abs(disc["FairTen4"] - smr["FairTen4"]) / smr["FairTen4"] + danch = abs(disc["AnchTen4"] - smr["AnchTen4"]) / smr["AnchTen4"] + print("%-12s FairTen %10.1f / %10.1f N (%.2e) AnchTen %8.1f / %8.1f N (%.2e)" % + (name, disc["FairTen4"], smr["FairTen4"], dfair, disc["AnchTen4"], smr["AnchTen4"], danch)) + if dfair > FAIR_TOL or danch > ANCH_TOL: + failures.append("%s: discrete and smeared tensions differ by %.2e (FairTen) / %.2e (AnchTen)" % + (name, dfair, danch)) + for f in failures: + print("FAIL: " + f) + if failures: + return 1 + print("PASS: discrete buoyancy modules in a cross current match the smeared section") + return 0 + + +if __name__ == "__main__": + sys.exit(main()) diff --git a/tests/test_deck_hermite_cable.f90 b/tests/test_deck_hermite_cable.f90 index 652e30f0..9860d77d 100644 --- a/tests/test_deck_hermite_cable.f90 +++ b/tests/test_deck_hermite_cable.f90 @@ -129,8 +129,9 @@ SUBROUTINE case_adaptive_mesh_refines() !! h*kappa target; adaptive_mesh true lets the coupled builder refine it (warm-started !! cubic-Hermite prolongation of the converged IC) before the dynamic run. Gate: (a) OFF keeps !! the deck's mesh EXACTLY (the default, so every other deck stays bit-for-bit); (b) ON yields - !! MORE nodes, a whole element multiple (uniform refinement -- the replicated hydro/property - !! arrays stay aligned with the refined solution); (c) the coupled node still tracks the + !! MORE nodes, every declared element split into a power of two of equal children (local + !! refinement keeps the declared element partition, so the hydro/property arrays mapped by + !! reference arc stay aligned with the refined solution); (c) the coupled node still tracks the !! refined fairlead; (d) the refined cable steps stably with smooth, bounded curvature (the !! prolongation produced a valid finer equilibrium, not a kink). TYPE(CD_HFMF_ModuleType), ALLOCATABLE :: plain, adapt ! see DEVELOPMENT.md (gfortran 16 -Wuninitialized) @@ -141,7 +142,10 @@ SUBROUTINE case_adaptive_mesh_refines() REAL(wp), PARAMETER :: DT = 0.05_wp, AMP = 1.0_wp, PER = 12.0_wp REAL(wp), PARAMETER :: PI = 3.141592653589793_wp INTEGER, PARAMETER :: NSTEP = 30 - LOGICAL :: stepped_ok + LOGICAL :: stepped_ok, nested + REAL(wp), ALLOCATABLE :: l_deck(:) + REAL(wp) :: acc, ratio + INTEGER :: i, j, k ALLOCATE (plain, adapt) CALL write_cable_deck('hcab_deck_hc_plain.dat') @@ -149,6 +153,7 @@ SUBROUTINE case_adaptive_mesh_refines() CALL require(es == CD_DECKDRV_OK, 'adaptive-mesh: plain deck init: '//TRIM(em)) IF (es /= CD_DECKDRV_OK) RETURN nn_plain = SIZE(plain%line%q)/6 + l_deck = plain%line%l0 CALL CD_HFMF_End(plain) CALL write_cable_deck('hcab_deck_hc_adapt.dat', extra_option='true adaptive_mesh', ba_value=-0.005_wp) @@ -158,8 +163,22 @@ SUBROUTINE case_adaptive_mesh_refines() nn_adapt = SIZE(adapt%line%q)/6 CALL require(nn_adapt > nn_plain, 'adaptive-mesh: accuracy policy refines the declared mesh') - CALL require(MOD(nn_adapt - 1, nn_plain - 1) == 0, & - 'adaptive-mesh: uniform refinement preserves the declared element partition') + ! Every declared element is tiled by refined elements of its length / 2^k (k <= 4). + nested = .TRUE. + j = 1 + DO i = 1, SIZE(l_deck) + acc = 0.0_wp + DO WHILE (acc < l_deck(i)*(1.0_wp - 1.0e-12_wp) .AND. j <= SIZE(adapt%line%l0)) + ratio = l_deck(i)/adapt%line%l0(j) + k = NINT(LOG(ratio)/LOG(2.0_wp)) + IF (k < 0 .OR. k > 4 .OR. ABS(ratio - 2.0_wp**k) > 1.0e-9_wp*ratio) nested = .FALSE. + acc = acc + adapt%line%l0(j) + j = j + 1 + END DO + IF (ABS(acc - l_deck(i)) > 1.0e-9_wp*l_deck(i)) nested = .FALSE. + END DO + IF (j /= SIZE(adapt%line%l0) + 1) nested = .FALSE. + CALL require(nested, 'adaptive-mesh: refinement preserves the declared element partition') CALL require(cn == nn_adapt, 'adaptive-mesh: coupled node tracks the refined fairlead') CALL require(adapt%line%has_axial_damping .AND. ALLOCATED(adapt%line%BA), & 'adaptive-mesh: deck BA is installed on the finite-EI dynamic cable') diff --git a/tests/test_hermite_automesh.f90 b/tests/test_hermite_automesh.f90 index ed825f7c..2f2fa6f2 100644 --- a/tests/test_hermite_automesh.f90 +++ b/tests/test_hermite_automesh.f90 @@ -19,6 +19,11 @@ PROGRAM test_hermite_automesh !! 5. Physical multi-island contact is accepted at the refinement cap. !! 6. Tension-controlled end layers trigger refinement through the EI-aware diagnosis. !! 7. FAIL-CLOSED: max_scale < 1 is rejected. + !! 8. LOCAL refinement (local_refinement): a line with one coarse section is refined where its + !! h*kappa fails, graded into the fine section, within the per-element cap, and agrees with + !! the global refinement; a resolved mesh, max_scale = 1 and the end-layer rig behave as + !! in the global mode; the element limit takes bending-length levels before h*kappa + !! levels; the per-element diagnosis outputs are consistent. USE CableDyn_Precision, ONLY: wp USE CableDyn_HermiteCableStatic, ONLY: CD_HermiteCable_Static_Solve, & CD_HermiteCable_Static_Solve_AutoMesh, & @@ -41,6 +46,11 @@ PROGRAM test_hermite_automesh CALL case_required_resolution_cap() CALL case_resolved_multi_island_cap() CALL case_fail_closed() + CALL case_local_refinement() + CALL case_local_unchanged() + CALL case_local_boundary_layer() + CALL case_local_element_limit() + CALL case_metrics_element_outputs() IF (nfail > 0) THEN WRITE (*, '(A,I0,A)') 'FAIL: ', nfail, ' assertion(s) failed' @@ -345,6 +355,236 @@ SUBROUTINE case_fail_closed() CALL check(es == CD_HCSTAT_BADINPUT, 'fail: EA size /= SIZE(l0) rejected (no OOB copy)') END SUBROUTINE case_fail_closed + !> The rig of build_rig on a two-section mesh: NC coarse elements over the first 30 m and NF + !> fine 1 m elements over the remaining 70 m (the deck mesh of a line with one coarse section). + SUBROUTINE build_two_section_rig(nc, l0, EA, EI, w, seed, fixed, nfix, seabed_z) + INTEGER, INTENT(IN) :: nc + REAL(wp), ALLOCATABLE, INTENT(OUT) :: l0(:), EA(:), EI(:), w(:), seed(:) + INTEGER, ALLOCATABLE, INTENT(OUT) :: fixed(:) + INTEGER, INTENT(OUT) :: nfix + REAL(wp), INTENT(OUT) :: seabed_z + INTEGER, PARAMETER :: NF = 70 + INTEGER :: ne + CALL build_rig(nc + NF, l0, EA, EI, w, seed, fixed, nfix, seabed_z) + ne = nc + NF + l0(1:nc) = 30.0_wp/REAL(nc, wp) + l0(nc + 1:ne) = 1.0_wp + BLOCK + INTEGER :: es + CHARACTER(160) :: em + CALL CD_HermiteCable_Trivial_Seed([0.0_wp, 0.0_wp, 0.0_wp], [90.0_wp, 0.0_wp, 0.0_wp], l0, seabed_z, & + seed, es, em) + IF (es /= CD_HCSTAT_OK) WRITE (*, '(A)') ' (seed error) '//TRIM(em) + END BLOCK + END SUBROUTINE build_two_section_rig + + SUBROUTINE case_local_refinement() + !! Three coarse 10 m elements beside seventy 1 m elements. The local mode refines the coarse + !! section (and grades into the fine one) instead of multiplying the whole line, keeps every + !! element a power-of-two child of its caller element within the cap, meets the target, and + !! reaches the equilibrium of the global refinement. + REAL(wp), ALLOCATABLE :: l0(:), EA(:), EI(:), w(:), seed(:) + REAL(wp), ALLOCATABLE :: l0o(:), EAo(:), EIo(:), wo(:), qo(:), curvo(:) + REAL(wp), ALLOCATABLE :: l0g(:), EAg(:), EIg(:), wg(:), qg(:), curvg(:), sg(:), so(:) + INTEGER, ALLOCATABLE :: fixed(:), fixo(:), fixg(:) + TYPE(CD_HermiteResolutionType) :: dg, dgg + INTEGER :: nfix, scale, scaleg, its, es, e, k, ng, no + REAL(wp) :: seabed_z, res, ratio, dmax, xg, deck_ratio + LOGICAL :: dyadic, graded + CHARACTER(240) :: em + CALL build_two_section_rig(3, l0, EA, EI, w, seed, fixed, nfix, seabed_z) + CALL CD_HermiteCable_Static_Solve_AutoMesh(l0, EA, EI, w, seed, fixed(1:nfix), seabed_z, 0.0_wp, & + 8, 120, 1.0e-8_wp, 0.7_wp, 0.12_wp, 0.0_wp, 16, [2, 5], & + l0o, EAo, EIo, wo, qo, curvo, fixo, scale, dg, res, its, es, em, & + local_refinement=.TRUE.) + IF (es /= CD_HCSTAT_OK) WRITE (*, '(A)') ' (local automesh error) '//TRIM(em) + CALL check(es == CD_HCSTAT_OK, 'local: solve ok') + IF (es /= CD_HCSTAT_OK) RETURN + CALL check(scale > 1, 'local: refined') + CALL check(dg%h_kappa_peak <= 0.12_wp, 'local: h*kappa target met') + CALL check(ABS(SUM(l0o) - SUM(l0)) <= 1.0e-12_wp*SUM(l0), 'local: rest length preserved') + ! Every element is a 2^-k child (k <= 4) of the caller element that contains it. + dyadic = .TRUE. + xg = 0.0_wp + DO e = 1, SIZE(l0o) + ratio = MERGE(10.0_wp, 1.0_wp, xg + 0.5_wp*l0o(e) < 30.0_wp)/l0o(e) + k = NINT(LOG(ratio)/LOG(2.0_wp)) + IF (k < 0 .OR. k > 4 .OR. ABS(ratio - 2.0_wp**k) > 1.0e-9_wp*ratio) dyadic = .FALSE. + xg = xg + l0o(e) + END DO + CALL check(dyadic, 'local: elements are power-of-two children within the cap') + ! Graded: neighbours differ by at most twice, except across the deck's own 10:1 jump + ! (the node at 30 m between a 10 m and a 1 m caller element), where the jump is at most it. + graded = .TRUE. + xg = 0.0_wp + DO e = 1, SIZE(l0o) - 1 + ratio = MAX(l0o(e)/l0o(e + 1), l0o(e + 1)/l0o(e)) + xg = xg + l0o(e) + deck_ratio = MERGE(10.0_wp, 1.0_wp, ABS(xg - 30.0_wp) < 1.0e-9_wp) + IF (ratio > MAX(2.0_wp, deck_ratio)*(1.0_wp + 1.0e-12_wp)) graded = .FALSE. + END DO + CALL check(graded, 'local: new neighbour length jumps at most 2x (the deck jump excepted)') + ! The far end of the fine section is not touched. + CALL check(ALL(ABS(l0o(SIZE(l0o) - 19:) - 1.0_wp) < 1.0e-12_wp), 'local: resolved fine section unchanged') + ! Same equilibrium as the global refinement, on far fewer elements. + CALL CD_HermiteCable_Static_Solve_AutoMesh(l0, EA, EI, w, seed, fixed(1:nfix), seabed_z, 0.0_wp, & + 8, 120, 1.0e-8_wp, 0.7_wp, 0.12_wp, 0.0_wp, 16, [2, 5], & + l0g, EAg, EIg, wg, qg, curvg, fixg, scaleg, dgg, res, its, es, em) + CALL check(es == CD_HCSTAT_OK, 'local: global reference ok') + IF (es /= CD_HCSTAT_OK) RETURN + CALL check(SIZE(l0o) < SIZE(l0g), 'local: fewer elements than the global refinement') + ng = SIZE(l0g) + 1 + no = SIZE(l0o) + 1 + ALLOCATE (sg(ng), so(no)) + sg(1) = 0.0_wp + DO e = 2, ng + sg(e) = sg(e - 1) + l0g(e - 1) + END DO + so(1) = 0.0_wp + DO e = 2, no + so(e) = so(e - 1) + l0o(e - 1) + END DO + dmax = 0.0_wp + DO e = 1, no + DO k = 1, 3, 2 + dmax = MAX(dmax, ABS(qo(6*(e - 1) + k) - interp(so(e), sg, qg(k::6)))) + END DO + END DO + CALL check(dmax < 1.0e-3_wp*SUM(l0), 'local: equilibrium within 1e-3 of the line length of the global one') + END SUBROUTINE case_local_refinement + + REAL(wp) FUNCTION interp(x, xs, ys) + !! Piecewise-linear interpolation of ys(xs) at x (xs ascending). + REAL(wp), INTENT(IN) :: x, xs(:), ys(:) + INTEGER :: i + interp = ys(SIZE(ys)) + DO i = 2, SIZE(xs) + IF (x <= xs(i)) THEN + interp = ys(i - 1) + (ys(i) - ys(i - 1))*(x - xs(i - 1))/(xs(i) - xs(i - 1)) + RETURN + END IF + END DO + END FUNCTION interp + + SUBROUTINE case_local_unchanged() + !! The local mode changes nothing when no refinement runs: a resolved mesh is returned + !! bit-identical to the global mode, and max_scale = 1 disables the local passes too. + REAL(wp), ALLOCATABLE :: l0(:), EA(:), EI(:), w(:), seed(:) + REAL(wp), ALLOCATABLE :: l0o(:), EAo(:), EIo(:), wo(:), qo(:), curvo(:) + REAL(wp), ALLOCATABLE :: l0g(:), EAg(:), EIg(:), wg(:), qg(:), curvg(:) + INTEGER, ALLOCATABLE :: fixed(:), fixo(:), fixg(:) + TYPE(CD_HermiteResolutionType) :: dg + INTEGER :: nfix, scale, its, es + REAL(wp) :: seabed_z, res + CHARACTER(200) :: em + CALL build_rig(64, l0, EA, EI, w, seed, fixed, nfix, seabed_z) + EI = 1.0e6_wp + CALL CD_HermiteCable_Static_Solve_AutoMesh(l0, EA, EI, w, seed, fixed(1:nfix), seabed_z, 0.0_wp, & + 8, 120, 1.0e-8_wp, 0.7_wp, 0.2_wp, 0.5_wp, 8, [2, 5], & + l0o, EAo, EIo, wo, qo, curvo, fixo, scale, dg, res, its, es, em, & + local_refinement=.TRUE.) + CALL CD_HermiteCable_Static_Solve_AutoMesh(l0, EA, EI, w, seed, fixed(1:nfix), seabed_z, 0.0_wp, & + 8, 120, 1.0e-8_wp, 0.7_wp, 0.2_wp, 0.5_wp, 8, [2, 5], & + l0g, EAg, EIg, wg, qg, curvg, fixg, scale, dg, res, its, es, em) + CALL check(es == CD_HCSTAT_OK .AND. scale == 1 .AND. SIZE(qo) == SIZE(qg), 'local unchanged: resolved mesh kept') + IF (SIZE(qo) == SIZE(qg)) & + CALL check(nan_max_abs(qo - qg) <= 0.0_wp, 'local unchanged: bit-identical to the global mode') + CALL build_rig(10, l0, EA, EI, w, seed, fixed, nfix, seabed_z) + CALL CD_HermiteCable_Static_Solve_AutoMesh(l0, EA, EI, w, seed, fixed(1:nfix), seabed_z, 0.0_wp, & + 8, 120, 1.0e-8_wp, 0.7_wp, 0.05_wp, 0.5_wp, 1, [2, 5], & + l0o, EAo, EIo, wo, qo, curvo, fixo, scale, dg, res, its, es, em, & + local_refinement=.TRUE.) + CALL check(es == CD_HCSTAT_OK .AND. scale == 1 .AND. SIZE(l0o) == 10, & + 'local unchanged: no refinement with max_scale = 1') + END SUBROUTINE case_local_unchanged + + SUBROUTINE case_local_boundary_layer() + !! The end-layer rig of case_boundary_layer_refinement in the local mode: the single + !! element is split once and the layer is resolved. + INTEGER, PARAMETER :: NE = 1, NN = 2, NDOF = 6*NN + REAL(wp) :: l0(NE), EA(NE), EI(NE), w(NE), seed(NDOF) + REAL(wp), ALLOCATABLE :: l0o(:), EAo(:), EIo(:), wo(:), qo(:), curvo(:) + INTEGER :: fixed(NDOF), i, scale, its, es + INTEGER, ALLOCATABLE :: fixo(:) + TYPE(CD_HermiteResolutionType) :: dg + REAL(wp) :: res + CHARACTER(240) :: em + l0 = 2.0_wp; EA = 1.0e6_wp; EI = 1.21e4_wp; w = 0.0_wp + seed = 0.0_wp + seed(4) = 1.01_wp; seed(7) = 2.02_wp; seed(10) = 1.01_wp + DO i = 1, NDOF + fixed(i) = i + END DO + CALL CD_HermiteCable_Static_Solve_AutoMesh(l0, EA, EI, w, seed, fixed, -1.0e4_wp, 0.0_wp, & + 1, 5, 1.0e-10_wp, 1.0_wp, 1.0_wp, 0.0_wp, 2, & + [1, 2, 3, 4, 5, 6], & + l0o, EAo, EIo, wo, qo, curvo, fixo, scale, dg, & + res, its, es, em, require_resolved=.TRUE., local_refinement=.TRUE.) + CALL check(es == CD_HCSTAT_OK .AND. scale == 2 .AND. SIZE(l0o) == 2, 'local boundary: end layer split once') + CALL check(.NOT. dg%boundary_unresolved, 'local boundary: end layer resolved') + END SUBROUTINE case_local_boundary_layer + + SUBROUTINE case_local_element_limit() + !! A pass that would exceed the element limit gives up bending-length levels before h*kappa + !! levels. The limit is lowered to 900 (max_elements) so that a small, well-conditioned line + !! reaches it: 60 elements of 1.67 m with EI = 5 (half the bending length is 18 cm) all ask + !! for 16 children by the bending-length rule (960 elements), and with the h*kappa target + !! 3e-3 the elements about the sag ask for 16 by h*kappa as well. Taking one level less + !! everywhere (8x) would leave the sag above the target with no pass able to split it + !! further within the limit; keeping its h*kappa levels and giving the bending-length rule + !! one level meets the target in one pass. (At the default limit of 8192 the same test needs + !! a string-like line on about 7000 elements, whose polish can settle on a folded + !! equilibrium depending on round-off.) + INTEGER, PARAMETER :: NE = 60, LIMIT = 900 + REAL(wp), PARAMETER :: TARGET = 3.0e-3_wp + REAL(wp), ALLOCATABLE :: l0(:), EA(:), EI(:), w(:), seed(:) + REAL(wp), ALLOCATABLE :: l0o(:), EAo(:), EIo(:), wo(:), qo(:), curvo(:) + INTEGER, ALLOCATABLE :: fixed(:), fixo(:) + TYPE(CD_HermiteResolutionType) :: dg + INTEGER :: nfix, scale, its, es + REAL(wp) :: seabed_z, res, h + CHARACTER(240) :: em + CALL build_rig(NE, l0, EA, EI, w, seed, fixed, nfix, seabed_z) + EI = 5.0_wp + h = l0(1) + CALL CD_HermiteCable_Static_Solve_AutoMesh(l0, EA, EI, w, seed, fixed(1:nfix), seabed_z, 0.0_wp, & + 8, 300, 1.0e-8_wp, 0.7_wp, TARGET, 0.0_wp, 16, [2, 5], & + l0o, EAo, EIo, wo, qo, curvo, fixo, scale, dg, res, its, es, em, & + local_refinement=.TRUE., max_elements=LIMIT) + IF (es /= CD_HCSTAT_OK) WRITE (*, '(A)') ' (local limit automesh error) '//TRIM(em) + WRITE (*, '(A,I0,A,I0,A,ES10.3)') ' local limit: ', SIZE(l0o), ' elements, ', its, ' Newton iterations, |R| ', res + CALL check(es == CD_HCSTAT_OK, 'local limit: solve ok') + IF (es /= CD_HCSTAT_OK) RETURN + CALL check(SIZE(l0o) <= LIMIT .AND. SIZE(l0o) > 8*NE, 'local limit: within the limit, beyond 8x') + CALL check(ABS(MINVAL(l0o) - h/16.0_wp) <= 1.0e-12_wp*h, 'local limit: h*kappa needs keep 16 children') + CALL check(ABS(MAXVAL(l0o) - h/8.0_wp) <= 1.0e-12_wp*h, 'local limit: bending-length needs give a level') + CALL check(dg%h_kappa_peak <= TARGET, 'local limit: h*kappa target met') + END SUBROUTINE case_local_element_limit + + SUBROUTINE case_metrics_element_outputs() + !! The per-element outputs of the resolution diagnosis: the h*kappa field peaks at + !! h_kappa_peak, and its length is checked. + REAL(wp), ALLOCATABLE :: l0(:), EA(:), EI(:), w(:), seed(:), q(:), curv(:), hk(:) + INTEGER, ALLOCATABLE :: fixed(:) + LOGICAL, ALLOCATABLE :: chat(:) + TYPE(CD_HermiteResolutionType) :: dg + INTEGER :: nfix, its, es + REAL(wp) :: seabed_z, res + CHARACTER(200) :: em + CALL build_rig(10, l0, EA, EI, w, seed, fixed, nfix, seabed_z) + ALLOCATE (q(SIZE(seed)), curv(11), hk(10), chat(11)) + CALL CD_HermiteCable_Static_Solve(l0, EA, EI, w, seed, fixed(1:nfix), seabed_z, 0.0_wp, & + 8, 120, 1.0e-8_wp, 0.7_wp, q, curv, res, its, es, em) + CALL CD_HermiteCable_Resolution_Metrics(l0, q, seabed_z, 0.5_wp, 0.12_wp, dg, es, em, EA=EA, EI=EI, & + elem_h_kappa=hk, chatter_node=chat) + CALL check(es == CD_HCSTAT_OK, 'metrics outputs: ok') + CALL check(ABS(MAXVAL(hk) - dg%h_kappa_peak) <= 0.0_wp .AND. MAXLOC(hk, 1) == dg%h_kappa_elem, & + 'metrics outputs: element h*kappa peaks at h_kappa_peak') + CALL check(.NOT. ANY(chat) .AND. .NOT. dg%contact_chatter, 'metrics outputs: no chatter off the seabed') + CALL CD_HermiteCable_Resolution_Metrics(l0, q, seabed_z, 0.5_wp, 0.12_wp, dg, es, em, elem_h_kappa=hk(1:9)) + CALL check(es == CD_HCSTAT_BADINPUT, 'metrics outputs: short elem_h_kappa rejected') + END SUBROUTINE case_metrics_element_outputs + SUBROUTINE check(cond, label) LOGICAL, INTENT(IN) :: cond CHARACTER(*), INTENT(IN) :: label diff --git a/tests/test_line_attachments.f90 b/tests/test_line_attachments.f90 index b67b30b0..9795d5ea 100644 --- a/tests/test_line_attachments.f90 +++ b/tests/test_line_attachments.f90 @@ -17,8 +17,12 @@ PROGRAM test_line_attachments !! 5. Deck current (uniform, profile): convergence to EQUIVALENT BUOYANCY and no drift at rest. !! 6. Coupled route (the OpenFAST aggregate): held SeaState-style kinematics at the !! attachment nodes, and a bit-identical checkpoint restart. + !! 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. USE CableDyn_Precision, ONLY: wp - USE CableDyn_DeckDriver, ONLY: CD_Run_Deck_Driver, CD_DECKDRV_OK + USE CableDyn_DeckDriver, ONLY: CD_Run_Deck_Driver, CD_DECKDRV_OK, CD_Attachment_Discrete_Verdict + 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, & CD_AGG_End, CD_AGG_NFluidNodes, CD_AGG_GetFluidNodePositions, & @@ -42,6 +46,7 @@ PROGRAM test_line_attachments CALL case_current('profile', 'profile -60.0 0.2 0.3 0.0 0.0 0.5 0.4 0.0 current') CALL case_grammar() CALL case_coupled() + CALL case_fallback_verdict() IF (nfail > 0) THEN WRITE (*, '(A,I0,A)') 'FAIL: ', nfail, ' assertion(s) failed' @@ -53,6 +58,55 @@ PROGRAM test_line_attachments INCLUDE 'nan_max_abs.inc' + 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 + !! elements beside a lumped attachment load carry its slope jump. With the attachment at + !! node 6 the verdict accepts the state; with it at node 3 it rejects the kink; a uniformly + !! compressed straight line is rejected under tensile_safety True; and an unstable state + !! (the caller's stability test) is rejected. + INTEGER, PARAMETER :: NE = 10 + REAL(wp), PARAMETER :: THETA = 0.6_wp + REAL(wp) :: l0(NE), ea(NE), ei(NE), w(NE), diam(NE), q(6*(NE + 1)), qc(6*(NE + 1)) + INTEGER :: i + LOGICAL :: accepted + CHARACTER(1024) :: msg + l0 = 1.0_wp + ea = 1.0e8_wp + ei = 1.0e4_wp + w = 100.0_wp + diam = 0.1_wp + q = 0.0_wp + qc = 0.0_wp + DO i = 1, NE + 1 + q(6*(i - 1) + 1:6*(i - 1) + 3) = [REAL(i - 1, wp), 0.0_wp, -50.0_wp] + q(6*(i - 1) + 4:6*(i - 1) + 6) = [1.0_wp, 0.0_wp, 0.0_wp] + qc(6*(i - 1) + 1:6*(i - 1) + 3) = [0.99_wp*REAL(i - 1, wp), 0.0_wp, -50.0_wp] + qc(6*(i - 1) + 4:6*(i - 1) + 6) = [0.99_wp, 0.0_wp, 0.0_wp] + END DO + q(6*5 + 4:6*5 + 6) = [COS(THETA), 0.0_wp, SIN(THETA)] + CALL CD_Attachment_Discrete_Verdict(l0, q, ea, ei, w, diam, [CD_ENDCONN_PINNED, CD_ENDCONN_PINNED], [6], & + -1000.0_wp, .FALSE., .TRUE., accepted, msg) + CALL require(accepted, 'fallback verdict: a slope jump beside the attachment node is accepted ('// & + TRIM(msg)//')') + CALL CD_Attachment_Discrete_Verdict(l0, q, ea, ei, w, diam, [CD_ENDCONN_PINNED, CD_ENDCONN_PINNED], [3], & + -1000.0_wp, .FALSE., .TRUE., accepted, msg) + CALL require(.NOT. accepted .AND. INDEX(msg, 'discrete ATTACHMENTS') > 0 .AND. & + INDEX(msg, 'is unresolved/kinked') > 0 .AND. INDEX(msg, 'away from the attachment nodes') > 0, & + 'fallback verdict: the bend away from the attachment fails the kink limit ('//TRIM(msg)//')') + CALL CD_Attachment_Discrete_Verdict(l0, qc, ea, ei, w, diam, [CD_ENDCONN_PINNED, CD_ENDCONN_PINNED], [6], & + -1000.0_wp, .TRUE., .TRUE., accepted, msg) + CALL require(.NOT. accepted .AND. INDEX(msg, 'carries axial compression under tensile_safety True') > 0, & + 'fallback verdict: a compressed state fails the tensile contract ('//TRIM(msg)//')') + CALL CD_Attachment_Discrete_Verdict(l0, qc, ea, ei, w, diam, [CD_ENDCONN_PINNED, CD_ENDCONN_PINNED], [6], & + -1000.0_wp, .FALSE., .TRUE., accepted, msg) + CALL require(accepted, 'fallback verdict: compression alone passes without tensile_safety ('//TRIM(msg)//')') + CALL CD_Attachment_Discrete_Verdict(l0, q, ea, ei, w, diam, [CD_ENDCONN_PINNED, CD_ENDCONN_PINNED], [6], & + -1000.0_wp, .FALSE., .FALSE., accepted, msg) + CALL require(.NOT. accepted .AND. INDEX(msg, 'is an unstable equilibrium') > 0, & + 'fallback verdict: an unstable state is rejected ('//TRIM(msg)//')') + END SUBROUTINE case_fallback_verdict + SUBROUTINE require(cond, msg) LOGICAL, INTENT(IN) :: cond CHARACTER(*), INTENT(IN) :: msg diff --git a/tests/test_openfast_aggregate.f90 b/tests/test_openfast_aggregate.f90 index 67e5db9a..5dd249bc 100644 --- a/tests/test_openfast_aggregate.f90 +++ b/tests/test_openfast_aggregate.f90 @@ -3694,8 +3694,12 @@ SUBROUTINE case_aggregate_cable_control() fr = aggr%ctrl_elem(1) WRITE (*, '(A,I0,A,I0,A)') ' cable control span on the refined mesh: ', ner - fr + 1, ' of ', ner, & ' elements' - CALL require(ner > 47 .AND. MOD(ner, 47) == 0 .AND. ner - fr + 1 == ner/47, & + ! static refinement is local, so the children of a segment are not a fixed count: the + ! span is the trailing elements that make up the fairlead-side segment and no more + CALL require(ner > 47 .AND. fr > 1 .AND. fr <= ner, & 'cablectrl: the span is the children of the refined fairlead-side segment') + IF (fr > 1) CALL require(SUM(aggr%cables(1)%line%l0(fr - 1:ner)) > 40.0_wp/13.0_wp*(1.0_wp + 1.0e-9_wp), & + 'cablectrl: the span stops at the fairlead-side segment') CALL require(ABS(SUM(aggr%cables(1)%line%l0(fr:ner)) - 40.0_wp/13.0_wp) <= 1.0e-12_wp*40.0_wp, & 'cablectrl: the refined span is the 40/13 m segment') base = aggr%cables(1)%line%l0 From 391a8ba39ea76f8ee117ba2fd40150566e74f29c Mon Sep 17 00:00:00 2001 From: Jae Hoon Seo Date: Tue, 20 Oct 2026 20:01:13 +0900 Subject: [PATCH 24/31] chore(release): prepare CableDyn 0.2.0 (#30) Set the version to 0.2.0 (released 2026-10-20) in every file the release metadata check names, and replace the unreleased notes with a short [0.2.0] section, one entry per user-visible change. The README links to the manual and to GitHub instead of to Markdown files, and the README and the manual state that CableDyn is not affiliated with the EPSRC-funded University of Edinburgh project of the same name. In OpenFAST a deck without dtM now solves every glue step instead of about every 0.1 s: held loads reach the platform about dtM/2 late, a negative damping that matters for stiff moorings and for tension statistics. A coarser deck dtM still trades accuracy for speed, as the console, the OpenFAST page and the known issues say. The solver builds without compiler warnings (no result changes), and the Holcombe and Bergdahl validation records are rerun with the 0.2.0 build: Holcombe is byte-identical, and the Bergdahl waveform RMSEs move from 5.95 % to 5.93 % and from 2.54 % to 2.56 %. Signed-off-by: Jae Hoon Seo --- CHANGELOG.md | 928 +------- CITATION.cff | 4 +- CMakeLists.txt | 2 +- README.md | 46 +- RELEASE.md | 2 +- VALIDATION.md | 6 +- doc/capi.rst | 8 +- doc/citing.rst | 6 +- doc/coupling_boundary.md | 2 +- doc/index.rst | 18 +- doc/installation.rst | 26 +- doc/modeling.rst | 5 +- doc/openfast.rst | 19 +- doc/options.rst | 2 +- doc/quickstart.rst | 4 +- doc/tutorial_openfast.rst | 9 +- examples/airy_wave_shallow_chain.dat | 2 +- examples/als_volturnus_line_break_tension.dat | 2 +- examples/als_volturnus_line_break_time.dat | 2 +- examples/buoy_clamped_cable.dat | 2 +- examples/chain_range_tdp.dat | 2 +- examples/chain_torsethaugen_spread.dat | 2 +- examples/chain_two_train_sea.dat | 2 +- examples/clump_weight_free_point.dat | 2 +- examples/connect_weighted_point.dat | 2 +- examples/dynamic_chain_current.dat | 2 +- examples/dynamic_chain_held.dat | 2 +- examples/dynamic_chain_waves.dat | 2 +- examples/iea15mw_umaine_mixed_cabledyn.dat | 2 +- examples/laid_cable_cross_current.dat | 2 +- examples/lazy_wave_buoyancy_modules.dat | 2 +- examples/lazy_wave_buoyancy_smeared.dat | 2 +- examples/lazy_wave_modes.dat | 2 +- examples/lazy_wave_vessel_motion.dat | 2 +- examples/lazy_wave_vessel_rao.dat | 2 +- examples/lozon_gomaine200_power_cable.dat | 2 +- examples/lozon_gomex80_power_cable.dat | 2 +- examples/lozon_gomex80_power_cable_motion.dat | 2 +- examples/lozon_humboldt800_power_cable.dat | 2 +- examples/mixed_body_rods_points.dat | 2 +- .../chain_wavekin7_currents1.dat | 2 +- examples/openfast/CableDyn_UMaine.dat | 2 +- .../openfast/CableDyn_UMaine_line_failure.dat | 2 +- examples/openfast/CableDyn_UMaine_rod.dat | 2 +- examples/openfast/README.md | 2 +- examples/rigid6_buoy.dat | 2 +- examples/rod_moored_spar.dat | 2 +- examples/spar_pinned_rods.dat | 2 +- examples/stream_wave_shallow_chain.dat | 2 +- examples/syrope_polyester_mooring.dat | 2 +- examples/torsion_lazy_wave_hangoff_twist.dat | 2 +- examples/ve_polyester_dynamic_waves.dat | 2 +- integration/openfast/README.md | 2 +- python/README.md | 4 +- python/cabledyn/__init__.py | 2 +- python/pyproject.toml | 2 +- release/check_release_metadata.py | 4 +- src/CableDyn_Banner.f90 | 2 +- src/CableDyn_CAPI.f90 | 6 +- src/CableDyn_CAPI.h | 4 +- src/CableDyn_HermiteCableDynamic.f90 | 13 +- src/CableDyn_HermiteCableStatic.f90 | 2 +- src/CableDyn_Model.f90 | 5 +- src/openfast/CableDyn_OF.f90 | 32 +- tests/data/buoy_clamped_cable_pinned_rod.dat | 2 +- tests/data/cable_statics_matrix.json | 2 +- tests/data/held_start_gomex80_power_cable.dat | 2 +- .../held_start_humboldt800_power_cable.dat | 2 +- tests/data/mixed_nmodes.dat | 2 +- tests/data/range_mixed_alloc.dat | 2 +- .../data/stack_humboldt800_2048_elements.dat | 2 +- tests/data/ve_polyester_waves_fine_mesh.dat | 2 +- tests/test_c_api.f90 | 2 +- tests/test_lozon_example_equilibrium.py | 2 +- validation/experiments/bergdahl/README.md | 5 +- .../experiments/bergdahl/provenance.json | 13 +- .../bergdahl/waveform_T1p25_R0p200.csv | 2002 ++++++++--------- .../bergdahl/waveform_T3p50_R0p200.csv | 2002 ++++++++--------- .../bergdahl/waveform_metrics.json | 24 +- .../experiments/holcombe/provenance.json | 12 +- 80 files changed, 2298 insertions(+), 3017 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index ffcd8df7..e5ebfa10 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -6,857 +6,101 @@ All notable changes to CableDyn are recorded in this file. The format follows [Keep a Changelog](https://keepachangelog.com/en/1.1.0/) and the project uses [Semantic Versioning](https://semver.org/spec/v2.0.0.html). -## [Unreleased] +## [0.2.0] - 2026-10-20 ### Added -- Seabed friction in the static solve, toward the as-laid position (OrcaFlex's *as laid* - statics seabed friction policy, opt-in): `asLaid staticsFriction`. Every grounded node is - held by a friction spring toward the position at which the line was laid from its lower end - (the anchor, or the fairlead when that is lower) along the lay azimuth on the seabed, with the regularised Coulomb law of the dynamics - (isotropic or axial/lateral, capped at `mu N`), in still water and in a current, on `EI = 0` - and finite-EI lines, standalone, coupled OpenFAST and through the C API; the march continues - the static springs, so a held run stays at rest. New OPTIONS `staticsFriction none|asLaid`, - `layAzimuth` and `layAzimuth` (default: the horizontal direction of each line's chord, - from its lower end), - `asLaidTension` and `asLaidTension` (default 0). The default stays `none`, as in MoorDyn: - frictionless statics in still water (friction from the still-water equilibrium in a current), - conservative for anchor loads, and every deck without the new rows runs as before. With - `asLaid`, a 700 m chain on a 5° slope with `frictionMu 1`, which the frictionless static - folds 24.0 m back past its anchor, holds where it was laid (friction up to 0.087 `mu N`, the - slope; FairTen 714.2 → 622.9 kN; held for 2 s to 1.5e-10 of FairTen), and a 650 m finite-EI - cable on a 10° slope, rejected as too long for its span, solves. As an illustration of the - effect on anchor loads, `asLaid` in `iea15mw_umaine_mixed_cabledyn.dat` lowers the chains' - AnchTen from 1351.6 to 368.2 kN (FairTen +0.16 %) and the laid cable's from 1230 N to 0.36 N: - runs laid slack and pulled taut are held back by friction. A run laid at the tension it - carries (`asLaidTension`) mobilises none: on a flat seabed FairTen equals the frictionless - one to 6e-6 and AnchTen to 0.4 %. A finite-EI line laid past the point under its fairlead has - no static solution yet (its touchdown hook is not reached); a lay azimuth across the span - solves it. A lay azimuth across the vertical plane of the chord, or a bathymetry sloping across - it under the laid run, solves a finite-EI line in 3D from the start (so a march from it stays - at rest), and a finite-EI line is laid from its lower end like an `EI = 0` one; a line whose - fairlead lies below its other end is laid, and seeded, from the fairlead. With discrete - `ATTACHMENTS` the reference sinks each node under its discrete load (its share of the line's - weight plus the attachment's net weight), so a module node rests on the laid path like the rest - of the run instead of taking its sink for a friction deflection. On a mesh the finite-EI - statics refines (adaptive refinement, the bending-length and stability refinements) or - coarsens, the reference is laid on that mesh itself, under its own lumped weights and nodal - seabed stiffnesses, and the march takes it on the final mesh: a run refined 16x on a seabed - curved along it and sloping across it, with a section change on the grounded run, rests where - its twin declared on the refined mesh does (to solver precision), where a reference - interpolated from the deck nodes moved it by up to 1 mm and reversed its lateral anchor force. The policy is rejected - where the statics carry no seabed friction: on decks with bodies, rods or dynamic - (`Connect`/`Free`) points (`frictionMu` itself is rejected on the latter and accepted on the - default monolithic body and rod march), and on a finite-EI deck whose line has a moving End B - (a line shared between two turbines, which takes the compatibility route). The Python `DeckFile`, `DeckWriter` and `DeckModel` take the new - rows. See the theory page (Friction in statics). -- Run-time profile of the standalone driver. With the environment variable - `CABLEDYN_PROFILE=1`, the driver prints at the end of the run how its wall time divides - between input parsing, initialisation and statics, and the dynamic march. The march is split - into the fluid sampled by the driver, the line, cable and object steps, the checks, the - outputs, and the progress report. The profile also gives the committed steps and the time per - step, the tension-only line steps and their Newton iterations, and (outside the mixed - `EI = 0` + finite-EI route) the finite-EI cable steps with their residual, tangent and solve - counts and times. Every output file is the same with and without it. See the manual's - command-line page (Run-time profile). -- A note when a finite-EI line starts its dynamics from a static state that is unstable out of - its vertical plane. A line solved in that plane (free in torsion, no current or end direction - across it) has its out-of-plane DOFs held in the statics and released in the dynamics. On - elements longer than half the bending length the touchdown can make that state unstable out of - the plane, which the planar solve does not see. One stability test with the dynamic - constraints now runs at the hand-off (0.35 ms on an 87-element lazy wave, 6 ms on 2048 - elements; on a line with `ATTACHMENTS`, on the discrete equilibrium after the attachment - polish) and the note names the line, its mesh and the factor that meets the bending length, - and recommends a finer mesh or `adaptive_mesh True`. Results do not change. -- Torsion of finite-EI lines in coupled OpenFAST (`CompMooring = 5`) and FAST.Farm runs. The - End A frame of a line restrained in torsion turns with the platform orientation, the torque - moment is returned to the platform, `PtfmInit` twists the line in the static initialisation, - the `Torq`/`Twist` channels are written, and the unwrapped twist is restored on a checkpoint - restart. The C API and the standalone deck that mixes `EI = 0` and finite-EI lines without a - body, which move the line ends by translation only, still refuse torsion columns by name, and - so does OpenFAST linearisation of a line restrained in torsion. See the manual's OpenFAST page - (Line torsion). -- C ABI 1 minor extension 2 (`CableDyn_GetAbiMinor() == 2`) for hosts that drive the - `Coupled` points of a deck, such as CFD solvers. Every existing function is unchanged. - `CableDyn_InitDeckAt` solves the statics with the `Coupled`/`Vessel` points at the host's - positions, the counterpart of `MoorDyn_Init(X, XD)` (the statics start at rest), so a body - that starts away from the deck coordinates starts without a transient: for foamMooring's - `EsfLOWC` box, whose fairleads start 15 mm below the deck, the fairlead load of - `CableDyn_InitDeck` followed by held fairleads deviates by up to 0.38 N of 0.52 N, and stays - constant to round-off after `CableDyn_InitDeckAt`. `CableDyn_SaveState` and - `CableDyn_RestoreState` keep one in-memory copy of the whole model for outer correctors - (PIMPLE); a restore followed by a step is bit-identical to stepping from the saved state, on - both routes and across any number of steps. `CableDyn_GetCoupledLayout` returns the deck point - id and type of every block of the coupled vector, which on the point route includes the - `Fixed` anchors. The Python `CableDyn` class gains `init_deck_at`, `save_state`, - `restore_state`, `coupled_layout` and `host_dofs`. The manual's C API page has a new section, - Coupling a host (CFD) solver, that compares the call sequence step by step with MoorDyn's C - API: initialisation, vector layout, end-of-step motion, outer correctors, load summation, - the fixed step of the aggregate route, and units. -- Run audit of tension-only (`EI = 0`) lines in the standalone driver. On the initial state and - at every output step it tracks the largest turn of a taut segment's chord, the segments that - snap from slack to taut, and non-physical tension spikes: a segment whose tension (the elastic - tension, or that of its viscoelastic or Syrope law) at one step exceeds four times its own one - step before and after, ten times the largest tension anywhere on the line one step before and - after, and the largest tension of the initial state. The first spike of a line is reported as - a warning, once per line, naming its segment from End A as `.Line.t.out` numbers it, and - the run summary counts them. The run ends with a note when a - taut segment turned by more than 1° in one solver step (with `ei0_substeps auto`, see Changed, - 1.1 times the larger of 1° and `ei0_substep_angle`; the sub-steps of a sub-stepped or - recovered step count as steps; the mean and standard deviation of the tension err by about - 1 % and more above it, 1.3 % at 2.9° on a heaving chain, and near 6° per step snap-load peaks - come out 10 to 20 % low with either generalised-α blend), and when segments snapped taut - while the axial wave crosses a segment more than once per solver step, so the snap peaks are - not resolved in time. The standalone driver also prints a note for a dynamic - deck with `rhoInf` above 0.95, on the missing numerical dissipation. See the manual's - troubleshooting page. -- Anchor uplift channels for the drag-anchor check of a catenary mooring (no vertical load at - the anchor in the intact condition). `AnchFz` and `AnchFH` are the vertical component - (positive upward, the line lifting its anchor) and the horizontal magnitude of the `AnchTen` - end force; for an anchor that holds one line they equal `Point

Fz` and `Point

FH`. - `TDPGrd` is the grounded length, the deformed chord length from the grounded end to the - touchdown point; it varies continuously with the touchdown point and is 0 only when nothing - touches (an anchor node on the seabed beside a node a few millimetres clear of it reads - micrometres to millimetres, so test it against a small tolerance such as 0.01 m). The - channels are available on the static, `EI = 0`, finite-EI, mixed and multibody routes, in the C - API and in coupled OpenFAST and FAST.Farm runs; the two-moving-end finite-EI route rejects - `AnchFz`/`AnchFH` by name. The Python deck reader and builder accept the new names. See the - manual's outputs page (Anchor uplift), which also states the end-node weight share that a laid - `Fixed` anchor carries (slightly negative `AnchFz` on an `EI = 0` line, not uplift; exactly 0 - on a finite-EI line, whose grounded end leaves its node weight to the floor). Because of that - share, `AnchFz` on an `EI = 0` line turns positive only after the anchor segment has started - to lift, so `TDPGrd` is the primary no-uplift check and `AnchFz` the vertical anchor load. -- `OutputRecovery` option (`equilibrium`, the default, or `element`): the definition of the - finite-EI node tension, curvature, bend moment and segment tension (see Changed). `element` - restores the definitions of 0.1.1. The Python deck reader accepts and checks it. -- `CD_HermiteCable_Dyn_Curvature_Exact` and `CD_HFMF_Curvature_Exact`: the exact geometric - nodal curvature of the cubic-Hermite centreline, the larger one-sided trace at a node, which - `CD_HermiteCable_Dyn_Curvature` and `CD_HFMF_Curvature` returned up to 0.1.1. -- `Pinned` and `CoupledPinned`/`VesselPinned` rods in coupled OpenFAST (`CompMooring = 5`) runs. - A `Pinned` rod turns about its fixed End A, which the coupled route previously refused. A - `CoupledPinned` rod (MoorDyn-F's coupled pinned rod) is a node of the coupling mesh at its - End A that takes the platform position only: the rod turns about it with its own rotation, - the pin acceleration loading that rotation through the rod's inertia, and the node returns - the rod's net force less its inertia with zero moment. The angular acceleration in that force - is solved for the node's current acceleration, so an output probe sees the rod's effective - inertia about the pin. `PtfmInit` moves the rod with the platform, the static initial - condition balances it about its pin (a pinned rod that carries no line keeps its deck - orientation), sub-cycled steps move the pin along the host path interpolated linearly as for - every other host node, the sub-step count resolves the rod's own swing about its pin under - its weight, buoyancy and pin acceleration (`|W d_g - B d_b|` and the pin-acceleration load - over the inertia about the pin) as well as its lines, so a short pinned rod that carries no - line stays stable at a coupling step beyond its explicit limit (a `CoupledPinned` rod takes - the stiffer of its step-start and end-of-step wetting, so a pin that crosses the free surface - within a step is covered), and checkpoint restarts and correction iterations reproduce the - run bit for bit with the existing rod state mirror. An end of a `Pinned` or `CoupledPinned` rod that - carries no line needs no `RodA`/`RodB` POINT row on the coupled route; other rods still - need one at both ends. The C API runs `Pinned` rods, as its manual page already stated. The - standalone driver and the C API refuse `CoupledPinned` rods by name; FAST.Farm decks still - refuse rods, OpenFAST linearisation still refuses rods, and `CoupledPinned` bodies remain - unsupported. See the manual's OpenFAST page (Lifecycle features). -- A warning when line nodes of a coupled OpenFAST run (`CompMooring = 5`) lie outside the - SeaState wave-kinematics grid (`X_HalfWidth`, `Y_HalfWidth`, `Z_Depth`). SeaState gives such a - node the kinematics of the grid boundary: waves out of phase beyond a half-width, and - kinematics that are too strong below `Z_Depth`. Its fluid load was therefore wrong without - any message. CableDyn now checks its nodes at the static equilibrium and at every CableDyn - step. At the first node outside the grid it prints one warning with the number of nodes, - the farthest node in each direction and the SeaState inputs to enlarge. Only nodes in the - water are checked (a cable or jumper above the free surface carries no fluid load), and - nodes below a grid that reaches the seabed (`Z_Depth` equal to the water depth, its - default) are not reported. - The OpenFAST tutorial and `examples/openfast/README.md` now enlarge the r-test `MD_Shared` - grid (`X_HalfWidth = 100 m`, `Z_Depth = 40 m`), which covers the platform but not the - moorings, and quote their results for the enlarged grid. With the `MD_Shared` grid, the - line-1 fairlead tension standard deviation of the tutorial was 18 % too high. See the - manual's OpenFAST page (SeaState grid). -- Active tensioning of finite-EI cables in OpenFAST (`CompMooring = 5`). A `CONTROL` row may - now name a finite-EI (cubic-Hermite) cable, alone or in a deck with `EI = 0` lines. Before - each mooring step, ServoDyn's `CableDeltaL` and `CableDeltaLdot` scale every cable element of - the line's fairlead-side deck segment by (S + `DeltaL`)/S, with the matching rate, so the - segment becomes S + `DeltaL` long. The cable's mass, attachment masses, tributary lengths and - seabed contact coefficients follow the new lengths, and the axial damping acts on the rate of - the strain the elastic force uses, so a segment paid out at constant strain carries no damping - force. The force-blended generalised-α step takes its committed force at the lengths of the - preceding step, so a pay-out ramp follows the quasi-static tension at any `rhoInf`; a deck - that controls a finite-EI cable under `False alpha_force_blend` fails at initialisation with - a message that names the line, as that blend has no such treatment. A command outside - MoorDyn-F's bounds stops the run as for `EI = 0` lines (see Changed), and FAST.Farm decks - still reject `CONTROL`. A zero command, with a `DeltaLdot` of either sign, leaves the run - bit-identical to an uncontrolled one, and a checkpoint restart continues bit-identically. See - the manual's deck format page (CONTROL). -- A note when the static layout of an `EI = 0` line folds back on the seabed (a hairpin), the - twin of the finite-EI note. A current toward the anchor or a seabed falling past it can carry - the grounded run of a tension-only line past its anchor where no seabed friction holds it, - and it folds back with zero tension at the fold: a 2 m/s current carried a chain 20 m past its - anchor, a 5° slope 24 m, without a word. The equilibrium is kept, and one note per line names - the fold (the distance past the anchor, or a turn above 150° of the grounded run at a deck - node, numbered from End A as the node channels), its cause - (a deck current on the line, a seabed steeper than 0.5° at the fold, or a slack run) and the - remedy that fits the deck's static friction: `frictionMu` against a current, - `staticsFriction asLaid` on a slope (with the default `staticsFriction none` the static solve - applies friction against a deck current only), or a shorter line where friction already acts - or the route rejects it; a run without `dtM` and `TMax` is told that friction needs them, - since the static-only line solve carries none. A run that the `staticsFriction asLaid` - reference itself lays past its end (laid from the lower end along `layAzimuth`) is not - noted, nor is a near-vertical line (horizontal span under a tenth of the water depth) past - its end. The finite-EI note on a run past its anchor, which named "seabed friction or a - shorter line" whatever the deck, now names the same cause and remedy by the same rule and - skips the same as-laid run. It is printed on the static, `TMax = 0`, point-system and - multibody routes and in the OpenFAST initialisation report, which now also prints the - initialisation notes of finite-EI cables, and returned in the line report of the OpenFAST - aggregate. No example deck prints it, and no result changes. See the manual's theory page - (EI = 0 path) and Troubleshooting. +- Seabed friction in the static solve toward the as-laid position (`staticsFriction asLaid`, + with `layAzimuth` and `asLaidTension`), as in OrcaFlex. The default stays `none`, so existing + decks run as before. A 700 m chain on a 5° slope that the frictionless statics folds 24 m past + its anchor now holds where it was laid. +- Active tensioning (`CONTROL`) of finite-EI cables in OpenFAST, alone or in a deck with + `EI = 0` lines. +- Sub-stepping of tension-only (`EI = 0`) lines through fast segment rotation and slack-to-taut + snaps, on by default (`ei0_substeps auto|off`, `ei0_substep_angle`, `ei0_substep_max`). + It brings snap-load peaks at coarse time steps closer to converged runs; `off` restores the + previous results. +- Torsion of finite-EI lines in coupled OpenFAST (`CompMooring = 5`) and FAST.Farm runs. +- `Pinned` and `CoupledPinned`/`VesselPinned` rods in coupled OpenFAST runs. +- Seabed contact for `Free`/`Connect` points and `Point3` buoys: a heavy clump no longer sinks + through the seabed. +- Anchor uplift channels `AnchFz`, `AnchFH` and `TDPGrd` for drag-anchor checks. +- C ABI 1 minor extension 2 for hosts that drive `Coupled` points (for example CFD solvers): + `CableDyn_InitDeckAt`, `CableDyn_SaveState`/`CableDyn_RestoreState` and + `CableDyn_GetCoupledLayout`, with matching Python methods. Existing functions are unchanged. +- `OutputRecovery equilibrium|element` option and the `CD_HermiteCable_Dyn_Curvature_Exact` and + `CD_HFMF_Curvature_Exact` functions (see Changed). +- Run-time profile of the standalone driver (`CABLEDYN_PROFILE=1`). +- New diagnostics, none of which changes results: + - run audit of `EI = 0` lines in the standalone driver: tension spikes, fast segment turns + and unresolved snaps, and a note for `rhoInf` above 0.95; + - a note when the static state of a finite-EI line is unstable out of its vertical plane; + - a note when the static layout of an `EI = 0` line folds back on the seabed, naming the + cause and the remedy; + - notes for a line stretched far beyond its elastic range and for a section too coarse for + its line; + - a warning when line nodes of a coupled OpenFAST run lie outside the SeaState + wave-kinematics grid. ### Changed -- Tension-only (`EI = 0`) lines resolve fast segment rotation and slack-to-taut snaps by - sub-stepping, on by default (new OPTIONS `ei0_substeps auto|off`, `ei0_substep_angle` - (default 1°) and `ei0_substep_max` (default 16), checked when the line is initialised; the - Python deck reader applies the same rules). A converged step in which a segment that ends it - taut (above 0.1 % of the largest step-start tension) turned by more than - `ei0_substep_angle`, or a segment slack at its start ends it above a quarter of that tension - while the step does not resolve the axial wave over it (the wave crosses the segment more - than once per step), is solved again from the same committed state in - `max(4, ceil(turn/angle))` equal sub-steps, at most `ei0_substep_max`, with the end motion on - the quintic of the recovering step and the last sub-step on the given end state; output and - coupling times are unchanged. The tensions are those of the run audit (the elastic tension, - or that of the viscoelastic or Syrope law), and the step-start tension is taken as at least - 0.1 % of the line's initial tension, so a line slack all over does not count barely taut - segments. At `dtM` 0.1 s a taut segment of the Lozon 80 m - all-chain mooring turns by up to 6° per step in 5 m / 7 s heave, and the snap-load peaks of - both generalised-α blends came out 10 to 20 % low. The release cap was not the cause: it acts - in 0.3 % of the element steps, never within 0.5 s of a peak, and the cycle maxima with and - without it agree to within 1 %; the peaks followed the algorithmic damping (28 and 31 % low at - `rhoInf` 0, 10 and 40 % high at 0.6). Over seven runs whose amplitude differs by up to 3e-4, - against 0.5 and 0.25 ms runs, the fairlead and anchor maxima move from 15 and 17 % low to 4 and - 8 % low (the configuration blend of 0.1.1 gave 10 and 18 % low), and the anchor maxima of - the 200 m semitaut mooring in 10 m / 14 s and 5 m / 7 s surge from 16 and 26 % high to 4 % - high and 2 % low (over thirteen runs 5 % high and 0.3 % low, single runs from 4 % low to - 21 % high). A single run at that step varies by 15 to 20 points, so a single comparison - can make either blend look accurate. The decision depends only on the committed state, the - step inputs and the line's initial tension, so restarts repeat it; when a sub-step does not - converge the plain step's own result is kept, and a step recovered after a stall or a half - of a line-system step halved after a failure takes its sub-steps as given (when the halves - fail too, the full step is re-run as the nominal step, sub-steps included). It applies on - every route that steps `EI = 0` lines (standalone lines and line systems, OpenFAST, - FAST.Farm and the C API, whose raw lines always take it) except the lines attached to the - bodies, rods and points of the monolithic body and point coupling, which needs the end - reaction and tangent of the nominal step. `monolithic bodyScheme` is the default of every - standalone deck with `Rigid6` bodies, `Point3` buoys, rods or `Free`/`Connect` points on - `EI = 0` lines, so those lines are not sub-stepped there: 7 of the 21 shipped `EI = 0` - dynamic example decks run this way, and none of them notes an unresolved segment turn. A - line of such a deck whose ends are all fixed or anchored is sub-stepped, `staggered - bodyScheme` sub-steps them all, and the standalone driver notes the exclusion once per run. - `False alpha_force_blend` (paper mode) turns it off unless the deck sets it, so the paper - reproduction is unchanged. A step that triggers costs its plain step and usually four - sub-steps, at most the plain step and three passes of `ei0_substep_max` sub-steps (49 line - solves at the default), and that once for every sub-step where bodies or rods sub-cycle the - lines (`staggered bodyScheme`, coupled runs); the OpenMP loop over the lines of a system - hands them out dynamically, which leaves every line's result unchanged. The standalone - driver reports the sub-stepped steps per line ("solved N of the M line step(s) it - examined"), OpenFAST and FAST.Farm print the counts (steps sub-stepped, largest count, steps - that needed more than `ei0_substep_max`, steps that kept the plain step) at the end of the - run, and `CD_AGG_Get_Substep_Counts` returns them to an aggregate host as 64-bit integers. - Only committed steps count: a step rolled back and taken again (a line-system halving, a - stall recovery, a corrector or a junction iteration) counts once. Over the shipped examples - 19 of the 21 `EI = 0` dynamic decks are unchanged bit for bit; in the two `als_volturnus` - line-break decks the pre-failure anchor snap at 250 s, a single-step peak at `dtM` 0.05 s, - moves from 2.145 to 1.918 MN (1.963 MN converged) and from 2.262 to 2.158 MN (2.334 MN - converged), with the other tension statistics within 0.02 %. The 20-run Lozon mooring - envelope at `dtM` 0.1 s takes 1.67 times as long (1.6 to 2.5 times on the 5 m / 7 s and - 10 m / 14 s motions; the steps that do not trigger cost only the measurement), and the - examples whose steps never trigger run as before. Of the reproducers of the force-blend - entry below, the semi-taut chain–polyester leg in 15 m surge now peaks at 4.65 MN at the - anchor at `dtM` 0.05 s (5.74 MN before, 4.6 MN at 0.0025 s), the Syrope line at 1.81 MN - (1.64 MN before, 1.78 MN at 1 and 2.5 ms), the lightly damped viscoelastic light cable at - 0.062 MN at the anchor (0.085 MN before, 0.082 to 0.095 MN at 0.5 to 2.5 ms; its snap is not - resolved at 0.1 s, and over seven runs whose amplitude differs by up to 3e-4 it peaks at - 0.056 to 0.079 MN with the sub-steps and 0.056 to 0.085 MN without) and the shipped - viscoelastic polyester at 1.80 MN as before (in its steps recovered after a stall, taken as - given, a segment now turns by up to 2.0° per solver step, which the run notes); the light - cable stays at 0.092 / 0.106 MN at `dtM` 0.1 s and its largest segment tension at `dtM` - 0.01 s moves from 0.107 to 0.095 MN. Its fairlead and anchor peaks at `dtM` 2.5 ms move from - 0.099 / 0.091 to 0.102 / 0.119 MN, and on the stiff seabed at `dtM` 0.05 s from 0.52 / 0.67 - to 0.62 / 0.86 MN. None of these is a converged peak: the undamped `EI = 0` cable has no - converged snap peak (see the force-blend entry below; converged finite-EI runs give 0.093 / - 0.057 MN). At a step that does not resolve the axial wave the sub-steps resolve more of the - segment rattle of this undamped cable and can raise isolated spikes, as its anchor peak at - 2.5 ms shows. At `dtM` 0.5 ms, where the step resolves the wave, the cable takes no sub-step, - with or without physical axial damping (`BA` 5.06e5 N·s), and its results equal those taken - as given bit for bit; without the axial-wave condition on the snap trigger `auto` sub-stepped - 8081 of the 60000 steps of that run and raised its anchor peak from 0.116 to 0.52 MN. `ei0_substep_max` and `ei0_substep_angle` do not change these runs. Validation: - the Bergdahl matrix at its 0.3125 ms step resolves the axial wave over a segment and takes no - sub-step, so its maxima are unchanged bit for bit (RMSE 1.58 N, MAPE 3.13 %, Pearson 0.993, - Lin concordance 0.989); of its refinement runs the 0.1 m mesh moves the T = 1.25 s mean - cycle maximum from 68.33 to 68.35 N (largest mesh-halving change 0.52 % to 0.56 %) and the - 0.625 ms step from 72.2 to 69.5 N. The WD0050/A2 cell of the L2-2 parity moves within its - recorded range (largest OrcaFlex summary difference 0.091 to 0.093, MoorDyn-C metric 0.078 - to 0.076); the other L2-2 cells, the one-hour VolturnUS-S record, the L3-2 regular-wave - comparison and the snap-load verification are unchanged bit for bit (the latter two step - the generalised-α kernel directly). `off ei0_substeps` gives the previous results bit for - bit. -- Finite-EI node tension, curvature and bend moment are recovered from nodal equilibrium. The - `TenN`, `CurvN` and `BendMomN` channels, the `Tension`, `Curvature` and - `BendMoment` columns of the static profile and the range graph, and the `.t.out` segment - tensions of a finite-EI line had used the element-mean axial force `EA(|r'| - 1)` and the - exact one-sided curvature of the element interpolation. With a stiff `EA` that axial force - oscillates between elements wherever the line bends over an element (the nodal seabed - reaction near touchdown, a section junction), and it exceeds the tension by `EI kappa^2` on - any mesh. The outputs now come from the element end forces, each element with its own - distributed loads and inertia: the effective tension is the axial component of the section - force, the bend moment the moment the neighbouring elements carry, and the curvature that - moment over `EI`. The derivation is in the manual's theory page (Node tension, curvature and - bend moment). On the lazy-wave cable of `examples/iea15mw_umaine_mixed_cabledyn.dat` on its - former 87-element mesh the static interior node tension now stays between 1217 N and the - 11.9 kN fairlead tension instead of dropping to -173 N. Against the equilibrium of the - converged line, the largest error falls from 1552 N to 60 N at that mesh, from 2059 N to - 12 N, 1921 N to 1 N and 516 N to 0.3 N at twice, four times and ten times the mesh density, and from 164 N to - 1 N at 0.25 m elements. The largest curvature error falls from 64 % to 30 %, 44 % to 7 %, 19 - % to 4 % and 2.1 % to 0.8 % of the peak. Under an 8 m surge and 2 m heave of the hang-off, - the error of the maximum-tension envelope against a 1 m mesh falls from 2164 N to 857 N, 1488 - N to 283 N and 3049 N to 31 N, and the minimum tension of the run from -719 N to +610 N at - that mesh. A `.t.out` segment tension is now the mean of the axial components of the - element's two end forces instead of the axial resultant at its midpoint. The library - curvature (`CD_HermiteCable_Dyn_Curvature`, `CD_HFMF_Curvature`) follows the same definition - as the channels. A section softer than `max(|w| L0^2)/12` times 1 m (about 1.3 kN m^2 for the - 10 m elements of that cable) takes its curvature from the exact geometric trace, as an - `EI = 0` section does: the recovered moment carries an error of that order whatever `EI` is, - which `Curv = BendMom/EI` would amplify (6.9 1/m against 0.12 1/m at `EI` = 100 N m^2). - Line-end values (`FairTen`, `AnchTen`, the end-node tension; the end reaction, without the - inertia, added mass and seabed friction that the recovered section forces of the interior - nodes include), positions and the material-strain checks (`tensile_safety`, the static - compression notes) are unchanged. At a `Fixed` anchor resting on the seabed the end element - carries the floor-support share of its weight, as in the residual, so the end node reports - the bend moment of the line (0.02 N m, not 903 N m, at the anchor of the 87-element cable of - `examples/iea15mw_umaine_mixed_cabledyn.dat`, and 0.1 N m, not 205 N m, at the next node; on - the example's 248-element mesh 0.1 N m and 1.5 N m, the bend of the laid run sinking into the - penalty seabed beside the anchor held at the seabed depth). On - a line restrained in torsion the condensed torque is left out of the recovery; it moves the - tension by at most 0.45 N of 9.4 kN on `examples/torsion_lazy_wave_hangoff_twist.dat`. Range - graphs and `.t.out` files written every step cost 4 % more run time, plain channels under 2 - %. `OutputRecovery element` restores the previous definitions. The T-6 record of - `VALIDATION.md` (twisted lazy wave against OrcaFlex), which reads the static-profile - curvature, moves from 0.056 % to 0.049 %. The curvatures of the one-hour coupled full-turbine - run in its coupled finite-EI touchdown row (0.156 1/m at the sag bend, 0.109 1/m at the - touchdown) were recorded with the previous definition and are marked as such, as is the - static sag-bend curvature of the Hs = 11 power-cable case of - `validation/OPENFAST_DLC_VERIFICATION.md`, which now also gives the recovered values. The other - records use end tensions or the exact geometric curvature - (`CD_HermiteCable_Dyn_Curvature_Exact`) and are unchanged. -- The touchdown point (`TDP` channels and `cabledyn.touchdown_history`) is located inside - the element by the parabola through the last grounded node and the next two nodes instead of - the linear clearance between the last grounded node and the next. On a stiff seabed the - linear interpolation held the TDP on the last grounded node until the next one grounded, so - the TDP moved in steps of one element and, under a small motion, jumped by an element and - back. The parabola reaches a node exactly when the node grounds or lifts off, so the TDP moves - continuously. On a 450 m finite-EI cable under a 10 m fairlead surge, the largest step between - output rows falls from 4.64 m to 0.08 m with 5 m elements and from 1.98 m to 0.08 m with - 2.5 m elements, and the largest error against a 1 m mesh from 2.96 m to 1.92 m and from - 1.39 m to 1.18 m; under a 0.5 m surge the quasi-static TDP excursion with 1 m elements is - 0.63 m against 0.64 m converged, where the linear interpolation gave 0.23 m. On the - `EI = 0` chain of `examples/chain_range_tdp.dat` the largest step falls from 2.59 m to 1.33 m. - The TDP now lies on the contact-onset height, and `TDPGrd` uses the same location. -- Active tensioning (`CONTROL`) of an `EI = 0` line now stops the run when a command leaves - MoorDyn-F's bounds, as MoorDyn-F does: with `UnstrLen` the line's unstretched length and N its - number of segments, a `DeltaL` above `UnstrLen`/N or below −0.5 `UnstrLen`/N, the comparisons - MoorDyn-F makes, so a command MoorDyn-F accepts is accepted (on a line of one section - `UnstrLen`/N is the controlled segment's initial length). The message names the channel, the - line, the command and the bound. A command beyond these bounds had printed a one-time warning - and been applied. A command within the bounds that would make the controlled segment of a - line of several sections non-positive also stops the run. Finite-EI cables take the same - bounds. Every row is checked before any line changes, and a row that still fails takes back - the lines the command had already changed, so a refused command changes nothing. -- Faster wave kinematics of directional and multi-train seas (`wavetrain` rows, spectral - `waves` rows, `WaveSpreading`). Each component's phase cosine is now computed once for the - surface elevation and the kinematics, and its depth profile with one exponential instead of - two. `examples/chain_two_train_sea.dat` runs 17 % faster with the release build. The formulas - are unchanged. With gfortran the results are bit-identical. With the Intel compiler of the - release, which had computed the second cosine through a fused sine/cosine evaluation, they - can differ in the last printed digit. -- Faster monolithic body steps with a finite-EI cable clamped or elastically connected to a - body or rod. The cable's finite-difference columns of the junction Jacobian, each of which - re-steps the whole cable, are now kept and reused across steps like the mooring lines' - condensed tangent. They are rebuilt when 20 steps old, after a step that needed more than two - outer iterations, when the step size changes, and from the third outer iteration of a step. - `examples/buoy_clamped_cable.dat` runs 66 % faster with the release build, with the same - outer iterations per step. The junction converges to the same tolerance, so results differ - only within it, and by no more than the tolerance already allowed against a tightly converged - run: tensions by about 2e-6 relative and the body position by under 1 µm. -- The OpenFAST linearisation check (`validation/scripts/openfast_lin_ab.py`) now compares - CableDyn's quasi-static mooring stiffness entry by entry with stock MoorDyn's zero-frequency - reduction `D - C A^-1 B`, and fails above 0.5 %. It writes the `.lin` files with the - full-precision `OutFmt` `ES24.15E3`, lets MoorDyn settle its initial condition, and - linearises at t = 0. Its default case is the `examples/openfast` IEA-15 UMaine twin. On - that case the per-fairlead stiffness agrees to 0.07–0.10 % (0.29 % for the transverse - term), and the platform 6 × 6 diagonals agree to 0.10 % or better. The earlier record had - called MoorDyn's reduction unusable; with the 4-digit default `OutFmt` the same case - reproduces that asymmetric reduction, so the check now refuses a reference written below - full precision. VALIDATION.md and the OpenFAST page of the manual are updated. -- The FAST.Farm shared-mooring comparison with stock MoorDyn now covers 600 s of the r-test - `MD_Shared` farm (`validation/scripts/fastfarm_shared_ab.py`): tension means agree to 0.02 %, - extremes to 0.25 %, and platform motions to millimetres. The migration guide now says that on - a line with no `Fixed` end `FairTen` and `AnchTen` name the opposite ends from MoorDyn's. -- The power cable of `examples/iea15mw_umaine_mixed_cabledyn.dat` is meshed to the - half-bending-length rule: 248 elements (2 m, 2.5 m and 2.5 m in its three sections) instead - of 87 (4 m, 4 m and 10 m). On the 10 m grounded elements the touchdown was under-resolved and - the static state, solved in the vertical plane of the cable, was unstable out of that plane. - The static fairlead tension of the cable changes from 11 898 N to 11 922 N (11 921 N on a - 1 m mesh), its anchor tension from 1218 N to 1230 N, and the touchdown curvature from - 0.058 1/m to 0.079 1/m (0.080 1/m on the 1 m mesh; the geometric curvature, which - `OutputRecovery element` reports, while the curvature recovered from nodal equilibrium reads - 0.100 1/m on the 87-element mesh and 0.081 1/m on the 248-element one). The curvature output - moves with the mesh: `Curv4N20`/`BendMom4N20` (76 m from the hang-off) become - `Curv4N38`/`BendMom4N38` (74 m, the peak of the sag bend). In the one-hour full-turbine run of - the validation record the hang-off tension statistics are unchanged (11.5 ± 1.1 kN), the - touchdown curvature (geometric) peaks at 0.109 1/m instead of 0.075 1/m, and the anchor - tension stays at its static 1.23 kN, where the coarse mesh showed stick-slip peaks up to 4.1 kN. The validation record and the tutorials - are updated. -- Faster tension-only (`EI = 0`) line steps. In every Newton evaluation the element kernels of - the line loads (axial damping, Morison drag, Froude-Krylov, buoyancy recovery, added mass) no - longer re-check, element by element, data the line model validates when it is set; the - Froude-Krylov and added-mass kernels check their section data once instead of three times; - the velocity Jacobians of the Froude-Krylov and buoyancy loads, which are zero, are no longer - added into the band; a step reuses the consistent-mass band of the previous one while the - lengths and masses are unchanged; and the Newton solve no longer rescans a matrix already - checked finite. With the release build, `examples/als_volturnus_line_break_time.dat` runs - 13 % faster and `examples/spar_pinned_rods.dat` 13 %. Every input error is reported as - before. With gfortran the results are bit-identical. With the Intel compiler of the release - they can differ in the last printed digit, and by more where a deck amplifies round-off. +- Finite-EI node tension, curvature and bend moment (and `.t.out` segment tensions) are now + recovered from nodal equilibrium. On the lazy-wave example the largest tension error falls from + 1552 N to 60 N on its former 87-element mesh, and oscillations near touchdown on a coarse mesh + are removed. End tensions and positions are unchanged. `OutputRecovery element` restores the + previous definitions. +- `EI = 0` lines step with a generalised-α force blend, as finite-EI lines do. Tension spikes of + lines that go slack are gone: a light cable under 3 m heave reported 4.2 MN where converged + runs give 0.093 MN. Tension statistics of the shipped examples change by at most 0.23 % (mean) + and 0.9 % (maximum). `False alpha_force_blend` selects the former scheme. +- Active tensioning of `EI = 0` lines follows MoorDyn-F through length ramps: fairlead tensions + within 0.13 % instead of up to 6.3 %. A command outside MoorDyn-F's bounds stops the run + instead of printing a warning, and the command acts on the segment at the host-driven + (fairlead-side) end, as in MoorDyn-F. +- In OpenFAST, a deck without `dtM` now solves every glue step (`dtM = DT`) instead of about + every 0.1 s, so the mooring loads reach the platform without delay. A deck `dtM` that is a + multiple of `DT` still trades this for speed (see Known issues). +- The touchdown point (`TDP`) now moves continuously instead of in steps of one element. +- Finite-EI statics refine the mesh locally instead of as a whole, which cuts solve time (for + example 10.0 s to 0.33 s on a 462-element lazy wave). Decks that do not refine are unchanged. +- The power cable of `examples/iea15mw_umaine_mixed_cabledyn.dat` is re-meshed from 87 to 248 + elements. Its static fairlead tension changes by 0.2 %. +- Faster runs: directional and multi-train wave kinematics (17 %), finite-EI cables clamped to + bodies or rods (66 %), and decks of `EI = 0` lines (13 %). Results can differ in the last digit + with the Intel compiler. +- The OpenFAST linearisation check and the FAST.Farm shared-mooring comparison against MoorDyn + are extended: per-fairlead stiffness agrees to 0.1 % (0.29 % for the transverse term) and + shared-mooring tension means to 0.02 %. ### Fixed -- Seabed contact in the explicit object sub-step estimate. The staggered march of free and - pinned rods and Rigid6 bodies (the coupled OpenFAST and C API routes, standalone rod decks and - `bodyScheme staggered`) applies the seabed penalty springs explicitly, but sized its sub-steps - from the lines, hydrostatics and (pinned rods) the swing only, so a rod or body resting on a - stiff seabed at a large coupling step could exceed the central-difference limit and be thrown - off the bed. The estimate now adds the contact springs that can act within the step - (`kBot d dl` per rod contact station, `kBot` over 1 m² at a body's reference point), in - heave, roll and pitch about the reference point, or about the pin of a pinned rod at both pin - poses. A station counts from its complete rigid-body motion: its reach - `dt |v + w x s| + dt² (|a| + |alpha x s| + |w|² |s| + g)/2` bounds its travel in every - direction, and it counts when its height above the highest floor within that horizontal - distance (the depth on a flat seabed; on a `bathymetryFile` grid the highest node of the - overlapped cells, raised for the crease rounding by the new `CD_Bathymetry_Max_Floor`) is at - most the reach plus the rod radius, so a rod sliding or turning towards a shallower bed is - covered as well as one landing. The monolithic scheme, which carries the contact in its - Jacobian, is unchanged. No shipped example or existing test changes its sub-step count. -- Line-free explicit object marches without a sub-step estimate. A standalone deck without lines - marched its bodies and rods by the explicit central difference at `dtM` with no sub-steps, and - the `bodyScheme staggered` multibody march skipped the bodies (and rods) when no `EI = 0` line - was present (finite-EI cables only), so a short pinned rod or a body on a stiff seabed could - exceed the explicit limit there. Both now take the estimate from the objects' own terms - (hydrostatic restoring, seabed contact, a pinned rod's swing about its pin), and the staggered - multibody march sizes a pinned rod as the coupled route does: its line springs through their - arms from the pin on its inertia about the pin, plus its swing and contact about the pin. A 1 m - dry pinned rod at `dtM = 0.6 s` (`omega0 dt = 2.29`) now takes 6 sub-steps on both routes and - equals a `dtM = 0.1 s` run at every row, where it previously turned over. No shipped example - or existing test changes its sub-step count. -- Further terms of the explicit object sub-step estimate (coupled and C API routes, standalone - rod decks, decks without lines and `bodyScheme staggered`; the monolithic scheme is - unchanged): a rod near the free surface adds its waterplane stiffness (`rhoW g D dl` at each - station whose section can cross the surface within the step, `rhoW g pi D^2/4` where its axis - can cross it) and takes its dry inertia, for free and pinned rods and the rods fixed to a - Rigid6 body, so a floating rod (a 5 cm rod at `omega dt = 2.2`) no longer grows; a finite-EI - cable on a body or rod of the staggered march adds its attachment spring (`EA/L` along its end - force, `T/L` across), as the explicit cable end force needs; a rod pinned to a body takes the - body's pin acceleration and a reduced-mass lower bound of its inertia about the pin; a step - that would need more than the 256-sub-step cap is warned about once per run. Of the existing - tests, only the staggered pinned-cable deck of `clamped_cable_ends` changes (10 steps now - sub-cycled 2 to 5 times; printed results unchanged); no shipped example changes. -- Seabed friction of rods and Rigid6 bodies is applied implicitly. The regularised friction - `-mu N v/sqrt(v^2 + vreg^2)` (`vreg = 1e-3 m/s`) is a damper of up to `mu N/vreg`, far stiffer - than any practical step, and was evaluated explicitly, so a rod or body resting on a - frictional bed chattered (velocity and friction flipping every step). It now enters the - implicit velocity derivative of the step as its secant coefficient `mu N/sqrt(v^2 + vreg^2)`, - as the line nodes treat it implicitly: a rod held in a cross current holds still (creep at - `vreg F/(mu N)`) where it slid back and forth at a few mm/s. This changes the results of decks - with rods or bodies on a frictional seabed; none of the shipped examples or existing tests has - one. -- Node output channels of a finite-EI line whose mesh the static solve refined read the wrong - node, silently. `TenN`, `CurvN`, `BendMomN`, `LNp/v/a{x,y,z}`, - `LNDec`/`Azi`, `TorqN` and `TwistN` name a deck node (1 + the total - `NumSegs` of the line's sections) and are checked against that count, but after an automatic - refinement (adaptive, stability or curvature refinement) they reported node `J` of the refined - mesh. On the lazy-wave cable of `tests/data/lazy_wave_touchdown_planar_coarse.dat` with its top - section cut from 20 to 4 elements (refined from 71 to 1136 elements), `Ten4N34`, the deck node - at the 220 m touchdown, reported 5488 N, the tension at 41 m from End A, against 1544 N, and - `BendMom4N54`, on the seabed at 420 m, 1214 N·m against 0. Each refined line now maps its deck - nodes onto the final mesh by their unstretched arc length from End A (an exact match, which - does not assume a uniform refinement; a deck node not on the mesh fails closed), and the node - channels read deck nodes on every route: standalone static and dynamic cubic-Hermite, mixed - `EI = 0` + finite-EI, multibody, OpenFAST and the C API `CableDyn_EvalChannel`. `.static.out`, - the range graphs, the per-line files and `CableDyn_GetLineValues` still list every node of the - refined mesh; `.static.out` then carries a `DeckNode` column naming the deck node of each row - (0 for a node the refinement added), `.Line.p.out` a `# DeckNode` comment line (also on the - multibody march, which writes no `.static.out`), and the new C API quantity - `CD_C_LINE_DECK_NODE` (10) of `CableDyn_GetLineValues`, Python `Line.deck_nodes`, gives the - same numbering in process. The Python `StaticProfile.deck_node_arc_lengths`, - `LineNodeHistory.deck_nodes`, `node_range_graph`, `profile_at`/`profiles_at` and - `line_range_graph` place main-output node channels at their deck node, from a static profile, - a per-line position file or `LinePositions` read from one. `EI = 0` lines are never refined, and every output of a deck whose meshes are - not refined is unchanged. See the manual's output reference (Node channels on a refined line). - -- Tension spikes of tension-only (`EI = 0`) lines that go slack. The generalised-α step evaluated - the axial force and the dynamic loads at the blended configuration - `q_α = (1 − α_f) q_{n+1} + α_f q_n`. A segment that was slack at the start of a step and - carries tension at `q_α` then ends the step stretched beyond it, - `q_{n+1} = (q_α − α_f q_n)/(1 − α_f)`, and a segment going slack within a step returned more - work to the motion than its strain energy. Both happened silently at the default - `rhoInf = 0.4`, at every `dtM` from 0.002 to 0.2 s, on realistic input: a light, axially stiff - cable (80 kg/m, EA 8e8 N) under 3 m heave reported 4.2 MN at the fairlead and 3.4 MN at the - anchor (`dtM` 0.0025 s) and 20 MN at the anchor (`dtM` 0.1 s), where converged finite-EI - runs of the same cable give 0.093 MN at the fairlead and 0.057 MN at the anchor; the same - cable in an `Hs` - 8 m JONSWAP sea 0.41 MN at the anchor against 0.043 MN; the shipped viscoelastic polyester in - 15 m surge 2.69 MN against 1.80 MN; a semi-taut chain–polyester leg 9.5 MN at the anchor - against 4.6 MN; and a line on a stiff seabed failed the plausibility guard. The step now blends - forces, `(1 − α_f) r(q_{n+1}, v_{n+1}) + α_f r(q_n, v_n)`, as the finite-EI path does, for the - axial force and every dynamic load (damping, viscoelastic and Syrope laws, seabed, drag, - Froude–Krylov, buoyancy; added mass stays at `q_α`). The step-start force is evaluated afresh - at the committed state, so no state is added and restarts stay exact. An element that - releases within a step returns at most its strain energy over the step, so a release can no - longer create energy. Its step-start force acts along its step-start chord for the whole step, - so the cap takes the shortening projected on that chord, which a segment that turns as it goes - slack exceeds by far (a nearly unstretched segment turning by 90° would otherwise return - hundreds of times its strain energy), and it fades out continuously as the end state crosses - the rest length. The viscoelastic and Syrope segments are capped the same way with the tension - of their law, their end tension estimated with a secant stiffness bounded by the law's axial - stiffness, so that damping carried at a vanishing stretch does not make the cap switch - abruptly (the same cable made lightly damped viscoelastic peaks at 0.085 MN at the anchor at - `dtM` 0.1 s, a snap that step does not resolve, against 0.145 MN without the cap on its - segments and 0.082 to 0.095 MN at 0.5 to 2.5 ms). An elastic segment with axial damping - keeps the step-start dashpot force along its old chord too; where its end state is slack, or - taut by less than `α_f/(1 − α_f)` of its stretch, the cap covers that force as well, crediting - the dashpot's end share, so that the whole blend of a segment ending slack returns at most its - strain energy unless that end share alone returns more (in the test chain it returned up to - 2750 times that with only the elastic share capped); a damped segment that ends taut beyond - that band keeps the plain force blend. A damped segment slack at the step start keeps its - step-start dashpot force under a cap too, so that this kept share returns at most the - dashpot's own one-step dissipation `T_d,n |l̇_n| Δt` plus the end share's credit (up to 46 - times that in the test chain before). The seabed contact of - a node that lifts off within a step is not capped (see the manual's theory page). At the - default `rhoInf` the light cable now peaks at 0.10 / 0.09 MN at `dtM` 0.0025 s and at 0.092 / - 0.106 MN at 0.1 s, the same cable in the JONSWAP sea at 0.075 / 0.043 MN and the - viscoelastic polyester at 1.80 MN, as at 0.0025 s; the stiff-seabed line runs to completion. - The light-cable figures are not converged peaks. The undamped `EI = 0` deck has no converged - snap peak: the peak rises as `dtM` falls (0.32 to 0.46 MN at microsecond steps, also with an - explicit lumped-mass solver), as single segments rattle, and falls with mesh refinement at a - fixed `dtM`; its 20 ms averages converge to 0.083 / 0.047 MN, the slack-to-taut event, and - converged finite-EI runs give 0.093 MN at the fairlead and 0.057 MN at the anchor. On the - stiff seabed the `EI = 0` peak does not converge either (0.74 to 0.95 MN at coarse steps, - 1.2 to 1.4 MN at 0.025 to 0.05 ms). The - chain–polyester anchor snap peaks at 5.7 MN at `dtM` 0.05 s, a single-step peak (4.6 MN at - 0.0025 s) that the new snap note reports. On a linear element the scheme is unchanged, so taut - lines keep their accuracy: every MoorDyn-C, OrcaFlex, analytic and experimental comparison that - runs locally still passes, and its reported error moves by at most 0.35 percentage points (the - minimum fairlead tension of the one-hour VolturnUS-S record, 0.15 % to 0.50 %; the snap-load - peak at 20 ms improves from 2.76 %, published as 2.7 %, to 1.5 %; see VALIDATION.md). Every - `EI = 0` dynamic output changes. Over the shipped examples the statistics of the tensions - change by at most 0.23 % (mean) and 0.9 % (maximum), except the two `als_volturnus` decks, - whose pre-failure anchor snap at 250 s is resolved by one or two samples and peaks 10 % lower. - Static runs and finite-EI lines are unchanged. The step costs up to 6 % more wall time on - `EI = 0` dynamic decks (one more force evaluation per step and about 4 % more Newton - iterations). `False alpha_force_blend`, which until now applied to finite-EI lines only, - selects the former scheme for `EI = 0` lines as well. Lines that the C API builds without a - deck (`CableDyn_InitLine`, `CableDyn_InitLines`) always take the force blend. The figures - of this entry take every step as given, as `off ei0_substeps` now does; the rotation- and - snap-resolved sub-steps of the default (under Changed) move the snap peaks among them, for - example the chain–polyester anchor to 4.65 MN and the viscoelastic light cable to 0.062 MN. -- `modified_newton` on `EI = 0` lines (with or without the force blend, so also under - `False alpha_force_blend`) rebuilds the tangent when an iterate reduces the residual by less - than a factor four, as the manual states; it had kept the first tangent for the whole step, - which a slow linear contraction could exhaust (30 iterations at the start of the 5 m heave - cells of the L2-2 parity test with the force blend). -- Active tensioning (`CONTROL`) of an `EI = 0` line now changes the segment at the line's - fairlead-side end, the end on a host-driven point (`Coupled`, `Vessel`, `Turbine`, - `Body` or a `Coupled`/`Vessel` rod end), and the segment at the `NodeB` written in the - deck when both or neither ends are host-driven, as MoorDyn-F does for a deck in its own order. - It had always changed the segment at CableDyn's End A, the `NodeA` of a line that the - automatic anchor-first swap leaves in deck order. Two kinds of line change: a line kept in - deck order whose only host-driven end is its `NodeB`, such as a stock-order - `Connect`-to-`Vessel` clump leg or a line from a `Fixed` anchor to a coupled rod end, now - controls the segment at the host-driven end instead of the one at its `NodeA`; and a line - with both or no host-driven ends that the swap leaves in deck order, such as a - `Connect`-to-`Fixed` or `Connect`-to-`Connect` line, a `Fixed` hang-off above a - `Free`/`Connect` point, or a line between two vessel points, now controls the segment at its - `NodeB`. Lines from a `Fixed` anchor to a `Coupled`, `Vessel` or `Body` point, - written in either order, and lines written fairlead first from a host-driven `NodeA` control - the same segment as before. -- Active tensioning (`CONTROL`) of `EI = 0` lines no longer lags behind the commanded length - on a pay-out or haul-in ramp. A length update had re-derived the committed acceleration - under the new length, and the next generalised-α step evaluated its blended configuration - with the new length only, so the force of each length change entered the committed side of - the blend. The committed state now keeps its acceleration and the lengths and rates it was - reached with, and each share of the step after a change takes the lengths of its own time - level. With the force-blended step (the default), the step-start force is evaluated at the - committed lengths and rates: the internal force, every dynamic load, every step-start - quantity of the release cap (stretch, tension, secant and law stiffness, dashpot tension, and - the one-step dissipation budget of a dashpot slack at the step start), - and the distributed external load and seabed coefficients those lengths give; the cap's - end-state quantities take the new lengths; the end-of-step force takes the new lengths, and the inertia (the - structural and added mass, which the force blend keeps at the α level) the blended ones. - Under `False alpha_force_blend` the step blends the old and new lengths with the - configuration. An acceleration re-derived between a command and the next step, as a host - state update does, is solved at the committed lengths, as the step evaluates its committed - side, and leaves them committed. On a taut line paid out at a tension change of 1 N per step, - the tension follows the closed form to 1.8 mN at `rhoInf` 0.4 and 0 alike (the start-up - transient), where a step-start force at the new lengths lags by 2.6 N. In - the coupled OpenFAST comparison with stock MoorDyn (`validation/scripts/activetension/`), the - controlled fairlead tensions had run up to 97 kN (4.1 %) above MoorDyn during the pay-out and - 148 kN (6.3 %) below it during the haul-in, at `rhoInf` 0.4 and still 58 kN and 89 kN at - `rhoInf` 0; they now stay within 3 kN (0.13 %). The hold tensions, which the published - comparison scores, move by less than 0.01 %, and the scorer now also gates the ramps. - This change leaves runs without `CONTROL`, and a zero command, bit-identical. A checkpoint restart - re-applies the restored command as the committed state's, so a restart during a ramp - continues bit-identically. A step that `ei0_substeps auto` solves in sub-steps spreads the - length change over them: the committed lengths are part of the state each pass starts from, - each sub-step ends at the lengths and rates interpolated linearly in time (the last at the - new ones), and the trigger takes the step-start tensions at the committed lengths. On a line - turning by 2.3° per step and paid out at 0.05 m/s, the sub-stepped march equals one taken as - given at a quarter of the step to 3e-8 N; applying the whole change in the first sub-step - departs from it by 22 N. -- Failure messages are no longer cut off by fixed-size buffers. The tensile qualification - failure of a dynamic step ended mid-advice (`... at element 64, xi= 0.5000; increase`) because - the buffers that carried it from the Hermite cable through the OpenFAST module and the deck - driver held 200, 300 and 256 characters. Every message buffer of the solver chain, the - C API handle (now 4096 characters; `CableDyn_GetLastError` still truncates to the caller's - buffer, and the Python binding reads 4097 bytes), the standalone driver and the OpenFAST - glue is now long enough for the longest diagnostic. A list that can outgrow its buffer (the - seed notes of a failed `EI = 0` static solve, the initialisation notes of a line) ends with - "further ... notes omitted" instead of stopping mid-note. Results do not change. -- A neutrally buoyant line is named as such. A finite-EI line whose net weight is zero and that - is longer than its span was reported as "the net-heavy line is too long for its span to hang - as a catenary", which is not the cause; the message now says the line is weightless, has no - catenary, and could only bow under axial compression, and advises shortening it to its span - or giving it weight or tension. An `EI = 0` line type rejected as net-buoyant (dry mass not - above the displaced water mass, the unchanged rule) whose mass lies within a relative 1e-6 below - the displaced mass is now named neutrally buoyant, "weightless and slack: its static shape is - indeterminate", with the advice to give it weight or a finite EI and a tension. The Python deck - reader words it the same way. No line type is accepted or rejected differently. -- A line stretched far beyond its elastic range now says so. A line 50 % shorter than its span - converged at 100 % strain and 1.2 GN with no message, because `maxStrain` guards only the - dynamics. The initialisation report notes the static fairlead strain (tension over the EA of - the End A section) of every line, `EI = 0` or finite-EI, above `maxStrain` when the option - is given and positive, and above 10 % otherwise (`0 maxStrain` disables only the dynamic - guard). Only a note: the equilibrium and the outputs are unchanged. -- A section too coarse for its line is warned about. The coarse-mesh warning fired only for a line - with fewer than three segments in all, so a 100 m one-segment top section on a 520 m line - (fairlead tension off by 50 %) passed silently. Every section whose segments are longer than - 1/8 of the line (coarser than a uniform eight-segment line, however the line is split into - sections) now gets a warning, for `EI = 0` and finite-EI lines, in the single-topology driver - and in the standalone mixed route. No example deck is affected. -- Rejection messages name the unsupported capability and the workaround. An `EI = 0` line - between two Coupled points suggests splitting it at a `Connect` point, and a finite-EI one, - which that split does not admit, says to anchor it or model the span with `EI = 0` lines; a - finite-EI cable ending on a `Connect`/`Free`/`Coupled` point, or on a Coupled End A that a deck - with `Connect`/`Free` points cannot drive (it would need `motionFile` coupling), names the point - and what the route supports; the "this coupled mode runs the mooring in - STILL WATER" rejection of deck waves or current now names the route that rejects it (a - standalone mixed deck, which is not coupled, or FAST.Farm) and gives that route's remedy (an - all-`EI = 0` or all-finite-EI deck, or OpenFAST with SeaState; in FAST.Farm, removing the - OPTION); an anchor below the seabed by more than the - tolerance gives the depth, the tolerance rule, and the Z to use. These messages change no - acceptance rule. -- `Free` and `Connect` points (clump weights, buoys) and `Point3` buoys now have their own - seabed contact. Until now only the end nodes of the attached lines held a point on the - seabed, over their tributary length, so a heavy clump sank silently into it: a 50 t clump - between two polyester lines ended 2.8 m below the seabed, a 20 t clump on chain 1.0 m. A - point with `Mass` or `Vol` (a `Point3` buoy: its BODY `Mass` and `Vol`) now rests on a - footprint `A = V^(2/3)` (`V` = `Vol`, or `Mass`/7850 kg/m³ for a clump declared by its mass - alone), the face area of a cube of its volume, with the line contact law, stiffness `kBot·A` - and damping `cBot·A`, along the surface normal on a bathymetry, in the point static - equilibrium (which does not place a `Point3` buoy) and in the monolithic, staggered and - OpenFAST/C API point steps. The 50 t clump now rests 0.95 m deep (its weight alone presses - its 3.44 m² footprint in by 1.43 m) and the 20 t clump 0.67 m. The point routes still reject - `frictionMu`, so the contact is frictionless. Formal OpenFAST linearisation of a deck with a - `Point3` buoy now fails closed by name, like a deck with Rigid6 bodies or rods: its - quasi-static re-solve held the buoy at its deck position. Results change only where a point touches the seabed: of the examples only - `clump_weight_free_point.dat`, whose clump now rests 4.7 cm deep instead of 6.6 cm and whose - anchor tension falls from 186 kN to 92 kN; decks whose points stay clear of the seabed give - identical output. See the manual's theory page (Seabed contact). -- A finite-EI deck mesh that cannot resolve the curvature of its static equilibrium (an - element folded beyond `L0*kappa = 0.7`), and a fragile mesh under `adaptive_mesh True`, are - now refined locally instead of as a whole. The static solve had multiplied every element by - the power of two that the worst one needed, up to 16, even when only one section was coarse: - a 462-element lazy wave whose 180 m top section had two elements was solved on 7392 elements - in 10.0 s, and a 410-element lazy wave with a rigid horizontal hang-off on 6560 elements in - 9.2 s. A refinement pass now splits into 2, 4, 8 or 16 equal elements only the elements whose - `L0*kappa` exceeds 0.12 (or the stricter `adaptive_mesh` target), that are longer than half - their bending length `(EI/|w|)^(1/3)`, or, at a line end, longer than the boundary layer - `sqrt(EI/T)`, and the elements about an isolated seabed-contact change, and grades the mesh - into the neighbouring elements (no element more than twice as long as the next, unless the - deck mesh has a larger ratio there). The cap of 16 per deck element, the element limit, the - acceptance checks and the fail-closed messages are unchanged; where a pass would exceed the - element limit, the bending-length splits give way first, then the grading, and only then the - curvature, end-layer and contact splits, and a refinement that stops short of its target - names what stopped it (the cap, the element limit or the limit of 12 passes, 16 for the - axial passes). The two decks above now solve on 492 and 436 elements in 0.33 s and 0.28 s, - with end tensions within 4e-7 and 2e-6 of the whole-line refinement and nodes within 0.7 mm - and 4 mm. The lazy wave of the node-channel entry above (its top section on 4 elements) now - refines to 269 elements instead of 1136, with node tensions within 0.9 N (of 1.2 to 12 kN) - of the same line on 1560 elements of 0.25 to 0.5 m. In the finite-EI statics matrix 61 - of the 123 decks refine: their CPU time falls from 65 s to 33 s, the end tensions change by - at most 0.21 % of the line's peak end tension (a 58 m line on 2 m end elements, whose - hang-off tension moves from 1157.5 N to 1155.1 N; 1157.5 N on a mesh 16 times finer) and the - nodes by at most 6.4e-4 of the line length. In a 761-deck statics robustness campaign 57 - decks refine: they solve in 18 s instead of 63 s, with the same outcomes and notes (two no - longer need the static residual floor note), end tensions within 1e-5 of the peak end - tension and nodes within 3.2e-5 of the line length. - Decks that do not refine, including every shipped example, give identical output. On a - deck that refines, the dynamics run on the new mesh; the local refinement only splits deck - elements, so every deck node is a node of the new mesh and the node output channels still - name deck nodes (see the node-channel entry above). -- A finite-EI line with discrete buoyancy modules (`ATTACHMENTS`) in a cross current on a - frictional seabed no longer fails its static solve. The lazy wave of - `tests/data/lazy_wave_touchdown_planar_refined_att.dat` (25 modules on 2 m elements) in a - 0.3 m/s current across its plane stopped with `finite-EI static solve with discrete - ATTACHMENTS failed at load fraction 0.125 (relative residual 1.304E+02)`. The homotopy from - the smeared to the lumped modules adds the module drag, which the smeared equilibrium does - not carry, and on the frictional seabed the damped Newton update for it overshot and - diverged from the first step, even in steps of 1/64 of the load; the seed and the step size - were not the cause. A step whose damped Newton solve does not converge is now repeated from - the last converged state with pseudo-transient continuation and then with a residual-merit - line search, and halved (down to 1/1024) when neither converges. A halved step doubles - again (up to 1/8) after two consecutive converged steps of its size, and each time a - doubled step fails, the number of converged steps a doubling waits for doubles; at most 64 - load steps may fail in all. A discrete state reached this way must pass the checks the - smeared state passed (the kink limit, except on the elements beside an attachment node, - which carry its slope jump as curvature at any mesh size; the tensile contract under - `tensile_safety True`; the physical-branch audit; the stability test), or the solve fails - closed naming the check; a state that passes them is reported in a note. The deck now solves in - 1.8 s, its fairlead and anchor tensions within 0.04 % and 0.2 % of the deck with the - equivalent smeared buoyancy section; in 0.6 m/s, and on the coarse mesh, it solved before - and its results are unchanged. A polish whose Newton steps all converge takes the same - solves as before, so every other deck is unchanged. A new test (`attachment_cross_current`) - checks the four cases against their smeared twins. -- The development environment (`environment.yml`) excludes OpenBLAS 0.3.34, which caused the - access violation in the modal analysis tests listed under Known issues for 0.1.1. On AMD - Zen 4 and Zen 5 CPUs that expose AVX-512, OpenBLAS 0.3.34 enlarges the GEMM blocking, - and its Zen and Haswell DGEMM kernels then overrun their stack buffer for an inner - dimension above 128. This happens in builds without the AVX-512 kernels, such as the - conda-forge Windows package, and in any build when `OPENBLAS_CORETYPE` forces one of these - kernels (OpenMathLib/OpenBLAS#6013 and #6021). The dense reference eigensolve - (`DSYGV`) of the modal tests reached it. On hosted CI runners the fault appeared only on - those runners whose AMD CPU exposed AVX-512. The solver itself calls only banded LAPACK - routines and a 4 × 4 eigensolve, none of which passes DGEMM an inner dimension above 128, - and the released Windows executables use reference LAPACK, so results are unchanged. An existing environment takes the exclusion with - `conda env update -f environment.yml`, followed by a fresh build directory. -- The anchor tension of a finite-EI cable laid on the seabed no longer jumps when the line moves - out of its plane. The seabed contact acts at the nodes, which carry no moment, so at an - anchor resting on the floor the end moment of the end element's weight turned the free end - tangent into the floor: the element dipped below the seabed between its nodes (27 mm for the - power cable of `examples/iea15mw_umaine_mixed_cabledyn.dat` on its former 10 m grounded - elements) and carried axial forces from −47 kN to +127 kN about a line tension of 1.2 kN. - Once the hang-off swayed, the element buckled sideways; with seabed friction the anchor tension then locked at about 2.5 times its - static value for the rest of the run (1.22 kN to 3.1 kN in a coupled OpenFAST run while the - platform drifted toward the anchor), and without friction the end nodes wandered by up to - 0.18 m. The seabed now carries the end element's weight with its end moment at a held line end - resting on the floor (along the floor normal on a sloped bathymetry), in the statics and the - dynamics alike, in the share in which the element lies on the floor: the contact force of - its inner node against half the element's weight, through a smooth step that is zero when - that node is clear of the floor and one from half the weight up. Lines whose held end does - not rest on the seabed, or whose end element rises from it (a taut line anchored on the - floor), are unchanged. In the - shipped finite-EI examples with an anchor on the seabed the end tensions change by at most - 0.34 N (0.004 %). Two decks of the statics robustness matrix change outcome. A lazy wave - in a 1 m/s current on a frictional bed (`LW_1015__cur_fr`) had been reported as a hairpin - past its anchor only at its exact seabed stiffness. It now fails closed: the friction-held - touchdown goes into compression at about 0.33 m/s, before any tension-only equilibrium is - reached from the still-water layout, and a slow current ramp in the dynamics with - `tensile_safety` stops at the same point. A short line in a 1.9 m/s current on a - frictionless bed (`CUR_1013`) had failed closed. It now finds the equilibrium with the - grounded run turned sideways on the seabed: when the refinement of the catenary - continuation stops on a compression in a current, its failure now names the current limit, - so the driver retries out of the plane. -- A finite-EI line solved in 3D (restrained in torsion, or with an end connection direction or - a current out of the vertical plane of its chord) on a deck mesh too coarse at touchdown or at a section - change no longer stops with "the converged state is an unstable equilibrium". The stable - equilibrium had read as a saddle: elements longer than the bending length cannot follow - the bend, the axial force at their Gauss points oscillates into compression, and that - compression lowered the out-of-plane stiffness until the stability test failed. Such a - state is now refined, from the mesh the route returned, to the mesh whose elements are at - most half the bending length: the catenary-continuation route is repeated there, as for a - failed polish, and the state of the mesh-sequenced route is prolongated there and polished. - This also covers a mesh that an adaptive or safety refinement left too coarse; a mesh that - already meets the rule is not refined again. A note names both meshes. An equilibrium that - is still unstable on the refined mesh stops as before. Decks that solved before give the - same results. `tests/data/lazy_wave_touchdown_torsion_coarse.dat` is the regression case, - solved with each route first. -- A finite-EI line over a bathymetry that is not a plane along its chord no longer fails its - statics on a few centimetres of roughness. The catenary seed is laid on the plane fitted to - the bathymetry along the chord, which need not pass through the anchor, and it was rejected - as soon as a node dipped about 1e-6 of the line length below that plane. The - catenary-continuation route then stopped at once, and the mesh-sequenced fallback often ended - on a kinked branch ("unresolved/kinked equilibrium"). In a sweep of a chain on a rough - seabed, 39 of 96 runs on a 25 m survey grid failed this way, at every roughness from 2 cm to - 0.5 m. The seed is now measured against the actual bed: a node deeper below it than its - static penalty penetration (submerged weight over `kBot` × `Diam` × length) is lifted onto - the bed, a shallower one is left to the contact solve, and the continuation, which queries - the full surface, settles the contact. The equilibrium is audited, tested for stability and - checked for kinks as before. A line too long for the fitted plane is also walked into place - from a retreated anchor over such a bathymetry (the moved anchor kept at its height above - the bed under it); as the bed can hold the excess length in its dips, a failed walk there - is not reported as proof that the line is too long, and the mesh-sequenced route still runs. - All 192 finite-EI runs of the sweep now solve, within 1 % of the fairlead force on a mesh - four times finer and 0.8 % of the `EI = 0` line. Decks over a flat seabed or a planar - bathymetry are unchanged, and so are all shipped examples and test decks. A deck over a - non-planar bathymetry that solved before can now take the catenary-continuation route - instead of the mesh-sequenced one, or start from a seed lifted out of a bump: in the sweep - 29 of 153 such runs changed, the fairlead force by at most 0.03 % and the anchor tension by - at most 2.2 % (on 0.5 m roughness, where the anchor tension of the same deck differs by up - to 13 % on a mesh four times finer). The decks `ROUGH_1001` to `ROUGH_1003` of the cable - statics matrix (with mesh twins) are the regression cases. -- A line resting in a trench, a valley or a pit of a gridded bathymetry now has a static - equilibrium. Along every interior grid line the bilinear surface has a crease, and a node on - it took the normal of one adjacent cell, so a node that had to rest in a concave crease was - pushed back across it from either side and had no equilibrium. An `EI = 0` chain whose - frictionless tension falls to zero inside a trench (its excess length resting slack at the - bottom) failed with "no admissible static equilibrium", and so did a grounded run on a - two-dimensional rough seabed, which slides sideways into a valley along a grid line; a - finite-EI line on such a seabed could fail its first dynamic step. Each crease is now - rounded within a band of half-width 5 % of the smaller grid spacing next to its line, by - the cubic fillet `J (d - |u|)^3 / (6 d^2)` of the slope jump `J` across the line, applied as - a tensor product in both directions, so that the surface is twice continuously - differentiable. It moves the surface by at most `|J| d / 6` along one line (1.7 cm for a - slope jump of 0.2 on a 10 m grid; at a crossing of two lines the two roundings add), and a - grid that is exactly planar, and every patch without a crease (one that would move the - surface by less than 1 µm), keep the bilinear surface bit for bit; the rounding errors of a - plane written to two or three decimals are themselves creases and are rounded by a fraction - of a millimetre. In a band the elastic contact force is the gradient of the penalty - potential of the normal penetration (up to the twist of a bilinear cell, which the tangent - leaves out as before), with its Hessian as the tangent, in the statics and the dynamics - alike. Every bathymetry query uses - this surface, the Python `Bathymetry` and its seabed clearance included. A `Fixed` point at - the tabulated depth of a creased grid node rests on the seabed and is placed on the rounded - surface. In the statics campaign the `EI = 0` decks on bathymetry solve 40 of 43 (32 - before; the three left have anchors below the seabed), a 30 m trench now solves at every - depth from 2 m to 30 m (5 of 11 before), with the anchor tension `w` times the trench depth - as for a chain piled at the bottom (the fairlead tension within 0.15 % of the same trench - sampled with a level bottom cell, on a mesh four times finer), and the `EI = 0` rough-seabed - sweep solves 192 of 192 (191). Decks over a flat seabed or a planar bathymetry are unchanged, and so are all shipped - examples and test decks. Decks over creased bathymetries that solved before change: the - fairlead tension by at most 0.04 % (0.4 % for an `EI = 0` run that settles in another valley - of a two-dimensional rough seabed), the anchor tension by up to 8.5 %. The rounding removes - horizontal reactions of the one-sided normals: on a 2 m trench the two ends' horizontal - forces now agree to 0.02 % (1.2 % before), and the anchor tension of a finite-EI line on a - rough two-dimensional seabed is half as far from the one on a mesh four times finer. The - decks `trench_touchdown_pile`, `trench_grounded_run_pile` and `rough2d_seabed` of the `EI = 0` - statics robustness matrix are the regression cases, with an independent nodal force balance - on the rounded surface. When the anchor walk of a finite-EI line over a non-planar bathymetry - reaches a state that is rejected, the failure no longer states that the line is too long for - its span to hang as a catenary, which is proven over a planar seabed only. +- Node output channels of a finite-EI line whose mesh the static solve refined now read the + deck node named, not the same index on the refined mesh. +- Static solves that failed or gave the wrong answer: + - creased gridded bathymetry (trenches, valleys) now has a static equilibrium; + - a finite-EI line over a rough, non-planar bathymetry no longer fails on a few centimetres + of roughness; + - a 3D finite-EI solve on a coarse mesh no longer stops with "unstable equilibrium"; + - a finite-EI line with `ATTACHMENTS` in a cross current on a frictional seabed now solves. +- The anchor tension of a finite-EI cable laid on the seabed no longer jumps when the line + moves out of its plane. +- Explicit sub-stepping of free and pinned rods and Rigid6 bodies now accounts for seabed + contact, free-surface crossing and decks without lines, and seabed friction of rods and + bodies is applied implicitly (no more chatter on a frictional bed). +- `modified_newton` on `EI = 0` lines rebuilds the tangent as documented. - Junction end tangent of a tension-only line step that ends right after a fresh tangent - evaluation. In the monolithic body and point coupling, a line step accepted within the - near-tolerance allowance at its Newton iteration limit (or converged on a freshly evaluated - tangent) still marked its last factorization as current, although the new tangent had - overwritten it. The condensed end tangent, and the warm start of a re-solve of the same step, - were then back-solved with the unfactored matrix: in a unit test the end tangent was wrong by - five orders of magnitude, which can slow or misdirect the outer junction iteration. The step - now clears the factorization flags whenever it overwrites the band without factoring it, so - the end query factors the current tangent (one more tangent assembly and factorization for - such a step of a junction solve). The outputs of the example decks and of the other tests - are unchanged. + evaluation. +- Error messages are no longer truncated, and now name the cause and workaround for neutral + buoyancy, unsupported couplings and anchors below the seabed. +- The development environment excludes OpenBLAS 0.3.34, which crashed the modal tests on some + AMD CPUs. Results are unchanged. + +### Known issues + +- In OpenFAST, a deck `dtM` larger than `DT` holds the loads between CableDyn's steps, so they + reach the platform about `dtM/2` late. The lag matters for stiff (taut or tension-leg) + moorings and for tension statistics; check such results at a smaller `dtM`. See the note on + the manual's OpenFAST page. ## [0.1.1] - 2026-10-09 @@ -1290,6 +534,6 @@ Corrections made during the pre-release review. values of the shipped example decks and states which tension (end element or `FairTen` end force) each comparison uses. -[Unreleased]: https://github.com/SMI-Lab-Inha/CableDyn/compare/v0.1.1...HEAD +[0.2.0]: https://github.com/SMI-Lab-Inha/CableDyn/releases/tag/v0.2.0 [0.1.1]: https://github.com/SMI-Lab-Inha/CableDyn/releases/tag/v0.1.1 [0.1.0]: https://github.com/SMI-Lab-Inha/CableDyn/releases/tag/v0.1.0 diff --git a/CITATION.cff b/CITATION.cff index 76e91526..b22c25e6 100644 --- a/CITATION.cff +++ b/CITATION.cff @@ -22,8 +22,8 @@ authors: repository-code: "https://github.com/SMI-Lab-Inha/CableDyn" url: "https://github.com/SMI-Lab-Inha/CableDyn" license: Apache-2.0 -version: 0.1.1 -date-released: 2026-10-09 +version: 0.2.0 +date-released: 2026-10-20 keywords: - mooring dynamics - cable dynamics diff --git a/CMakeLists.txt b/CMakeLists.txt index e602d2ee..fa0bb6dc 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -8,7 +8,7 @@ # cmake_minimum_required(VERSION 3.20) # VERSION is a bare numeric triple matching the release version. -project(CableDynCore VERSION 0.1.1 LANGUAGES C Fortran +project(CableDynCore VERSION 0.2.0 LANGUAGES C Fortran DESCRIPTION "CableDyn geometrically nonlinear cable/mooring solver — Fortran core") option(CABLEDYN_ENABLE_COVERAGE "Instrument the GNU Fortran core for gcov/gcovr source coverage" OFF) diff --git a/README.md b/README.md index f4f91a0a..b5b9f446 100644 --- a/README.md +++ b/README.md @@ -21,7 +21,7 @@ in the MoorDyn v2 format and solves them with two line formulations: - **Finite-bending lines** (finite-EI): cubic-Hermite elements for dynamic power cables, including lazy-wave configurations, with continuous centreline curvature. -The current stable release is `v0.1.1`. Interfaces are +The current stable release is `v0.2.0`. Interfaces are versioned and may change before `1.0.0`. ## Capabilities @@ -48,8 +48,8 @@ a named error rather than running approximately. |---|---| | `CableDyn_driver.exe` | Standalone solver for Windows x64 | | `openfast.exe` | OpenFAST with CableDyn available as `CompMooring = 5` | - | `cabledyn-0.1.1-py3-none-any.whl` | Python package (pre- and post-processing, batch runs) | - | `cabledyn-0.1.1.tar.gz` | Python source distribution | + | `cabledyn-0.2.0-py3-none-any.whl` | Python package (pre- and post-processing, batch runs) | + | `cabledyn-0.2.0.tar.gz` | Python source distribution | | `SHA256SUMS.txt` | Checksums for the assets above | Both executables are statically linked, need no installer, compiler, or runtime @@ -82,7 +82,7 @@ a named error rather than running approximately. this run writes `examples\wd0050.out`: ```powershell - python -m pip install "cabledyn-0.1.1-py3-none-any.whl[post]" + python -m pip install "cabledyn-0.2.0-py3-none-any.whl[post]" cabledyn-run examples\wd0050_chain.dat wd0050 --executable .\CableDyn_driver.exe ``` @@ -92,8 +92,8 @@ a named error rather than running approximately. For OpenFAST, set `CompMooring = 5` in the `.fst` file and point `MooringFile` at a CableDyn deck; ready-to-run cases are in -[`examples/openfast`](examples/openfast/README.md). Every shipped deck is listed -in [`examples/`](examples/README.md). +[`examples/openfast`](https://cabledyn.readthedocs.io/en/latest/tutorial_openfast.html). Every shipped deck is listed +in [`examples/`](https://cabledyn.readthedocs.io/en/latest/examples.html). ## Documentation @@ -115,9 +115,9 @@ The driver is `build/cabledyn` (`build\bin\cabledyn.exe` with the conda toolchai on Windows); the release ships the same program as `CableDyn_driver.exe`. -See [DEVELOPMENT.md](DEVELOPMENT.md) for the full test suite, the Python package, -and the OpenFAST build, and [ARCHITECTURE.md](ARCHITECTURE.md) for the source -layout. +See the [development guide](https://cabledyn.readthedocs.io/en/latest/development.html) +for the full test suite, the Python package, and the OpenFAST build; the source +layout is described in the architecture notes in the repository. ## Validation @@ -125,8 +125,8 @@ CableDyn is verified against analytical solutions and compared with MoorDyn, OrcaFlex, two physical experiments (Holcombe lazy-wave, Bergdahl dynamic chain), the IEA 15 MW VolturnUS-S reference systems, and coupled OpenFAST runs. Results, acceptance criteria, and reproduction commands are in -[VALIDATION.md](VALIDATION.md); data and scripts are in -[`validation/`](validation/README.md). +the [validation record](https://cabledyn.readthedocs.io/en/latest/validation.html); data and scripts are in +[`validation/`](https://cabledyn.readthedocs.io/en/latest/validation.html). ## Repository layout @@ -151,19 +151,21 @@ If you use CableDyn in academic work, please cite: > offshore wind. *Ocean Engineering* 368 (Part 2), 128332, 2026. > -To identify the software version, also cite the release (CableDyn 0.1.1). -[CITATION.cff](CITATION.cff) contains both entries (GitHub **Cite this +To identify the software version, also cite the release (CableDyn 0.2.0). +The [citation file](https://cabledyn.readthedocs.io/en/latest/citing.html) contains both entries (GitHub **Cite this repository**); BibTeX is on the manual's [How to cite](https://cabledyn.readthedocs.io/en/latest/citing.html) page. ## Contributing and support Questions, bug reports, and feature requests are welcome in -[GitHub Issues](https://github.com/SMI-Lab-Inha/CableDyn/issues); see -[SUPPORT.md](SUPPORT.md) for where each belongs. Read -[CONTRIBUTING.md](CONTRIBUTING.md) before opening a pull request. Everyone taking -part is expected to follow the [Code of Conduct](CODE_OF_CONDUCT.md). Report -security issues privately as described in [SECURITY.md](SECURITY.md). +[GitHub Issues](https://github.com/SMI-Lab-Inha/CableDyn/issues); the +support notes in the repository say where each belongs. Read the +[contributing guide](https://cabledyn.readthedocs.io/en/latest/contributing.html) +before opening a pull request. Everyone taking part is expected to follow the +[Code of Conduct](https://github.com/SMI-Lab-Inha/CableDyn?tab=coc-ov-file). Report +security issues privately as described in the +[security policy](https://github.com/SMI-Lab-Inha/CableDyn/security/policy). If you extend or fix CableDyn in your own copy, please consider contributing the change here, so that every user benefits and the validation record stays in one @@ -181,7 +183,7 @@ CableDyn builds on the work of others, and we are grateful to the developers and maintainers of MoorDyn (Hall et al.), whose open input format CableDyn reads and which serves as a comparison reference; of OpenFAST (NLR), which hosts CableDyn as a mooring module; and of OrcaFlex, the industry reference used for many of the comparisons -in [VALIDATION.md](VALIDATION.md). OrcaFlex is a product of Orcina Ltd. +in the [validation record](https://cabledyn.readthedocs.io/en/latest/validation.html). OrcaFlex is a product of Orcina Ltd. ## License and name @@ -193,3 +195,9 @@ are welcome under the licence, but, as Section 6 of the Apache License 2.0 provides, they may not use the name in a way that implies they are the official CableDyn or endorsed by its maintainers; describing a work as "based on CableDyn" is fine. + +This software is developed independently at the Department of Naval Architecture +and Ocean Engineering, Inha University. It is not affiliated with, derived from, +or endorsed by the EPSRC-funded research project (2022–2025) of the same name +led by the University of Edinburgh, "CableDyn: Subsea Power Cable Dynamics Under +Complex Ocean Environment" ([cabledyn.eng.ed.ac.uk](https://cabledyn.eng.ed.ac.uk)). diff --git a/RELEASE.md b/RELEASE.md index 1d3a1e8a..91365683 100644 --- a/RELEASE.md +++ b/RELEASE.md @@ -124,7 +124,7 @@ where practical), and keep the workflow URL with the release record. Tag only the commit that passed every check: ```powershell -$ReleaseVersion = "0.1.1" +$ReleaseVersion = "0.2.0" git tag -s "v$ReleaseVersion" -m "CableDyn v$ReleaseVersion" git push origin "v$ReleaseVersion" ``` diff --git a/VALIDATION.md b/VALIDATION.md index 78cee30d..bd2f11fd 100644 --- a/VALIDATION.md +++ b/VALIDATION.md @@ -291,11 +291,7 @@ scripts, results, and source provenance are in over the full 30-condition period-radius matrix, cycle-maximum upper-end force has RMSE 1.58 N, mean absolute percentage error 3.13%, Pearson correlation 0.993, and Lin concordance 0.989. Two phase-averaged measured histories have - waveform RMSEs of 5.95% and 2.54% of their force ranges; these two were computed with the - executable of the 2026-10-09 record (the configuration-blended `EI = 0` step, without - sub-steps), because the - article supplement's `expData.dat` they need was not available for the rerun (see the - experiment's README and `provenance.json`). Halving the mesh length + waveform RMSEs of 5.93% and 2.56% of their force ranges. Halving the mesh length and the time step changes the mean cycle maximum by at most 0.56% and 0.19%. The 0.3125 ms step resolves the segment axial modes that the snap loads excite (and the axial wave over a segment, so the matrix takes no rotation- and snap-resolved sub-step and equals diff --git a/doc/capi.rst b/doc/capi.rst index 4281f708..8944618c 100644 --- a/doc/capi.rst +++ b/doc/capi.rst @@ -110,12 +110,12 @@ files directly, as shown below. - Library files - Header * - Linux - - ``lib/libcabledyn.so.0.1.1``, the soname link ``libcabledyn.so.1``, and the development + - ``lib/libcabledyn.so.0.2.0``, the soname link ``libcabledyn.so.1``, and the development link ``libcabledyn.so``. ``lib`` is the platform ``CMAKE_INSTALL_LIBDIR``, which can be ``lib64`` or a multiarch directory. - ``include/CableDyn_CAPI.h`` * - macOS - - ``lib/libcabledyn.0.1.1.dylib``, ``lib/libcabledyn.1.dylib``, ``lib/libcabledyn.dylib`` + - ``lib/libcabledyn.0.2.0.dylib``, ``lib/libcabledyn.1.dylib``, ``lib/libcabledyn.dylib`` - ``include/CableDyn_CAPI.h`` * - Windows, GNU toolchain - ``bin/libcabledyn.dll`` and the import library ``lib/libcabledyn.dll.a``. The GNU @@ -245,7 +245,7 @@ ABI and versioning - the same four numbers, reported by the loaded library * - ``CableDyn_GetVersionString`` - runtime - - ``"CableDyn 0.1.1 C-ABI 1"`` + - ``"CableDyn 0.2.0 C-ABI 1"`` * - shared-library ``SOVERSION`` - 1 - soname ``libcabledyn.so.1`` or install name ``libcabledyn.1.dylib``. The Windows DLL @@ -732,7 +732,7 @@ Version queries - ``char *`` - ``version_len`` - yes: no-op - - receives ``"CableDyn 0.1.1 C-ABI 1"``, truncated to ``version_len - 1`` characters and + - receives ``"CableDyn 0.2.0 C-ABI 1"``, truncated to ``version_len - 1`` characters and ``NUL``-terminated * - ``version_len`` - in diff --git a/doc/citing.rst b/doc/citing.rst index 620b1ab6..822a3a14 100644 --- a/doc/citing.rst +++ b/doc/citing.rst @@ -37,21 +37,21 @@ Software release ---------------- Seo, J. H. (2026). *CableDyn: A cable and mooring dynamics solver for floating offshore -wind* (version 0.1.1) [Computer software]. https://github.com/SMI-Lab-Inha/CableDyn +wind* (version 0.2.0) [Computer software]. https://github.com/SMI-Lab-Inha/CableDyn .. code-block:: bibtex @software{CableDyn_0_1_1, author = {Seo, Jae Hoon}, title = {{CableDyn}: A cable and mooring dynamics solver for floating offshore wind}, - version = {0.1.1}, + version = {0.2.0}, year = {2026}, url = {https://github.com/SMI-Lab-Inha/CableDyn}, license = {Apache-2.0} } When results depend on a particular release, quote the version reported in the solver banner -(``CableDyn v0.1.1``) together with the options recorded for the run. +(``CableDyn v0.2.0``) together with the options recorded for the run. Relation to the journal article ------------------------------- diff --git a/doc/coupling_boundary.md b/doc/coupling_boundary.md index 14725a37..94b4850c 100644 --- a/doc/coupling_boundary.md +++ b/doc/coupling_boundary.md @@ -108,7 +108,7 @@ Rules shared by every entry point: The interface ships as the versioned shared library `libcabledyn` (`cabledyn.dll` in an Intel Fortran and MSVC build; CMake target `cabledyn_shared`) with the installed header; it reports -CableDyn 0.1.1 and C ABI version 1, minor extension 2. The Python package uses the same library. +CableDyn 0.2.0 and C ABI version 1, minor extension 2. The Python package uses the same library. ### Concurrency diff --git a/doc/index.rst b/doc/index.rst index 906eab0b..754283b4 100644 --- a/doc/index.rst +++ b/doc/index.rst @@ -12,8 +12,9 @@ with MoorDyn-C, MoorDyn-F, and OrcaFlex on common reference cases. .. admonition:: Release status :class: note - CableDyn ``v0.1.1`` is the current stable release. It adds torsion of finite-EI cables to - the first public release and makes the Windows builds more robust. + CableDyn ``v0.2.0`` is the current stable release. It adds active tensioning and coupled + torsion of finite-EI cables, sub-stepping of tension-only lines through snaps and seabed + friction in the static solve, and recovers node results from nodal equilibrium. Every comparative-accuracy statement is linked to a passing benchmark in :doc:`validation`. The project remains below ``1.0.0``, so public APIs may evolve between minor releases. @@ -49,8 +50,8 @@ Download to first result in five minutes ---------------------------------------- #. Download ``CableDyn_driver.exe``, ``SHA256SUMS.txt``, and **Source code (zip)** (for the - ``examples`` folder) from the `v0.1.1 release - `_ and verify the checksum — + ``examples`` folder) from the `v0.2.0 release + `_ and verify the checksum — :doc:`installation`. No installer and no runtime DLLs. #. Put ``CableDyn_driver.exe`` in a working folder, unzip the source archive, and copy its ``examples`` folder next to the executable. @@ -161,6 +162,15 @@ How to cite If CableDyn contributes to published work, cite the method article and the software release as described in :doc:`citing`. +Name +---- + +This software is developed independently at the Department of Naval Architecture and Ocean +Engineering, Inha University. It is not affiliated with, derived from, or endorsed by the +EPSRC-funded research project (2022--2025) of the same name led by the University of Edinburgh, +"CableDyn: Subsea Power Cable Dynamics Under Complex Ocean Environment" +(`cabledyn.eng.ed.ac.uk `_). + .. toctree:: :hidden: :caption: Getting started diff --git a/doc/installation.rst b/doc/installation.rst index b2251e11..b7d78cba 100644 --- a/doc/installation.rst +++ b/doc/installation.rst @@ -6,8 +6,8 @@ Installation There are two ways to get CableDyn: * **Windows release (recommended for users).** Two single-file executables and a Python wheel, - attached to the `v0.1.1 GitHub release - `_. No installer, no compiler, + attached to the `v0.2.0 GitHub release + `_. No installer, no compiler, and no runtime DLLs. Start here if you want a first result in five minutes. * **Build from source** (Windows, Linux, macOS). Needed for the C/Python in-process API, for development, and on every platform other than Windows x64. @@ -35,10 +35,10 @@ What is on the release page - OpenFAST v5.0.0 (maintained by NLR, the National Laboratory of the Rockies, formerly NREL) with CableDyn built in as ``CompMooring = 5``; stock MoorDyn (``CompMooring = 3``) is still available in the same binary (:doc:`openfast`) - * - ``cabledyn-0.1.1-py3-none-any.whl`` + * - ``cabledyn-0.2.0-py3-none-any.whl`` - the pure-Python package: deck editing, case generation, driver automation, result readers, fatigue and spectral post-processing (:doc:`python`) - * - ``cabledyn-0.1.1.tar.gz`` + * - ``cabledyn-0.2.0.tar.gz`` - the Python source distribution (same package as the wheel) * - ``SHA256SUMS.txt`` - SHA-256 checksums of the four files above @@ -56,7 +56,7 @@ Download and verify ~~~~~~~~~~~~~~~~~~~ 1. Create a folder, for example ``C:\CableDyn``, and download into it ``CableDyn_driver.exe``, - ``openfast.exe`` (only if you will couple with OpenFAST), ``cabledyn-0.1.1-py3-none-any.whl`` + ``openfast.exe`` (only if you will couple with OpenFAST), ``cabledyn-0.2.0-py3-none-any.whl`` (only if you will use Python), ``SHA256SUMS.txt``, and ``Source code (zip)``. 2. Verify every downloaded asset against ``SHA256SUMS.txt`` in PowerShell: @@ -76,8 +76,8 @@ Download and verify OK CableDyn_driver.exe OK openfast.exe - OK cabledyn-0.1.1-py3-none-any.whl - not downloaded cabledyn-0.1.1.tar.gz + OK cabledyn-0.2.0-py3-none-any.whl + not downloaded cabledyn-0.2.0.tar.gz ``not downloaded`` only reports an asset you chose to skip. @@ -86,7 +86,7 @@ Download and verify ``(Get-FileHash .\CableDyn_driver.exe -Algorithm SHA256).Hash`` with its line in ``SHA256SUMS.txt`` (the comparison is case-insensitive). -3. Unzip ``Source code (zip)``. It expands to a folder such as ``CableDyn-0.1.1``; copy (or move) +3. Unzip ``Source code (zip)``. It expands to a folder such as ``CableDyn-0.2.0``; copy (or move) its ``examples`` folder into ``C:\CableDyn`` so the layout is:: C:\CableDyn\ @@ -112,7 +112,7 @@ Check that it runs .. code-block:: text =================================================================== - CableDyn v0.1.1 + CableDyn v0.2.0 Geometrically nonlinear cable & mooring dynamics for floating wind (lazy-wave power cables and taut / semi-taut / catenary moorings) ------------------------------------------------------------------- @@ -158,9 +158,9 @@ Python 3.10 or newer: .. code-block:: powershell - py -m pip install .\cabledyn-0.1.1-py3-none-any.whl + py -m pip install .\cabledyn-0.2.0-py3-none-any.whl # optional extras for DataFrames and plots: - py -m pip install ".\cabledyn-0.1.1-py3-none-any.whl[post]" + py -m pip install ".\cabledyn-0.2.0-py3-none-any.whl[post]" This installs the ``cabledyn`` package and four console commands: ``cabledyn-run``, ``cabledyn-deck``, ``cabledyn-study``, and ``cabledyn-post``. @@ -188,7 +188,7 @@ Check the installation from a new terminal: .. code-block:: text - 0.1.1 C:\CableDyn\CableDyn_driver.exe + 0.2.0 C:\CableDyn\CableDyn_driver.exe The in-process API (``cabledyn.CableDyn``, stepping the solver from Python without a subprocess) additionally needs the shared library from a source build; see :doc:`python`. @@ -259,7 +259,7 @@ The script downloads the LAPACK source from its release tag and verifies its SHA integration to OpenFAST itself (do not pre-apply it), builds both executables, rejects any non-system DLL import, runs a standalone and a coupled ``CompMooring = 5`` / ``CompMooring = 3`` smoke case with a system-only ``PATH``, and writes -``SHA256SUMS.txt`` into ``build-static-release\dist``. The v0.1.1 assets were built from +``SHA256SUMS.txt`` into ``build-static-release\dist``. The v0.2.0 assets were built from OpenFAST revision ``2895884d2be01862173c88d70f86b358d2f1a50a`` and smoke-tested against ``r-test`` revision ``dd5feaaaa500ba7283140107806300d551cff0a7``. diff --git a/doc/modeling.rst b/doc/modeling.rst index 45bc5616..38231b0b 100644 --- a/doc/modeling.rst +++ b/doc/modeling.rst @@ -199,8 +199,9 @@ performance comparisons keep the default. Choose ``dtM`` by convergence of peaks, phase, rainflow ranges, and accumulated damage—not only by solver success. Numerical stability at a large implicit step is not evidence of fatigue accuracy. -In OpenFAST the default target is ``dtM = 0.1 s``; loads and assembled OpenFAST channels are -zero-order-held between CableDyn solves. The separate ``.CD.out`` contains only genuine committed +In OpenFAST the default is ``dtM = DT`` (a solve every glue step); with a larger deck ``dtM``, +loads and assembled OpenFAST channels are zero-order-held between CableDyn solves, which delays +the loads by about ``dtM/2`` (see :doc:`openfast`). The separate ``.CD.out`` contains only genuine committed ``dtM`` samples, while ``DT_Out`` changes the assembled OpenFAST recording cadence only. Neither file convention substitutes for a time-step convergence study, which should cover the forcing bandwidth, the shortest element transit time, contact switching, and constitutive relaxation diff --git a/doc/openfast.rst b/doc/openfast.rst index dad65c98..69e0ee92 100644 --- a/doc/openfast.rst +++ b/doc/openfast.rst @@ -76,8 +76,9 @@ Time step ~~~~~~~~~ ``DT`` is the OpenFAST glue step; ``dtM`` is CableDyn's committed step. With no deck ``dtM``, -CableDyn targets 0.1 s rounded to a whole number of glue steps and holds its loads (zero-order -hold) between commits. ``dtM = DT`` solves every glue step. The console reports the result, for +CableDyn solves every glue step (``dtM = DT``). A deck ``dtM`` that is a whole multiple of ``DT`` +solves once per that many glue steps and holds its loads (zero-order hold) between commits, which +is faster but delays the loads (see the note below). The console reports the result, for example ``CableDyn time step dtM = 2.50000E-02 s (1 x glue DT; deck dtM)``. A deck ``dtM`` larger than ``DT`` but not a whole multiple of it is never coarsened: CableDyn uses the largest multiple of ``DT`` that does not exceed it and reports a warning with both values (``dtM = 0.025`` @@ -89,6 +90,18 @@ two ``dtM`` values (for example 0.1, 0.05, and 0.025 s) and demonstrate converge peaks, and damage. If CableDyn needs a smaller step than the glue step, reduce ``DT`` as well. ``DT_Out`` changes only the sampling of the main OpenFAST table. +.. note:: + + With ``dtM`` larger than ``DT``, CableDyn holds its loads between commits, so the platform + receives the mooring load on average half a ``dtM`` late. A spring force delayed this way + acts on the platform as a negative damping of about the mooring stiffness times ``dtM/2``. For a catenary mooring this + is small: in the three-seed DLC-1.1 comparison of :doc:`validation` the platform motions with + ``dtM`` above ``DT`` agree with MoorDyn within 0.6 % in mean and standard deviation, but the + fairlead tension's standard deviation differs by about 3 % from CableDyn's own solution at + every glue step. For stiff taut, semi-taut or tension-leg moorings the lag can be comparable + to the system's own damping. Check such systems, and any fatigue or tension-range result, at + a smaller ``dtM`` (down to ``dtM = DT``) before relying on them. + Fluid source ~~~~~~~~~~~~ @@ -174,7 +187,7 @@ Run and confirm Before trusting a run, confirm in the console: -#. ``Running CableDyn (v0.1.1, ...)`` and ``Parsing CableDyn input file: ``; +#. ``Running CableDyn (v0.2.0, ...)`` and ``Parsing CableDyn input file: ``; #. the ``dtM`` line and the model inventory (``Created CableDyn model: ... line object(s)``); #. for every line, the converged fairlead effective tension, force vector, inclination, declination, and azimuth at the static equilibrium — printed unconditionally, whether or not diff --git a/doc/options.rst b/doc/options.rst index 12acbe91..cfa29341 100644 --- a/doc/options.rst +++ b/doc/options.rst @@ -481,7 +481,7 @@ Finite-EI cable controls curvature = moment / ``EI`` (see :ref:`theory-output-recovery`). ``element`` reports the length-weighted element-mean axial force :math:`EA(\lvert\mathbf r'\rvert - 1)`, the larger one-sided exact curvature, and the axial resultant at the element midpoint as the - segment tension, the definitions up to CableDyn 0.1.1. End forces, positions, ``TDP`` + segment tension, the definitions of the releases before 0.2.0. End forces, positions, ``TDP`` channels and the material-strain checks (``tensile_safety``, compression notes) are the same under both - both (finite-EI lines) diff --git a/doc/quickstart.rst b/doc/quickstart.rst index b50b1e69..ffb15dae 100644 --- a/doc/quickstart.rst +++ b/doc/quickstart.rst @@ -18,7 +18,7 @@ and the ``examples`` folder (from the release's **Source code (zip)**) side by s .. code-block:: powershell Set-Location C:\CableDyn - .\CableDyn_driver.exe --version # prints the v0.1.1 banner, exit code 0 + .\CableDyn_driver.exe --version # prints the v0.2.0 banner, exit code 0 2. Solve a mooring line ----------------------- @@ -38,7 +38,7 @@ The run takes well under a second: .. code-block:: text =================================================================== - CableDyn v0.1.1 + CableDyn v0.2.0 Geometrically nonlinear cable & mooring dynamics for floating wind (lazy-wave power cables and taut / semi-taut / catenary moorings) ------------------------------------------------------------------- diff --git a/doc/tutorial_openfast.rst b/doc/tutorial_openfast.rst index 0b04142a..7614aac0 100644 --- a/doc/tutorial_openfast.rst +++ b/doc/tutorial_openfast.rst @@ -150,9 +150,10 @@ Division of responsibility: settings, its own time step ``dtM``, and the ``OUTPUTS`` list. Fairlead ``Coupled`` points are given in platform axes; ``Fixed`` anchors in global axes. * **The time step.** ``CableDyn_UMaine.dat`` sets ``dtM = 0.025`` = ``DT``, so CableDyn solves - every glue step. Without a deck ``dtM``, CableDyn targets 0.1 s rounded to a whole number of - glue steps and holds its loads between solves. For fatigue, snap, or touchdown work use - ``dtM = DT`` or prove that a coarser value converges. + every glue step, which is also the default without a deck ``dtM``. A larger ``dtM`` solves + once per several glue steps and holds the loads between solves, which is faster but delays + them. For fatigue, snap, or touchdown work keep ``dtM = DT`` or prove that a coarser value + converges. The complete ownership table is in :doc:`options`; the coupling contract in :doc:`openfast`. @@ -167,7 +168,7 @@ The CableDyn part of the console (other modules' lines trimmed): .. code-block:: text - Running CableDyn (v0.1.1, 2026-10-09). + Running CableDyn (v0.2.0, 2026-10-20). CableDyn: geometrically nonlinear cable & mooring dynamics for floating wind. ... CableDyn time step dtM = 2.50000E-02 s (1 x glue DT; deck dtM) diff --git a/examples/airy_wave_shallow_chain.dat b/examples/airy_wave_shallow_chain.dat index c8b1467b..ea0518cb 100644 --- a/examples/airy_wave_shallow_chain.dat +++ b/examples/airy_wave_shallow_chain.dat @@ -27,7 +27,7 @@ LineID LineType Length NumSegs 30.0 WtrDpth - Water depth (m) [default: absent standalone; host-owned OpenFAST] 1.0e5 kBot - Seabed penalty stiffness base (Pa/m) [default: 1.0e5] 1.0e4 cBot - Seabed normal damping base (Pa-s/m) [default: 1.0e4] -0.05 dtM - CableDyn internal time step (s) [default: omitted standalone; 0.1 s target OpenFAST] +0.05 dtM - CableDyn internal time step (s) [default: omitted standalone; the glue DT in OpenFAST] 60.0 TMax - Standalone simulation duration (s) [default: omitted standalone; host-owned OpenFAST] airy 8.0 10.0 0.0 waves - Wave model, height, period, and direction (m, s, deg) {none; airy; jonswap} [default: none] 10.0 rampTime - Half-cosine start-up ramp of the wave amplitudes (s) [default: 0] diff --git a/examples/als_volturnus_line_break_tension.dat b/examples/als_volturnus_line_break_tension.dat index c6fe3bb5..2a63af55 100644 --- a/examples/als_volturnus_line_break_tension.dat +++ b/examples/als_volturnus_line_break_tension.dat @@ -54,7 +54,7 @@ FailID Point Line(s) FailTime FailTen 200.0 WtrDpth - Water depth (m) [default: absent standalone; host-owned OpenFAST] 1.0e5 kBot - Seabed penalty stiffness base (Pa/m) [default: 1.0e5] 1.0e4 cBot - Seabed normal damping base (Pa-s/m) [default: 1.0e4] -0.05 dtM - CableDyn internal time step (s) [default: omitted standalone; 0.1 s target OpenFAST] +0.05 dtM - CableDyn internal time step (s) [default: omitted standalone; the glue DT in OpenFAST] 1800.0 TMax - Standalone simulation duration (s) [default: omitted standalone; host-owned OpenFAST] jonswap 6.0 11.0 3.3 60.0 waves - Wave model, JONSWAP Hs, Tp, gamma, and direction (m, s, deg) {none; airy; jonswap} 20.0 rampTime - Half-cosine start-up ramp of the wave amplitudes (s) [default: 0] diff --git a/examples/als_volturnus_line_break_time.dat b/examples/als_volturnus_line_break_time.dat index 94599725..e3404635 100644 --- a/examples/als_volturnus_line_break_time.dat +++ b/examples/als_volturnus_line_break_time.dat @@ -54,7 +54,7 @@ FailID Point Line(s) FailTime FailTen 200.0 WtrDpth - Water depth (m) [default: absent standalone; host-owned OpenFAST] 1.0e5 kBot - Seabed penalty stiffness base (Pa/m) [default: 1.0e5] 1.0e4 cBot - Seabed normal damping base (Pa-s/m) [default: 1.0e4] -0.05 dtM - CableDyn internal time step (s) [default: omitted standalone; 0.1 s target OpenFAST] +0.05 dtM - CableDyn internal time step (s) [default: omitted standalone; the glue DT in OpenFAST] 1800.0 TMax - Standalone simulation duration (s) [default: omitted standalone; host-owned OpenFAST] jonswap 6.0 11.0 3.3 60.0 waves - Wave model, JONSWAP Hs, Tp, gamma, and direction (m, s, deg) {none; airy; jonswap} 20.0 rampTime - Half-cosine start-up ramp of the wave amplitudes (s) [default: 0] diff --git a/examples/buoy_clamped_cable.dat b/examples/buoy_clamped_cable.dat index 5c8494bb..4193c17e 100644 --- a/examples/buoy_clamped_cable.dat +++ b/examples/buoy_clamped_cable.dat @@ -54,7 +54,7 @@ LineID End Stiffness EzX EzY EzZ 100.0 WtrDpth - Water depth (m) [default: absent standalone; host-owned OpenFAST] 1.0e5 kBot - Seabed penalty stiffness base (Pa/m) [default: 1.0e5] 1.0e4 cBot - Seabed normal damping base (Pa-s/m) [default: 1.0e4] -0.05 dtM - CableDyn internal time step (s) [default: omitted standalone; 0.1 s target OpenFAST] +0.05 dtM - CableDyn internal time step (s) [default: omitted standalone; the glue DT in OpenFAST] 30.0 TMax - Standalone simulation duration (s) [default: omitted standalone; host-owned OpenFAST] static bodyIC - Free Rigid6 body / rod start {static=equilibrium; deck=deck pose} [default: static] monolithic bodyScheme - Body time integration {monolithic; staggered}; a clamped End A needs monolithic [default: monolithic] diff --git a/examples/chain_range_tdp.dat b/examples/chain_range_tdp.dat index 87d11df9..fb073fcb 100644 --- a/examples/chain_range_tdp.dat +++ b/examples/chain_range_tdp.dat @@ -30,7 +30,7 @@ LineID LineType Length NumSegs 50.0 WtrDpth - Water depth (m) [default: absent standalone; host-owned OpenFAST] 1.0e5 kBot - Seabed penalty stiffness base (Pa/m) [default: 1.0e5] 1.0e4 cBot - Seabed normal damping base (Pa-s/m) [default: 1.0e4] -0.05 dtM - CableDyn internal time step (s) [default: omitted standalone; 0.1 s target OpenFAST] +0.05 dtM - CableDyn internal time step (s) [default: omitted standalone; the glue DT in OpenFAST] 120.0 TMax - Standalone simulation duration (s) [default: omitted standalone; host-owned OpenFAST] 30.0 RangeStart - First output time in the range graphs (s) [default: 0] data/range_tdp/chain_surge_5m_30s_dt005.txt motionFile - Prescribed fairlead motion history diff --git a/examples/chain_torsethaugen_spread.dat b/examples/chain_torsethaugen_spread.dat index e876d2ec..a2a9fc86 100644 --- a/examples/chain_torsethaugen_spread.dat +++ b/examples/chain_torsethaugen_spread.dat @@ -30,7 +30,7 @@ LineID LineType Length NumSegs 50.0 WtrDpth - Water depth (m) [default: absent standalone; host-owned OpenFAST] 1.0e5 kBot - Seabed penalty stiffness base (Pa/m) [default: 1.0e5] 1.0e4 cBot - Seabed normal damping base (Pa-s/m) [default: 1.0e4] -0.1 dtM - CableDyn internal time step (s) [default: omitted standalone; 0.1 s target OpenFAST] +0.1 dtM - CableDyn internal time step (s) [default: omitted standalone; the glue DT in OpenFAST] 300.0 TMax - Standalone simulation duration (s) [default: omitted standalone; host-owned OpenFAST] torsethaugen 5.0 11.0 30.0 waves - Wave model, Hs, Tp, and mean direction (m, s, deg) {none; airy; jonswap} and pm, torsethaugen, ochihubble, stream [default: none] 4.0 WaveSpreading - cos-2s spreading exponent s of a spectral waves row {0=long-crested; 0=0} [defau False modified_newton - Tangent-reuse mode {False=full Newton; True=guarded reuse} [default: False] False adaptive_mesh - Automatic finite-EI refinement {False; True} [default: False] dynamic_solver 1.0e-8 1.0e-14 30 12 - Relative tolerance, absolute tolerance, max iterations, backtracks [defaults shown] -0.025 dtM - CableDyn internal time step (s); set equal to the example glue DT [default: 0.1 s target] +0.025 dtM - CableDyn internal time step (s); set equal to the example glue DT [default: the glue DT] none current - Current model and velocity (m/s) {none; uniform; profile} [default: SeaState host field] none waves - Wave model, height, period, and direction (m, s, deg) {none; airy; jonswap} [default: SeaState host field] 0 WaterKin - Water-kinematics source {0/none; file; SEASTATE coupled only} [default: no policy/full host field] diff --git a/examples/openfast/CableDyn_UMaine_line_failure.dat b/examples/openfast/CableDyn_UMaine_line_failure.dat index d196d3b9..dd4eec7d 100644 --- a/examples/openfast/CableDyn_UMaine_line_failure.dat +++ b/examples/openfast/CableDyn_UMaine_line_failure.dat @@ -46,7 +46,7 @@ none frictionMu - Seabed friction coefficient {none; value>=0} [defau False modified_newton - Tangent-reuse mode {False=full Newton; True=guarded reuse} [default: False] False adaptive_mesh - Automatic finite-EI refinement {False; True} [default: False] dynamic_solver 1.0e-8 1.0e-14 30 12 - Relative tolerance, absolute tolerance, max iterations, backtracks [defaults shown] -0.025 dtM - CableDyn internal time step (s); set equal to the example glue DT [default: 0.1 s target] +0.025 dtM - CableDyn internal time step (s); set equal to the example glue DT [default: the glue DT] none current - Current model and velocity (m/s) {none; uniform; profile} [default: SeaState host field] none waves - Wave model, height, period, and direction (m, s, deg) {none; airy; jonswap} [default: SeaState host field] 0 WaterKin - Water-kinematics source {0/none; file; SEASTATE coupled only} [default: no policy/full host field] diff --git a/examples/openfast/CableDyn_UMaine_rod.dat b/examples/openfast/CableDyn_UMaine_rod.dat index 7d03a95e..7c55433f 100644 --- a/examples/openfast/CableDyn_UMaine_rod.dat +++ b/examples/openfast/CableDyn_UMaine_rod.dat @@ -49,7 +49,7 @@ none frictionMu - Seabed friction coefficient {none; value>=0} [defau False modified_newton - Tangent-reuse mode {False=full Newton; True=guarded reuse} [default: False] False adaptive_mesh - Automatic finite-EI refinement {False; True} [default: False] dynamic_solver 1.0e-8 1.0e-14 30 12 - Relative tolerance, absolute tolerance, max iterations, backtracks [defaults shown] -0.025 dtM - CableDyn internal time step (s); set equal to the example glue DT [default: 0.1 s target] +0.025 dtM - CableDyn internal time step (s); set equal to the example glue DT [default: the glue DT] none current - Current model and velocity (m/s) {none; uniform; profile} [default: SeaState host field] none waves - Wave model, height, period, and direction (m, s, deg) {none; airy; jonswap} [default: SeaState host field] 0 WaterKin - Water-kinematics source {0/none; file; SEASTATE coupled only} [default: no policy/full host field] diff --git a/examples/openfast/README.md b/examples/openfast/README.md index b0bae7a4..61103ba3 100644 --- a/examples/openfast/README.md +++ b/examples/openfast/README.md @@ -70,7 +70,7 @@ Grid sizing is described in the manual's OpenFAST page (SeaState grid). .\openfast.exe IEA-15-UMaine_CompMooring3_MoorDyn.fst # MoorDyn ``` -The CableDyn run log identifies the module with `Running CableDyn (v0.1.1, 2026-10-09)` and +The CableDyn run log identifies the module with `Running CableDyn (v0.2.0, 2026-10-20)` and prints the converged fairlead state of each line, as the standalone driver does: ```text diff --git a/examples/rigid6_buoy.dat b/examples/rigid6_buoy.dat index 332e7d65..623c3e80 100644 --- a/examples/rigid6_buoy.dat +++ b/examples/rigid6_buoy.dat @@ -45,7 +45,7 @@ LineID LineType Length NumSegs 100.0 WtrDpth - Water depth (m) [default: absent standalone; host-owned OpenFAST] 1.0e5 kBot - Seabed penalty stiffness base (Pa/m) [default: 1.0e5] 1.0e4 cBot - Seabed normal damping base (Pa-s/m) [default: 1.0e4] -0.01 dtM - CableDyn internal time step (s) [default: omitted standalone; 0.1 s target OpenFAST] +0.01 dtM - CableDyn internal time step (s) [default: omitted standalone; the glue DT in OpenFAST] 60.0 TMax - Standalone simulation duration (s) [default: omitted standalone; host-owned OpenFAST] uniform 0.6 0.0 0.0 current - Current model and X/Y/Z velocity (m/s) {none; uniform; profile} [default: none] 0.4 rhoInf - Generalised-alpha spectral radius {0<=rhoInf<=1} [default: 0.4] diff --git a/examples/rod_moored_spar.dat b/examples/rod_moored_spar.dat index 7bd244f3..828a31b5 100644 --- a/examples/rod_moored_spar.dat +++ b/examples/rod_moored_spar.dat @@ -48,7 +48,7 @@ LineID LineType Length NumSegs 50.0 WtrDpth - Water depth (m) [default: absent standalone; host-owned OpenFAST] 1.0e5 kBot - Seabed penalty stiffness base (Pa/m) [default: 1.0e5] 1.0e4 cBot - Seabed normal damping base (Pa-s/m) [default: 1.0e4] -0.01 dtM - CableDyn internal time step (s) [default: omitted standalone; 0.1 s target OpenFAST] +0.01 dtM - CableDyn internal time step (s) [default: omitted standalone; the glue DT in OpenFAST] 30.0 TMax - Standalone simulation duration (s) [default: omitted standalone; host-owned OpenFAST] uniform 0.5 0.0 0.0 current - Current model and X/Y/Z velocity (m/s) {none; uniform; profile} [default: none] 0.4 rhoInf - Generalised-alpha spectral radius {0<=rhoInf<=1} [default: 0.4] diff --git a/examples/spar_pinned_rods.dat b/examples/spar_pinned_rods.dat index 8c65bdf5..a7376bbb 100644 --- a/examples/spar_pinned_rods.dat +++ b/examples/spar_pinned_rods.dat @@ -54,7 +54,7 @@ ID LineType AttachA AttachB UnstrLen NumSegs Outputs 150.0 WtrDpth - Water depth (m) [default: absent standalone; host-owned OpenFAST] 3.0e5 kBot - Seabed penalty stiffness base (Pa/m) [default: 1.0e5] 1.0e4 cBot - Seabed normal damping base (Pa-s/m) [default: 1.0e4] -0.02 dtM - CableDyn internal time step (s) [default: omitted standalone; 0.1 s target OpenFAST] +0.02 dtM - CableDyn internal time step (s) [default: omitted standalone; the glue DT in OpenFAST] 60.0 TMax - Standalone simulation duration (s) [default: omitted standalone; host-owned OpenFAST] airy 4.0 8.0 0.0 waves - Wave model, height, period, and direction (m, s, deg) {none; airy; jonswap} [default: none] 20.0 rampTime - Half-cosine start-up ramp of the waves (s) {>=0; 0=off} [default: 0] diff --git a/examples/stream_wave_shallow_chain.dat b/examples/stream_wave_shallow_chain.dat index 05b3134c..54d14636 100644 --- a/examples/stream_wave_shallow_chain.dat +++ b/examples/stream_wave_shallow_chain.dat @@ -28,7 +28,7 @@ LineID LineType Length NumSegs 30.0 WtrDpth - Water depth (m) [default: absent standalone; host-owned OpenFAST] 1.0e5 kBot - Seabed penalty stiffness base (Pa/m) [default: 1.0e5] 1.0e4 cBot - Seabed normal damping base (Pa-s/m) [default: 1.0e4] -0.05 dtM - CableDyn internal time step (s) [default: omitted standalone; 0.1 s target OpenFAST] +0.05 dtM - CableDyn internal time step (s) [default: omitted standalone; the glue DT in OpenFAST] 60.0 TMax - Standalone simulation duration (s) [default: omitted standalone; host-owned OpenFAST] stream 8.0 10.0 0.0 waves - Wave model, height, period, and direction (m, s, deg) {none; airy; jonswap} or stream (Dean stream function) [default: none] 20 StreamOrder - Fourier terms of the stream-function wave {0=default 20; 2 to 60} [default: 0] diff --git a/examples/syrope_polyester_mooring.dat b/examples/syrope_polyester_mooring.dat index 1b08e646..698ab545 100644 --- a/examples/syrope_polyester_mooring.dat +++ b/examples/syrope_polyester_mooring.dat @@ -38,7 +38,7 @@ LineID LineType Length NumSegs 1025.0 rhoW - Water density (kg/m^3) [default: 1025] 30.0 WtrDpth - Water depth (m) [default: absent standalone; host-owned OpenFAST] 1.0e5 kBot - Seabed penalty stiffness base (Pa/m) [default: 1.0e5] -0.01 dtM - CableDyn internal time step (s) [default: omitted standalone; 0.1 s target OpenFAST] +0.01 dtM - CableDyn internal time step (s) [default: omitted standalone; the glue DT in OpenFAST] 2.0 TMax - Standalone simulation duration (s) [default: omitted standalone; host-owned OpenFAST] 0.4 rhoInf - Generalised-alpha spectral radius {0<=rhoInf<=1} [default: 0.4] 1.0e4 cBot - Seabed normal damping base (Pa-s/m) [default: 1.0e4] diff --git a/examples/torsion_lazy_wave_hangoff_twist.dat b/examples/torsion_lazy_wave_hangoff_twist.dat index e20300bf..b2046ccf 100644 --- a/examples/torsion_lazy_wave_hangoff_twist.dat +++ b/examples/torsion_lazy_wave_hangoff_twist.dat @@ -43,7 +43,7 @@ LineID End Stiffness EzX EzY EzZ TorsStiffness NxX NxY NxZ Pr 1.0e4 cBot - Seabed normal damping base (Pa-s/m) [default: 1.0e4] 0.4 rhoInf - Generalised-alpha spectral radius {0<=rhoInf<=1} [default: 0.4] False modified_newton - Tangent-reuse mode {False=full Newton; True=guarded reuse} [default: False] -0.1 dtM - CableDyn internal time step (s) [default: omitted standalone; 0.1 s target OpenFAST] +0.1 dtM - CableDyn internal time step (s) [default: omitted standalone; the glue DT in OpenFAST] 90.0 TMax - Standalone simulation duration (s): 60 s twist ramp, 30 s hold data/torsion/hangoff_roll_2turns_60s_dt01.txt motionFile - Held hang-off with the roll history (12th column, deg) False adaptive_mesh - Automatic finite-EI refinement {False; True} [default: False] diff --git a/examples/ve_polyester_dynamic_waves.dat b/examples/ve_polyester_dynamic_waves.dat index 92ca2bb9..79560dc7 100644 --- a/examples/ve_polyester_dynamic_waves.dat +++ b/examples/ve_polyester_dynamic_waves.dat @@ -28,7 +28,7 @@ LineID LineType Length NumSegs 1025.0 rhoW - Water density (kg/m^3) [default: 1025] 200.0 WtrDpth - Water depth (m) [default: absent standalone; host-owned OpenFAST] 3.0e6 kBot - Seabed penalty stiffness base (Pa/m) [default: 1.0e5] -0.05 dtM - CableDyn internal time step (s) [default: omitted standalone; 0.1 s target OpenFAST] +0.05 dtM - CableDyn internal time step (s) [default: omitted standalone; the glue DT in OpenFAST] 10.0 TMax - Standalone simulation duration (s) [default: omitted standalone; host-owned OpenFAST] 0.4 rhoInf - Generalised-alpha spectral radius {0<=rhoInf<=1} [default: 0.4] airy 1.5 10.0 0.0 waves - Wave model, height, period, and direction (m, s, deg) {none; airy; jonswap} [default: none] diff --git a/integration/openfast/README.md b/integration/openfast/README.md index 4e4ec18d..018f210d 100644 --- a/integration/openfast/README.md +++ b/integration/openfast/README.md @@ -9,7 +9,7 @@ who only run coupled cases should use the released `openfast.exe` and the The patches in [`patches/`](patches/) apply to the public OpenFAST upstream commit `2895884d2be01862173c88d70f86b358d2f1a50a` (the OpenFAST v5.0.0 release, used by -CableDyn v0.1.1). They add only the OpenFAST host integration; the CableDyn sources come from +CableDyn v0.2.0). They add only the OpenFAST host integration; the CableDyn sources come from this repository. | File | Purpose | diff --git a/python/README.md b/python/README.md index 739ed6b5..e28f1776 100644 --- a/python/README.md +++ b/python/README.md @@ -15,8 +15,8 @@ The wheel and source distribution are attached to each package is not on PyPI or conda-forge. It requires Python 3.10 or newer and NumPy. ```powershell -py -m pip install .\cabledyn-0.1.1-py3-none-any.whl -py -m pip install ".\cabledyn-0.1.1-py3-none-any.whl[post]" # adds pandas and matplotlib +py -m pip install .\cabledyn-0.2.0-py3-none-any.whl +py -m pip install ".\cabledyn-0.2.0-py3-none-any.whl[post]" # adds pandas and matplotlib ``` The package does not contain the solver. `CableDynDriver` runs diff --git a/python/cabledyn/__init__.py b/python/cabledyn/__init__.py index 1be4b311..fbbc8b60 100644 --- a/python/cabledyn/__init__.py +++ b/python/cabledyn/__init__.py @@ -282,7 +282,7 @@ "upcrossing_maxima", ] -__version__ = "0.1.1" +__version__ = "0.2.0" def __getattr__(name: str) -> Any: diff --git a/python/pyproject.toml b/python/pyproject.toml index b4fbc1d9..ffdfe1f0 100644 --- a/python/pyproject.toml +++ b/python/pyproject.toml @@ -7,7 +7,7 @@ build-backend = "setuptools.build_meta" [project] name = "cabledyn" -version = "0.1.1" +version = "0.2.0" description = "Python APIs for the CableDyn standalone driver and native coupling library" readme = "README.md" requires-python = ">=3.10" diff --git a/release/check_release_metadata.py b/release/check_release_metadata.py index 919255ce..f6b5a95a 100644 --- a/release/check_release_metadata.py +++ b/release/check_release_metadata.py @@ -26,8 +26,8 @@ def capture(relative_path: str, pattern: str, label: str) -> str: return match.group(1) -# Spellings that name a CableDyn release: "CableDyn 0.1.1", "CableDyn v0.1.1", "v0.1.1", -# "cabledyn-0.1.1-py3-none-any.whl", ".../releases/tag/v0.1.1" and "libcabledyn.so.0.1.1". +# Spellings that name a CableDyn release: "CableDyn 0.2.0", "CableDyn v0.2.0", "v0.2.0", +# "cabledyn-0.2.0-py3-none-any.whl", ".../releases/tag/v0.2.0" and "libcabledyn.so.0.2.0". VERSION_REFERENCE = re.compile( r"(?i)(?:cabledyn[ _-]+v?|cabledyn-|releases/tag/v|libcabledyn\.(?:so\.)?|(? Minor extension level of ABI 1: 1 adds the in-process object queries, 2 the host-coupling !> calls (initialization at host positions, state save/restore, the coupled layout query). INTEGER(C_INT), PARAMETER :: CD_C_ABI_MINOR = 2_C_INT diff --git a/src/CableDyn_CAPI.h b/src/CableDyn_CAPI.h index 8c5de611..2a15ea53 100644 --- a/src/CableDyn_CAPI.h +++ b/src/CableDyn_CAPI.h @@ -44,8 +44,8 @@ #define CD_C_NOT_INITIALIZED 5 #define CABLEDYN_CAPI_VERSION_MAJOR 0 -#define CABLEDYN_CAPI_VERSION_MINOR 1 -#define CABLEDYN_CAPI_VERSION_PATCH 1 +#define CABLEDYN_CAPI_VERSION_MINOR 2 +#define CABLEDYN_CAPI_VERSION_PATCH 0 #define CABLEDYN_CAPI_ABI_VERSION 1 #ifdef __cplusplus diff --git a/src/CableDyn_HermiteCableDynamic.f90 b/src/CableDyn_HermiteCableDynamic.f90 index 246dca11..fd7c555b 100644 --- a/src/CableDyn_HermiteCableDynamic.f90 +++ b/src/CableDyn_HermiteCableDynamic.f90 @@ -1595,6 +1595,12 @@ ELEMENTAL LOGICAL FUNCTION bits_equal(a, b) RESULT(same) same = TRANSFER(a, 0_INT64) == TRANSFER(b, 0_INT64) END FUNCTION bits_equal + ELEMENTAL LOGICAL FUNCTION reals_equal(a, b) RESULT(same) + !! a == b, written so that gfortran does not warn: a NaN never matches, +0 matches -0. + REAL(wp), INTENT(IN) :: a, b + same = a <= b .AND. a >= b + END FUNCTION reals_equal + ELEMENTAL REAL(wp) FUNCTION positive_zero(x) RESULT(y) !! x with a negative zero replaced by +0, on the bits (so no floating-point mode can keep !! the sign); every other value is returned unchanged. @@ -5310,7 +5316,7 @@ SUBROUTINE CD_HermiteCable_Dyn_Node_Values(model, node, tension, curvature, bend END IF ! the cached residuals belong to the time and load configuration they were computed at, and ! each to its element's state (exact comparisons; a NaN never matches and is recomputed) - IF (.NOT. (model%rc_key_ok .AND. model%rc_key_epoch == model%rc_epoch .AND. model%rc_t == model%t)) THEN + IF (.NOT. (model%rc_key_ok .AND. model%rc_key_epoch == model%rc_epoch .AND. reals_equal(model%rc_t, model%t))) THEN model%rc_t = model%t; model%rc_key_epoch = model%rc_epoch model%rc_key_ok = .TRUE. model%rc_have = .FALSE. @@ -5338,8 +5344,9 @@ SUBROUTINE cached_end_residual(e, ge) ! the element's residual depends on its own two nodes' q, v and a only (element_end_residual) i0 = 6*(e - 1) IF (model%rc_have(e)) THEN - IF (ALL(model%rc_q(:, e) == model%q(i0 + 1:i0 + 12)) .AND. ALL(model%rc_v(:, e) == model%v(i0 + 1:i0 + 12)) & - .AND. ALL(model%rc_a(:, e) == model%a(i0 + 1:i0 + 12))) THEN + IF (ALL(reals_equal(model%rc_q(:, e), model%q(i0 + 1:i0 + 12))) .AND. & + ALL(reals_equal(model%rc_v(:, e), model%v(i0 + 1:i0 + 12))) .AND. & + ALL(reals_equal(model%rc_a(:, e), model%a(i0 + 1:i0 + 12)))) THEN ge = model%rc_g(:, e); RETURN END IF END IF diff --git a/src/CableDyn_HermiteCableStatic.f90 b/src/CableDyn_HermiteCableStatic.f90 index 22b34085..687b3541 100644 --- a/src/CableDyn_HermiteCableStatic.f90 +++ b/src/CableDyn_HermiteCableStatic.f90 @@ -2557,7 +2557,7 @@ SUBROUTINE add_end_support(iend, e, inode, sgn, sp_stat, sp_msg) IF (.NOT. (elem > CD_ZERO)) RETURN R(base + 1:base + 3) = R(base + 1:base + 3) + (mom*elem)*end_support(:, iend) ! d(gap)/d(r_inner) = -n_in (floor gradient held over the node) - IF (delem /= CD_ZERO) THEN + IF (.NOT. (delem <= CD_ZERO .AND. delem >= CD_ZERO)) THEN DO j = 1, 3 DO i = 1, 3 ab(KL_H + KU_H + 1 + base + i - bin - j, bin + j) = ab(KL_H + KU_H + 1 + base + i - bin - j, bin + j) - & diff --git a/src/CableDyn_Model.f90 b/src/CableDyn_Model.f90 index 10554bec..c89dde2d 100644 --- a/src/CableDyn_Model.f90 +++ b/src/CableDyn_Model.f90 @@ -5348,7 +5348,8 @@ SUBROUTINE CD_Update_Model_External_Loads(model, f_ext, ErrStat, ErrMsg) ! (enter_committed_lengths); a failed recompute restores f_ext, the remainder and a. BLOCK REAL(wp) :: f_dist(SIZE(model%f_ext)) - REAL(wp), ALLOCATABLE :: base_entry(:) + ! the remainder on entry (f_ext_dist_base has the size of f_ext wherever dist_load exists) + REAL(wp) :: base_entry(SIZE(model%f_ext)) INTEGER :: es2 CHARACTER(1024) :: em2 IF (ALLOCATED(model%dist_load)) THEN @@ -5367,7 +5368,7 @@ SUBROUTINE CD_Update_Model_External_Loads(model, f_ext, ErrStat, ErrMsg) IF (ErrStat /= CD_MODEL_OK) THEN model%f_ext = model%f_ext_rollback model%a = model%a_rollback - IF (ALLOCATED(base_entry)) model%f_ext_dist_base = base_entry + IF (ALLOCATED(model%dist_load)) model%f_ext_dist_base = base_entry RETURN END IF END BLOCK diff --git a/src/openfast/CableDyn_OF.f90 b/src/openfast/CableDyn_OF.f90 index 8cab4b7d..694d40c9 100644 --- a/src/openfast/CableDyn_OF.f90 +++ b/src/openfast/CableDyn_OF.f90 @@ -117,7 +117,7 @@ MODULE CableDyn PRIVATE - TYPE(ProgDesc), PARAMETER :: CableDyn_ProgDesc = ProgDesc( 'CableDyn', 'v0.1.1', '2026-10-09' ) + TYPE(ProgDesc), PARAMETER :: CableDyn_ProgDesc = ProgDesc( 'CableDyn', 'v0.2.0', '2026-10-20' ) !> Module-level instance registry: the CableDyn solver objects cannot live inside the !> registry-generated types, so each initialized module holds an integer handle @@ -132,8 +132,8 @@ MODULE CableDyn ! CableDyn's OWN time step (supercycling): the implicit mooring solve advances at ! dt_moor = nsuper * (glue DT), ONE step per nsuper glue steps, instead of being ! chained to the turbine's small DT. The deck's OPTIONS dtM sets it (clamped to at - ! least the glue DT); absent a deck dtM the default target is 0.1 s. Between mooring - ! solves CD_CalcOutput returns the last + ! least the glue DT); absent a deck dtM the mooring solves every glue step. Between + ! mooring solves CD_CalcOutput returns the last ! committed load state as a zero-order hold; feeding instantaneous endpoints into a ! lagged mooring interior creates artificial stiff-EA load chatter. INTEGER(IntKi) :: nsuper = 1 ! glue steps per mooring step @@ -484,7 +484,6 @@ SUBROUTINE CD_Init(InitInp, u, p, x, xd, z, other, y, m, DTcoupling, InitOut, Er CHARACTER(ChanLen) :: chan_hdr, chan_unt CHARACTER(1024) :: native_root, init_note INTEGER(IntKi) :: note_at, note_end - REAL(wp), PARAMETER :: DTM_DEFAULT = 0.1_wp ErrStat = ErrID_None ErrMsg = '' @@ -582,13 +581,14 @@ SUBROUTINE CD_Init(InitInp, u, p, x, xd, z, other, y, m, DTcoupling, InitOut, Er ! ------------------------------------------------------------------------------ ! CableDyn's OWN time step. The implicit generalised-alpha solve can remain stable at a - ! large mooring step, but stability does not establish time-domain or fatigue accuracy. - ! The practical default targets 0.1 s, advancing at - ! dt_moor = nsuper * DT (one implicit step per nsuper glue steps): the deck's OPTIONS - ! dtM is the author's intent (rounded to the nearest integer multiple of the glue DT - ! and clamped to at least one glue step -- a MoorDyn-migrated deck's explicit-RK4 - ! dtM like 0.001 s does not transfer to an implicit solver); absent a deck dtM, the - ! target is DTM_DEFAULT. The CableDyn-owned .CD.out records only committed dtM rows; + ! large mooring step, but stability does not establish time-domain or fatigue accuracy, + ! and the loads held between solves reach the platform about dtM/2 late (a negative + ! damping of about the mooring stiffness times dtM/2). The default therefore solves + ! every glue step; a deck may advance at dt_moor = nsuper * DT (one implicit step per + ! nsuper glue steps): the deck's OPTIONS dtM is the author's intent (rounded down to an + ! integer multiple of the glue DT and clamped to at least one glue step -- a + ! MoorDyn-migrated deck's explicit-RK4 dtM like 0.001 s does not transfer to an + ! implicit solver). The CableDyn-owned .CD.out records only committed dtM rows; ! OpenFAST's assembled output still receives zero-order-held module channels at DT_Out. ! Between coarse mooring steps, CD_CalcOutput returns the last committed mooring load ! state as a zero-order hold; injecting instantaneous @@ -624,15 +624,17 @@ SUBROUTINE CD_Init(InitInp, u, p, x, xd, z, other, y, m, DTcoupling, InitOut, Er ' x glue DT = '//TRIM(Num2LStr(dtC))//' s).' ) END IF ELSE - nsuper = MAX(1_IntKi, NINT(DTM_DEFAULT/dtC, IntKi)) + nsuper = 1_IntKi END IF dt_moor = REAL(nsuper, wp)*dtC CALL WrScr( ' CableDyn time step dtM = '//TRIM(Num2LStr(dt_moor))//' s ('//TRIM(Num2LStr(nsuper))// & ' x glue DT'//TRIM(MERGE('; deck dtM ', '; the default', has_dtm))//')' ) IF (nsuper > 1_IntKi) THEN - CALL WrScr( ' CableDyn: coupled loads use a zero-order hold between dtM solves; the separate .CD.out '// & - 'records committed CableDyn samples only. Verify dtM convergence for fatigue, snap, contact, '// & - 'or local cable-response calculations; set deck dtM = DT for glue-rate solves.' ) + CALL WrScr( ' CableDyn: coupled loads are held between dtM solves and reach the platform about dtM/2 '// & + 'late, which matters for stiff (taut or tension-leg) moorings and for tension statistics; '// & + 'the separate .CD.out records committed CableDyn samples only. Verify dtM convergence for '// & + 'fatigue, snap, contact, or local cable-response calculations; omit dtM or set it to DT for '// & + 'glue-rate solves.' ) END IF ! The run must END on a mooring boundary: with supercycling, a trailing partial ! interval would take only skipped glue steps, leaving the committed mooring state -- diff --git a/tests/data/buoy_clamped_cable_pinned_rod.dat b/tests/data/buoy_clamped_cable_pinned_rod.dat index 20976ff4..c81851ef 100644 --- a/tests/data/buoy_clamped_cable_pinned_rod.dat +++ b/tests/data/buoy_clamped_cable_pinned_rod.dat @@ -56,7 +56,7 @@ LineID End Stiffness EzX EzY EzZ 100.0 WtrDpth - Water depth (m) [default: absent standalone; host-owned OpenFAST] 1.0e5 kBot - Seabed penalty stiffness base (Pa/m) [default: 1.0e5] 1.0e4 cBot - Seabed normal damping base (Pa-s/m) [default: 1.0e4] -0.05 dtM - CableDyn internal time step (s) [default: omitted standalone; 0.1 s target OpenFAST] +0.05 dtM - CableDyn internal time step (s) [default: omitted standalone; the glue DT in OpenFAST] 6.0 TMax - Standalone simulation duration (s) [default: omitted standalone; host-owned OpenFAST] static bodyIC - Free Rigid6 body / rod start {static=equilibrium; deck=deck pose} [default: static] monolithic bodyScheme - Body time integration {monolithic; staggered}; a clamped End A needs monolithic [default: monolithic] diff --git a/tests/data/cable_statics_matrix.json b/tests/data/cable_statics_matrix.json index f96d6514..9e5e0d41 100644 --- a/tests/data/cable_statics_matrix.json +++ b/tests/data/cable_statics_matrix.json @@ -1454,7 +1454,7 @@ { "id": "FINE_A01557", "expect": "fine_mesh", - "deck": "--------------------- CableDyn Input File ------------------------------------\nCableDyn: IEA-15MW UMaine VolturnUS-S -- MIXED deck (3 mooring chains + 1 touchdown power cable)\nThis aggregate deck works as an OpenFAST MooringFile and as a CableDyn_driver static-initialization example.\nDemonstrates CompMooring=5 carrying an EI=0 catenary mooring AND a finite-EI Hermite lazy-wave\ncable behind one deck. Line 4 terminates on the 200 m seabed and exercises coupled finite-EI\nnormal contact, contact damping, and friction through the OpenFAST aggregate.\n--------------------------- LINE TYPES ----------------------------------------\nName Diam Mass EA BA EI Cdn Cdt Can Cat\n(-) (m) (kg/m) (N) (-) (Nm2) (-) (-) (-) (-)\nmain 0.333 685.00 3.27e9 -1.0 0.0 2.0 0.4 0.82 0.27\nbare 0.16 36.70 4.69e8 0.0 1.99e4 1.2 0.1 1.0 0.0\nbuoy 0.29 59.53 4.69e8 0.0 1.99e4 1.2 0.1 1.0 0.0\n--------------------------- POINTS --------------------------------------------\nID Type X Y Z\n(-) (-) (m) (m) (m)\n1 Coupled -58.000 0.000 -14.000\n2 Fixed -837.600 0.000 -200.000\n3 Coupled 29.000 50.229 -14.000\n4 Fixed 418.800 725.383 -200.000\n5 Coupled 29.000 -50.229 -14.000\n6 Fixed 418.800 -725.383 -200.000\n7 Coupled 30.000 0.000 -20.000\n8 Fixed 500.000 0.000 -200.000\n--------------------------- LINES ---------------------------------------------\nID NodeA NodeB Outputs\n(-) (-) (-) (-)\n1 1 2 -\n2 3 4 -\n3 5 6 -\n4 7 8 -\n--------------------------- SECTIONS ------------------------------------------\nLineID LineType Length NumSegs\n(-) (-) (m) (-)\n1 main 850.0 50\n2 main 850.0 50\n3 main 850.0 50\n4 bare 80.0 20\n4 buoy 100.0 25\n4 bare 420.0 100000\n--------------------------- OPTIONS -------------------------------------------\n9.80665 g - Gravitational acceleration (m/s^2); overridden by OpenFAST [default: 9.80665]\n1025.0 rhoW - Water density (kg/m^3); overridden by OpenFAST [default: 1025]\n0.4 rhoInf - Generalized-alpha spectral radius {0<=rhoInf<=1} [default: 0.4]\nFalse modified_newton - Tangent-reuse mode {False=full Newton; True=modified Newton with guarded refresh} [default: False]\n3.0e6 kBot - Seabed penalty stiffness base (Pa/m) [default: 1.0e5]\n3.0e5 cBot - Seabed normal damping base (Pa-s/m) [default: 1.0e4]\n0.35 frictionMu - Coulomb seabed-friction coefficient [default: none]\n200.0 WtrDpth - Water depth; flat seabed elevation is z=-WtrDpth (m) [default: absent standalone; host-owned OpenFAST]\n0.025 dtM - CableDyn internal time step (s) [default: omitted standalone; 0.1 s target OpenFAST]\n0.0 TMax - Standalone simulation duration (s); 0 writes the initialized mixed statics [default: host-owned OpenFAST]\nFalse adaptive_mesh - Automatic finite-EI refinement {False; True} [default: False]\ndynamic_solver 1.0e-8 1.0e-14 30 12 - Relative tolerance, absolute tolerance, max iterations, backtracks [defaults shown]\nnone current - Current model and velocity (m/s) {none; uniform; profile} [default: none]\nnone waves - Wave model, height, period, and direction (m, s, deg) {none; airy; jonswap} [default: none]\n0 WaterKin - Water-kinematics source {0/none; file; SEASTATE coupled only} [default: no policy]\n-- Complete option/default reference: cabledyn_options_reference.dat and doc/options.rst.\n--------------------------- OUTPUTS -------------------------------------------\n\"FairTen1\"\n\"AnchTen1\"\n\"FairIncl1\"\n\"AnchIncl1\"\n\"FairTen2\"\n\"AnchTen2\"\n\"FairIncl2\"\n\"AnchIncl2\"\n\"FairTen3\"\n\"AnchTen3\"\n\"FairIncl3\"\n\"AnchIncl3\"\n\"FairTen4\"\n\"AnchTen4\"\n\"FairIncl4\"\n\"AnchIncl4\"\n\"Curv4N20\"\n\"BendMom4N20\"\nEND\n--------------------------- need this line ------------------------------------\n", + "deck": "--------------------- CableDyn Input File ------------------------------------\nCableDyn: IEA-15MW UMaine VolturnUS-S -- MIXED deck (3 mooring chains + 1 touchdown power cable)\nThis aggregate deck works as an OpenFAST MooringFile and as a CableDyn_driver static-initialization example.\nDemonstrates CompMooring=5 carrying an EI=0 catenary mooring AND a finite-EI Hermite lazy-wave\ncable behind one deck. Line 4 terminates on the 200 m seabed and exercises coupled finite-EI\nnormal contact, contact damping, and friction through the OpenFAST aggregate.\n--------------------------- LINE TYPES ----------------------------------------\nName Diam Mass EA BA EI Cdn Cdt Can Cat\n(-) (m) (kg/m) (N) (-) (Nm2) (-) (-) (-) (-)\nmain 0.333 685.00 3.27e9 -1.0 0.0 2.0 0.4 0.82 0.27\nbare 0.16 36.70 4.69e8 0.0 1.99e4 1.2 0.1 1.0 0.0\nbuoy 0.29 59.53 4.69e8 0.0 1.99e4 1.2 0.1 1.0 0.0\n--------------------------- POINTS --------------------------------------------\nID Type X Y Z\n(-) (-) (m) (m) (m)\n1 Coupled -58.000 0.000 -14.000\n2 Fixed -837.600 0.000 -200.000\n3 Coupled 29.000 50.229 -14.000\n4 Fixed 418.800 725.383 -200.000\n5 Coupled 29.000 -50.229 -14.000\n6 Fixed 418.800 -725.383 -200.000\n7 Coupled 30.000 0.000 -20.000\n8 Fixed 500.000 0.000 -200.000\n--------------------------- LINES ---------------------------------------------\nID NodeA NodeB Outputs\n(-) (-) (-) (-)\n1 1 2 -\n2 3 4 -\n3 5 6 -\n4 7 8 -\n--------------------------- SECTIONS ------------------------------------------\nLineID LineType Length NumSegs\n(-) (-) (m) (-)\n1 main 850.0 50\n2 main 850.0 50\n3 main 850.0 50\n4 bare 80.0 20\n4 buoy 100.0 25\n4 bare 420.0 100000\n--------------------------- OPTIONS -------------------------------------------\n9.80665 g - Gravitational acceleration (m/s^2); overridden by OpenFAST [default: 9.80665]\n1025.0 rhoW - Water density (kg/m^3); overridden by OpenFAST [default: 1025]\n0.4 rhoInf - Generalized-alpha spectral radius {0<=rhoInf<=1} [default: 0.4]\nFalse modified_newton - Tangent-reuse mode {False=full Newton; True=modified Newton with guarded refresh} [default: False]\n3.0e6 kBot - Seabed penalty stiffness base (Pa/m) [default: 1.0e5]\n3.0e5 cBot - Seabed normal damping base (Pa-s/m) [default: 1.0e4]\n0.35 frictionMu - Coulomb seabed-friction coefficient [default: none]\n200.0 WtrDpth - Water depth; flat seabed elevation is z=-WtrDpth (m) [default: absent standalone; host-owned OpenFAST]\n0.025 dtM - CableDyn internal time step (s) [default: omitted standalone; the glue DT in OpenFAST]\n0.0 TMax - Standalone simulation duration (s); 0 writes the initialized mixed statics [default: host-owned OpenFAST]\nFalse adaptive_mesh - Automatic finite-EI refinement {False; True} [default: False]\ndynamic_solver 1.0e-8 1.0e-14 30 12 - Relative tolerance, absolute tolerance, max iterations, backtracks [defaults shown]\nnone current - Current model and velocity (m/s) {none; uniform; profile} [default: none]\nnone waves - Wave model, height, period, and direction (m, s, deg) {none; airy; jonswap} [default: none]\n0 WaterKin - Water-kinematics source {0/none; file; SEASTATE coupled only} [default: no policy]\n-- Complete option/default reference: cabledyn_options_reference.dat and doc/options.rst.\n--------------------------- OUTPUTS -------------------------------------------\n\"FairTen1\"\n\"AnchTen1\"\n\"FairIncl1\"\n\"AnchIncl1\"\n\"FairTen2\"\n\"AnchTen2\"\n\"FairIncl2\"\n\"AnchIncl2\"\n\"FairTen3\"\n\"AnchTen3\"\n\"FairIncl3\"\n\"AnchIncl3\"\n\"FairTen4\"\n\"AnchTen4\"\n\"FairIncl4\"\n\"AnchIncl4\"\n\"Curv4N20\"\n\"BendMom4N20\"\nEND\n--------------------------- need this line ------------------------------------\n", "lines": { "1": { "oracle_tfair": [], diff --git a/tests/data/held_start_gomex80_power_cable.dat b/tests/data/held_start_gomex80_power_cable.dat index 41f13f52..ed822118 100644 --- a/tests/data/held_start_gomex80_power_cable.dat +++ b/tests/data/held_start_gomex80_power_cable.dat @@ -30,7 +30,7 @@ LineID LineType Length NumSegs 1.0e4 cBot - Seabed normal damping base (Pa-s/m) [default: 1.0e4] 0.4 rhoInf - Generalized-alpha spectral radius {0<=rhoInf<=1} [default: 0.4] False modified_newton - Tangent-reuse mode {False=full Newton; True=guarded reuse} [default: False] -0.05 dtM - CableDyn internal time step (s) [default: omitted standalone; 0.1 s target OpenFAST] +0.05 dtM - CableDyn internal time step (s) [default: omitted standalone; the glue DT in OpenFAST] 0.2 TMax - Standalone simulation duration (s); 0 selects static initialization only False adaptive_mesh - Automatic finite-EI refinement {False; True} [default: False] True tensile_safety - Refine and reject local axial compression in this tensile cable diff --git a/tests/data/held_start_humboldt800_power_cable.dat b/tests/data/held_start_humboldt800_power_cable.dat index 98747ea2..409f5e8f 100644 --- a/tests/data/held_start_humboldt800_power_cable.dat +++ b/tests/data/held_start_humboldt800_power_cable.dat @@ -30,7 +30,7 @@ LineID LineType Length NumSegs 1.0e4 cBot - Seabed normal damping base (Pa-s/m) [default: 1.0e4] 0.4 rhoInf - Generalized-alpha spectral radius {0<=rhoInf<=1} [default: 0.4] False modified_newton - Tangent-reuse mode {False=full Newton; True=guarded reuse} [default: False] -0.05 dtM - CableDyn internal time step (s) [default: omitted standalone; 0.1 s target OpenFAST] +0.05 dtM - CableDyn internal time step (s) [default: omitted standalone; the glue DT in OpenFAST] 0.2 TMax - Standalone simulation duration (s); 0 selects static initialization only False adaptive_mesh - Automatic finite-EI refinement {False; True} [default: False] True tensile_safety - Refine and reject local axial compression in this tensile cable diff --git a/tests/data/mixed_nmodes.dat b/tests/data/mixed_nmodes.dat index 7284b9f1..2123a9bb 100644 --- a/tests/data/mixed_nmodes.dat +++ b/tests/data/mixed_nmodes.dat @@ -46,7 +46,7 @@ False modified_newton - Tangent-reuse mode {False=full Newton; True=modified 3.0e5 cBot - Seabed normal damping base (Pa-s/m) [default: 1.0e4] 0.35 frictionMu - Coulomb seabed-friction coefficient [default: none] 200.0 WtrDpth - Water depth; flat seabed elevation is z=-WtrDpth (m) [default: absent standalone; host-owned OpenFAST] -0.025 dtM - CableDyn internal time step (s) [default: omitted standalone; 0.1 s target OpenFAST] +0.025 dtM - CableDyn internal time step (s) [default: omitted standalone; the glue DT in OpenFAST] 0.0 TMax - Standalone simulation duration (s); 0 writes the initialized mixed statics [default: host-owned OpenFAST] 2 nModes - modal analysis (not supported on the mixed standalone route) False adaptive_mesh - Automatic finite-EI refinement {False; True} [default: False] diff --git a/tests/data/range_mixed_alloc.dat b/tests/data/range_mixed_alloc.dat index 5e7b6ab8..3dbd59d8 100644 --- a/tests/data/range_mixed_alloc.dat +++ b/tests/data/range_mixed_alloc.dat @@ -46,7 +46,7 @@ False modified_newton - Tangent-reuse mode {False=full Newton; True=modified 3.0e5 cBot - Seabed normal damping base (Pa-s/m) [default: 1.0e4] 0.35 frictionMu - Coulomb seabed-friction coefficient [default: none] 200.0 WtrDpth - Water depth; flat seabed elevation is z=-WtrDpth (m) -0.025 dtM - CableDyn internal time step (s) [default: omitted standalone; 0.1 s target OpenFAST] +0.025 dtM - CableDyn internal time step (s) [default: omitted standalone; the glue DT in OpenFAST] 0.0 TMax - Standalone simulation duration (s); 0 writes the initialized mixed statics False adaptive_mesh - Automatic finite-EI refinement {False; True} [default: False] dynamic_solver 1.0e-8 1.0e-14 30 12 - Relative/absolute tolerance, max iterations, backtracks [defaults] diff --git a/tests/data/stack_humboldt800_2048_elements.dat b/tests/data/stack_humboldt800_2048_elements.dat index cf343cfe..70810c46 100644 --- a/tests/data/stack_humboldt800_2048_elements.dat +++ b/tests/data/stack_humboldt800_2048_elements.dat @@ -30,7 +30,7 @@ LineID LineType Length NumSegs 1.0e4 cBot - Seabed normal damping base (Pa-s/m) [default: 1.0e4] 0.4 rhoInf - Generalised-alpha spectral radius {0<=rhoInf<=1} [default: 0.4] False modified_newton - Tangent-reuse mode {False=full Newton; True=guarded reuse} [default: False] -0.05 dtM - CableDyn internal time step (s) [default: omitted standalone; 0.1 s target OpenFAST] +0.05 dtM - CableDyn internal time step (s) [default: omitted standalone; the glue DT in OpenFAST] 0.2 TMax - Standalone simulation duration (s); 0 selects static initialisation only False adaptive_mesh - Automatic finite-EI refinement {False; True} [default: False] True tensile_safety - Refine and reject local axial compression in this tensile cable diff --git a/tests/data/ve_polyester_waves_fine_mesh.dat b/tests/data/ve_polyester_waves_fine_mesh.dat index 8dd6d1c5..c4351c22 100644 --- a/tests/data/ve_polyester_waves_fine_mesh.dat +++ b/tests/data/ve_polyester_waves_fine_mesh.dat @@ -24,7 +24,7 @@ LineID LineType Length NumSegs 1025.0 rhoW - Water density (kg/m^3) [default: 1025] 200.0 WtrDpth - Water depth (m) [default: absent standalone; host-owned OpenFAST] 3.0e6 kBot - Seabed penalty stiffness base (Pa/m) [default: 1.0e5] -0.05 dtM - CableDyn internal time step (s) [default: omitted standalone; 0.1 s target OpenFAST] +0.05 dtM - CableDyn internal time step (s) [default: omitted standalone; the glue DT in OpenFAST] 10.0 TMax - Standalone simulation duration (s) [default: omitted standalone; host-owned OpenFAST] 0.4 rhoInf - Generalized-alpha spectral radius {0<=rhoInf<=1} [default: 0.4] airy 1.5 10.0 0.0 waves - Wave model, height, period, and direction (m, s, deg) {none; airy; jonswap} [default: none] diff --git a/tests/test_c_api.f90 b/tests/test_c_api.f90 index 92e78e42..c189dda6 100644 --- a/tests/test_c_api.f90 +++ b/tests/test_c_api.f90 @@ -57,7 +57,7 @@ SUBROUTINE case_version() abi_version = -1_C_INT msg = 'x' CALL CableDyn_GetVersion(major, minor, patch, abi_version) - CALL require(major == 0_C_INT .AND. minor == 1_C_INT .AND. patch == 1_C_INT .AND. abi_version == 1_C_INT, & + CALL require(major == 0_C_INT .AND. minor == 2_C_INT .AND. patch == 0_C_INT .AND. abi_version == 1_C_INT, & 'c-api-version:tuple') CALL CableDyn_GetVersionString(C_LOC(msg), INT(SIZE(msg), C_INT)) CALL require(INDEX(c_text(msg), 'CableDyn') == 1 .AND. INDEX(c_text(msg), 'C-ABI 1') > 0, & diff --git a/tests/test_lozon_example_equilibrium.py b/tests/test_lozon_example_equilibrium.py index 2e2dd12e..98faa8c7 100644 --- a/tests/test_lozon_example_equilibrium.py +++ b/tests/test_lozon_example_equilibrium.py @@ -327,7 +327,7 @@ def main() -> int: static_mixed_text = mixed_text for option_row in ( "0.025 dtM - CableDyn internal time step (s) " - "[default: omitted standalone; 0.1 s target OpenFAST]\n", + "[default: omitted standalone; the glue DT in OpenFAST]\n", "0.0 TMax - Standalone simulation duration (s); 0 writes the initialized mixed statics " "[default: host-owned OpenFAST]\n", "0.35 frictionMu - Coulomb seabed-friction coefficient [default: none]\n", diff --git a/validation/experiments/bergdahl/README.md b/validation/experiments/bergdahl/README.md index 29b3335f..b6686d67 100644 --- a/validation/experiments/bergdahl/README.md +++ b/validation/experiments/bergdahl/README.md @@ -74,9 +74,8 @@ at the upper line end. Across the 30 conditions, the cycle maxima have an RMSE o mean absolute percentage error of 3.13%, a mean bias of +0.46 N, a Pearson correlation of 0.993 and a Lin concordance coefficient of 0.989. For the two waveform conditions, halving the nominal element length and the time step changes the mean cycle maximum by no more than 0.56% and -0.19%, respectively, and the phase-averaged force histories have RMSEs of 5.95% and 2.54% of -the measured force range (computed with the executable of the 2026-10-09 record; see -`provenance.json`). The waveform CSVs carry the measured phase averages computed from the +0.19%, respectively, and the phase-averaged force histories have RMSEs of 5.93% and 2.56% of +the measured force range. The waveform CSVs carry the measured phase averages computed from the supplement's `expData.dat`. ## Time step diff --git a/validation/experiments/bergdahl/provenance.json b/validation/experiments/bergdahl/provenance.json index 9cdba7c6..5bcddb9f 100644 --- a/validation/experiments/bergdahl/provenance.json +++ b/validation/experiments/bergdahl/provenance.json @@ -1,8 +1,8 @@ { - "CableDyn_release": "v0.1.1+dev (unreleased)", - "validation_date": "2026-10-19", + "CableDyn_release": "v0.2.0", + "validation_date": "2026-10-20", "executable_name": "cabledyn.exe", - "executable_sha256": "88d2bba2da6fb0801656d4bacd30e9d0e916f768c7047161457edea324274c66", + "executable_sha256": "55fe625602eaef9c3bdb7bbee889858d3a50fa4baa66437801d9c102dc2424a3", "compiler": "GNU Fortran 16.2.0", "build_type": "Release", "platform": "Windows 11 x86-64", @@ -17,9 +17,8 @@ "force_maxima_sha256": "978889378964c6d6749bc27c11d99d6584956e3c8eac146ae79bf5f7a05e2e95", "aggregate_metrics_sha256": "35d800fa34137a3a1500cbd0081a490bc1b61cf636cfef5a923b5c18947ba1a7", "case_manifest_sha256": "8da5e7b4a8a92755363807902aba48e0ff42abab04ac44912041853db9e56604", - "waveform_T1p25_sha256": "65c8c846636c378b800bb3c7a95ccd2bde766d789af3cdffce26a2e688e1a134", - "waveform_T3p50_sha256": "b3ca65ebfc1d61b5510e54876fc11d1604fc18ffcca3eab523dc7d67f50da4d8", - "waveform_metrics_sha256": "2803a57cb7726f966a00e00bf6eb070231b9c702ae67a81685da50991d0adb11", - "waveform_note": "Waveform metrics were computed with the executable of the 2026-10-09 validation (sha256 71090e2e28c9e1d99c5180d05a395ebcc891a77cc5294d315a57c691904745ac); the development builds since then (the force-blended EI = 0 step and its rotation- and snap-resolved sub-steps) were not rerun on them because the article supplement's expData.dat, which reduce_bergdahl_waveforms.py reads, was not available. The measured phase averages are those of expData.dat, as carried in the waveform CSVs.", + "waveform_T1p25_sha256": "e6fad502f89d8796f2f7868dc9c9ca8e2ebc6969f4ebc3aa36e2bf30498a4522", + "waveform_T3p50_sha256": "a21956ee9d7c0a41c0948eb2cae7fa1f25c0b8dc26714a4dce95fa0236e5434e", + "waveform_metrics_sha256": "0fb6015cb30aa2bbb1cd8951b603f9201af50372ee6d3633a72fc70ea5280d1a", "refinement_summary_sha256": "9039f6c9b91ed2d15d7c609dd8d2300eef34d0363700487a8dfc0a8f15be1087" } diff --git a/validation/experiments/bergdahl/waveform_T1p25_R0p200.csv b/validation/experiments/bergdahl/waveform_T1p25_R0p200.csv index 689e438e..2eaf8b7c 100644 --- a/validation/experiments/bergdahl/waveform_T1p25_R0p200.csv +++ b/validation/experiments/bergdahl/waveform_T1p25_R0p200.csv @@ -1,1002 +1,1002 @@ time_in_cycle_s,measured_mean_N,measured_std_N,predicted_mean_N,predicted_std_N -0.0,11.525394998838706,1.147109920663804,10.7477118,0.3650847378516388 -0.00125,11.556536049750768,1.1709330987081792,10.62465080000012,0.19917788977010492 -0.0025,11.39114432781078,1.703121627685561,10.658561799999998,0.19332850696599296 -0.00375,11.550298915999477,1.597487808580788,10.908390399999998,0.26965316539918455 -0.005,11.78141707300275,1.348174055030013,10.925374600000001,0.15961762432858115 -0.00625,11.979029052755964,1.2284317156669287,10.7729694,0.23636542256070345 -0.0075,12.139913989218982,1.221742952277128,10.8222488,0.31398952029120314 -0.00875,12.306751796332405,1.2455839638134134,10.923604800000001,0.35225796144189553 -0.01,12.475254849155917,1.2927416890978451,11.312814800000002,0.5616011451316673 -0.01125,12.632950194908496,1.354839686636493,12.4012246,1.9522158610997142 -0.0125,12.771598565058648,1.4124114456869772,12.5683574,1.3634780530007808 -0.01375,12.882895473051157,1.4451955899223845,12.843965,1.6302036715906083 -0.015,12.9689318105045,1.4529074984114583,12.494156800000773,1.4414133362689148 -0.01625,13.044686901758176,1.4533946503083013,12.6307468,1.2771898075931 -0.0175,13.118060831749503,1.4527568613242638,12.4636732,0.8594337923395847 -0.01875,13.18741817296263,1.4505075116161552,12.806343199998816,0.9504600647323748 -0.02,13.198945482125582,1.3938836415760356,14.334471000000002,2.49427683604988 -0.02125,13.172579914842833,1.3536455030874701,12.844895600000001,1.6252963799120765 -0.0225,13.222793075864892,1.3436429531962009,11.511228200000001,0.5912138456254218 -0.02375,13.265766329752736,1.3233420853395834,11.596723599999999,0.6485287445767537 -0.025,13.301531884295,1.2905931895680571,12.319151399999999,1.514332000770736 -0.02625,13.327739001053759,1.2389855111814787,12.564898399999999,1.2120681853570783 -0.0275,13.345255249888583,1.1709338609267388,12.5375802,1.4102084967329118 -0.02875,13.36358412132691,1.0983364576766745,11.839949400000892,1.0534212722904972 -0.03,13.419945752955167,1.0315974412954492,12.3579006,1.3083514755983197 -0.03125,13.515872626931376,1.027948702086835,12.7509166,1.2932313625632887 -0.0325,13.530090639119491,0.9819999450027478,12.3412931999998,0.8079769120025554 -0.03375,13.546028299911514,0.9412212187767868,12.936586,1.138951767970005 -0.035,13.568301620815582,0.9192949298878015,12.6602918,0.4554219969881779 -0.03625,13.60303136458217,0.9261662328564486,13.4789454,1.350456073645789 -0.0375,13.671482095870829,0.9687222191624648,13.4389464,1.2389055354224145 -0.03875,13.763584152228319,1.0664751584592451,13.746042800000001,1.241774010259999 -0.04,13.84110675747833,1.1799007981555738,13.698252,1.5332540155394994 -0.04125,13.908539501106441,1.293590781373662,13.3415334,0.6063283078459226 -0.0425,13.973411508863508,1.407886681139084,14.132754199999999,1.8305189203216934 -0.04375,14.024684464949926,1.4968645719648543,13.622153800000001,1.8478866175370983 -0.045,13.993760016693086,1.4836340386693208,13.7807482,1.7015674829179415 -0.04625,13.932453456577226,1.4424402056131176,13.9118312,2.124265007989164 -0.0475,13.890547437118807,1.4051800803774834,14.6249384,1.7548982522078884 -0.04875,13.866578488955161,1.4002555612316834,16.0304728,1.5566804933073772 -0.05,13.851091710550834,1.4255917360274595,16.322527400000432,3.5078742096646534 -0.05125,13.842668495917104,1.4272833780186265,15.6232246,1.5303575636536062 -0.0525,13.844330066608913,1.4208024506050487,15.3815584,2.0998142304382075 -0.05375,13.841049276756166,1.4024002214436582,15.023048399999999,1.2982396713830617 -0.055,13.830215664302584,1.3606986313510068,15.382414,1.4415814480637221 -0.05625,13.826285402465304,1.3124885751360116,16.216763200000003,1.7676503773046288 -0.0575,13.838366548341368,1.277806782922273,16.22508,2.690703155931085 -0.05875,13.861734512023757,1.250280846468323,15.121392599999998,2.000522298177479 -0.06,13.968784261253168,1.1328806775584115,16.19310099999769,1.8092373608923242 -0.06125,14.044556273008347,1.0707432282513074,16.346346000000004,4.513191790721783 -0.0625,14.06569194510721,1.0262948762562445,15.590092799999999,3.432729022630347 -0.06375,14.084004238748756,0.9791515458418115,15.054194200000783,1.7833782198620798 -0.065,14.108064095009498,0.9202587700881542,15.1765868,2.031719128620809 -0.06625,14.146933636078446,0.8121869561694578,14.845536399999997,1.2938161801617336 -0.0675,14.248840257806954,0.7574310294539854,15.814213999999998,2.98537867739982 -0.06875,14.371376382051965,0.819186939989948,17.122298199999996,2.5532735981959895 -0.07,14.449455866801499,0.8699004559113191,15.861088,1.1089759794069032 -0.07125,14.488132299133412,0.8617507864932435,14.7784052,0.467093947924505 -0.0725,14.507454330966425,0.8321633988706341,15.0886908,0.5668836550847095 -0.07375,14.520266420869099,0.8115163541221139,16.195521999999997,0.88462812476119 -0.075,14.543596228715336,0.804613574451162,16.335615,0.42243195323448185 -0.07625,14.572733825643473,0.8475576825383351,17.201156,1.367675481031411 -0.0775,14.600409591796774,0.9653449590976451,18.080314200000913,1.785832314176271 -0.07875,14.63965266524805,1.1222572784404423,15.9154092,1.6655744646368114 -0.08,14.604311143999084,1.2614944737859426,16.8250592,1.8960171089684819 -0.08125,14.486072029397475,1.3529706790665987,17.185320800000913,1.9720242244547053 -0.0825,14.37455062065863,1.399265911194497,16.782423,2.088158468856231 -0.08375,14.254290860633441,1.3981841748270347,17.8938896,1.8495703590284958 -0.085,14.109190983952333,1.386695293780523,17.2830374,1.3695805571551087 -0.08625,14.079149136698803,1.2219771493619813,17.2654132,0.9492746611237962 -0.0875,14.205348609243217,0.9997679630803085,17.73166919999987,0.6492740128844852 -0.08875,14.144836586483377,0.972413355725428,18.2704866,1.539458655235924 -0.09,14.096182329532247,0.9512520311123394,20.190786,2.5109806431982897 -0.09125,14.068208188568391,0.9308905906507043,20.560166400000938,3.116732806352368 -0.0925,14.062205854089902,0.9133713244414476,18.749807,1.8635979286852624 -0.09375,14.078881950131317,0.9047049146850871,17.880819600000002,1.2529868160851896 -0.095,14.116281827495664,0.9139213394949692,19.003242199997967,2.322937813573808 -0.09625,14.172583691620224,0.947062259762627,19.895982799999995,1.6684223212926932 -0.0975,14.24027720878167,1.004255061955748,18.716711399999998,1.3636614315490125 -0.09875,14.31515026760779,1.0781490176304955,18.0324022,1.4432000961222247 -0.1,14.39299075672625,1.15766746010347,19.817073200000003,2.015995887676411 -0.10125,14.47013465529242,1.2272571141879838,20.072184399999998,2.2387455212409253 -0.1025,14.55127573925857,1.2769357351439197,19.786762,1.9799607295252097 -0.10375,14.64039773399719,1.294618986076384,18.100284199999997,1.144430337669882 -0.105,14.746827681170833,1.2479389906889518,18.779723800000003,1.8187752830244592 -0.10625,14.85463508642203,1.0980660167415746,20.304644400000004,2.874950853550074 -0.1075,14.960400567668087,0.9798304638296474,20.724090999999998,2.8658770228656882 -0.10875,15.06831296982761,0.917219201713889,20.698303000001626,2.7871598217660303 -0.11,15.171718636448254,0.8788626862660728,18.4495602,2.0507938516848054 -0.11125,15.253913441175927,0.843148670938675,18.2033092,1.1929221584907368 -0.1125,15.317943077685726,0.822281904674954,18.776067399999153,0.5831946438466593 -0.11375,15.345856289445207,0.8116464348932717,21.3004142,2.6819712885144202 -0.115,15.331963548665664,0.8396306552371637,22.6245832,3.806288269236277 -0.11625,15.269183290487424,0.9512771400130003,20.647513,2.888812307603421 -0.1175,15.21287924687008,1.11078155275331,19.8016284,0.4578947749748842 -0.11875,15.203197089934415,1.2292985365853568,21.105014599997865,1.940730940703746 -0.12,15.22644825758458,1.302331101608236,20.8435042,2.103974691973552 -0.12125,15.267452528641615,1.3683930277673104,20.792636199999997,1.5603097611088959 -0.1225,15.323312626799327,1.4362036672099345,22.802216599997298,2.410978206016078 -0.12375,15.397156431683664,1.5026021321140917,23.8240378,2.166494546768857 -0.125,15.495122998835663,1.5604066190556332,22.836676200000007,2.2918051929975864 -0.12625,15.62779313871705,1.600579952688946,21.51321440000006,0.4896366734894316 -0.1275,15.769674762713946,1.649723565019996,23.506214399999998,1.697314406318494 -0.12875,15.908244188066357,1.728972451617944,23.370950399999998,2.4570525663121856 -0.13,16.042875036512584,1.8540626018270547,23.800182,1.5325037667919448 -0.13125,16.16286895475806,2.0390055096517976,24.8693156,3.8590337507939476 -0.1325,16.297773869446885,2.268576552795164,24.529065799999998,2.1979256657193167 -0.13375,16.46797510043117,2.5140458470684863,26.649890399999997,1.0627020161707137 -0.135,16.658836524706167,2.764702899448912,26.329731600000002,1.5181111654114139 -0.13625,16.88774265910308,2.9785692554307137,26.763319000000003,3.880171604158572 -0.1375,17.160205854619388,3.1432039523306203,28.340083600000003,3.55836601724616 -0.13875,17.45032784980079,3.2916887879790258,29.061535600000003,1.373399905281161 -0.14,17.72986938062675,3.439507183334817,28.8688644,2.3342514734872295 -0.14125,17.963251753351262,3.576106336843433,29.2156228,1.651717140865136 -0.1425,18.160097441741552,3.681036266835612,30.274254000000003,1.2558515612860057 -0.14375,18.342125427017,3.749637796314992,30.731068399999508,1.0900589845659636 -0.145,18.520161766051668,3.8104137681028236,30.825747200000002,0.9756053879159846 -0.14625,18.701845399643386,3.8739644762476315,30.9684634,1.442824200403952 -0.1475,18.89924763193564,3.928089894879325,31.474787599999996,1.364293482243026 -0.14875,19.116914107706286,3.9641167275463625,32.084609,1.8425896830227833 -0.15,19.34887180653875,3.98438943032357,31.944255600000254,1.638519985237776 -0.15125,19.585954053895914,3.994567312434933,31.985777600000006,1.020366869196956 -0.1525,19.824154515596156,4.0125901575724265,31.938235,0.8365635596689596 -0.15375,19.961521153080728,4.145515925767436,31.869986199999897,0.6737883134658872 -0.155,20.07256766084225,4.4142194050367936,32.175281,0.35637034525055605 -0.15625,20.376381549905734,4.478167678386396,32.5158186,1.2760458437669089 -0.1575,20.709525196996946,4.52409832481901,33.47437619999827,2.0518026815976436 -0.15875,21.06937567436144,4.548805953819452,34.3789128,1.3138635411094648 -0.16,21.469380708893667,4.561472091064812,34.4239594,0.6397966550966026 -0.16125,21.915448921662833,4.570033654421888,34.4817408,0.8322461360500272 -0.1625,22.38786646330141,4.583034146569255,34.4554872,0.402944856471949 -0.16375,22.87384415037127,4.598521667708591,34.0793302,1.0015776891633015 -0.165,23.36084836999808,4.611317079923997,34.5234564,0.49368398252758616 -0.16625,23.935500626225235,4.57309803231348,34.1569528,1.3322731965958416 -0.1675,24.294221802420235,4.586906755227691,33.281697799999996,0.8547899309313958 -0.16875,24.561683304754975,4.554701540974743,34.3198664,0.903638730855037 -0.17,24.779312432608332,4.510044924675835,35.4916872,0.7184205133518253 -0.17125,25.00006427367657,4.497569525431957,34.809045,0.9619548017773484 -0.1725,25.26199603582597,4.522184517656694,34.529281999999995,0.6434581427307466 -0.17375,25.556238083600764,4.562291508940056,34.51987379999999,1.0716583433822087 -0.175,25.859423014508252,4.605820502471582,34.229684800000015,1.5208173784880477 -0.17625,26.172858952968824,4.65393874926601,34.3331156,1.280125223398204 -0.1775,26.50975987086674,4.707014235151529,35.015979200000004,0.9610507388734483 -0.17875,26.857579520979986,4.761014232910419,35.618884,0.44413901535611483 -0.18,27.202809432836087,4.732600423599567,35.6036116,0.9061082102957122 -0.18125,27.606484207186156,4.560205176665199,34.9339672,0.8854704507789637 -0.1825,28.03392045719407,4.287861603579483,34.8921202,1.13659550429812 -0.18375,28.41916489775267,3.932876913947986,35.09663340000001,0.927356857460655 -0.185,28.786715084185246,3.535196458495313,35.355537799999325,1.1911401254464749 -0.18625,29.139966732395674,3.137781007000377,35.947342199999994,0.8834305252583254 -0.1875,29.46798758833775,2.781570586337756,35.81235,1.0798035086993842 -0.18875,29.763859396648513,2.495569723591644,34.8889400000011,1.1807380240445449 -0.19,29.931755652209585,2.3320257388623062,35.2324842,1.2232866920733265 -0.19125,30.145825005870055,2.2154873321650874,35.9577722,1.022461617081149 -0.1925,30.36266477596969,2.0960989385118034,35.4115192,0.6031405439453552 -0.19375,30.486550374131863,1.9799481721247927,35.7112922,0.8866124239441948 -0.195,30.64153631289942,1.8954882298360942,36.287463,0.9125551484395347 -0.19625,30.821722551302088,1.8234587632597334,36.915316600000004,0.9343267203046791 -0.1975,30.987468820153314,1.7652677235130723,37.248217600000004,0.3905672233979715 -0.19875,31.14614440607042,1.717903994765187,36.9060498,0.3924952419586751 -0.2,31.319315029804667,1.7005025635657243,36.8021566,0.3522472020624146 -0.20125,31.500280191132763,1.7089267879639742,36.634841400000006,0.9428159241277158 -0.2025,31.677218351052463,1.7086579026139994,37.2030818,1.0060227056434667 -0.20375,31.860241460230068,1.6966771292868377,38.2613308,0.8513098481614674 -0.205,32.051420340339085,1.6907708119843718,38.2615914,0.7947669544192176 -0.20625,32.241518721198204,1.6961631992903516,38.332927999999335,0.6835947232546329 -0.2075,32.420275347016975,1.711024464711539,38.854375,0.8261274108643907 -0.20875,32.58554513917215,1.7345918740958377,39.229262,0.8985008909798015 -0.21,32.74683480284567,1.7583868758565393,39.0085372,0.9921559338857466 -0.21125,32.90933669745089,1.7736762602876859,39.0329344,0.8925121232777739 -0.2125,33.08126669020401,1.7828369831816777,39.321098000000006,0.899916001217059 -0.21375,33.311030672728776,1.8029054856495992,38.7276616,1.2650072465829205 -0.215,33.57833333927349,1.8723149612698815,39.0779092,1.389178415017742 -0.21625,33.86160219125072,1.8769194689642847,40.105383999999205,0.9089999581864604 -0.2175,34.06745776628107,1.857003116186456,39.42761720000001,0.6648194742392095 -0.21875,34.20882556871395,1.8574177726840941,39.0599948,1.2259845642065401 -0.22,34.33227259793791,1.8574805331040625,39.83897139999906,0.9005356672686163 -0.22125,34.445904050436525,1.8540307739436777,39.976072,0.9883871636681643 -0.2225,34.55447072157005,1.8493387467594145,39.8937862,1.1186732806423871 -0.22375,34.66210946452761,1.8455558448770992,40.369944200000006,0.4570070429793161 -0.225,34.770775635122085,1.8428401096152411,40.85768300000001,0.4652845872839547 -0.22625,34.8831027293955,1.8403469545831272,41.081675,0.23288915298592305 -0.2275,35.00061853970025,1.837620984557463,41.307434799999996,0.3675495206427293 -0.22875,35.12409652964701,1.8333217222549947,41.3020786,0.3621131784177407 -0.23,35.25345946288892,1.8262594067839328,41.552173800000006,0.36987483186978126 -0.23125,35.396163884425285,1.8066944423347098,42.0359744,0.18918432163183946 -0.2325,35.550281621142155,1.779774336440642,41.989619999999995,0.11509412238902621 -0.23375,35.736540950847576,1.7690337062474388,42.256936399999624,0.3869573208795501 -0.235,35.97991136343875,1.8640847626929606,42.662469599999994,0.3946614685186529 -0.23625,36.10565530943341,1.9002625965956377,43.2263282,0.33232299988369896 -0.2375,36.25995033615795,1.9294494016388257,43.1116106000004,0.4953601921581007 -0.23875,36.416214192788225,1.9589991804661995,42.4576496,0.6289907423542105 -0.24,36.59281949398801,2.0177149026657344,41.5105688,0.5293264064726015 -0.24125,36.80311423885269,2.1241769695308816,41.169173,0.4536702528362419 -0.2425,37.03311087345981,2.261203380381083,41.6761456,0.40569547501395675 -0.24375,37.27506741039263,2.4249648212930066,42.58208259999873,0.2430540094905849 -0.245,37.52052887512917,2.6131864448739837,43.179403,0.17667214366871917 -0.24625,37.77117202124726,2.827802682260074,43.6212862,0.19190814977405285 -0.2475,38.03057978863745,3.062078582142675,44.125771199999306,0.12915745329528922 -0.24875,38.30354073840217,3.3104957694503976,44.494844,0.28093936033154915 -0.25,38.604057791259415,3.5494033825829074,44.38520200000001,0.2701402120695849 -0.25125,38.95256121126635,3.7625961966426673,44.05785760000033,0.19923831639577363 -0.2525,39.46048487332595,3.973004279051523,44.3022664,0.62905729196616 -0.25375,40.169513644481604,4.4347763982985065,46.4716182,1.1020320340143042 -0.255,40.840275552876335,5.109393881012242,50.49928799999999,0.6866907603947358 -0.25625,41.17540843645229,5.332751819782552,52.17650960000001,1.0106726691396182 -0.2575,41.375216881263135,5.475322301999672,51.9099784,0.6255598334490472 -0.25875,41.67481968107979,5.907325410706396,52.0473206,0.5245347834503453 -0.26,42.02161260342867,6.343016923856078,52.43054020000001,0.44667133891900673 -0.26125,42.49630712534095,6.538806379071054,52.876448200000006,0.32235313317028597 -0.2625,43.21367005314688,6.577008129973765,52.6062052,0.5359361611369393 -0.26375,43.85512475273858,6.570129110063762,52.56831460000001,0.6006175956449326 -0.265,44.892990760346315,6.724740101904145,52.7267151999996,0.43743248483440317 -0.26625,44.602405463845194,6.710190049259505,53.061544600000005,0.44932467694953077 -0.2675,45.53579876942849,6.758274391952376,53.386237400000006,0.5859625718420916 -0.26875,46.368737652581984,7.274747384397864,53.753115599999695,0.46174143934096645 -0.27,46.7719101289635,7.440868234857993,53.854771400000004,0.21930341955222782 -0.27125,47.899029818159704,7.071833726534465,54.099271,0.21861451242312352 -0.2725,48.16466567701189,7.112385844420995,54.0387572,0.5478924815588371 -0.27375,48.3864524789889,7.167697955389649,53.91590240000001,0.5671608156539888 -0.275,48.881826276785006,7.362970613667282,54.20657839999948,0.3896875591247103 -0.27625,49.37876458908128,7.480866902673808,54.6463664,0.17663793235967165 -0.2775,49.694773076263964,7.5510904787780655,55.22389019999999,0.26872001543186197 -0.27875,49.81529596609473,7.530077227432517,55.59797459999961,0.3540559613461011 -0.28,50.063288901345324,7.467825889006211,55.70291640000001,0.46905799095666306 -0.28125,50.42453252565921,7.279120930611521,55.433336600000004,0.48403818645929 -0.2825,51.05832766895917,6.817284129522287,55.38312539999977,0.5256657463950581 -0.28375,51.993089909345095,6.291581246471716,55.759351800000005,0.37538094238546615 -0.285,52.91745629234399,5.863490903466829,56.2251664,0.4677160109278914 -0.28625,53.44746567042378,5.340926137855397,56.29960940000001,0.3571973387601021 -0.2875,53.38573898361142,5.292683738142055,56.427117800000005,0.2410061347283506 -0.28875,53.05002492293594,5.7991000954454694,56.7726624,0.29351416241009537 -0.29,53.297729968329094,5.037962872793847,56.8313578,0.5030043737172661 -0.29125,54.00492360271622,3.7556035421597063,56.947258,0.2651928299379541 -0.2925,54.6493327349178,3.127943141568824,57.0084532,0.12524220724939342 -0.29375,54.93361350452128,2.949442286661408,57.2560972,0.24766534129385198 -0.295,55.01933449306399,2.996434559628386,57.6077084,0.2586901411946356 -0.29625,55.2380272698249,3.0143038440762067,57.62152639999999,0.43433510795099306 -0.2975,55.55840969582432,2.9558899669206746,57.6882028,0.4495089136977161 -0.29875,55.91176907742496,2.9367967856394643,57.6592398,0.42619740657200156 -0.3,56.2480879060185,3.008928378338898,57.60681619999997,0.32658559073772486 -0.30125,56.44958817614397,3.1628925586933527,57.7432726,0.2122019635425166 -0.3025,56.50679974125981,3.4807572213803675,58.18554759999999,0.2835956179109613 -0.30375,56.77120479725138,3.7618205699760714,58.5471052,0.7352828060703575 -0.305,56.95680965253849,3.7895008203147356,58.6927594,0.6997656178198541 -0.30625,57.149736463600014,3.7127337514349383,58.6745422,0.32209833788720493 -0.3075,57.41362796619139,3.620944582214645,58.820682399999995,0.3379625110974596 -0.30875,57.70090849861119,3.553672920810739,59.018279400000004,0.3987593835514096 -0.31,57.98129400090951,3.4896799683461177,59.15511919999982,0.5135381038488195 -0.31125,58.29304019045204,3.397989895292501,59.3368416,0.38699648902839084 -0.3125,58.48715829557767,3.4507919661563786,59.792702600000005,0.38527643429789543 -0.31375,58.62911323627833,3.540633460337912,59.969650400000106,0.4733024525107288 -0.315,58.91608435869083,3.729087746147129,59.670173399999996,0.4633619033669042 -0.31625,58.986525365223734,3.6069661999346576,59.601771,0.3797200072724619 -0.3175,59.00262400103546,3.3732764631021603,59.824043200000006,0.459256341484471 -0.31875,59.30641148740505,3.1455596364882408,60.040577600000006,0.26058744398339695 -0.32,59.74862657230375,3.0166534615695455,60.51608040000001,0.3950600737651194 -0.32125,60.14898382003954,2.9943358891968663,60.915608199999994,0.4609867134329351 -0.3225,60.49733861199949,3.0294891518899343,61.11235939999999,0.4001463689355433 -0.32375,60.80316732130621,3.084108664686331,61.3472078,0.2900221562496555 -0.325,61.07344985569808,3.1380776363110843,61.3012504,0.5527437522390458 -0.32625,61.34406666650188,3.1785857364900556,61.1515548,0.7754550055820125 -0.3275,61.716261841874946,3.2342347746095106,61.44902319999941,0.6169861894996159 -0.32875,62.12223244714813,3.309338455194751,61.811001399999995,0.3254231495680662 -0.33,62.62978847808009,3.4154497204441787,62.0780664,0.4850772653998533 -0.33125,62.90252527832451,3.3350437467075205,62.34348999999984,0.43925060258469495 -0.3325,63.11128170385873,3.160147842593392,62.7075818,0.5259934632309595 -0.33375,63.299425408753876,2.9648788439719818,62.8504862,0.5403706817506839 -0.335,63.44796836565467,2.747114916465185,62.637643600000004,0.5077727201507577 -0.33625,63.54594316654441,2.5181849976559354,62.704226199999994,0.778468059873494 -0.3375,63.78194916661517,2.468345682639045,63.183735,0.6883548267768593 -0.33875,63.9913482652612,2.477504609043261,63.551559399999995,0.46165405411227556 -0.34,64.11105696700334,2.4532799812858355,63.4680606,0.3039636183029152 -0.34125,64.0722225669319,2.2569598296899245,63.34272040000015,0.3035766459985766 -0.3425,63.77355977276731,2.3228945525685454,63.248382400000004,0.2695086491985006 -0.34375,63.91525395287895,2.266871562252851,63.2311462,0.17130198010443395 -0.345,64.07145186422726,2.185715074936424,63.40036299999963,0.3900122487508055 -0.34625,64.23077999075147,2.0735984489716173,63.77729860000001,0.468106512522847 -0.3475,64.38272146645217,1.9350503913012118,64.23839640000001,0.3756580849686323 -0.34875,64.53044600287573,1.7824947091795078,64.5565078,0.27262450133415983 -0.35,64.67589494800583,1.6296352791611177,64.630385,0.1363798327558009 -0.35125,64.81408885080495,1.483966322436494,64.5994458,0.25123596977681956 -0.3525,64.94147004212259,1.353508907968042,64.3346442,0.3173942489983097 -0.35375,65.0470445580853,1.2362832852929433,64.035212,0.23710640745349115 -0.355,65.12439813540574,1.1373236428792484,64.073773,0.227965472513931 -0.35625,65.0782268082168,1.1507485768701913,64.26903680000001,0.19010914138646848 -0.3575,64.91406608578426,1.4927293772973342,64.531669,0.4131422289139702 -0.35875,64.78166260068538,1.88314196661301,64.83095259999962,0.522629999807509 -0.36,65.30330123264315,1.2269113973841828,64.9157588,0.3637693020049954 -0.36125,65.49542528062418,1.3489367291647427,64.7664974,0.273504891115864 -0.3625,65.54780344612674,1.4212271881298135,64.56646399999993,0.1837545441247436 -0.36375,65.51976225643436,1.4920380878404738,64.4106814,0.3191894240248278 -0.365,65.3395067690975,1.6682010959979148,64.43114419999999,0.24309291119487597 -0.36625,65.32477597256234,1.658911366487909,64.7498234,0.24025492905412207 -0.3675,65.3605435256114,1.6383363077100168,64.9434066,0.3206077443041588 -0.36875,65.50670314588389,1.5999344913986482,64.911355,0.16368783450519112 -0.37,65.73003542055723,1.5886251376129976,64.8510344,0.1330025557885984 -0.37125,65.90960488099972,1.5307238352923698,64.836452,0.2099050646530504 -0.3725,66.05055964306403,1.4878823183753431,64.93570999999979,0.27300007168402995 -0.37375,66.10083361122267,1.4460540338926844,65.1426026,0.2725256941515788 -0.375,66.15091943875183,1.3748933444180726,65.3138582,0.22719141371033902 -0.37625,66.21242960166582,1.2873453392372534,65.37360399999997,0.20423706388623633 -0.3775,66.2856794493075,1.1897621227316342,65.3374242,0.38254605175351025 -0.37875,66.37245458804423,1.095656066102949,65.229175,0.33589187081931504 -0.38,66.45751995931325,1.0461897243290434,65.1953056,0.31122608982827826 -0.38125,66.52098238578097,1.0612505351313726,65.2553202,0.25939501841920687 -0.3825,66.55774998990564,1.1111957642332964,65.33337959999999,0.0059080739077979946 -0.38375,66.44586855235262,1.1199568508186075,65.46940219999999,0.2355257819086928 -0.385,66.41130748964908,1.1959588102929015,65.60699919999999,0.3433873783640002 -0.38625,66.44025824201903,1.2547933379961644,65.59271559999999,0.19716640854820752 -0.3875,66.49187918572939,1.318735556802987,65.54311560000001,0.18733627618750429 -0.38875,66.54419117780937,1.3887666942680224,65.5428876,0.400899390105297 -0.39,66.57871928457466,1.466759863623637,65.62384199999985,0.498317627494711 -0.39125,66.59725078567243,1.5492230926283796,65.7004456,0.42682455190663726 -0.3925,66.61241429221167,1.6379884842631882,65.73570459999999,0.2937337547972698 -0.39375,66.62550805169845,1.7311710094031518,65.79560179999986,0.15200515072764556 -0.395,66.63792236933226,1.8266952749886134,65.89153400000001,0.11445875259673312 -0.39625,66.65775036225214,1.9138732278429684,66.03552020000001,0.16329055237122553 -0.3975,66.72112881161279,1.946504794181596,66.1719786,0.18097545343720037 -0.39875,66.84133391471119,1.9490123188941955,66.1877342,0.30257105925005606 -0.4,67.03816581617626,1.9880961227899556,66.1130586,0.32622384800670023 -0.40125,67.36165475831316,2.1523135242293177,66.0224196,0.30216490867620815 -0.4025,67.57692707154408,2.365497884272383,65.88580440000001,0.38478405176514285 -0.40375,67.83688650450762,2.5098481833000816,65.7773598000001,0.3726027509254793 -0.405,68.08450706883758,2.6016339778233917,65.8214774,0.2983744970021714 -0.40625,68.18667972071536,2.573893673039394,65.96974320000001,0.20558770594857737 -0.4075,68.1510080662096,2.4329187834010635,66.06081899999992,0.24018050366642424 -0.40875,68.06261668417996,2.340769562258999,66.0913218,0.20065431666226027 -0.41,67.96301942752866,2.4082596372284075,66.0741074,0.1263064399894176 -0.41125,67.90690163168658,2.5565897369785207,65.8935132,0.15709860876914125 -0.4125,67.8812799043891,2.602123263054298,65.738355,0.20418938489427332 -0.41375,67.71585824402098,2.6373194375574727,65.86276360000001,0.13609599348547965 -0.415,67.77469628637893,2.7054946272552054,66.111349,0.09901311854497152 -0.41625,67.93423498468019,2.692859558478106,66.28005,0.16800634461829078 -0.4175,68.10038148856931,2.6626069837507482,66.3307468,0.12835060125180353 -0.41875,68.26680826393539,2.6313840858314594,66.2215426,0.14591086805580905 -0.42,68.44068336011583,2.6156334591704673,66.001317,0.1640184922211547 -0.42125,68.62169709478236,2.6228079359700267,65.8271396000002,0.09480227828125173 -0.4225,68.8064095819759,2.655509141262329,65.810576,0.13075537722785904 -0.42375,68.98738237343564,2.7141381397198696,65.9365452,0.21100372340245618 -0.425,69.15660498652592,2.795681489133451,66.13177679999987,0.1658080658780603 -0.42625,69.30622724459857,2.8852587619001566,66.22762660000001,0.06618791591975157 -0.4275,69.35891954369141,3.0463802596689757,66.04361180000001,0.15484122412071297 -0.42875,69.36423910887196,3.2452812026962787,65.6964608,0.18570948184920574 -0.43,69.45184217063942,3.2947157194286465,65.4390446,0.1458813037517181 -0.43125,69.56042023491482,3.295160403604901,65.39493360000002,0.07185104783717429 -0.4325,69.69844398133745,3.2406328819736396,65.57180980000001,0.1316681445251652 -0.43375,69.85971599345338,3.1477039442382093,65.8386524,0.2505190452845852 -0.435,70.03513452230276,3.0406880890138948,66.01535559999985,0.16937351799754627 -0.43625,70.21440981191598,2.9396976711593745,65.9626658,0.09619663854158457 -0.4375,70.3865036206431,2.86597091471126,65.72589500000001,0.130307936843846 -0.43875,70.54230446013867,2.8238455977771872,65.56433060000015,0.0826726291877323 -0.44,70.66478198177347,2.803437941600315,65.58103080000001,0.08460128562084328 -0.44125,70.50342308644993,2.863270944891383,65.77994939999999,0.17346827338825016 -0.4425,70.30867628537878,3.155018132143993,66.35900899999999,0.2857358531231252 -0.44375,70.31151283338407,3.1563417933500317,67.272972,0.2670981674834159 -0.445,70.39685421360092,2.995432202062305,67.84045760000001,0.18568538163732182 -0.44625,70.43243967312623,2.8967548705523276,67.79321200000001,0.15591334122678469 -0.4475,70.41272482202197,2.862946746713692,67.7101154,0.13004153409314978 -0.44875,70.37868979985736,2.83424497498045,67.8113568,0.09453606181875521 -0.45,70.33910078069816,2.7944376914778846,67.8269122,0.061544358118351225 -0.45125,70.3114755748212,2.731909328183094,67.70704860000001,0.17673951718079425 -0.4525,70.3360949631364,2.6664699256002544,67.60898400000008,0.2935486776608403 -0.45375,70.38675273266033,2.619648576962748,67.61439019999999,0.2891522970783728 -0.455,70.43585711430708,2.5306066307080854,67.6627362,0.1774709458367781 -0.45625,70.90958844687678,2.0858996631163573,67.65891960000005,0.1382583338040993 -0.4575,70.99857116349328,1.8566463830963849,67.6200846,0.13539775769671744 -0.45875,71.0195328778505,1.6026342426939963,67.57872119999999,0.1238966870368211 -0.46,71.01143751860242,1.415980873040135,67.5534632,0.16453384377902294 -0.46125,70.93980736159908,1.2954551684745672,67.5377738,0.15383732129168035 -0.4625,70.83413116413207,1.2161597257154249,67.49552159999999,0.21284495495148673 -0.46375,70.72153080679213,1.170590418691168,67.45497900000001,0.21075835588061834 -0.465,70.61105564333091,1.1516310902093705,67.4323616,0.13236275716303184 -0.46625,70.51732979451761,1.1421156577552667,67.42917659999998,0.0720402588578287 -0.4675,70.44095817562045,1.1394132614995818,67.48062580000001,0.10049637719689106 -0.46875,70.37231131938148,1.1497665629078222,67.52910119999999,0.13651685763743515 -0.47,70.3077873071686,1.1740765288214798,67.48693700000013,0.1540362563245978 -0.47125,70.24408245328914,1.2102367178934863,67.3489426,0.12209840780616613 -0.4725,70.17914142087413,1.254285801215061,67.1960226,0.11688795671624894 -0.47375,70.11118456392869,1.3006188445288798,67.11309739999999,0.20746833316508964 -0.475,70.037084028373,1.3420855511369654,67.15883679999999,0.1988474820225315 -0.47625,69.94430461500026,1.360388832583098,67.3093022,0.11427788583623764 -0.4775,69.82913157600551,1.3531359246394254,67.3914818,0.053019787525035035 -0.47875,69.70539238825435,1.3432161438818766,67.30245860000001,0.061832300553996536 -0.48,69.585407125596,1.3431537494271482,67.08739460000001,0.10835650244124677 -0.48125,69.46496321344648,1.345976674138934,66.9202928,0.0972885607109084 -0.4825,69.33938547163547,1.3510130840774275,66.95184520000001,0.12912336420144632 -0.48375,69.20846246920756,1.360081890491506,67.08103339999982,0.12426378465912305 -0.485,69.07254235977992,1.374865501112149,67.13062240000001,0.07294563178354074 -0.48625,68.93125649700923,1.3960113241082366,67.02881500000001,0.109700820300033 -0.4875,68.7852791177019,1.4245212211427971,66.78420520000017,0.15879250138040463 -0.48875,68.63196389506565,1.4598933887655083,66.529071,0.1415829096466117 -0.49,68.47020104815566,1.502073065111958,66.48789339999999,0.12393676851241672 -0.49125,68.30116623112586,1.550489264849327,66.6799002,0.12028991310870553 -0.4925,68.12822450594744,1.6050401581064755,66.8379594,0.15272336046198015 -0.49375,67.95418256565146,1.665142344063895,66.75157340000001,0.2247221200867854 -0.495,67.78158938377592,1.7289625010207086,66.4810958,0.23549780675241538 -0.49625,67.61094416449377,1.7905028429367378,66.2253948,0.1485949636283116 -0.4975,67.44157107820476,1.846035458147052,66.144559,0.12971673485690466 -0.49875,67.2723301657672,1.8923640030594597,66.26037000000001,0.2880787635022762 -0.5,67.04593824941259,1.8123735355117632,66.4789446,0.2713466553549141 -0.50125,66.7259032709344,1.551986461609284,66.60730099999994,0.15889955717854956 -0.5025,66.53834031592243,1.3617885522873434,66.47067999999999,0.11946712306530383 -0.50375,66.27654265620389,1.4059499652988032,66.1093192,0.13621292958343093 -0.505,65.98161589359508,1.4639325278957198,65.76325440000001,0.11077772675632655 -0.50625,65.73764111267033,1.5064994516870218,65.6631242,0.10074499242741124 -0.5075,65.52746787964021,1.5774696447832852,65.82905559999999,0.15759216355136568 -0.50875,65.3599954974657,1.6754249319764132,66.12756300000001,0.11416076310405336 -0.51,65.21130809172224,1.7782769004792185,66.2915748,0.21640596064156736 -0.51125,65.07958593608511,1.86417981253192,66.1186592,0.27583502001685567 -0.5125,65.01523865936956,1.8874457651472922,65.8061538,0.23492448420120018 -0.51375,64.91803712440066,1.91249834387356,65.6158952,0.20996774212649713 -0.515,64.70151318391432,1.9949861496199044,65.59674179999993,0.21231180885008946 -0.51625,64.52464972362696,2.0680446956232705,65.7063646,0.20100820155357102 -0.5175,64.40884707164416,2.069053143474832,65.8472234,0.18543442490891734 -0.51875,64.29705752548263,2.065192283273012,65.85464280000008,0.20633028791642277 -0.52,64.18615723130242,2.062818936164204,65.694443,0.20496980175504115 -0.52125,64.07364353773521,2.0647175515256775,65.5502046,0.22408184628456282 -0.5225,63.95403734326027,2.0692124491537753,65.5272362,0.21657417741088325 -0.52375,63.81668537590443,2.068141600662988,65.5725708,0.20080217562242678 -0.525,63.661446612151586,2.0651489623901136,65.5762306,0.22036907298734443 -0.52625,63.49333240851984,2.0634422982852305,65.47682,0.23070858491504243 -0.5275,63.30869444826964,2.0516994626338696,65.26161259999999,0.182790724158258 -0.52875,63.104644900773714,2.029206476074093,64.97762060000039,0.11729933220746196 -0.53,62.89640206293689,2.021112363508424,64.746997,0.10281558922410791 -0.53125,62.69519177285213,2.038833192921256,64.6337576,0.10343050410927924 -0.5325,62.49507530999211,2.0749592127129937,64.5695130000001,0.06938572259123796 -0.53375,62.29552306527328,2.134470941666385,64.46290719999999,0.06737936119613967 -0.535,62.104694527747995,2.202241181725963,64.27099079999999,0.09934739918437883 -0.53625,61.93524342295928,2.2497663554267597,64.007181,0.0730678006135406 -0.5375,61.77916662222746,2.2868541306789845,63.73251739999999,0.058389193583230165 -0.53875,61.66326819111455,2.3419333653523013,63.528390200000004,0.0973255230512514 -0.54,61.58212616607767,2.4453391053346785,63.4168872,0.09888523802974875 -0.54125,61.4341673134364,2.496766901382025,63.3429982,0.07133256795251285 -0.5425,61.18801374434284,2.447178939475783,63.22711940000001,0.05516008261233798 -0.54375,60.9188436913853,2.390921967816178,63.05351079999999,0.08906696593687351 -0.545,60.672190474702994,2.3765191328566764,62.830998199999996,0.09380961103586272 -0.54625,60.40278081108565,2.406640257441105,62.61331260000027,0.07460748486782662 -0.5475,60.05929150223984,2.518157096076586,62.50006079999999,0.06212954969014393 -0.54875,59.7110248338086,2.708930624325758,62.508336400000005,0.05263429917173781 -0.55,59.41007986310367,2.8538656963592066,62.545651199999995,0.044207135348208436 -0.55125,59.10409382657226,2.927556442158565,62.4863838,0.09833018029425099 -0.5525,58.786013030805044,2.968768513544063,62.25944560000001,0.12384964124816907 -0.55375,58.47415764235841,2.981979310440715,61.9254132,0.07174608236830844 -0.555,58.15609272535116,2.991189350855238,61.6482136,0.06466655398503975 -0.55625,57.783595571190055,3.0587594289222544,61.53158620000001,0.12737400571231114 -0.5575,57.46665600403216,3.0696714142191546,61.529761199999996,0.11554845453185632 -0.55875,57.20675109604246,3.0073323300207924,61.500662999999996,0.06729178966263401 -0.56,56.909469896118445,2.8743195166753917,61.29881300000041,0.08926272844243884 -0.56125,56.69881199602718,2.8393316856323088,60.9149532,0.08619366235228906 -0.5625,56.505535856997874,2.8125222391626754,60.526353199999996,0.012037857978062309 -0.56375,56.3118825773337,2.793292785410588,60.313152400000185,0.09333808435617343 -0.565,56.084996344609,2.7928970418412793,60.295617199999995,0.11773094001238552 -0.56625,55.868255202974865,2.812067840267035,60.329183799999996,0.07814704465109482 -0.5675,55.60267681710298,2.931125490418839,60.215318,0.08839368125607261 -0.56875,55.25116454961815,3.2339988298752407,59.8789126,0.10572045875467986 -0.57,55.05506462175041,3.273962184895723,59.444547,0.04083380069868584 -0.57125,54.89006781131962,3.2420076227649557,59.1290278,0.06828674115595362 -0.5725,54.72568797346449,3.25603405104035,59.045922399999995,0.139197381265956 -0.57375,54.50300911517862,3.2723571273378895,59.108284000000005,0.12571120983627512 -0.575,54.19062954301691,3.240879525924185,59.1016476,0.0799441306557283 -0.57625,53.92766117532643,3.241240055736771,58.868630200000005,0.10722592679804506 -0.5775,53.72574989995326,3.208888652986369,58.44557000000066,0.09186195920789172 -0.57875,53.581003294966145,3.120689670929918,58.041045200000006,0.017297477712082312 -0.58,53.451635084964174,3.0477196453788333,57.8428082,0.0985694744467063 -0.58125,53.26110395383055,3.0440923301401326,57.85343399999997,0.12024277475799372 -0.5825,53.03246285208336,3.0663308449162683,57.9010394,0.081556794939479 -0.58375,52.793017268372544,3.0959426932054814,57.7701474,0.10803209598910868 -0.585,52.549396151401744,3.136270580763424,57.3938596,0.13665676280850522 -0.58625,52.29473765818272,3.200764110410146,56.9204658,0.09273651720708308 -0.5875,52.038998359063015,3.2696770738930114,56.57368820000001,0.08167805006670986 -0.58875,51.793694271393385,3.3224710054100743,56.4700586,0.12941526179048407 -0.59,51.56403095337126,3.3465553346757018,56.52886679999999,0.10931949057098672 -0.59125,51.263118766720176,3.244266392032464,56.53343280000009,0.05997386553906903 -0.5925,50.8889869405356,3.0981633287087416,56.310778400000004,0.11638376324384758 -0.59375,50.62431623596097,3.081093505711143,55.871282599999994,0.13821781824822627 -0.595,50.442507414075834,3.1299510918289943,55.399463600000615,0.11860991218400843 -0.59625,50.29214634578301,3.2094818234406026,55.10596439999999,0.15150204538487128 -0.5975,50.135491446888715,3.2871893011143687,55.055999,0.17294036481400227 -0.59875,49.95150770028783,3.347999905968241,55.1275868,0.12140700414185242 -0.6,49.7405925299885,3.3966960451615718,55.1063992,0.05856316449526797 -0.60125,49.51152422735595,3.432221942096889,54.846767799999995,0.12481892246650739 -0.6025,49.27804193624595,3.456879273777224,54.3864064,0.15196075121162037 -0.60375,49.03944051277773,3.476900472672412,53.913528199999995,0.11936691415421535 -0.605,48.777559913872665,3.5079577964167177,53.615220799999996,0.09969241321284134 -0.60625,48.506741234197875,3.5547074168523722,53.5400976,0.1122142203479569 -0.6075,48.220466180498846,3.579870250280165,53.5704374,0.10452731670860092 -0.60875,47.90894483000063,3.584526750492158,53.510238600000186,0.0855619821930328 -0.61,47.582634246582245,3.5775683507942957,53.230368399999996,0.08637812617960464 -0.61125,47.2636811146084,3.5567864035821395,52.771303599999996,0.08926810138453649 -0.6125,46.95077088881816,3.5349496519814707,52.302726600000234,0.07793797289078712 -0.61375,46.62858545702372,3.522061213743811,51.9878226,0.08497909012692419 -0.615,46.30604567754008,3.5242493655985854,51.86987499999999,0.1007874021691215 -0.61625,46.01781506680424,3.492430856735652,51.855968999999995,0.09481574984410467 -0.6175,45.714811130668956,3.4314987174580365,51.78701160000001,0.08382555463759211 -0.61875,45.362456116456826,3.352681305144679,51.5480906,0.08239452154300121 -0.62,44.9976557168665,3.2784926468325684,51.1497674,0.07453622898832395 -0.62125,44.69628618810299,3.1799513936836057,50.718552,0.058673689908679064 -0.6225,44.454131452489065,3.114514073529219,50.39931420000037,0.06430218505383234 -0.62375,44.251383499413606,3.0827843548277483,50.2476884,0.07254508533525907 -0.625,44.057220689370006,3.056795235998767,50.2003662,0.070425793592973 -0.62625,43.8582824843885,3.0347272264643093,50.11687960000019,0.08168603115462769 -0.6275,43.64053976434732,3.021154878903992,49.887583,0.1003471779548372 -0.62875,43.393860629993235,3.0219226510846915,49.511618399999996,0.09662656873913919 -0.63,43.154366676440254,3.0130584076921556,49.0872074,0.06964734390341057 -0.63125,42.90448990366472,2.9420049050482913,48.740306,0.05217631269551379 -0.6325,42.64672683015284,2.8763902430847432,48.531233199999996,0.06029225588083322 -0.63375,42.44012195631465,2.878140134692195,48.4213764,0.047336225776884705 -0.635,42.22972821338116,2.928519100728845,48.300233399999996,0.03976988997093251 -0.63625,41.90895437019746,3.1888971634012715,48.0649592,0.08211958863267727 -0.6375,41.63016243921695,3.296148222903783,47.705103799999996,0.10536786191102118 -0.63875,41.34146803084682,3.312848060152701,47.3030112,0.09572948294125659 -0.64,41.02394112664391,3.285006948962623,46.96427640000042,0.09200194859238264 -0.64125,40.7217816820285,3.2929354111929126,46.7468582,0.11040447837021912 -0.6425,40.46107843214558,3.3709946083062357,46.6224416,0.11050987007864874 -0.64375,40.23766191411432,3.4681405690771245,46.49664700000009,0.07035517614575362 -0.645,40.0458855553,3.5252732826065003,46.2771638,0.03649060318356141 -0.64625,39.86420722577365,3.555307871655283,45.9406064,0.08120558649686586 -0.6475,39.68070538823287,3.5811384755503637,45.5456858,0.10253916119073671 -0.64875,39.49337629995167,3.6029849159507394,45.1888554,0.08793114185713717 -0.65,39.301713343460925,3.62017949191709,44.939619,0.0880368085490384 -0.65125,39.10059966699429,3.6296121419825402,44.7935386,0.11541201406829363 -0.6525,38.85438478374712,3.6286624153091864,44.669655,0.11673048069163355 -0.65375,38.477545109406385,3.662953594201124,44.47275040000034,0.08126548899016263 -0.655,38.19511764440058,3.709813380007319,44.161201999999996,0.030271518387752095 -0.65625,37.936491436410016,3.7328918431737264,43.7636488,0.035768448186915075 -0.6575,37.64039503043442,3.7622580814297097,43.358565200000555,0.05129368088468099 -0.65875,37.289807424221046,3.796985387252896,43.024677000000004,0.04560513572504832 -0.66,36.866314343842724,3.844732462241555,42.7958618,0.06645087642913391 -0.66125,36.3181621985641,3.9727594359502945,42.6382518,0.10637159075946928 -0.6625,35.89274998598196,4.063846739697887,42.476560600000006,0.12764271535931915 -0.66375,35.44590638877168,3.938723646867663,42.244094399999994,0.10323048938806664 -0.665,34.975053396806004,3.974422352328863,41.9068558,0.06138822869003497 -0.66625,34.54687896649305,4.099469637086444,41.5243026,0.032646989475293736 -0.6675,34.09235926141283,4.270121781680986,41.157103,0.05180632030457248 -0.66875,33.6916692865044,4.398648774867686,40.8372854,0.05684435725118242 -0.67,33.37336146261658,4.448273327074011,40.5964368,0.06354315030906178 -0.67125,33.083137672776324,4.472066865834192,40.41197720000025,0.10181578242928373 -0.6725,32.79142725875864,4.478785061592661,40.237573399999995,0.13272966173881323 -0.67375,32.47656529540473,4.462286659640304,40.022062999999996,0.1284642285988595 -0.675,32.024733179375666,4.295102520071947,39.738690200000164,0.09941806971913578 -0.67625,31.68199835040444,4.304126110169466,39.394461,0.08092188049285465 -0.6775,31.359669353528762,4.355466582827333,39.02438239999999,0.0874291892808119 -0.67875,31.02492037138042,4.385670949577754,38.6765772,0.08546784099121663 -0.68,30.668197248978743,4.373150524467015,38.385746,0.06604947174277764 -0.68125,30.292579745692645,4.364789700085291,38.157751000000005,0.09278457571978224 -0.6825,29.957471420573274,4.403978600340495,37.948442799999995,0.12539295659924393 -0.68375,29.70304179049445,4.495947634515349,37.6532894,0.10037061887724051 -0.685,29.491202092599792,4.592740016561564,37.254425400000585,0.07160917562226973 -0.68625,29.268223852290642,4.646807773297114,36.869242199999995,0.08727275155052663 -0.6875,29.03683776252692,4.681098584305772,36.528023000000005,0.09540864611763503 -0.68875,28.801080007575987,4.702403970325195,36.18078220000051,0.08013213394578127 -0.69,28.549525429101248,4.710559836585207,35.8163446,0.06613390972337958 -0.69125,28.25935808847096,4.710845541632994,35.4119192,0.06717460265383098 -0.6925,27.943519472425283,4.7048892598577305,34.9723216,0.06625811667109333 -0.69375,27.604777125050603,4.703131274292944,34.6121588,0.12014000967079888 -0.695,27.282826078464655,4.705947789664044,34.367287399999995,0.12247419301755032 -0.69625,26.954123821773774,4.70150990289849,34.1100936,0.07882024095560704 -0.6975,26.527772700161872,4.738455444349218,33.7727956,0.030490047479465706 -0.69875,26.083122636483637,4.800242833053649,33.3607404,0.09385434685884303 -0.7,25.699984387354913,4.8221334380678424,32.8843356,0.18491970536235394 -0.70125,25.339911432873524,4.856700179787537,32.413056000000005,0.17167042716932882 -0.7025,24.989055454378985,4.927161481629462,32.06528600000041,0.07963166806314904 -0.70375,24.63046793705413,5.07608765550731,31.839301,0.041458569445893205 -0.705,24.410676584702088,5.583711326918018,31.620646599999997,0.055486831003401016 -0.70625,23.32335494356236,4.943382973948352,31.33590540000018,0.0672717942660809 -0.7075,22.727834246378247,5.060379976314911,30.9388628,0.08591798878407293 -0.70875,22.216779979981226,5.279453407936839,30.435487799999997,0.11836266530118353 -0.71,21.852053985811498,5.364433645039771,29.9484484,0.10766236632547191 -0.71125,21.549515041824993,5.417318242041772,29.589211800000005,0.09677008777096403 -0.7125,21.30416873750106,5.457432902575538,29.340606199999996,0.11765457825856157 -0.71375,21.08402067769125,5.482783072632026,29.120840000000005,0.14264449159185885 -0.715,20.870361131370835,5.498553438111248,28.818751,0.1780840735256808 -0.71625,20.467696158168717,5.069469741084413,28.363500000000727,0.18966352448349272 -0.7175,20.073230049030975,4.713453023282028,27.800297,0.1561995019502302 -0.71875,19.762048525156505,4.5571358108843185,27.250787000000003,0.1052531620783907 -0.72,19.478301780077008,4.464647780171309,26.78790760000063,0.1191852205530801 -0.72125,19.203435060118817,4.403672752532287,26.325235199999998,0.11017245301435401 -0.7225,18.921745029920746,4.345070520969502,25.986235799999996,0.16252509799781675 -0.72375,18.636276487590354,4.2846745180375665,25.7900166,0.1457447994365492 -0.725,18.354296019247002,4.22702581035411,25.3783812,0.13284477105516795 -0.72625,18.07269339661529,4.179229125940769,24.890815799999995,0.14219762591091403 -0.7275,17.76980014812224,4.136613542253633,24.443278599999996,0.09748502455403026 -0.72875,17.38856519965929,4.093979965283361,24.018570599999997,0.0421844683420333 -0.73,16.872827367812416,4.137392832351108,23.593398,0.0790929375513397 -0.73125,16.516759560318885,4.184251448767012,23.139791600000002,0.09417880000456615 -0.7325,16.185194569306926,4.241435610329623,22.644808400000002,0.07676639596398965 -0.73375,15.862330785339218,4.288109813956939,22.153797400000663,0.06855087594479985 -0.735,15.489737776996426,4.205249353000097,21.770057,0.09987161026287712 -0.73625,15.072997756297587,4.021546097709683,21.5226144,0.13440373536773373 -0.7375,14.677888006375921,3.8850689437449826,21.321230000000096,0.09619740647482318 -0.73875,14.350220705447642,3.859505351170189,21.064484400000005,0.05377979654386952 -0.74,14.077963501783751,3.9131942450737798,20.689561,0.09147499014484757 -0.74125,13.821489378112938,3.9795155943595075,20.143875399999995,0.15657789884846499 -0.7425,13.568966514432239,4.0312225048753625,19.4752262,0.16457439459922119 -0.74375,13.309694204825846,4.0366809785294695,18.828024,0.10604064146118738 -0.745,13.021172054978251,3.972160457335078,18.3071482,0.040362552715357686 -0.74625,12.641732966332901,3.8035572832640416,18.0268396,0.2025834567833703 -0.7475,12.348212634829864,3.8387640355600454,17.873130600000234,0.16582335184269797 -0.74875,12.225437896607405,4.004204540381484,17.625394800000002,0.1103162573295512 -0.75,12.110100075993335,4.201633532161947,17.239628999999997,0.07310070803008696 -0.75125,11.763145463851727,3.9531825536392424,16.78393240000065,0.03259015870321163 -0.7525,11.179751058101509,3.531888018467112,16.3591268,0.034715804948178636 -0.75375,10.842287558223788,3.5033882710279096,15.977242999999998,0.04831998825537875 -0.755,10.62647245852775,3.5062293656378563,15.566594599999998,0.07466333115927816 -0.75625,10.389198036517554,3.4949120212365377,15.0861132,0.08730540459616454 -0.7575,10.171581952616718,3.4823013234120737,14.5144756,0.10063498758533258 -0.75875,9.978720450524454,3.44683019433488,13.8889046,0.09638613522338149 -0.76,9.791953759358334,3.3934083457480053,13.3430456,0.04842734797921526 -0.76125,9.610605805835041,3.341509757601997,12.983209800000001,0.05629064643171151 -0.7625,9.428183079282682,3.3011664982674325,12.743388200000002,0.09155941021107519 -0.76375,9.163945105360174,3.2367157462614826,12.505842600000001,0.08355600294892043 -0.765,8.82494057444775,3.1783188589583933,12.305216600000293,0.18292174903418754 -0.76625,8.555100483581892,3.097834883690558,12.006708399999999,0.14409464365929794 -0.7675,8.295710506529078,3.006940613304856,11.5458622,0.046320097848558645 -0.76875,8.053606033156775,2.8956189672740043,10.991992800000295,0.08045575288155699 -0.77,7.7788794991370835,2.7230512165653664,10.4661768,0.10612071185777007 -0.77125,7.5239592885108415,2.6040218424018735,10.00227296,0.09537720961489167 -0.7725,7.334318806662716,2.627153032221651,9.55781198,0.06883841329462789 -0.77375,7.167127888443496,2.722424302075233,9.09056406,0.09010196524603664 -0.775,7.002662798715668,2.8413841169340017,8.659880219999998,0.08229029266746478 -0.77625,6.8281928129473854,2.918932754394116,8.271748980000002,0.07596389745087462 -0.7775,6.647031802061967,2.926985292379647,7.934068579999999,0.08805579775220365 -0.77875,6.472449480081487,2.856181669748956,7.690591160000314,0.07241449081810095 -0.78,6.302715257370998,2.7248107326362594,7.443743959999999,0.08486530167372902 -0.78125,6.052367784161738,2.4763014481271663,7.117965719999999,0.05284660068118844 -0.7825,5.885615374852905,2.370961821834715,6.689906540000668,0.0641444059147 -0.78375,5.763735136067297,2.3174051410365015,6.17192492,0.062174305398347764 -0.785,5.65257807672975,2.2754297289599084,5.611220319999999,0.10729928690003931 -0.78625,5.547321141884403,2.241704820459966,5.08869782,0.1354669899914811 -0.7875,5.441766022366353,2.2111981923260076,4.698203699999999,0.08954382381942927 -0.78875,5.332408756255337,2.1791679451276758,4.38860586,0.11246478523010212 -0.79,5.213075468992834,2.1417434912020994,4.13658242,0.10043680388645894 -0.79125,5.0715559475737075,2.0877080658565794,3.8440892,0.11869780369627758 -0.7925,4.874109012429557,2.008155302826833,3.47213796,0.0977903592892111 -0.79375,4.708351977289518,1.9534942870615946,3.1325884000000004,0.06577904707933213 -0.795,4.579893014400917,1.8796532615508545,2.8154663399999995,0.07735857866699719 -0.79625,4.444058217572761,1.7773012898918008,2.508777200000432,0.0691032470573858 -0.7975,4.302290451143784,1.6550419079124852,2.1901557,0.05365492559318294 -0.79875,4.15913081259092,1.5227744730742228,1.8172447600000001,0.05347043137284379 -0.8,4.086497916288667,1.2617517456697933,1.3949701400002408,0.04762249524474264 -0.80125,3.9520382494694584,1.148514726401168,0.9531367379999999,0.03683326882589327 -0.8025,3.8181456464750787,1.0612932596152482,0.536382906,0.10607105202136552 -0.80375,3.6971131157605472,1.0075347735842914,0.201564502,0.09388030360863092 -0.805,3.6005425441912497,0.9843192495312184,0.0893672774,0.017520922933056994 -0.80625,3.525557642944259,0.972965102858092,0.1083871142,0.05046259521815792 -0.8075,3.458894269264071,0.9658441013055807,0.19996811340000004,0.07750834544247609 -0.80875,3.3919127004502823,0.9642559284097084,0.1174348462,0.03806541279560861 -0.81,3.3236681037806464,0.9678880459976572,0.10742563620001197,0.043063265066227964 -0.81125,3.253570945724031,0.9763532189847797,0.11972661740000001,0.04522853392572988 -0.8125,3.1820014555364167,0.9889918581230688,0.19934300400000002,0.08242913862904325 -0.81375,3.109238281771427,1.005309704734328,0.09661997500010451,0.03347693657993816 -0.815,3.0070718301598327,1.028987981826106,0.10801980960000002,0.04081635900015633 -0.81625,2.8510389567607217,1.123981850429556,0.1665636342,0.07442618918241561 -0.8175,2.7026218973324307,1.279884987010931,0.1435203204,0.1037491541623342 -0.81875,2.6099573594612813,1.3573071183147711,0.1113652348,0.031094089455331233 -0.82,2.5537055278911667,1.3626274057175114,0.1675352054,0.08193848527904815 -0.82125,2.504118704549866,1.3549696220135286,0.12328992759999999,0.05134321454185837 -0.8225,2.455666638740252,1.3388895626801562,0.1418925278,0.045498678224055636 -0.82375,2.4056469476450673,1.3107356134432926,0.1562665234,0.07034509660606073 -0.825,2.355261801524416,1.2742384002714011,0.1035796122,0.033738825391067574 -0.82625,2.3605036113981206,1.224017718655804,0.1876220548,0.0986606857687591 -0.8275,2.4190165176492453,1.2575556936637329,0.14203307740013232,0.0694466192624118 -0.82875,2.41381724209348,1.2916659416031628,0.1063249042,0.04191099233175183 -0.83,2.359560108896833,1.2641916334104888,0.1752333734,0.07858025932161951 -0.83125,2.297053313430404,1.2277207246596546,0.14786539340003851,0.06988667865375242 -0.8325,2.230839561416159,1.1893411194662742,0.11896877879999998,0.03576325357812601 -0.83375,2.162350705616669,1.1496485289507508,0.148512402,0.02421073312788091 -0.835,2.0927692809354173,1.1082673330621664,0.16370059939999998,0.06383502811721986 -0.83625,2.01746628098554,1.0601388834314378,0.1350265688,0.06790718900975001 -0.8375,1.9214321215490318,1.0056495734109079,0.13413543320000001,0.0482811410341372 -0.83875,1.7844127411916808,0.9907178356080678,0.1671461442,0.06507024567683307 -0.84,1.6380781523130838,1.0501452738020316,0.13483705880000002,0.06405510718614818 -0.84125,1.5680766660046974,1.0063530896302089,0.14859961139989952,0.07274185796249921 -0.8425,1.498137127700957,0.9806403893531078,0.1704821402,0.06919700254828486 -0.84375,1.4339099049867021,0.973471163265176,0.1094237808,0.034030895257410126 -0.845,1.3810453654466672,0.9727197189794998,0.1661277159998879,0.05984423220964428 -0.84625,1.348070918480732,0.954120367352814,0.1554664574,0.05765267225608549 -0.8475,1.3280459081496252,0.9199226742304464,0.12367085960000002,0.03959963428937801 -0.84875,1.3114170933717697,0.8831317552708111,0.170703294,0.03415587124553815 -0.85,1.296497222770084,0.845759375316808,0.1300683208,0.047857479324113474 -0.85125,1.2825676958363783,0.8097681743984787,0.1538428594,0.059482481542925666 -0.8525,1.2695007449812994,0.7808485174400578,0.1440434568,0.04145144863821167 -0.85375,1.256994308049769,0.762155809416101,0.1212961854,0.029015166528094317 -0.855,1.2447463259176674,0.7558494454640532,0.1589059714,0.06054037884979438 -0.85625,1.2402827097399538,0.7597799473181505,0.1329350026,0.05968687800094225 -0.8575,1.2456011031433754,0.7807734902615037,0.139330292,0.027633834041913545 -0.85875,1.2557603026547932,0.8259991536729174,0.12279629860010104,0.03318573906538637 -0.86,1.2674193781274241,0.8923181697699084,0.1415525734,0.06433537479863584 -0.86125,1.2762655215795984,0.9651062199483263,0.14366720819999998,0.06247618687062032 -0.8625,1.277745456751629,1.0285186658260774,0.09547815739998379,0.041014493167181046 -0.86375,1.2679659990912193,1.0685822628883062,0.14208894660000002,0.060272685890282236 -0.865,1.4384261314329165,1.2075365354228365,0.1287267366,0.05395826845106889 -0.86625,1.3521170751922558,1.1326422104449867,0.099207605,0.04119038086927331 -0.8675,1.22032278560446,1.0674785606811794,0.1538339432,0.05505038548183637 -0.86875,1.1019415975716855,1.083982861966829,0.10827653820000001,0.03520300374249896 -0.87,1.1638203554352502,1.0447382330015447,0.0989341944,0.05140632009881279 -0.87125,1.1446233914662565,1.019067046562568,0.1599193346,0.07274928298973189 -0.8725,1.1546251268367622,0.9815782752767995,0.09592906160006512,0.04477516139875839 -0.87375,1.116820709759718,0.9848853577730845,0.1172993998,0.032532983084713446 -0.875,1.0811265131651668,0.9897118802801104,0.14353813040000002,0.051794968711638974 -0.87625,1.0532068017705616,0.9883678599850293,0.0999246669999831,0.04986633712270358 -0.8775,1.033494151469805,0.9807757852099611,0.29581262119999996,0.3631387750517858 -0.87875,1.0184505894712468,0.9718304321442414,0.589533306,0.8360209593205418 -0.88,1.0071782927931903,0.9631610160860059,0.6297650050000001,1.2144288278016457 -0.88125,1.0008748789418545,0.9527105925528514,0.7220454048,1.3539439697732296 -0.8825,1.0017753837284202,0.9372567112503734,0.062358084999999994,0.03155719936994119 -0.88375,1.0124674688458495,0.9114184496619224,0.0901481922,0.05953246095425337 -0.885,1.0249675255844999,0.8758675739083833,0.9339586514,1.2376726873899127 -0.88625,1.0345291051188878,0.83480668255321,0.2491243006,0.43636216668578887 -0.8875,1.0415703074831248,0.7985727386180161,0.0491613504,0.001488720193237232 -0.88875,1.0469113664882488,0.7733951015514046,0.0487622058,0.0014324786679405376 -0.89,1.049695146476922,0.7601692748360177,0.6818418948010367,0.8865181472841652 -0.89125,1.0488422529723744,0.7556428632576838,0.0502220914,0.0013678983902738532 -0.8925,1.044383011920125,0.7563849289314049,0.7266455646,0.9558903781777257 -0.89375,1.032475858177629,0.7573287615571892,0.2645703528000002,0.4758478482984525 -0.895,1.007342311401,0.7531046519366562,0.41346581880000005,0.5796009853524198 -0.89625,0.969015317008142,0.7406214639070056,0.5654452316,0.6904136826294495 -0.8975,0.9277503992534926,0.7247824126172167,0.28871728059999996,0.522784173047636 -0.89875,0.8898862346835394,0.702754285103582,0.0915602888,0.08465045711167543 -0.9,0.8537732541919164,0.663816543319716,0.3852685736,0.6265049423804819 -0.90125,0.8107941752864306,0.6101418888174721,0.48467881439999994,0.3974715924772413 -0.9025,0.7635320441811669,0.5569855657317816,0.1960274836,0.2063192998036411 -0.90375,0.7151470405587115,0.516517093210556,0.27702088199936553,0.2799059726407602 -0.905,0.6687993441010827,0.4978764326017586,0.4660830538,0.37070571113126743 -0.90625,0.6290420789125978,0.5014189348190735,0.1622921132,0.17390057728966066 -0.9075,0.5985453887344344,0.519274277033356,0.1935478357998466,0.1570982217865066 -0.90875,0.5796498318189116,0.5422237611583782,0.19071710079999998,0.1520259709835539 -0.91,0.5675981185760826,0.5723910319650903,0.2681609328,0.20500345691316058 -0.91125,0.5592324707189659,0.6111016993605036,0.3465021216,0.2845906965097666 -0.9125,0.555971771186884,0.6533646215692124,0.2705587496,0.1875262396747512 -0.91375,0.581276043365906,0.6829208018447395,0.20434782540000002,0.16380003426644976 -0.915,0.6398040828173334,0.731132985698588,0.24360911000000002,0.11847705185908282 -0.91625,0.9336527366094081,0.9989473845624811,0.2501103334,0.1156157568357871 -0.9175,0.9308912870352489,1.0404232296389058,0.32892030980000003,0.2700059687058818 -0.91875,0.9073042805399667,1.0671411646768645,0.333793336,0.17684458546070073 -0.92,0.982612692030166,1.0424450991000183,0.15329429519999999,0.0963905159367002 -0.92125,1.0908832659160983,1.0643552498593298,0.31974037799968147,0.09776538055320676 -0.9225,1.1541302833770042,1.0958005283314758,0.35462171800000003,0.14776470668768293 -0.92375,1.1880977737018188,1.069497156414092,0.1864268126,0.09746735587429792 -0.925,1.2371095287210834,1.0176458086780948,0.2511564559999124,0.07611487943711 -0.92625,1.2896183783651145,0.9708504763034773,0.30146440399999996,0.07361472539939974 -0.9275,1.324694622813331,0.9391698669339197,0.26736820400000005,0.05946357524914459 -0.92875,1.3199388823022267,0.9055326458898635,0.24588289,0.06288573627624788 -0.93,1.258385819036995,0.8802605288322859,0.29862558000000006,0.05377451982516673 -0.93125,1.1837403405268951,0.8810116506550214,0.28198466,0.055163995468887575 -0.9325,1.1410316496412114,0.842011205136271,0.27639863,0.023825659285928474 -0.93375,1.103855495403506,0.7827832633155198,0.258036048,0.03762494072684195 -0.935,1.0456783336866458,0.7157249955732683,0.33040858599996914,0.05086297155281428 -0.93625,0.9640882996022319,0.6637272633646444,0.24983203199999998,0.040019177515212265 -0.9375,0.8852799445984166,0.6604761783281168,0.28811503,0.020942801405745594 -0.93875,0.8306736040432802,0.6782412420657967,0.31004290200001966,0.020010405135632073 -0.94,0.8023614388974312,0.6935291321921505,0.274304706,0.016961400573815535 -0.94125,0.7856167463328658,0.7198960608854013,0.30460009600000004,0.05241552771885521 -0.9425,0.7756098078200947,0.7542104587450381,0.313955376,0.0364268356856553 -0.94375,0.7715377531664057,0.7888547630910911,0.28557161799999997,0.03475850354203299 -0.945,0.777590963853418,0.8116858587965394,0.310431684,0.01868475796822318 -0.94625,0.8669784534745647,0.79773007927214,0.32001675,0.05420361850433372 -0.9475,0.9055717843993629,0.816197967143252,0.30770838200000006,0.0427023842742934 -0.94875,0.9377953387115717,0.830695628643396,0.31014221,0.025391735129415637 -0.95,0.962308950946,0.8422447247671442,0.337441292,0.055726045053084206 -0.95125,0.9764727376422163,0.8489499490611242,0.314802612,0.03804564285491204 -0.9525,0.9803515947469837,0.8524751666298387,0.3173691379999631,0.02884802234657125 -0.95375,0.9708877401978723,0.8503317014657168,0.33961396,0.030152565539986815 -0.955,0.9445426075795006,0.8388866677015338,0.329283228,0.02260160515304876 -0.95625,0.8951797376790012,0.8047558382160854,0.33998647200003107,0.012834248666475546 -0.9575,0.821881412057,0.732244626968361,0.32284788,0.036172921364396336 -0.95875,0.7392560275880551,0.6552271181386558,0.35899696600000003,0.028092095325889806 -0.96,0.6630686706463333,0.6086274702736626,0.35281292200000003,0.016831774198030065 -0.96125,0.5873299391056296,0.56449893660621,0.34256527600000003,0.025876042300144755 -0.9625,0.5201252282517705,0.5255502671421785,0.375529528,0.03469271120529526 -0.96375,0.4755221774711678,0.5010714778367727,0.323256268,0.03135257170485174 -0.965,0.4532432788194174,0.5002033249847297,0.3671519,0.03159433295426728 -0.96625,0.4590733266322122,0.5105215195706466,0.39874928400007426,0.06537739423079265 -0.9675,0.4800377552366956,0.5294232331172715,0.32411160400000005,0.05577149198796712 -0.96875,0.5047161435815279,0.556943885683371,0.39738312200000003,0.04484326048860095 -0.97,0.5361642778029089,0.5856420686867152,0.37227583600008907,0.04653178816927454 -0.97125,0.5742885091226833,0.6153048466538067,0.341016406,0.039654210794872476 -0.9725,0.6117958140083796,0.6508492360201312,0.42474454799999994,0.034189184158915954 -0.97375,0.646527933474499,0.6901411633028889,0.384345006,0.029929924961613754 -0.975,0.6769708607333333,0.7315643828773815,0.349846216,0.05484699642760421 -0.97625,0.7040922435179594,0.7755387795861285,0.412932454,0.04323771700466076 -0.9775,0.7283779689238262,0.8206344599683658,0.41050328199999997,0.028171065944079386 -0.97875,0.7494369002733965,0.86368315157506,0.42644797,0.020534738492270853 -0.98,0.7673952750180834,0.9010228679317341,0.38407017000000004,0.039855175866586635 -0.98125,0.7817255641500783,0.9268365433866785,0.38188856800000004,0.03832011037887573 -0.9825,0.7931514406763339,0.9400443242811659,0.44744432000000006,0.059710518061650154 -0.98375,0.6118498659177489,0.6096609834647246,0.44078417999999997,0.05667356643850684 -0.985,0.5657780749176665,0.6343205780664968,0.3738067,0.044765955344749433 -0.98625,0.5953950399034461,0.6364995033073041,0.43486031399999997,0.04318592503875574 -0.9875,0.6338230991455236,0.6416857170887561,0.49533143000000024,0.042140169668693536 -0.98875,0.6805889665883255,0.6519503693031866,0.416354748,0.054945439334735204 -0.99,0.7388937260976666,0.66434450778828,0.42728880599999997,0.044296927613795396 -0.99125,0.8264138169142803,0.6808775962131473,0.46770330399999993,0.08201287911916476 -0.9925,0.945384141556421,0.7276907320503153,0.4942575960000001,0.03521260636162325 -0.99375,1.0401570675916663,0.7701741135711988,0.42607025600000004,0.07405498790578208 -0.995,1.1338730347517847,0.825666598626471,0.458899204,0.07448530916582767 -0.99625,1.2093488389919218,0.8607827310674769,0.517238946,0.049876913425173273 -0.9975,1.262664737183716,0.8698552001989015,0.46911558400009346,0.0732241523288992 -0.99875,1.303572240816057,0.881641920742597,0.48298549599999996,0.05166588244427583 -1.0,1.3346013369442498,0.9013500206205373,0.5213382980000001,0.08451348283728444 -1.00125,1.3539780288976742,0.9225781234590552,0.5251535739999273,0.04176004598051361 -1.0025,1.3612097453288357,0.9395631524422704,0.528826094,0.09275959419350448 -1.00375,1.3466729106269721,0.9392481140899792,0.466955982,0.06369061845028645 -1.005,1.3062696351408327,0.9225209582738395,0.538605372,0.039670342011059984 -1.00625,1.2583332646042131,0.9108146799691444,0.545707898,0.011348155204200388 -1.0075,1.2277989489469971,0.9046027444262144,0.535716304,0.0767235369031331 -1.00875,1.2191116579670371,0.8929826917449243,0.5145935419999998,0.10127858439073026 -1.01,1.2169747295369169,0.8816963248434982,0.576864454,0.036695017661534504 -1.01125,0.9874967265563429,0.7926364023934914,0.6195579720000001,0.07320387262124711 -1.0125,0.9886136950840488,0.7931379927449875,0.563654546,0.04049431498700441 -1.01375,0.9896681627089929,0.7984887793217166,0.5529757120000001,0.12006930494006625 -1.015,0.9915641951626006,0.8066539222980367,0.6029454059999921,0.06552508125970428 -1.01625,1.0066642911132553,0.8069315441009245,0.558731976,0.1335670198229317 -1.0175,1.0726177913019088,0.7719637577998749,0.629988926,0.052068970031686146 -1.01875,1.1462472226848683,0.7754342399282655,0.644127362000031,0.05265074551632396 -1.02,1.2208392036259168,0.792305814189221,0.572724468,0.07595977111276185 -1.02125,1.3224868538096202,0.7936738831968768,0.662042394,0.03121296013040703 -1.0225,1.4335332951773794,0.8085943190512315,0.64443441,0.03792438710604631 -1.02375,1.540831416608695,0.8399972026902596,0.6526916359999999,0.08270084063754629 -1.025,1.623272890416333,0.8666743821947666,0.608049050000052,0.11117758328243028 -1.02625,1.6526815905804473,0.8698465990438257,0.653197308,0.05489104897014558 -1.0275,1.6393886091775836,0.8891816569619908,0.712710658,0.12518099632573693 -1.02875,1.567024922205077,0.9757456698053817,0.6451426160001632,0.021395901671172567 -1.03,1.5261368858271662,1.0311771932191613,0.652392242,0.03291215858898302 -1.03125,1.449283679319267,0.993795883477251,0.7325424359999999,0.10591394849194334 -1.0325,1.2455468285000506,1.0477785082051883,0.7091781760000642,0.08320686966300042 -1.03375,1.1465913301903659,1.0438200763681862,0.6989657040000001,0.14234041744518589 -1.035,1.0882020088014999,1.0299781408057447,0.686526678,0.09100751991395006 -1.03625,1.071768229111161,0.9568592483643911,0.709908658,0.08994670997038005 -1.0375,1.0627662375086937,0.8787915223531927,0.7697662839999999,0.09105858522932986 -1.03875,1.059479064473047,0.8194731239803923,0.745728014,0.07785753320515926 -1.04,1.0619278839186668,0.7947108236787901,0.783244916,0.05344293521602998 -1.04125,1.0643131865780198,0.806080462843848,0.753784412,0.0664528024134947 -1.0425,1.0397526019060284,0.8371852736341612,0.81018308,0.09668608484639427 -1.04375,1.0067055345106646,0.8819551562133605,0.8167273900000002,0.10549946096818624 -1.045,1.0163270902573331,0.8951670378541726,0.786956116,0.07265104647040557 -1.04625,1.0519923899398005,0.9004509985995762,0.8476757699998231,0.1172363409480813 -1.0475,1.060417080900028,0.8931021885729987,0.902582258,0.04929164914134814 -1.04875,1.025136977612325,0.8534002713801558,0.83541796,0.2270459193400247 -1.05,0.9886178277246667,0.8486490547839098,0.8654392260000862,0.1125231993904934 -1.05125,1.0265574318310913,0.8448107211715916,0.84518857,0.07129890507749859 -1.0525,1.1019733625980523,0.8785276215608764,0.9472540520000001,0.061808687147417336 -1.05375,1.1503506662135237,0.9143088270287073,0.975495818,0.021704317765074303 -1.055,1.1786464374219034,0.9375581753606862,0.980492348,0.025757204280660376 -1.05625,1.2047879441612006,0.9737711937062821,1.0047403400000001,0.07224269646090425 -1.0575,1.226851632620221,1.0241688609506887,1.055614662,0.07357556890158727 -1.05875,1.2392699440041393,1.0712185892107184,1.0152109,0.08022738138329082 -1.06,1.2464432199071782,1.10765850225677,1.0516612099998597,0.1346386555472062 -1.06125,1.259157911059711,1.1320697669393236,1.1369609,0.0977929303374993 -1.0625,1.2779686925187916,1.1480263120092322,1.133040472,0.12877795796131386 -1.06375,1.3019678877133118,1.158964497558761,1.1271842999999468,0.05202987428312585 -1.065,1.3301611011054881,1.1687348258874761,1.28860486,0.21597649051657916 -1.06625,1.3619543025885825,1.1796032894994761,1.2925967999999999,0.1860444433741438 -1.0675,1.4007378237096069,1.1898533525786816,1.097120534,0.3637494680931792 -1.06875,1.4662717772453149,1.1789950436852168,1.191769224,0.19600518750868526 -1.07,1.55936628987467,1.1607885003835097,1.33838012,0.034426901087695985 -1.07125,1.6619128996145038,1.1630837380160883,1.43353716,0.1230277468709112 -1.0725,1.761425716107446,1.1770860597124206,1.43919652,0.06865133768293964 -1.07375,1.8692393786506594,1.1897424282141607,1.5370145599999998,0.13991380046199156 -1.075,1.9186261210963333,1.1911761817171844,1.53423848,0.17827227614273622 -1.07625,1.9457383216419988,1.1760975449715385,1.46155038,0.22673132419213055 -1.0775,1.9814884676277982,1.134129890898825,1.4515914599999555,0.13168051979594947 -1.07875,2.0213646045935714,1.0870685008301884,1.5351411,0.10735289374993578 -1.08,2.0305841703657497,0.9922809901390199,1.6593589799999997,0.04785246600518097 -1.08125,1.8316092493134117,0.6527705628038251,1.7378776199999622,0.03609013788293579 -1.0825,1.8484248952724143,0.7248395091518288,1.8290748000000001,0.11640237828639935 -1.08375,2.0531323011544282,1.213632151079295,1.8294923400000003,0.13946805510393043 -1.085,2.112529659203833,1.5179705088270368,1.7716698000000002,0.09521428971186516 -1.08625,2.0688707056134112,1.5011645838420473,1.7960459200000003,0.12731966948451837 -1.0875,2.01931231533935,1.4495955501979603,1.88554174,0.07196411714898611 -1.08875,1.9643522032605214,1.375457400422816,2.10177418,0.23749254658026003 -1.09,1.93159710228625,1.2979431590592176,2.1531656200000002,0.20652568950280017 -1.09125,1.9381999099479208,1.2761290071298685,2.0007275800002517,0.2963863266381078 -1.0925,1.9008592096396122,1.2649583826437574,1.96810024,0.29026865884826086 -1.09375,1.795195943668725,1.1600298194952274,2.1838349,0.37299324725963867 -1.095,1.6529368607241677,1.01646870050999,2.161039960000148,0.16689293808538697 -1.09625,1.515704837913905,0.9319835594197458,2.09250828,0.27957703296232506 -1.0975,1.4208815472405838,0.91403209352513,2.18249994,0.21372898798803128 -1.09875,1.3713478290094454,0.9149681723711912,2.3280418999999997,0.14101143326721785 -1.1,1.3942401704812502,0.9877150316165783,2.29019124,0.17413365512080942 -1.10125,1.4046807717677512,1.066704977166607,2.2684672400000006,0.24897846115409855 -1.1025,1.3608098389583139,1.0436668558419553,2.32249526,0.12235176653932289 -1.10375,1.3144975080831323,0.99750270858482,2.38454992,0.13328327285783836 -1.105,1.3018088818225835,0.9655546443843429,2.4225599,0.1421478253605381 -1.10625,1.3961151203885853,1.0775316579880203,2.41284114,0.12329669984978515 -1.1075,1.408026115240579,1.1823099066033018,2.4248395400000002,0.14116259192906955 -1.10875,1.4024091994317196,1.250561912018045,2.459268579999939,0.128870798535191 -1.11,1.394444880253667,1.2647656494489654,2.5126411000000006,0.11662405609377931 -1.11125,1.4005799844111493,1.229054088634028,2.5149074,0.13412296434982704 -1.1125,1.4240982127120363,1.1841960441336787,2.6109374199998077,0.07546972418053542 -1.11375,1.4507965934806781,1.1500531910537624,2.6933799,0.06891406482848775 -1.115,1.4760996469224998,1.1343721726356808,2.6585411,0.09877571037671665 -1.11625,1.411711641410814,1.2151086375096545,2.6857867000000004,0.08841664737969317 -1.1175,1.4643153501965145,1.227316287990978,2.85367894,0.09769899361005717 -1.11875,1.517743638257121,1.2463930976893138,2.94202628,0.15855826620017963 -1.12,1.5707810329971033,1.2691245908732933,3.0394554,0.16421546419067848 -1.12125,1.6217417554023583,1.2902536332691752,3.0698352400000006,0.15218693621981164 -1.1225,1.669946548216599,1.3090048683208477,3.0491610600000194,0.18621960014434916 -1.12375,1.7226195243846865,1.336743270843567,3.0521886599999997,0.1669276845812672 -1.125,1.7821470661935,1.381848537126805,3.2544722800000003,0.21095242532934294 -1.12625,1.8294258282089249,1.4066131778863702,3.564090599999703,0.3023548022594539 -1.1275,1.8576797191249115,1.3909492402048043,3.5027258000000003,0.23486652112279643 -1.12875,1.8832994177475284,1.3669731488798011,3.37870012,0.18472359812960282 -1.13,1.9118018315449994,1.3482001359079683,3.5643957800000003,0.2953327964689952 -1.13125,1.9443660177282422,1.3382644594807995,3.6804213600000004,0.18073035913346988 -1.1325,2.0246647580595916,1.386725483409845,3.8410907799999996,0.1716981330447045 -1.13375,2.1321374890478846,1.5363517461568286,3.89572766,0.17068948734671086 -1.135,2.1481670411865,1.5436613267606216,3.89109982,0.19339755411914322 -1.13625,2.147845982086786,1.5112974076799617,4.16222818,0.11749652105108047 -1.1375,2.147917712037993,1.4737422595206304,4.54941958,0.390290083394636 -1.13875,2.149005139124529,1.4325428284141914,4.01330472,0.11803005990817349 -1.14,2.1517311714306495,1.3893310492039381,4.05810058,0.4351125601700404 -1.14125,2.173674498043983,1.3170389482759994,4.204753200000001,0.2003449456648582 -1.1425,2.2229374252488783,1.2099466993155905,4.493447720000001,0.4067026144113004 -1.14375,2.279343858184148,1.1185735608617238,4.807754739999886,0.7036026573803017 -1.145,2.3299774174766665,1.0735874874618763,4.17061662,0.24245231837725742 -1.14625,2.388804795455585,1.071739629013105,4.060575500000001,0.21903709443189065 -1.1475,2.4391413037039436,1.095854062036026,4.309259620000001,0.4005253836290742 -1.14875,2.476451123018934,1.117133987245256,4.5142051,0.3253485286102889 -1.15,2.516277621823093,1.1358440369685172,4.5450696,0.3084094895794957 -1.15125,2.5859950849529483,1.0950418083512299,4.41285386,0.16349410545139853 -1.1525,2.6945855130581204,1.0080789496636757,4.47427316,0.202368869513898 -1.15375,2.8170634040146765,0.9648155560465977,4.632442659999708,0.1618572439249398 -1.155,2.9209386872841754,0.9946617634208407,5.00306102,0.6581998944443376 -1.15625,2.8847362054619805,1.2018630113340574,5.08797456,0.502598267117499 -1.1575,3.048659982846885,1.1626969484270875,4.986693299999894,0.4007581373666178 -1.15875,3.3057109829629,1.238640516188959,5.1255029,0.4116465302911408 -1.16,3.401744439451004,1.3158010047190318,5.0642456000000005,0.32135059621676454 -1.16125,3.5717940610974446,1.367379143153897,5.220215380000001,0.25343399044767445 -1.1625,3.8271201180586227,1.578283011320021,5.38497608,0.17123288137551723 -1.16375,3.780997613019899,1.5208548497466639,5.57952752,0.12587802483190608 -1.165,3.7444008355107496,1.5528613478606477,5.79034086,0.1509491608305359 -1.16625,3.7830416323967953,1.6044972365985495,5.868224580000001,0.10868417373772492 -1.1675,3.8460417385500247,1.646851630190114,6.04796752,0.058038248118607215 -1.16875,3.9284866127280114,1.686392381026912,6.17891866,0.05683873610697179 -1.17,4.037036947432835,1.7373781787650233,6.2627054,0.09735729757190785 -1.17125,4.160194958592686,1.8012368612321354,6.356841599999845,0.08671042084817747 -1.1725,4.286211717437639,1.8559806647900474,6.49001782,0.10091122312922861 -1.17375,4.404128275885065,1.8746771173657508,6.563233219999999,0.13351366930614994 -1.175,4.50994442391675,1.8788133804356961,6.606089440000001,0.18008093487765645 -1.17625,4.6051918453328655,1.8872610227002757,6.6897873599999995,0.16750120706654031 -1.1775,4.700203856946926,1.9001987473451025,6.75437362,0.16720948255579587 -1.17875,4.797454643829581,1.9175916714232375,6.818197260000001,0.15269063822914297 -1.18,4.895969987257497,1.9393002001491404,6.890408840000001,0.09331772462310153 -1.18125,4.992850362926189,1.9620172129639404,6.932023899999953,0.08315808164561507 -1.1825,5.086273959466005,1.9857811434094181,7.107448100000001,0.4043687850051238 -1.18375,5.174778275210201,2.009251613032982,7.267415420000001,0.5807514926325867 -1.185,5.261310938644837,2.034689205218421,7.213210539999844,0.4070415020267266 -1.18625,5.348722468706114,2.0629070466047725,7.4816655,0.45514575531052126 -1.1875,5.4357582706104575,2.09297184193496,7.301577499999999,0.16528102109809836 -1.18875,5.843064757294367,1.3698281109375863,7.395869819999699,0.17562159920669373 -1.19,6.112043843454267,1.2637297982798505,7.5250581,0.10391888548173041 -1.19125,6.058100344947957,1.5262572287203389,7.66276084,0.10250136287819787 -1.1925,6.143020067688453,1.5257895028343034,7.8818145799999995,0.12023173945870957 -1.19375,6.236097192528194,1.5155933069485938,8.02031174,0.10349452011330373 -1.195,6.347900430331916,1.570952892457254,8.17866706,0.1520891651553885 -1.19625,6.452580567241696,1.6396877908845433,8.37490232,0.24008328756444522 -1.1975,6.5697195276540485,1.731935177069116,8.384987740000001,0.11352349276527719 -1.19875,6.68994755892264,1.8452321752181315,8.38270606,0.11775752593105476 -1.2,6.809556539542083,1.9593104475027703,8.470225260000001,0.14616679280668726 -1.20125,6.916441716072484,2.0414768868160955,8.54528416,0.14450458713031564 -1.2025,6.9492428657633,2.0612664728621213,8.547957099999996,0.16051297743998427 -1.20375,6.862458145818185,2.1403554198438925,8.557412039999999,0.24466897390254208 -1.205,6.554542486123666,2.804952189499856,8.52892842,0.4047397096712986 -1.20625,6.622403067569448,2.9075645772795378,8.389384600000163,0.20388413753678092 -1.2075,6.926238264867693,2.5541857734160147,8.32780808,0.12682598784967958 -1.20875,7.257413144532567,2.346911388935554,8.531492019999998,0.2667974933299824 -1.21,7.461462559536916,2.3483431045654672,9.13329746,1.4310955259202989 -1.21125,7.588578482498996,2.36620394052514,9.3511625,0.8471414471428542 -1.2125,7.746812396684654,2.3561104807777875,9.586455379999999,1.6288907455843802 -1.21375,7.928002995186236,2.324936406716453,9.57061166,0.5528880908331791 -1.215,8.11438775267275,2.288420603410446,9.264865499999999,0.892568838462222 -1.21625,8.283865131113222,2.2546084886100366,8.93400388000022,0.3622164287501777 -1.2175,8.432733988225253,2.2339518706974513,9.2060397,0.3200408555299079 -1.21875,8.57192843474883,2.232212120734615,9.65247142,0.3095713922210869 -1.22,8.712028047488163,2.235050086440591,9.881967599999735,0.3223102723453171 -1.22125,8.852060442309645,2.2372294660901293,10.2220736,0.12909877562277658 -1.2225,8.985387303724957,2.238977433778425,10.363843600000001,0.07926291728986518 -1.22375,9.1068751457456,2.239398432631933,10.3667422,0.13574914567576482 -1.225,9.213629545378001,2.240146137164283,10.4264884,0.125384015096822 -1.22625,9.301748210285323,2.2395914466040647,10.310807239999999,0.2688271733217977 -1.2275,9.381863683591222,2.2404571584068442,10.451017000000002,0.12408810171607895 -1.22875,9.455505156335485,2.243143430985133,11.127560800000001,0.6944386028553569 -1.23,9.5228718481955,2.247602613011603,11.04857232,0.726631908514285 -1.23125,9.503217071391278,2.3427698612903005,10.955523340000001,1.5047128973314874 -1.2325,9.670625076109165,2.233672216516611,11.51683518,1.8360605206351484 -1.23375,9.867348164395509,2.16404734846597,11.595280400000389,2.5078998284713316 -1.235,10.003562079606155,2.1555532912209405,10.962340860000001,1.4355927632908811 -1.23625,10.067805642215843,2.134464021504178,11.536263780000002,2.392846123379808 -1.2375,10.156389945818844,2.0856525834874238,11.541442000000007,1.5122701726954142 -1.23875,10.26882600108417,2.0263567408755407,11.05686236,1.9292855962467939 -1.24,10.353728234369418,1.9748578412840163,11.341865219999999,1.9480220558243024 -1.24125,10.478079979187955,1.8135989582008556,11.9215542,1.2290971358003808 -1.2425,10.62583635940595,1.6252740718320091,11.981458919999998,2.0699083566363106 -1.24375,10.765225403528433,1.4848999070009428,11.25623148,1.466944587277226 -1.245,10.894488904672889,1.3844634845488415,11.23477946,1.4427252322774415 -1.24625,11.026218808610814,1.302307314194056,10.695072880000001,1.2685979941126235 -1.2475,11.156825502881446,1.2437602316488732,10.504810919999942,0.4908862354063834 -1.24875,11.282494216979588,1.2082640875041333,10.7382746,0.250241115139579 -1.25,11.525394998838706,1.147109920663804,10.7477118,0.3650847378516388 +0.0,11.525394998838706,1.147109920663804,10.5630536,0.29406958868403965 +0.00125,11.556536049750768,1.1709330987081792,10.733376800000006,0.3704221422125279 +0.0025,11.39114432781078,1.703121627685561,10.6718468,0.2668707953583536 +0.00375,11.550298915999477,1.597487808580788,10.740924399999999,0.2571430090500228 +0.005,11.78141707300275,1.348174055030013,10.987207999999999,0.3749048262239363 +0.00625,11.979029052755964,1.2284317156669287,11.178224400000001,0.19296490433962307 +0.0075,12.139913989218982,1.221742952277128,11.2714088,0.31332155486129626 +0.00875,12.306751796332405,1.2455839638134134,11.451442199999999,0.458687543991223 +0.01,12.475254849155917,1.2927416890978451,12.055632,1.3143955772873324 +0.01125,12.632950194908496,1.354839686636493,12.0684206,0.9708752934323235 +0.0125,12.771598565058648,1.4124114456869772,12.1944854,1.395853113510623 +0.01375,12.882895473051157,1.4451955899223845,12.0276598,0.45300946903205036 +0.015,12.9689318105045,1.4529074984114583,13.355500799996463,2.177343737374807 +0.01625,13.044686901758176,1.4533946503083013,15.2640996,4.29574314895395 +0.0175,13.118060831749503,1.4527568613242638,13.680638400000001,1.5594425071827112 +0.01875,13.18741817296263,1.4505075116161552,12.07600940000097,1.8537567898444263 +0.02,13.198945482125582,1.3938836415760356,12.2989062,1.3167526667756175 +0.02125,13.172579914842833,1.3536455030874701,12.693306000000002,1.9460949524116238 +0.0225,13.222793075864892,1.3436429531962009,12.499474000000003,1.9058145424639303 +0.02375,13.265766329752736,1.3233420853395834,12.8962622,2.416583901022826 +0.025,13.301531884295,1.2905931895680571,11.7659214,0.5432691264656961 +0.02625,13.327739001053759,1.2389855111814787,13.290650399999999,0.47425443605547823 +0.0275,13.345255249888583,1.1709338609267388,13.806833000000001,1.629690019374697 +0.02875,13.36358412132691,1.0983364576766745,12.213384000001392,1.9062530763156729 +0.03,13.419945752955167,1.0315974412954492,12.9219472,1.471118510965449 +0.03125,13.515872626931376,1.027948702086835,13.325018199999999,1.1248517257093043 +0.0325,13.530090639119491,0.9819999450027478,12.852048800000594,1.0156552468086983 +0.03375,13.546028299911514,0.9412212187767868,12.542727600000001,0.8038481217200172 +0.035,13.568301620815582,0.9192949298878015,12.096616999999998,0.8423253588801065 +0.03625,13.60303136458217,0.9261662328564486,12.2511494,0.5694152018846181 +0.0375,13.671482095870829,0.9687222191624648,13.172041400000001,1.4031354226357842 +0.03875,13.763584152228319,1.0664751584592451,12.965228199999999,1.3667951654519046 +0.04,13.84110675747833,1.1799007981555738,12.465530399999999,0.7750528032452372 +0.04125,13.908539501106441,1.293590781373662,13.029467399999998,1.3411040221466042 +0.0425,13.973411508863508,1.407886681139084,13.283776600000001,1.7549914597160585 +0.04375,14.024684464949926,1.4968645719648543,13.2511508,1.9697090887363797 +0.045,13.993760016693086,1.4836340386693208,13.1265526,1.3701541091141172 +0.04625,13.932453456577226,1.4424402056131176,13.4195166,0.6225647733250735 +0.0475,13.890547437118807,1.4051800803774834,14.477061800000001,1.5888257001794441 +0.04875,13.866578488955161,1.4002555612316834,15.6089664,2.3822422377862416 +0.05,13.851091710550834,1.4255917360274595,16.029777400000906,2.3638413010788817 +0.05125,13.842668495917104,1.4272833780186265,14.801082200000002,1.484295224562385 +0.0525,13.844330066608913,1.4208024506050487,15.628214200000002,1.8301861808827544 +0.05375,13.841049276756166,1.4024002214436582,17.3608072,1.8919941769902997 +0.055,13.830215664302584,1.3606986313510068,16.7805682,2.7077163142875023 +0.05625,13.826285402465304,1.3124885751360116,15.711144799999996,2.1656162823549097 +0.0575,13.838366548341368,1.277806782922273,15.9008306,1.5679212853878541 +0.05875,13.861734512023757,1.250280846468323,16.7088276,2.609829104864589 +0.06,13.968784261253168,1.1328806775584115,18.187570999999693,2.094687654760611 +0.06125,14.044556273008347,1.0707432282513074,15.409381999999999,2.099676153999707 +0.0625,14.06569194510721,1.0262948762562445,14.1766716,1.1150362392556123 +0.06375,14.084004238748756,0.9791515458418115,15.493626799998804,2.6265621377544415 +0.065,14.108064095009498,0.9202587700881542,15.2141444,2.723528432244889 +0.06625,14.146933636078446,0.8121869561694578,14.766280999999998,2.1036718169472155 +0.0675,14.248840257806954,0.7574310294539854,15.439164799999997,1.220097170682196 +0.06875,14.371376382051965,0.819186939989948,16.7216038,2.14977760522634 +0.07,14.449455866801499,0.8699004559113191,16.6480492,2.235713585052365 +0.07125,14.488132299133412,0.8617507864932435,16.1437702,1.8470277432190083 +0.0725,14.507454330966425,0.8321633988706341,15.718538599999999,0.842666539489257 +0.07375,14.520266420869099,0.8115163541221139,15.0719606,0.8111593102222896 +0.075,14.543596228715336,0.804613574451162,15.956821600000001,2.4548496542365488 +0.07625,14.572733825643473,0.8475576825383351,16.8226992,3.3184541897704727 +0.0775,14.600409591796774,0.9653449590976451,15.762660200001491,1.677002319503949 +0.07875,14.63965266524805,1.1222572784404423,15.7855714,1.2753001018345833 +0.08,14.604311143999084,1.2614944737859426,16.182229,0.7607628674228923 +0.08125,14.486072029397475,1.3529706790665987,16.65314700000041,1.0467631425818953 +0.0825,14.37455062065863,1.399265911194497,17.5427802,1.9964656650415247 +0.08375,14.254290860633441,1.3981841748270347,19.3702296,3.2790671849768196 +0.085,14.109190983952333,1.386695293780523,18.8979738,2.858083668104505 +0.08625,14.079149136698803,1.2219771493619813,18.9163498,1.9589750038236065 +0.0875,14.205348609243217,0.9997679630803085,18.603458600000824,1.7463931658970133 +0.08875,14.144836586483377,0.972413355725428,17.896194400000002,0.9388154160639358 +0.09,14.096182329532247,0.9512520311123394,17.0546536,1.3317000948088127 +0.09125,14.068208188568391,0.9308905906507043,17.13058539999949,0.8572066332083771 +0.0925,14.062205854089902,0.9133713244414476,17.741294200000002,1.1939630382209063 +0.09375,14.078881950131317,0.9047049146850871,17.627141399999996,0.9719881465245858 +0.095,14.116281827495664,0.9139213394949692,18.341192799997796,2.224656501368769 +0.09625,14.172583691620224,0.947062259762627,19.2698866,1.8343856995522505 +0.0975,14.24027720878167,1.004255061955748,18.39114,1.3710664430072301 +0.09875,14.31515026760779,1.0781490176304955,18.7283188,1.5880629934393975 +0.1,14.39299075672625,1.15766746010347,19.518464400000006,2.2736100596130817 +0.10125,14.47013465529242,1.2272571141879838,20.3714352,1.6169480114203418 +0.1025,14.55127573925857,1.2769357351439197,21.3024164,3.1386321085494084 +0.10375,14.64039773399719,1.294618986076384,20.2471784,1.9345527924543178 +0.105,14.746827681170833,1.2479389906889518,20.359585799999998,2.2560827342462875 +0.10625,14.85463508642203,1.0980660167415746,21.332551,2.021733296500307 +0.1075,14.960400567668087,0.9798304638296474,20.9808984,2.6028693710394495 +0.10875,15.06831296982761,0.917219201713889,21.16488419999913,3.0155889824517437 +0.11,15.171718636448254,0.8788626862660728,21.928500999999997,2.8912846195163833 +0.11125,15.253913441175927,0.843148670938675,21.936105400000002,2.9934468783472346 +0.1125,15.317943077685726,0.822281904674954,21.90402379999973,3.1224655776483314 +0.11375,15.345856289445207,0.8116464348932717,22.1276248,1.2333002076650683 +0.115,15.331963548665664,0.8396306552371637,20.11776,1.307203030506929 +0.11625,15.269183290487424,0.9512771400130003,20.4339856,1.620805457055627 +0.1175,15.21287924687008,1.11078155275331,21.9776108,2.886196536549737 +0.11875,15.203197089934415,1.2292985365853568,21.772114999999694,1.5266292144889857 +0.12,15.22644825758458,1.302331101608236,22.2233074,1.0303310949749602 +0.12125,15.267452528641615,1.3683930277673104,22.672013600000003,2.6632018237603208 +0.1225,15.323312626799327,1.4362036672099345,24.3905351999991,2.7226646171493827 +0.12375,15.397156431683664,1.5026021321140917,22.569039600000004,1.6548369438215955 +0.125,15.495122998835663,1.5604066190556332,21.857040599999998,2.671212311949071 +0.12625,15.62779313871705,1.600579952688946,22.013074400000036,2.1575151078635613 +0.1275,15.769674762713946,1.649723565019996,23.0397964,2.99929771293853 +0.12875,15.908244188066357,1.728972451617944,23.894685,2.796615625750883 +0.13,16.042875036512584,1.8540626018270547,22.654370399999998,1.7979743646510369 +0.13125,16.16286895475806,2.0390055096517976,24.399211799999996,2.531875371300235 +0.1325,16.297773869446885,2.268576552795164,26.639197799999998,2.0496022950629227 +0.13375,16.46797510043117,2.5140458470684863,26.4706648,2.715981625174902 +0.135,16.658836524706167,2.764702899448912,24.8931438,0.6957148123338325 +0.13625,16.88774265910308,2.9785692554307137,27.316056599999996,2.1142083224828627 +0.1375,17.160205854619388,3.1432039523306203,26.597376000000004,2.454571838351447 +0.13875,17.45032784980079,3.2916887879790258,26.9671624,1.261247026144086 +0.14,17.72986938062675,3.439507183334817,27.9347506,2.3976499033334293 +0.14125,17.963251753351262,3.576106336843433,28.1039102,1.5454760159186234 +0.1425,18.160097441741552,3.681036266835612,28.231363599999998,1.5777914470367433 +0.14375,18.342125427017,3.749637796314992,29.38770579999856,0.7906730546841195 +0.145,18.520161766051668,3.8104137681028236,30.491895399999997,1.0021141234199822 +0.14625,18.701845399643386,3.8739644762476315,30.9831322,1.3682412278544667 +0.1475,18.89924763193564,3.928089894879325,31.924708600000002,1.3544192788803633 +0.14875,19.116914107706286,3.9641167275463625,31.806144999999997,0.8974396077177005 +0.15,19.34887180653875,3.98438943032357,32.12683239999922,0.936722692400527 +0.15125,19.585954053895914,3.994567312434933,32.2373106,0.6002191185627964 +0.1525,19.824154515596156,4.0125901575724265,32.2629228,0.7928689966981928 +0.15375,19.961521153080728,4.145515925767436,32.598983799999495,0.8251028317353536 +0.155,20.07256766084225,4.4142194050367936,32.7683724,0.41163990533632827 +0.15625,20.376381549905734,4.478167678386396,32.930267,0.648013154031999 +0.1575,20.709525196996946,4.52409832481901,33.30013359999946,0.4267700746192252 +0.15875,21.06937567436144,4.548805953819452,33.5285022,0.675698981873732 +0.16,21.469380708893667,4.561472091064812,33.6582628,1.3442467341190372 +0.16125,21.915448921662833,4.570033654421888,33.9430218,1.2921526533930496 +0.1625,22.38786646330141,4.583034146569255,33.5749754,1.0519737798088395 +0.16375,22.87384415037127,4.598521667708591,33.282378,0.8480142550149143 +0.165,23.36084836999808,4.611317079923997,33.5790444,0.7020747675453108 +0.16625,23.935500626225235,4.57309803231348,33.428672399999996,0.670892079949003 +0.1675,24.294221802420235,4.586906755227691,32.84238980000001,1.4708504028087632 +0.16875,24.561683304754975,4.554701540974743,33.636300199999994,1.0642637749532309 +0.17,24.779312432608332,4.510044924675835,34.6171662,0.988937818977107 +0.17125,25.00006427367657,4.497569525431957,34.41878799999999,0.9209736486070063 +0.1725,25.26199603582597,4.522184517656694,34.4401968,1.4256305849683493 +0.17375,25.556238083600764,4.562291508940056,34.8574584,0.725204838979855 +0.175,25.859423014508252,4.605820502471582,34.67911340000041,1.053437291643027 +0.17625,26.172858952968824,4.65393874926601,34.5520366,0.8070104330331175 +0.1775,26.50975987086674,4.707014235151529,34.8132626,1.5542107920434414 +0.17875,26.857579520979986,4.761014232910419,34.8596452,0.9942866896371976 +0.18,27.202809432836087,4.732600423599567,34.8912556,1.03549086711873 +0.18125,27.606484207186156,4.560205176665199,36.0751006,0.974980744947458 +0.1825,28.03392045719407,4.287861603579483,35.756259799999995,1.1826096927645653 +0.18375,28.41916489775267,3.932876913947986,36.238187800000006,0.9274729997529321 +0.185,28.786715084185246,3.535196458495313,36.95201680000012,0.6547703616715375 +0.18625,29.139966732395674,3.137781007000377,36.0369918,0.9911053798134689 +0.1875,29.46798758833775,2.781570586337756,35.2119212,1.0632137017588221 +0.18875,29.763859396648513,2.495569723591644,35.18504979999976,0.7723924323764845 +0.19,29.931755652209585,2.3320257388623062,35.194262599999995,0.7371575684548731 +0.19125,30.145825005870055,2.2154873321650874,35.4035798,0.8779377193387347 +0.1925,30.36266477596969,2.0960989385118034,36.02738720000001,0.4093532137625151 +0.19375,30.486550374131863,1.9799481721247927,36.1719626,0.4066825608521942 +0.195,30.64153631289942,1.8954882298360942,36.4817154,0.3955482789171248 +0.19625,30.821722551302088,1.8234587632597334,36.6475144,0.26797612518338215 +0.1975,30.987468820153314,1.7652677235130723,36.9670508,0.9090029800249291 +0.19875,31.14614440607042,1.717903994765187,36.8367444,1.242905919581325 +0.2,31.319315029804667,1.7005025635657243,37.08824919999999,1.1340629446028103 +0.20125,31.500280191132763,1.7089267879639742,37.362914,0.87104859296224 +0.2025,31.677218351052463,1.7086579026139994,37.6505826,0.2970401820491628 +0.20375,31.860241460230068,1.6966771292868377,37.9153352,0.6688128207695326 +0.205,32.051420340339085,1.6907708119843718,37.848598800000005,0.5111736099004919 +0.20625,32.241518721198204,1.6961631992903516,38.10430639999974,0.9119090787474678 +0.2075,32.420275347016975,1.711024464711539,38.7536158,1.1016141456395712 +0.20875,32.58554513917215,1.7345918740958377,38.921018600000004,1.0313055694193163 +0.21,32.74683480284567,1.7583868758565393,39.249671,0.6458726285348386 +0.21125,32.90933669745089,1.7736762602876859,39.173250599999996,0.8351178623657277 +0.2125,33.08126669020401,1.7828369831816777,38.632941800000005,1.1015107269017848 +0.21375,33.311030672728776,1.8029054856495992,39.2986876,0.6939900083591278 +0.215,33.57833333927349,1.8723149612698815,39.6142708,0.3310505913077336 +0.21625,33.86160219125072,1.8769194689642847,39.65824979999981,0.8333592287962568 +0.2175,34.06745776628107,1.857003116186456,39.901782600000004,0.5789161999022822 +0.21875,34.20882556871395,1.8574177726840941,39.6770072,0.6153451682963784 +0.22,34.33227259793791,1.8574805331040625,39.68555759999967,0.662723342861543 +0.22125,34.445904050436525,1.8540307739436777,39.8298644,0.5196925846539491 +0.2225,34.55447072157005,1.8493387467594145,39.7828372,0.9457103682151833 +0.22375,34.66210946452761,1.8455558448770992,39.938520200000006,0.8150013936955558 +0.225,34.770775635122085,1.8428401096152411,40.2122434,0.23834295261723001 +0.22625,34.8831027293955,1.8403469545831272,40.457144799999995,0.24746043369334975 +0.2275,35.00061853970025,1.837620984557463,41.022982,0.36145646038838464 +0.22875,35.12409652964701,1.8333217222549947,41.2827224,0.4836700522120434 +0.23,35.25345946288892,1.8262594067839328,41.394644,0.3359278844134556 +0.23125,35.396163884425285,1.8066944423347098,41.6692764,0.44736120997500334 +0.2325,35.550281621142155,1.779774336440642,41.588808400000005,0.5962124567344247 +0.23375,35.736540950847576,1.7690337062474388,41.94353899999909,0.5316651551365195 +0.235,35.97991136343875,1.8640847626929606,42.510496599999996,0.2126194034508615 +0.23625,36.10565530943341,1.9002625965956377,42.763283799999996,0.40122894592576586 +0.2375,36.25995033615795,1.9294494016388257,42.76150360000006,0.2802174841740371 +0.23875,36.416214192788225,1.9589991804661995,41.8975104,0.48268666386621606 +0.24,36.59281949398801,2.0177149026657344,41.5668968,0.45312603220814884 +0.24125,36.80311423885269,2.1241769695308816,42.045345,1.3364409619130204 +0.2425,37.03311087345981,2.261203380381083,42.67726640000001,0.8156380354503441 +0.24375,37.27506741039263,2.4249648212930066,43.36910199999933,0.5806060648159784 +0.245,37.52052887512917,2.6131864448739837,43.36632999999999,0.3595296902851012 +0.24625,37.77117202124726,2.827802682260074,43.78022,0.22682568539960346 +0.2475,38.03057978863745,3.062078582142675,44.27282719999973,0.3596578908640273 +0.24875,38.30354073840217,3.3104957694503976,44.1634232,0.18381260544015998 +0.25,38.604057791259415,3.5494033825829074,44.1224694,0.30411951469496173 +0.25125,38.95256121126635,3.7625961966426673,44.05733900000011,0.20037174855646642 +0.2525,39.46048487332595,3.973004279051523,44.1801392,0.4048040781244689 +0.25375,40.169513644481604,4.4347763982985065,45.7344332,0.9101566173468179 +0.255,40.840275552876335,5.109393881012242,49.5562732,1.0594057102487697 +0.25625,41.17540843645229,5.332751819782552,52.0663462,0.3023209165691341 +0.2575,41.375216881263135,5.475322301999672,52.10938980000001,0.5659604367782255 +0.25875,41.67481968107979,5.907325410706396,52.307895200000004,0.3921504057178815 +0.26,42.02161260342867,6.343016923856078,52.3038176,0.5829509641070156 +0.26125,42.49630712534095,6.538806379071054,51.998870999999994,0.38524414260115486 +0.2625,43.21367005314688,6.577008129973765,52.115967,0.32888045216993483 +0.26375,43.85512475273858,6.570129110063762,52.594314,0.3044226949136688 +0.265,44.892990760346315,6.724740101904145,52.751736199999776,0.31736047558233627 +0.26625,44.602405463845194,6.710190049259505,53.216492,0.2560056443821112 +0.2675,45.53579876942849,6.758274391952376,53.9073906,0.639406689214541 +0.26875,46.368737652581984,7.274747384397864,54.07669460000052,0.5353492485398166 +0.27,46.7719101289635,7.440868234857993,53.7464418,0.42238760127955943 +0.27125,47.899029818159704,7.071833726534465,53.993105400000005,0.3791063552939981 +0.2725,48.16466567701189,7.112385844420995,54.33692699999999,0.7293436445040838 +0.27375,48.3864524789889,7.167697955389649,54.487108,0.6326013197903568 +0.275,48.881826276785006,7.362970613667282,54.65331339999959,0.42975274287696935 +0.27625,49.37876458908128,7.480866902673808,55.0022238,0.2943100543877177 +0.2775,49.694773076263964,7.5510904787780655,55.235083800000005,0.41646935161689796 +0.27875,49.81529596609473,7.530077227432517,55.24419620000002,0.1356798321239807 +0.28,50.063288901345324,7.467825889006211,55.2857638,0.26843239394901763 +0.28125,50.42453252565921,7.279120930611521,55.286481800000004,0.2987802736915527 +0.2825,51.05832766895917,6.817284129522287,55.591970599999456,0.2965395853968865 +0.28375,51.993089909345095,6.291581246471716,55.9376478,0.04957957883746054 +0.285,52.91745629234399,5.863490903466829,56.187329,0.2566046960530928 +0.28625,53.44746567042378,5.340926137855397,56.11749100000001,0.3708246230147087 +0.2875,53.38573898361142,5.292683738142055,56.48704,0.15474048148916897 +0.28875,53.05002492293594,5.7991000954454694,56.6799444,0.2972650999088183 +0.29,53.297729968329094,5.037962872793847,56.6268908,0.44269915927489645 +0.29125,54.00492360271622,3.7556035421597063,56.801279799999996,0.46344885612082504 +0.2925,54.6493327349178,3.127943141568824,57.0720716,0.5632462518963609 +0.29375,54.93361350452128,2.949442286661408,57.309849199999995,0.7977043959363639 +0.295,55.01933449306399,2.996434559628386,57.448304799999995,0.6337530736510875 +0.29625,55.2380272698249,3.0143038440762067,57.8063258,0.642188698730521 +0.2975,55.55840969582432,2.9558899669206746,58.019585600000006,0.6491659247259516 +0.29875,55.91176907742496,2.9367967856394643,58.0715196,0.5796018283341589 +0.3,56.2480879060185,3.008928378338898,58.186605800000066,0.8512045511349589 +0.30125,56.44958817614397,3.1628925586933527,58.250091,0.5806649868486995 +0.3025,56.50679974125981,3.4807572213803675,58.648205,0.8475416414194625 +0.30375,56.77120479725138,3.7618205699760714,58.5775216,0.49706496886302587 +0.305,56.95680965253849,3.7895008203147356,58.9872978,0.9883239602831134 +0.30625,57.149736463600014,3.7127337514349383,59.1852486,0.749870651303809 +0.3075,57.41362796619139,3.620944582214645,59.1235832,0.4712635828904024 +0.30875,57.70090849861119,3.553672920810739,59.021637399999996,0.22022124184283595 +0.31,57.98129400090951,3.4896799683461177,59.260304399999335,0.35743117639763466 +0.31125,58.29304019045204,3.397989895292501,59.5319516,0.34734139684221227 +0.3125,58.48715829557767,3.4507919661563786,59.3558854,0.47710344574452584 +0.31375,58.62911323627833,3.540633460337912,59.61962299999949,0.41376102807575477 +0.315,58.91608435869083,3.729087746147129,59.7205778,0.4843169182329893 +0.31625,58.986525365223734,3.6069661999346576,59.685046799999995,0.44257468986454773 +0.3175,59.00262400103546,3.3732764631021603,59.76738379999999,0.37751834731996714 +0.31875,59.30641148740505,3.1455596364882408,59.919957999999994,0.3383096982891565 +0.32,59.74862657230375,3.0166534615695455,60.4102178,0.5895487360360484 +0.32125,60.14898382003954,2.9943358891968663,60.9009676,0.5442398751298 +0.3225,60.49733861199949,3.0294891518899343,60.924212999999995,0.5159102849003885 +0.32375,60.80316732130621,3.084108664686331,60.937024199999996,0.7755947950990256 +0.325,61.07344985569808,3.1380776363110843,61.097628400000005,0.6613126113452719 +0.32625,61.34406666650188,3.1785857364900556,61.211940000000006,0.5665379456254472 +0.3275,61.716261841874946,3.2342347746095106,61.48040799999952,0.7727475899872475 +0.32875,62.12223244714813,3.309338455194751,61.8484826,0.7327403667226208 +0.33,62.62978847808009,3.4154497204441787,62.0183464,0.20312126674058673 +0.33125,62.90252527832451,3.3350437467075205,62.228951399999666,0.3184263294375111 +0.3325,63.11128170385873,3.160147842593392,62.4479498,0.3564338259813458 +0.33375,63.299425408753876,2.9648788439719818,62.565676599999996,0.35969018401438274 +0.335,63.44796836565467,2.747114916465185,62.6296026,0.3304061061456054 +0.33625,63.54594316654441,2.5181849976559354,62.856453,0.22498866182876717 +0.3375,63.78194916661517,2.468345682639045,63.019777,0.37946517411944264 +0.33875,63.9913482652612,2.477504609043261,63.149689,0.5735985831925515 +0.34,64.11105696700334,2.4532799812858355,63.206697,0.4112256747839299 +0.34125,64.0722225669319,2.2569598296899245,63.351391999999706,0.09726893364561554 +0.3425,63.77355977276731,2.3228945525685454,63.4580614,0.15012717762050987 +0.34375,63.91525395287895,2.266871562252851,63.35251679999999,0.18201667374227093 +0.345,64.07145186422726,2.185715074936424,63.53851859999954,0.23731682301372 +0.34625,64.23077999075147,2.0735984489716173,63.91050260000001,0.44487492092025055 +0.3475,64.38272146645217,1.9350503913012118,63.9994966,0.430211392474448 +0.34875,64.53044600287573,1.7824947091795078,64.037239,0.2854926122538022 +0.35,64.67589494800583,1.6296352791611177,64.25783120000001,0.10794856489411998 +0.35125,64.81408885080495,1.483966322436494,64.150273,0.4002121083419416 +0.3525,64.94147004212259,1.353508907968042,64.0728824,0.44086789312366764 +0.35375,65.0470445580853,1.2362832852929433,64.17057980000001,0.41106681082544005 +0.355,65.12439813540574,1.1373236428792484,64.24828679999999,0.6057286094334654 +0.35625,65.0782268082168,1.1507485768701913,64.3238762,0.173863633838992 +0.3575,64.91406608578426,1.4927293772973342,64.59503099999999,0.2213213030245839 +0.35875,64.78166260068538,1.88314196661301,64.87352779999972,0.25378968152338155 +0.36,65.30330123264315,1.2269113973841828,64.89739180000001,0.16362363587116144 +0.36125,65.49542528062418,1.3489367291647427,64.701321,0.3102890308027304 +0.3625,65.54780344612674,1.4212271881298135,64.49223560000003,0.37231288007978924 +0.36375,65.51976225643436,1.4920380878404738,64.3907186,0.365179638159495 +0.365,65.3395067690975,1.6682010959979148,64.499924,0.3362989460368528 +0.36625,65.32477597256234,1.658911366487909,64.7201836,0.4147934298326105 +0.3675,65.3605435256114,1.6383363077100168,64.845745,0.4120921864662046 +0.36875,65.50670314588389,1.5999344913986482,64.86597520000001,0.4775898544888678 +0.37,65.73003542055723,1.5886251376129976,64.93277859999999,0.38766930367814384 +0.37125,65.90960488099972,1.5307238352923698,65.08964660000001,0.23913940244614357 +0.3725,66.05055964306403,1.4878823183753431,65.27333139999972,0.254552899462057 +0.37375,66.10083361122267,1.4460540338926844,65.4575538,0.07808457870603915 +0.375,66.15091943875183,1.3748933444180726,65.485204,0.25132194079805475 +0.37625,66.21242960166582,1.2873453392372534,65.32503280000033,0.2503342495061163 +0.3775,66.2856794493075,1.1897621227316342,65.0361856,0.252907043198289 +0.37875,66.37245458804423,1.095656066102949,65.1380604,0.3851950237312261 +0.38,66.45751995931325,1.0461897243290434,65.350044,0.31453811048345126 +0.38125,66.52098238578097,1.0612505351313726,65.27793879999999,0.1727521960416153 +0.3825,66.55774998990564,1.1111957642332964,65.50337540000001,0.4582741232617238 +0.38375,66.44586855235262,1.1199568508186075,65.7142092,0.5189026899599739 +0.385,66.41130748964908,1.1959588102929015,65.4802,0.22916428101036881 +0.38625,66.44025824201903,1.2547933379961644,65.22908079999999,0.17848414613685037 +0.3875,66.49187918572939,1.318735556802987,65.21081059999999,0.2504384959252458 +0.38875,66.54419117780937,1.3887666942680224,65.1735594,0.3086191430562933 +0.39,66.57871928457466,1.466759863623637,65.34896819999959,0.2340470327621376 +0.39125,66.59725078567243,1.5492230926283796,65.74400139999999,0.22521291967891283 +0.3925,66.61241429221167,1.6379884842631882,66.0707922,0.1709926306575808 +0.39375,66.62550805169845,1.7311710094031518,66.10432240000016,0.3391972250457319 +0.395,66.63792236933226,1.8266952749886134,65.92482199999999,0.14999497142404583 +0.39625,66.65775036225214,1.9138732278429684,66.0176072,0.20385066407593627 +0.3975,66.72112881161279,1.946504794181596,66.0902918,0.36831530641380905 +0.39875,66.84133391471119,1.9490123188941955,65.9906974,0.26299584440499824 +0.4,67.03816581617626,1.9880961227899556,66.0310072,0.26138558000337775 +0.40125,67.36165475831316,2.1523135242293177,66.1986158,0.3269895481742509 +0.4025,67.57692707154408,2.365497884272383,66.1962288,0.2755219914756334 +0.40375,67.83688650450762,2.5098481833000816,65.95634920000028,0.3889894490606382 +0.405,68.08450706883758,2.6016339778233917,65.8613822,0.3934356198842443 +0.40625,68.18667972071536,2.573893673039394,65.81728079999999,0.31415080451623695 +0.4075,68.1510080662096,2.4329187834010635,65.92329959999985,0.19440037678935262 +0.40875,68.06261668417996,2.340769562258999,65.9497676,0.17351211009840486 +0.41,67.96301942752866,2.4082596372284075,65.9399402,0.16121149994866862 +0.41125,67.90690163168658,2.5565897369785207,65.9224064,0.262866519594642 +0.4125,67.8812799043891,2.602123263054298,65.8775172,0.2896442819351019 +0.41375,67.71585824402098,2.6373194375574727,65.79574679999999,0.22735248205419004 +0.415,67.77469628637893,2.7054946272552054,65.8555164,0.31062783988770004 +0.41625,67.93423498468019,2.692859558478106,66.11440339999999,0.2023666373820047 +0.4175,68.10038148856931,2.6626069837507482,66.2409146,0.1454905249227572 +0.41875,68.26680826393539,2.6313840858314594,66.181031,0.22932878900173148 +0.42,68.44068336011583,2.6156334591704673,65.97178,0.20762338289917986 +0.42125,68.62169709478236,2.6228079359700267,65.7939296000002,0.2071974057699711 +0.4225,68.8064095819759,2.655509141262329,65.767246,0.13231051028357155 +0.42375,68.98738237343564,2.7141381397198696,65.8687942,0.16825628814905785 +0.425,69.15660498652592,2.795681489133451,65.9793829999999,0.09232156388960917 +0.42625,69.30622724459857,2.8852587619001566,65.99250120000002,0.17232663148858135 +0.4275,69.35891954369141,3.0463802596689757,65.8378876,0.2945654650265382 +0.42875,69.36423910887196,3.2452812026962787,65.64241100000001,0.2903710795060373 +0.43,69.45184217063942,3.2947157194286465,65.54094239999999,0.24423485782398266 +0.43125,69.56042023491482,3.295160403604901,65.7446068,0.26267509050669297 +0.4325,69.69844398133745,3.2406328819736396,65.9638626,0.3147234722058424 +0.43375,69.85971599345338,3.1477039442382093,66.0548,0.30239698455837816 +0.435,70.03513452230276,3.0406880890138948,66.0716026,0.1842827273709608 +0.43625,70.21440981191598,2.9396976711593745,66.0314632,0.11712414182268673 +0.4375,70.3865036206431,2.86597091471126,65.85094219999999,0.16036806430427547 +0.43875,70.54230446013867,2.8238455977771872,65.68369440000015,0.1876683267957146 +0.44,70.66478198177347,2.803437941600315,65.6565154,0.14255563209778688 +0.44125,70.50342308644993,2.863270944891383,65.80344319999999,0.14407186036384875 +0.4425,70.30867628537878,3.155018132143993,66.37575340000001,0.15996066769146475 +0.44375,70.31151283338407,3.1563417933500317,67.2310078,0.23648024906257897 +0.445,70.39685421360092,2.995432202062305,67.7577418,0.385540680055552 +0.44625,70.43243967312623,2.8967548705523276,67.6162456,0.43543812937178117 +0.4475,70.41272482202197,2.862946746713692,67.41093980000001,0.3071555596805922 +0.44875,70.37868979985736,2.83424497498045,67.49571080000001,0.31067875379594406 +0.45,70.33910078069816,2.7944376914778846,67.666202,0.2363646771336644 +0.45125,70.3114755748212,2.731909328183094,67.7076726,0.19923801466913826 +0.4525,70.3360949631364,2.6664699256002544,67.68940820000003,0.05579109802835718 +0.45375,70.38675273266033,2.619648576962748,67.6511972,0.1371777033420547 +0.455,70.43585711430708,2.5306066307080854,67.57188799999999,0.2794852350080436 +0.45625,70.90958844687678,2.0858996631163573,67.60436039999995,0.35512075505772855 +0.4575,70.99857116349328,1.8566463830963849,67.65218780000001,0.32028731274700567 +0.45875,71.0195328778505,1.6026342426939963,67.5742256,0.15709566150852533 +0.46,71.01143751860242,1.415980873040135,67.5605376,0.09207269856368888 +0.46125,70.93980736159908,1.2954551684745672,67.6525144,0.13248489703849442 +0.4625,70.83413116413207,1.2161597257154249,67.6779004,0.1758112012722744 +0.46375,70.72153080679213,1.170590418691168,67.54937600000001,0.22852773388256842 +0.465,70.61105564333091,1.1516310902093705,67.4317878,0.18726538848569663 +0.46625,70.51732979451761,1.1421156577552667,67.39977800000001,0.10444337520405962 +0.4675,70.44095817562045,1.1394132614995818,67.428901,0.07193637061667965 +0.46875,70.37231131938148,1.1497665629078222,67.4699648,0.10533202172273688 +0.47,70.3077873071686,1.1740765288214798,67.46518000000003,0.12601755544958324 +0.47125,70.24408245328914,1.2102367178934863,67.4103322,0.14847678381383222 +0.4725,70.17914142087413,1.254285801215061,67.2992798,0.1410660845586242 +0.47375,70.11118456392869,1.3006188445288798,67.16052979999999,0.1441823173232405 +0.475,70.037084028373,1.3420855511369654,67.11008140000001,0.16652513665450305 +0.47625,69.94430461500026,1.360388832583098,67.18252279999999,0.19434035184490095 +0.4775,69.82913157600551,1.3531359246394254,67.24085360000001,0.1909597930384802 +0.47875,69.70539238825435,1.3432161438818766,67.1237732,0.18465358849667396 +0.48,69.585407125596,1.3431537494271482,66.9295372,0.21729533663127795 +0.48125,69.46496321344648,1.345976674138934,66.919688,0.1507638884812932 +0.4825,69.33938547163547,1.3510130840774275,67.0877996,0.20377856417764056 +0.48375,69.20846246920756,1.360081890491506,67.2105293999999,0.2288436014253401 +0.485,69.07254235977992,1.374865501112149,67.1760686,0.22075464956439658 +0.48625,68.93125649700923,1.3960113241082366,67.0190522,0.3281202554684777 +0.4875,68.7852791177019,1.4245212211427971,66.8405314000001,0.27262828380933124 +0.48875,68.63196389506565,1.4598933887655083,66.71789159999999,0.2239613758381129 +0.49,68.47020104815566,1.502073065111958,66.70043919999999,0.2084643091519528 +0.49125,68.30116623112586,1.550489264849327,66.79712180000001,0.26767915166986767 +0.4925,68.12822450594744,1.6050401581064755,66.8526472,0.3089177352705709 +0.49375,67.95418256565146,1.665142344063895,66.78774539999999,0.23101929244719038 +0.495,67.78158938377592,1.7289625010207086,66.6565598,0.17208195315372218 +0.49625,67.61094416449377,1.7905028429367378,66.4722944,0.18305266447336913 +0.4975,67.44157107820476,1.846035458147052,66.3474540000001,0.1494639411915698 +0.49875,67.2723301657672,1.8923640030594597,66.3618062,0.16529399175317946 +0.5,67.04593824941259,1.8123735355117632,66.42743039999999,0.19687277180402526 +0.50125,66.7259032709344,1.551986461609284,66.41190220000011,0.15436405313805743 +0.5025,66.53834031592243,1.3617885522873434,66.234171,0.16577980777374643 +0.50375,66.27654265620389,1.4059499652988032,66.0111854,0.09899067928244558 +0.505,65.98161589359508,1.4639325278957198,65.8844922,0.11498621904254365 +0.50625,65.73764111267033,1.5064994516870218,65.835904,0.21192792220823645 +0.5075,65.52746787964021,1.5774696447832852,65.86040879999999,0.23670608889654984 +0.50875,65.3599954974657,1.6754249319764132,65.93349359999999,0.22955437905385434 +0.51,65.21130809172224,1.7782769004792185,65.97331160000002,0.25747761698408184 +0.51125,65.07958593608511,1.86417981253192,65.9169058,0.30438635822454063 +0.5125,65.01523865936956,1.8874457651472922,65.76658119999999,0.2550482413077926 +0.51375,64.91803712440066,1.91249834387356,65.6952318,0.2160370462101332 +0.515,64.70151318391432,1.9949861496199044,65.78442839999983,0.24155281794519734 +0.51625,64.52464972362696,2.0680446956232705,65.87760519999999,0.28341229188886635 +0.5175,64.40884707164416,2.069053143474832,65.8635128,0.2726886857071656 +0.51875,64.29705752548263,2.065192283273012,65.78318140000002,0.15215576442517897 +0.52,64.18615723130242,2.062818936164204,65.6419034,0.09732532523603506 +0.52125,64.07364353773521,2.0647175515256775,65.48583860000001,0.21738608482559652 +0.5225,63.95403734326027,2.0692124491537753,65.45680660000001,0.2332041781321649 +0.52375,63.81668537590443,2.068141600662988,65.514846,0.14673409391651535 +0.525,63.661446612151586,2.0651489623901136,65.5023724,0.08835867501440162 +0.52625,63.49333240851984,2.0634422982852305,65.36071239999998,0.08843244364654902 +0.5275,63.30869444826964,2.0516994626338696,65.12690620000001,0.1751006677491602 +0.52875,63.104644900773714,2.029206476074093,64.85740220000037,0.2583156212420555 +0.53,62.89640206293689,2.021112363508424,64.69350419999999,0.21711393759429742 +0.53125,62.69519177285213,2.038833192921256,64.6701774,0.1074952735579586 +0.5325,62.49507530999211,2.0749592127129937,64.64686220000007,0.05360588396990415 +0.53375,62.29552306527328,2.134470941666385,64.51835860000001,0.09292776774624212 +0.535,62.104694527747995,2.202241181725963,64.2795668,0.0924540155547645 +0.53625,61.93524342295928,2.2497663554267597,63.99156479999999,0.11272207954389121 +0.5375,61.77916662222746,2.2868541306789845,63.73146920000001,0.1358549629630791 +0.53875,61.66326819111455,2.3419333653523013,63.5696028,0.09364511818402464 +0.54,61.58212616607767,2.4453391053346785,63.500087199999996,0.04276001912066955 +0.54125,61.4341673134364,2.496766901382025,63.424762199999996,0.07528882685830625 +0.5425,61.18801374434284,2.447178939475783,63.2702994,0.07945747010382384 +0.54375,60.9188436913853,2.390921967816178,63.052397600000006,0.08577439363119889 +0.545,60.672190474702994,2.3765191328566764,62.834361799999996,0.10212075499476296 +0.54625,60.40278081108565,2.406640257441105,62.672777200000176,0.0740040322158951 +0.5475,60.05929150223984,2.518157096076586,62.604842999999995,0.043925618402019286 +0.54875,59.7110248338086,2.708930624325758,62.595815599999995,0.12893786059493792 +0.55,59.41007986310367,2.8538656963592066,62.56207320000006,0.14517592791402373 +0.55125,59.10409382657226,2.927556442158565,62.42668619999999,0.11857886319323611 +0.5525,58.786013030805044,2.968768513544063,62.16908959999999,0.14209639885760567 +0.55375,58.47415764235841,2.981979310440715,61.878753399999994,0.1450062485284692 +0.555,58.15609272535116,2.991189350855238,61.671202199999996,0.09914935798682596 +0.55625,57.783595571190055,3.0587594289222544,61.5918532,0.09258026593286442 +0.5575,57.46665600403216,3.0696714142191546,61.570273799999995,0.12459407316441584 +0.55875,57.20675109604246,3.0073323300207924,61.470039199999995,0.09908703666575022 +0.56,56.909469896118445,2.8743195166753917,61.22113360000043,0.052258296482942196 +0.56125,56.69881199602718,2.8393316856323088,60.858007199999996,0.09461034406554004 +0.5625,56.505535856997874,2.8125222391626754,60.522271599999996,0.10351428031580985 +0.56375,56.3118825773337,2.793292785410588,60.33791260000017,0.06608418639738178 +0.565,56.084996344609,2.7928970418412793,60.298396600000004,0.0814683783274202 +0.56625,55.868255202974865,2.812067840267035,60.2757366,0.09565062318824655 +0.5675,55.60267681710298,2.931125490418839,60.12249440000001,0.05753033617840448 +0.56875,55.25116454961815,3.2339988298752407,59.8012244,0.08101884207269078 +0.57,55.05506462175041,3.273962184895723,59.4285526,0.11928238331078131 +0.57125,54.89006781131962,3.2420076227649557,59.169372599999996,0.09517241169740352 +0.5725,54.72568797346449,3.25603405104035,59.089502,0.06369322088731252 +0.57375,54.50300911517862,3.2723571273378895,59.107092,0.09400253677694041 +0.575,54.19062954301691,3.240879525924185,59.047791800000006,0.0931612313127077 +0.57625,53.92766117532643,3.241240055736771,58.7990048,0.06487120176318528 +0.5775,53.72574989995326,3.208888652986369,58.41343680000057,0.10296380940254281 +0.57875,53.581003294966145,3.120689670929918,58.06067599999999,0.13128777535056402 +0.58,53.451635084964174,3.0477196453788333,57.879462000000004,0.10837881390751711 +0.58125,53.26110395383055,3.0440923301401326,57.858009200000026,0.09556771254822984 +0.5825,53.03246285208336,3.0663308449162683,57.8515498,0.10892079208167584 +0.58375,52.793017268372544,3.0959426932054814,57.697932,0.10117139471955443 +0.585,52.549396151401744,3.136270580763424,57.3616092,0.11348894228602037 +0.58625,52.29473765818272,3.200764110410146,56.95887799999999,0.14992380289166898 +0.5875,52.038998359063015,3.2696770738930114,56.654511,0.14207968752604933 +0.58875,51.793694271393385,3.3224710054100743,56.530755,0.08680112803414507 +0.59,51.56403095337126,3.3465553346757018,56.5280202,0.04930759236872174 +0.59125,51.263118766720176,3.244266392032464,56.482227200000146,0.05670115741058597 +0.5925,50.8889869405356,3.0981633287087416,56.25515299999999,0.02755807674711606 +0.59375,50.62431623596097,3.081093505711143,55.8569852,0.07915431192739887 +0.595,50.442507414075834,3.1299510918289943,55.43341100000056,0.12975489544517863 +0.59625,50.29214634578301,3.2094818234406026,55.143073,0.11232184966203161 +0.5975,50.135491446888715,3.2871893011143687,55.0390716,0.0638385404422751 +0.59875,49.95150770028783,3.347999905968241,55.031790799999996,0.07071603256475677 +0.6,49.7405925299885,3.3966960451615718,54.955467,0.07480037529651751 +0.60125,49.51152422735595,3.432221942096889,54.707909400000005,0.06129038714431345 +0.6025,49.27804193624595,3.456879273777224,54.32294420000001,0.09651579202234196 +0.60375,49.03944051277773,3.476900472672412,53.9317998,0.1228399958755301 +0.605,48.777559913872665,3.5079577964167177,53.6643244,0.11189033809181204 +0.60625,48.506741234197875,3.5547074168523722,53.555077600000004,0.09717113051364448 +0.6075,48.220466180498846,3.579870250280165,53.5187396,0.08796389286121965 +0.60875,47.90894483000063,3.584526750492158,53.41616020000022,0.053023335030017604 +0.61,47.582634246582245,3.5775683507942957,53.1640632,0.05755055855680288 +0.61125,47.2636811146084,3.5567864035821395,52.79148100000001,0.10428879662983934 +0.6125,46.95077088881816,3.5349496519814707,52.40544360000022,0.10814951699539385 +0.61375,46.62858545702372,3.522061213743811,52.11083,0.08551445367012499 +0.615,46.30604567754008,3.5242493655985854,51.938632999999996,0.09951636539283433 +0.61625,46.01781506680424,3.492430856735652,51.83279279999999,0.11180760677252663 +0.6175,45.714811130668956,3.4314987174580365,51.6963664,0.079065492626684 +0.61875,45.362456116456826,3.352681305144679,51.458272,0.04892257562210031 +0.62,44.9976557168665,3.2784926468325684,51.129038200000004,0.0862136420394146 +0.62125,44.69628618810299,3.1799513936836057,50.783646,0.09738136828469807 +0.6225,44.454131452489065,3.114514073529219,50.49543220000036,0.08124987881037536 +0.62375,44.251383499413606,3.0827843548277483,50.2971452,0.09392807303037645 +0.625,44.057220689370006,3.056795235998767,50.15848999999999,0.12239479287330897 +0.62625,43.8582824843885,3.0347272264643093,50.00667540000025,0.12215145136183427 +0.6275,43.64053976434732,3.021154878903992,49.7787688,0.10029117818233181 +0.62875,43.393860629993235,3.0219226510846915,49.4679412,0.10951091271740918 +0.63,43.154366676440254,3.0130584076921556,49.1256842,0.12401727225753448 +0.63125,42.90448990366472,2.9420049050482913,48.8208994,0.10644914953535131 +0.6325,42.64672683015284,2.8763902430847432,48.591713399999996,0.06287801832755174 +0.63375,42.44012195631465,2.878140134692195,48.4187318,0.06540718366280523 +0.635,42.22972821338116,2.928519100728845,48.239873599999996,0.08998862986122261 +0.63625,41.90895437019746,3.1888971634012715,48.004222600000006,0.09233750845295559 +0.6375,41.63016243921695,3.296148222903783,47.7030398,0.09978722974258741 +0.63875,41.34146803084682,3.312848060152701,47.3693612,0.11730263210473867 +0.64,41.02394112664391,3.285006948962623,47.058967600000415,0.1076853921769603 +0.64125,40.7217816820285,3.2929354111929126,46.811174199999996,0.07249447079398645 +0.6425,40.46107843214558,3.3709946083062357,46.6228258,0.08810173409019774 +0.64375,40.23766191411432,3.4681405690771245,46.45113660000008,0.12925981036570972 +0.645,40.0458855553,3.5252732826065003,46.2404846,0.12310911216193653 +0.64625,39.86420722577365,3.555307871655283,45.958178000000004,0.09527669947316611 +0.6475,39.68070538823287,3.5811384755503637,45.61969740000001,0.1135827555234512 +0.64875,39.49337629995167,3.6029849159507394,45.2759928,0.13296872792014042 +0.65,39.301713343460925,3.62017949191709,44.9790126,0.10238880830100665 +0.65125,39.10059966699429,3.6296121419825402,44.7490792,0.04627486577182093 +0.6525,38.85438478374712,3.6286624153091864,44.56305239999999,0.07326522504435629 +0.65375,38.477545109406385,3.662953594201124,44.373731800000286,0.10366770544963769 +0.655,38.19511764440058,3.709813380007319,44.132276,0.10820560207771274 +0.65625,37.936491436410016,3.7328918431737264,43.8205092,0.1223711967874797 +0.6575,37.64039503043442,3.7622580814297097,43.462218600000526,0.14000798850170632 +0.65875,37.289807424221046,3.796985387252896,43.1031508,0.1282198587317881 +0.66,36.866314343842724,3.844732462241555,42.7898024,0.08258216175603592 +0.66125,36.3181621985641,3.9727594359502945,42.54892099999999,0.0643731170404233 +0.6625,35.89274998598196,4.063846739697887,42.3606414,0.08767979792004726 +0.66375,35.44590638877168,3.938723646867663,42.1696194,0.08537803272973496 +0.665,34.975053396806004,3.974422352328863,41.9319344,0.07425293040210666 +0.66625,34.54687896649305,4.099469637086444,41.6281626,0.08627874221846474 +0.6675,34.09235926141283,4.270121781680986,41.271806399999996,0.09367657593443575 +0.66875,33.6916692865044,4.398648774867686,40.9155904,0.07365459276107589 +0.67,33.37336146261658,4.448273327074011,40.5884846,0.10116641480896775 +0.67125,33.083137672776324,4.472066865834192,40.326950400000335,0.11794610087364998 +0.6725,32.79142725875864,4.478785061592661,40.1285594,0.10249257286164713 +0.67375,32.47656529540473,4.462286659640304,39.9534668,0.06266070078765594 +0.675,32.024733179375666,4.295102520071947,39.745105800000125,0.042446296819585685 +0.67625,31.68199835040444,4.304126110169466,39.4637906,0.06322966643356512 +0.6775,31.359669353528762,4.355466582827333,39.1129368,0.07678586396401312 +0.67875,31.02492037138042,4.385670949577754,38.73522,0.08742739795967941 +0.68,30.668197248978743,4.373150524467015,38.38733499999999,0.09984742480404628 +0.68125,30.292579745692645,4.364789700085291,38.1091828,0.10094157640536255 +0.6825,29.957471420573274,4.403978600340495,37.894465600000004,0.08799449254527451 +0.68375,29.70304179049445,4.495947634515349,37.666571399999995,0.053892980807338044 +0.685,29.491202092599792,4.592740016561564,37.33602280000053,0.018380016640387846 +0.68625,29.268223852290642,4.646807773297114,36.9405432,0.04586406219143776 +0.6875,29.03683776252692,4.681098584305772,36.572925999999995,0.09491833056633596 +0.68875,28.801080007575987,4.702403970325195,36.20545480000054,0.13232839373954625 +0.69,28.549525429101248,4.710559836585207,35.7973404,0.1504717787204635 +0.69125,28.25935808847096,4.710845541632994,35.375639,0.14365489396988979 +0.6925,27.943519472425283,4.7048892598577305,34.9728986,0.05813414373068306 +0.69375,27.604777125050603,4.703131274292944,34.6273334,0.16595575461489598 +0.695,27.282826078464655,4.705947789664044,34.350007600000005,0.225036359556184 +0.69625,26.954123821773774,4.70150990289849,34.06096720000001,0.15604219933146274 +0.6975,26.527772700161872,4.738455444349218,33.696276,0.07348959127318758 +0.69875,26.083122636483637,4.800242833053649,33.2707918,0.09874960369389045 +0.7,25.699984387354913,4.8221334380678424,32.836155399999996,0.17208447871118512 +0.70125,25.339911432873524,4.856700179787537,32.446545199999996,0.14321979435364304 +0.7025,24.989055454378985,4.927161481629462,32.127185400000414,0.09418501874117788 +0.70375,24.63046793705413,5.07608765550731,31.882558,0.1952221316180608 +0.705,24.410676584702088,5.583711326918018,31.6528028,0.23234915915535406 +0.70625,23.32335494356236,4.943382973948352,31.33895100000019,0.2016032691636438 +0.7075,22.727834246378247,5.060379976314911,30.9118174,0.10030154310029343 +0.70875,22.216779979981226,5.279453407936839,30.4226382,0.08498137324555279 +0.71,21.852053985811498,5.364433645039771,29.951265,0.14047666724228625 +0.71125,21.549515041824993,5.417318242041772,29.575336800000002,0.13844818371217496 +0.7125,21.30416873750106,5.457432902575538,29.308014200000002,0.09549984100091553 +0.71375,21.08402067769125,5.482783072632026,29.056757599999997,0.04294627703654914 +0.715,20.870361131370835,5.498553438111248,28.735094399999998,0.016482592159609677 +0.71625,20.467696158168717,5.069469741084413,28.307160600000664,0.036111461162573515 +0.7175,20.073230049030975,4.713453023282028,27.7852334,0.053955870781593064 +0.71875,19.762048525156505,4.5571358108843185,27.2630044,0.05879083825138045 +0.72,19.478301780077008,4.464647780171309,26.808962800000643,0.04548840751994289 +0.72125,19.203435060118817,4.403672752532287,26.317134,0.05079161040467334 +0.7225,18.921745029920746,4.345070520969502,25.984901,0.07341100969200712 +0.72375,18.636276487590354,4.2846745180375665,25.7884486,0.11079906367970867 +0.725,18.354296019247002,4.22702581035411,25.346622399999994,0.11829879191817579 +0.72625,18.07269339661529,4.179229125940769,24.8629214,0.08127954739846988 +0.7275,17.76980014812224,4.136613542253633,24.4177648,0.05782825954669539 +0.72875,17.38856519965929,4.093979965283361,24.024868199999997,0.03390876550687145 +0.73,16.872827367812416,4.137392832351108,23.640819999999998,0.06670899169152618 +0.73125,16.516759560318885,4.184251448767012,23.213156599999998,0.10123009909508233 +0.7325,16.185194569306926,4.241435610329623,22.747457800000003,0.10829199066043618 +0.73375,15.862330785339218,4.288109813956939,22.263699800000687,0.07742986146642092 +0.735,15.489737776996426,4.205249353000097,21.817742199999998,0.061417354177788805 +0.73625,15.072997756297587,4.021546097709683,21.476922599999998,0.1134132821754132 +0.7375,14.677888006375921,3.8850689437449826,21.222235400000145,0.1278000916990284 +0.73875,14.350220705447642,3.859505351170189,20.9515642,0.10159585774380846 +0.74,14.077963501783751,3.9131942450737798,20.588061,0.05188613906430087 +0.74125,13.821489378112938,3.9795155943595075,20.111068999999997,0.07283515597223637 +0.7425,13.568966514432239,4.0312225048753625,19.553166799999996,0.08309047496073174 +0.74375,13.309694204825846,4.0366809785294695,18.966663600000004,0.06141137806058416 +0.745,13.021172054978251,3.972160457335078,18.423331400000002,0.05668657149008043 +0.74625,12.641732966332901,3.8035572832640416,18.1332644,0.061816012458747155 +0.7475,12.348212634829864,3.8387640355600454,17.893707400000427,0.060827323020178466 +0.74875,12.225437896607405,4.004204540381484,17.535558,0.04205329764120735 +0.75,12.110100075993335,4.201633532161947,17.151419800000003,0.06552281931281627 +0.75125,11.763145463851727,3.9531825536392424,16.714656000000634,0.07411827801560629 +0.7525,11.179751058101509,3.531888018467112,16.2845816,0.07656680017670935 +0.75375,10.842287558223788,3.5033882710279096,15.8956468,0.05804292182256197 +0.755,10.62647245852775,3.5062293656378563,15.5017682,0.04087365077528574 +0.75625,10.389198036517554,3.4949120212365377,15.044989800000002,0.10551293255426121 +0.7575,10.171581952616718,3.4823013234120737,14.5229598,0.16315066665723435 +0.75875,9.978720450524454,3.44683019433488,13.9782724,0.15478752430283257 +0.76,9.791953759358334,3.3934083457480053,13.484244799999999,0.0731631926223838 +0.76125,9.610605805835041,3.341509757601997,13.104864600000003,0.054630256216678885 +0.7625,9.428183079282682,3.3011664982674325,12.792064,0.1502861569190591 +0.76375,9.163945105360174,3.2367157462614826,12.475559999999998,0.1849181324302732 +0.765,8.82494057444775,3.1783188589583933,12.266688600000279,0.06681041302689061 +0.76625,8.555100483581892,3.097834883690558,11.928411,0.031317962856801565 +0.7675,8.295710506529078,3.006940613304856,11.4111186,0.050632075024632614 +0.76875,8.053606033156775,2.8956189672740043,10.891486400000291,0.06401922748510532 +0.77,7.7788794991370835,2.7230512165653664,10.3960172,0.05993298307860213 +0.77125,7.5239592885108415,2.6040218424018735,9.961671860000001,0.050722638924478675 +0.7725,7.334318806662716,2.627153032221651,9.55562262,0.09066770658281256 +0.77375,7.167127888443496,2.722424302075233,9.168036279999999,0.11356871611943596 +0.775,7.002662798715668,2.8413841169340017,8.764301380000001,0.11189476483985768 +0.77625,6.8281928129473854,2.918932754394116,8.370340760000001,0.08221558889689345 +0.7775,6.647031802061967,2.926985292379647,8.02577874,0.07952245782015292 +0.77875,6.472449480081487,2.856181669748956,7.718220500000413,0.09731296979460441 +0.78,6.302715257370998,2.7248107326362594,7.41880596,0.14275030888820497 +0.78125,6.052367784161738,2.4763014481271663,7.039202759999999,0.13640436282712157 +0.7825,5.885615374852905,2.370961821834715,6.5872984400006755,0.0874192404400613 +0.78375,5.763735136067297,2.3174051410365015,6.08485664,0.02127051770416032 +0.785,5.65257807672975,2.2754297289599084,5.57555208,0.058889527394283124 +0.78625,5.547321141884403,2.241704820459966,5.08741846,0.09711748628518459 +0.7875,5.441766022366353,2.2111981923260076,4.73016742,0.03572715236325156 +0.78875,5.332408756255337,2.1791679451276758,4.44348124,0.0914895926883107 +0.79,5.213075468992834,2.1417434912020994,4.12706922,0.09962852005940373 +0.79125,5.0715559475737075,2.0877080658565794,3.8231623400000005,0.05964948292942686 +0.7925,4.874109012429557,2.008155302826833,3.49654326,0.07605037156853996 +0.79375,4.708351977289518,1.9534942870615946,3.11361596,0.07286788035559966 +0.795,4.579893014400917,1.8796532615508545,2.76079806,0.08810920558916079 +0.79625,4.444058217572761,1.7773012898918008,2.4210434200004993,0.10391094796103423 +0.7975,4.302290451143784,1.6550419079124852,2.0554590599999996,0.09817814785420931 +0.79875,4.15913081259092,1.5227744730742228,1.67543582,0.08242873474618549 +0.8,4.086497916288667,1.2617517456697933,1.2696586800002119,0.06399105824337373 +0.80125,3.9520382494694584,1.148514726401168,0.876450232,0.06498268458407645 +0.8025,3.8181456464750787,1.0612932596152482,0.5548535219999999,0.05291824053215269 +0.80375,3.6971131157605472,1.0075347735842914,0.217537938,0.09883207923231666 +0.805,3.6005425441912497,0.9843192495312184,0.080218397,0.0 +0.80625,3.525557642944259,0.972965102858092,0.09147455959999999,0.02516954473939078 +0.8075,3.458894269264071,0.9658441013055807,0.224704544,0.056165805923819694 +0.80875,3.3919127004502823,0.9642559284097084,0.1019060662,0.03004498297997486 +0.81,3.3236681037806464,0.9678880459976572,0.10551029759995292,0.05655440902166244 +0.81125,3.253570945724031,0.9763532189847797,0.17953645179999997,0.0795080321171008 +0.8125,3.1820014555364167,0.9889918581230688,0.12903743939999998,0.04706816202915312 +0.81375,3.109238281771427,1.005309704734328,0.10191815560002297,0.048522135324987045 +0.815,3.0070718301598327,1.028987981826106,0.1436589034,0.06776219938115415 +0.81625,2.8510389567607217,1.123981850429556,0.1723920476,0.052825338585935806 +0.8175,2.7026218973324307,1.279884987010931,0.08464839760000001,0.009905782481964857 +0.81875,2.6099573594612813,1.3573071183147711,0.1312738612,0.052251443155681525 +0.82,2.5537055278911667,1.3626274057175114,0.187551288,0.042080047412168746 +0.82125,2.504118704549866,1.3549696220135286,0.080218397,0.0 +0.8225,2.455666638740252,1.3388895626801562,0.15971776399999998,0.0344633400738151 +0.82375,2.4056469476450673,1.3107356134432926,0.1634860028,0.04338255975339824 +0.825,2.355261801524416,1.2742384002714011,0.0927537096,0.028029811092809626 +0.82625,2.3605036113981206,1.224017718655804,0.178909156,0.03730451845925075 +0.8275,2.4190165176492453,1.2575556936637329,0.13193795600028907,0.05129924017967167 +0.82875,2.41381724209348,1.2916659416031628,0.1047508636,0.054856262973343145 +0.83,2.359560108896833,1.2641916334104888,0.1960511748,0.06948841091922109 +0.83125,2.297053313430404,1.2277207246596546,0.11862914140006228,0.049652433735142984 +0.8325,2.230839561416159,1.1893411194662742,0.1125481054,0.032057755000976615 +0.83375,2.162350705616669,1.1496485289507508,0.18818120400000002,0.053470457949850496 +0.835,2.0927692809354173,1.1082673330621664,0.11520925819999998,0.049934804721825765 +0.83625,2.01746628098554,1.0601388834314378,0.15000315839999998,0.062143495327669815 +0.8375,1.9214321215490318,1.0056495734109079,0.161610411,0.0636228426642645 +0.83875,1.7844127411916808,0.9907178356080678,0.1114400522,0.031223699737529163 +0.84,1.6380781523130838,1.0501452738020316,0.169066354,0.054314245516074604 +0.84125,1.5680766660046974,1.0063530896302089,0.13035495100007327,0.058787523344503 +0.8425,1.498137127700957,0.9806403893531078,0.14870256739999999,0.05015239413875995 +0.84375,1.4339099049867021,0.973471163265176,0.15481592160000002,0.05288403009817219 +0.845,1.3810453654466672,0.9727197189794998,0.12480232400001304,0.03938987570257423 +0.84625,1.348070918480732,0.954120367352814,0.153936222,0.04950387509321992 +0.8475,1.3280459081496252,0.9199226742304464,0.13371242020000002,0.05676071398588517 +0.84875,1.3114170933717697,0.8831317552708111,0.1491416874,0.048813997409834234 +0.85,1.296497222770084,0.845759375316808,0.14194079060000003,0.04781979425942533 +0.85125,1.2825676958363783,0.8097681743984787,0.132117822,0.035183998109140746 +0.8525,1.2695007449812994,0.7808485174400578,0.143730894,0.040245137466701865 +0.85375,1.256994308049769,0.762155809416101,0.135348466,0.046918302156734155 +0.855,1.2447463259176674,0.7558494454640532,0.14036088740000002,0.04835742816971094 +0.85625,1.2402827097399538,0.7597799473181505,0.13685530780000002,0.04439902851483008 +0.8575,1.2456011031433754,0.7807734902615037,0.124861504,0.03514783386789618 +0.85875,1.2557603026547932,0.8259991536729174,0.13631106220000208,0.03798662794118155 +0.86,1.2674193781274241,0.8923181697699084,0.1237058926,0.04487292108655211 +0.86125,1.2762655215795984,0.9651062199483263,0.13247220359999998,0.04464230613930328 +0.8625,1.277745456751629,1.0285186658260774,0.11854666140002786,0.03736408355505855 +0.86375,1.2679659990912193,1.0685822628883062,0.12081170700000002,0.03321672247869593 +0.865,1.4384261314329165,1.2075365354228365,0.1237674326,0.033357997096663476 +0.86625,1.3521170751922558,1.1326422104449867,0.1128510632,0.037885575878162776 +0.8675,1.22032278560446,1.0674785606811794,0.124628339,0.04139008720849147 +0.86875,1.1019415975716855,1.083982861966829,0.1125768044,0.03589399064286306 +0.87,1.1638203554352502,1.0447382330015447,0.11802895040000001,0.030188446771713767 +0.87125,1.1446233914662565,1.019067046562568,0.11921158220000001,0.02933546659010121 +0.8725,1.1546251268367622,0.9815782752767995,0.11167091259999393,0.033105667005287394 +0.87375,1.116820709759718,0.9848853577730845,0.12357211979999998,0.036929499066358056 +0.875,1.0811265131651668,0.9897118802801104,0.11452769600000001,0.03164919060938668 +0.87625,1.0532068017705616,0.9883678599850293,0.11932306239997958,0.026563148481112762 +0.8775,1.033494151469805,0.9807757852099611,0.1221792354,0.027128985568238 +0.87875,1.0184505894712468,0.9718304321442414,0.5116546131999999,0.8632901378921087 +0.88,1.0071782927931903,0.9631610160860059,0.212712704,0.16474778785427813 +0.88125,1.0008748789418545,0.9527105925528514,0.7364828712,1.4295126021615783 +0.8825,1.0017753837284202,0.9372567112503734,0.1011770576,0.05023073934990357 +0.88375,1.0124674688458495,0.9114184496619224,0.6897815528,1.3714178305998102 +0.885,1.0249675255844999,0.8758675739083833,0.0843178728,0.05125512803203384 +0.88625,1.0345291051188878,0.83480668255321,0.08328892439999999,0.04941271389797118 +0.8875,1.0415703074831248,0.7985727386180161,0.0751991838,0.03741001269147251 +0.88875,1.0469113664882488,0.7733951015514046,0.3658669646,0.6510347328736832 +0.89,1.049695146476922,0.7601692748360177,0.8115310638022077,1.0123636347637808 +0.89125,1.0488422529723744,0.7556428632576838,0.45517515899999994,0.8614930971478549 +0.8925,1.044383011920125,0.7563849289314049,0.31651452119999995,0.5932449214771234 +0.89375,1.032475858177629,0.7573287615571892,0.8212332959991031,1.0676199803232684 +0.895,1.007342311401,0.7531046519366562,0.5397440802,0.5073680960179385 +0.89625,0.969015317008142,0.7406214639070056,0.314845023,0.5853301391755791 +0.8975,0.9277503992534926,0.7247824126172167,0.053529624600000006,0.002237391693207138 +0.89875,0.8898862346835394,0.702754285103582,0.3158914384,0.5868530741761819 +0.9,0.8537732541919164,0.663816543319716,0.14428073700000002,0.2043824751813875 +0.90125,0.8107941752864306,0.6101418888174721,0.0533566698,0.002566132302102271 +0.9025,0.7635320441811669,0.5569855657317816,0.7203995636,0.8866097098481542 +0.90375,0.7151470405587115,0.516517093210556,0.18589635159996631,0.19383231806350634 +0.905,0.6687993441010827,0.4978764326017586,0.4970362584,0.6717349028182542 +0.90625,0.6290420789125978,0.5014189348190735,0.3481736828,0.36003515190949453 +0.9075,0.5985453887344344,0.519274277033356,0.43781216399974043,0.28007732305779814 +0.90875,0.5796498318189116,0.5422237611583782,0.18662378019999998,0.0910112265542936 +0.91,0.5675981185760826,0.5723910319650903,0.18167748979999998,0.10454769302461711 +0.91125,0.5592324707189659,0.6111016993605036,0.233916922,0.08318897452858323 +0.9125,0.555971771186884,0.6533646215692124,0.286855056,0.18682131503394153 +0.91375,0.581276043365906,0.6829208018447395,0.291584872,0.16034102818047574 +0.915,0.6398040828173334,0.731132985698588,0.21829405600000001,0.087009050460429 +0.91625,0.9336527366094081,0.9989473845624811,0.24553578599999998,0.07724045350343516 +0.9175,0.9308912870352489,1.0404232296389058,0.2280721522,0.08768563922292623 +0.91875,0.9073042805399667,1.0671411646768645,0.223707555,0.10038133205416085 +0.92,0.982612692030166,1.0424450991000183,0.292344028,0.14978246806822929 +0.92125,1.0908832659160983,1.0643552498593298,0.21543042219997188,0.0876349863748905 +0.9225,1.1541302833770042,1.0958005283314758,0.321997216,0.08522097713760109 +0.92375,1.1880977737018188,1.069497156414092,0.2437802974,0.0954583024705976 +0.925,1.2371095287210834,1.0176458086780948,0.36730152199998284,0.13033310840827428 +0.92625,1.2896183783651145,0.9708504763034773,0.2413440342,0.15024805275812322 +0.9275,1.324694622813331,0.9391698669339197,0.2538529606,0.09920068333750502 +0.92875,1.3199388823022267,0.9055326458898635,0.280406324,0.05873014319678974 +0.93,1.258385819036995,0.8802605288322859,0.263099514,0.04757636345533232 +0.93125,1.1837403405268951,0.8810116506550214,0.304232374,0.04990856675498838 +0.9325,1.1410316496412114,0.842011205136271,0.25737169400000004,0.037438475415242665 +0.93375,1.103855495403506,0.7827832633155198,0.26787070599999996,0.032981600020500525 +0.935,1.0456783336866458,0.7157249955732683,0.30842800199999026,0.04049269415036167 +0.93625,0.9640882996022319,0.6637272633646444,0.275666368,0.030080039789339867 +0.9375,0.8852799445984166,0.6604761783281168,0.300526364,0.04914265521921337 +0.93875,0.8306736040432802,0.6782412420657967,0.28606287200005226,0.07493771458593743 +0.94,0.8023614388974312,0.6935291321921505,0.28169478400000003,0.05290400857851256 +0.94125,0.7856167463328658,0.7198960608854013,0.30835798799999997,0.03096461812620447 +0.9425,0.7756098078200947,0.7542104587450381,0.301427086,0.01910598120552385 +0.94375,0.7715377531664057,0.7888547630910911,0.332948242,0.07751763534042509 +0.945,0.777590963853418,0.8116858587965394,0.26886454200000004,0.053139740534549756 +0.94625,0.8669784534745647,0.79773007927214,0.29804555600000004,0.047469292048449914 +0.9475,0.9055717843993629,0.816197967143252,0.34470868,0.07542132008044974 +0.94875,0.9377953387115717,0.830695628643396,0.32022601,0.013032993327727907 +0.95,0.962308950946,0.8422447247671442,0.28895944,0.07302180787813152 +0.95125,0.9764727376422163,0.8489499490611242,0.35714756200000003,0.07141653365857145 +0.9525,0.9803515947469837,0.8524751666298387,0.3160678980000516,0.025365881284542986 +0.95375,0.9708877401978723,0.8503317014657168,0.3160615,0.058115504132434825 +0.955,0.9445426075795006,0.8388866677015338,0.343715742,0.044543640500184424 +0.95625,0.8951797376790012,0.8047558382160854,0.32028676000000333,0.03013018610587485 +0.9575,0.821881412057,0.732244626968361,0.36576032799999997,0.07205460253327485 +0.95875,0.7392560275880551,0.6552271181386558,0.32655677000000005,0.02064358150653976 +0.96,0.6630686706463333,0.6086274702736626,0.32072687,0.03965666829566247 +0.96125,0.5873299391056296,0.56449893660621,0.383206294,0.013620880188549848 +0.9625,0.5201252282517705,0.5255502671421785,0.33846467199999997,0.035848550118426255 +0.96375,0.4755221774711678,0.5010714778367727,0.342397492,0.028592452358483872 +0.965,0.4532432788194174,0.5002033249847297,0.38089378,0.04450131606948946 +0.96625,0.4590733266322122,0.5105215195706466,0.3588855740000114,0.03770212165080422 +0.9675,0.4800377552366956,0.5294232331172715,0.37261608599999996,0.026539091042233905 +0.96875,0.5047161435815279,0.556943885683371,0.35160934599999993,0.054398205476491414 +0.97,0.5361642778029089,0.5856420686867152,0.3879847859999269,0.03933655586915286 +0.97125,0.5742885091226833,0.6153048466538067,0.37938558,0.055648949911808764 +0.9725,0.6117958140083796,0.6508492360201312,0.37287366200000005,0.048945202930059134 +0.97375,0.646527933474499,0.6901411633028889,0.3889092799999999,0.018453311078469085 +0.975,0.6769708607333333,0.7315643828773815,0.38154614800000003,0.031244274699828118 +0.97625,0.7040922435179594,0.7755387795861285,0.3896624,0.03662224062675234 +0.9775,0.7283779689238262,0.8206344599683658,0.39904298399999993,0.02924322087626514 +0.97875,0.7494369002733965,0.86368315157506,0.401460238,0.058829081426826385 +0.98,0.7673952750180834,0.9010228679317341,0.4162978300000001,0.05894388862794132 +0.98125,0.7817255641500783,0.9268365433866785,0.411509126,0.043561903237030165 +0.9825,0.7931514406763339,0.9400443242811659,0.391021742,0.040707960541507965 +0.98375,0.6118498659177489,0.6096609834647246,0.41557510200000003,0.038359778233755096 +0.985,0.5657780749176665,0.6343205780664968,0.460791358,0.023072399759356845 +0.98625,0.5953950399034461,0.6364995033073041,0.3998888480000001,0.02075636747216429 +0.9875,0.6338230991455236,0.6416857170887561,0.4638306539999356,0.046224431180266416 +0.98875,0.6805889665883255,0.6519503693031866,0.440639322,0.043846478420766805 +0.99,0.7388937260976666,0.66434450778828,0.44960802,0.037747309448202405 +0.99125,0.8264138169142803,0.6808775962131473,0.45585353399999995,0.04508967380560575 +0.9925,0.945384141556421,0.7276907320503153,0.43385366999999997,0.024775933448630157 +0.99375,1.0401570675916663,0.7701741135711988,0.44829432999999996,0.0720015203269108 +0.995,1.1338730347517847,0.825666598626471,0.48384277400000003,0.0454355478837521 +0.99625,1.2093488389919218,0.8607827310674769,0.48121756599999993,0.04375071495883216 +0.9975,1.262664737183716,0.8698552001989015,0.4805187820000083,0.06618079221960332 +0.99875,1.303572240816057,0.881641920742597,0.48088456399999996,0.05220444180948907 +1.0,1.3346013369442498,0.9013500206205373,0.501938012,0.06571932007841051 +1.00125,1.3539780288976742,0.9225781234590552,0.49811328799997734,0.06492089015637671 +1.0025,1.3612097453288357,0.9395631524422704,0.5211870980000001,0.059099044595300104 +1.00375,1.3466729106269721,0.9392481140899792,0.511918376,0.05108636685900828 +1.005,1.3062696351408327,0.9225209582738395,0.5285945479999999,0.05029683941981263 +1.00625,1.2583332646042131,0.9108146799691444,0.566131092,0.026635578300699056 +1.0075,1.2277989489469971,0.9046027444262144,0.544914628,0.05030535258726223 +1.00875,1.2191116579670371,0.8929826917449243,0.5022539000000001,0.0508842790868555 +1.01,1.2169747295369169,0.8816963248434982,0.567896768,0.04357942164863274 +1.01125,0.9874967265563429,0.7926364023934914,0.5610203200000001,0.06439564573341859 +1.0125,0.9886136950840488,0.7931379927449875,0.583282946,0.07018105122826127 +1.01375,0.9896681627089929,0.7984887793217166,0.5909252840000001,0.1109088515729314 +1.015,0.9915641951626006,0.8066539222980367,0.5263247820000536,0.08733183109454574 +1.01625,1.0066642911132553,0.8069315441009245,0.584232774,0.0539956194746637 +1.0175,1.0726177913019088,0.7719637577998749,0.6673034760000001,0.06507795035234 +1.01875,1.1462472226848683,0.7754342399282655,0.6079197760001243,0.023417188322677977 +1.02,1.2208392036259168,0.792305814189221,0.5761605120000001,0.09576883641106469 +1.02125,1.3224868538096202,0.7936738831968768,0.70294273,0.07781239160050539 +1.0225,1.4335332951773794,0.8085943190512315,0.598852206,0.07629166781198278 +1.02375,1.540831416608695,0.8399972026902596,0.606535004,0.06644550117435477 +1.025,1.623272890416333,0.8666743821947666,0.690440179999988,0.06638824227048094 +1.02625,1.6526815905804473,0.8698465990438257,0.630623784,0.06046417131756815 +1.0275,1.6393886091775836,0.8891816569619908,0.65816113,0.0762682268396988 +1.02875,1.567024922205077,0.9757456698053817,0.6894311460000031,0.049257613928878625 +1.03,1.5261368858271662,1.0311771932191613,0.696901454,0.03475387076730349 +1.03125,1.449283679319267,0.993795883477251,0.6761539799999999,0.044641142728152124 +1.0325,1.2455468285000506,1.0477785082051883,0.7292040399998724,0.09811270336122395 +1.03375,1.1465913301903659,1.0438200763681862,0.6946345220000001,0.06463333214406143 +1.035,1.0882020088014999,1.0299781408057447,0.6941039159999999,0.0681109355275864 +1.03625,1.071768229111161,0.9568592483643911,0.7922144280000001,0.12280428781440274 +1.0375,1.0627662375086937,0.8787915223531927,0.7580446839999999,0.10699549440651825 +1.03875,1.059479064473047,0.8194731239803923,0.717270494,0.10684723864584018 +1.04,1.0619278839186668,0.7947108236787901,0.754699704,0.04494261779510603 +1.04125,1.0643131865780198,0.806080462843848,0.7336322939999999,0.050973381201841805 +1.0425,1.0397526019060284,0.8371852736341612,0.8228662919999999,0.0635413862851006 +1.04375,1.0067055345106646,0.8819551562133605,0.8360540839999999,0.06113837333788231 +1.045,1.0163270902573331,0.8951670378541726,0.78815552,0.10886605126100399 +1.04625,1.0519923899398005,0.9004509985995762,0.8351077699998669,0.09947544058601755 +1.0475,1.060417080900028,0.8931021885729987,0.8544910480000001,0.02781014310565068 +1.04875,1.025136977612325,0.8534002713801558,0.8196118159999999,0.11617896711431004 +1.05,0.9886178277246667,0.8486490547839098,0.9181562359998681,0.04563013728459496 +1.05125,1.0265574318310913,0.8448107211715916,0.9757624360000001,0.09012582889521144 +1.0525,1.1019733625980523,0.8785276215608764,0.9856055340000001,0.09650889532020394 +1.05375,1.1503506662135237,0.9143088270287073,0.8700002280000001,0.06403990969000638 +1.055,1.1786464374219034,0.9375581753606862,0.8790379199999998,0.11431601310259139 +1.05625,1.2047879441612006,0.9737711937062821,1.032581514,0.11250752701472815 +1.0575,1.226851632620221,1.0241688609506887,1.066989282,0.08248882464364868 +1.05875,1.2392699440041393,1.0712185892107184,1.026114362,0.11421824472121658 +1.06,1.2464432199071782,1.10765850225677,1.0565647839999213,0.0897059414173172 +1.06125,1.259157911059711,1.1320697669393236,1.13586682,0.06426662446011146 +1.0625,1.2779686925187916,1.1480263120092322,1.127237396,0.1208125697876429 +1.06375,1.3019678877133118,1.158964497558761,1.1651715999998196,0.11689235321021893 +1.065,1.3301611011054881,1.1687348258874761,1.30433146,0.23777161190464477 +1.06625,1.3619543025885825,1.1796032894994761,1.21242454,0.15893114795295166 +1.0675,1.4007378237096069,1.1898533525786816,1.201099014,0.2034454971355915 +1.06875,1.4662717772453149,1.1789950436852168,1.23655388,0.149670451546496 +1.07,1.55936628987467,1.1607885003835097,1.30346056,0.12104200608484232 +1.07125,1.6619128996145038,1.1630837380160883,1.3736241,0.12045697183731208 +1.0725,1.761425716107446,1.1770860597124206,1.43036428,0.1970970566058433 +1.07375,1.8692393786506594,1.1897424282141607,1.44208488,0.07035069207418644 +1.075,1.9186261210963333,1.1911761817171844,1.4305376,0.10394569877770315 +1.07625,1.9457383216419988,1.1760975449715385,1.4911827800000002,0.09936729922440284 +1.0775,1.9814884676277982,1.134129890898825,1.564454159999886,0.06113651197134748 +1.07875,2.0213646045935714,1.0870685008301884,1.65607492,0.07551743838390573 +1.08,2.0305841703657497,0.9922809901390199,1.6816262599999998,0.09361125382726694 +1.08125,1.8316092493134117,0.6527705628038251,1.687535619999919,0.10361762620908946 +1.0825,1.8484248952724143,0.7248395091518288,1.8051130200000003,0.10992368237828463 +1.08375,2.0531323011544282,1.213632151079295,1.7671256800000001,0.1606023682924913 +1.085,2.112529659203833,1.5179705088270368,1.76213998,0.16842528109757457 +1.08625,2.0688707056134112,1.5011645838420473,1.9042949200000003,0.22099291612206032 +1.0875,2.01931231533935,1.4495955501979603,1.88748548,0.10925274187027077 +1.08875,1.9643522032605214,1.375457400422816,1.96486448,0.27188619533125796 +1.09,1.93159710228625,1.2979431590592176,2.0015982,0.10419808195554753 +1.09125,1.9381999099479208,1.2761290071298685,2.000977279999977,0.18537210617577463 +1.0925,1.9008592096396122,1.2649583826437574,2.0667825200000003,0.09862872362353164 +1.09375,1.795195943668725,1.1600298194952274,2.10917132,0.05788127612300024 +1.095,1.6529368607241677,1.01646870050999,2.126862959999957,0.06393047280440144 +1.09625,1.515704837913905,0.9319835594197458,2.1855395799999995,0.10952395383511776 +1.0975,1.4208815472405838,0.91403209352513,2.22734774,0.02489853708620252 +1.09875,1.3713478290094454,0.9149681723711912,2.2218677999999996,0.0606302215033889 +1.1,1.3942401704812502,0.9877150316165783,2.26369528,0.06684581547484489 +1.10125,1.4046807717677512,1.066704977166607,2.3311667799999998,0.06811713123096862 +1.1025,1.3608098389583139,1.0436668558419553,2.33644928,0.05388153546992698 +1.10375,1.3144975080831323,0.99750270858482,2.3276400799999997,0.09575822260204088 +1.105,1.3018088818225835,0.9655546443843429,2.4175096,0.07628705237335484 +1.10625,1.3961151203885853,1.0775316579880203,2.4090129399999998,0.058921390445771056 +1.1075,1.408026115240579,1.1823099066033018,2.39722992,0.043894416217863205 +1.10875,1.4024091994317196,1.250561912018045,2.539566279999703,0.07809316010802415 +1.11,1.394444880253667,1.2647656494489654,2.65250594,0.22725531028016263 +1.11125,1.4005799844111493,1.229054088634028,2.52740616,0.10826128785144301 +1.1125,1.4240982127120363,1.1841960441336787,2.6028226199999827,0.19132481126890852 +1.11375,1.4507965934806781,1.1500531910537624,2.60219866,0.11049541796849759 +1.115,1.4760996469224998,1.1343721726356808,2.61998068,0.08979146488612941 +1.11625,1.411711641410814,1.2151086375096545,2.7913254600000004,0.18574910608143724 +1.1175,1.4643153501965145,1.227316287990978,2.96113278,0.14291079019369732 +1.11875,1.517743638257121,1.2463930976893138,2.91295278,0.16673607039674107 +1.12,1.5707810329971033,1.2691245908732933,2.93500938,0.30358904848457896 +1.12125,1.6217417554023583,1.2902536332691752,2.8632883,0.1423980035057548 +1.1225,1.669946548216599,1.3090048683208477,2.937419699999758,0.20787180557867677 +1.12375,1.7226195243846865,1.336743270843567,3.17378494,0.07290621656681959 +1.125,1.7821470661935,1.381848537126805,3.3814444999999997,0.1468731092220935 +1.12625,1.8294258282089249,1.4066131778863702,3.364554660000067,0.13511601981921606 +1.1275,1.8576797191249115,1.3909492402048043,3.42104724,0.10595961113751323 +1.12875,1.8832994177475284,1.3669731488798011,3.58308076,0.15450306493659927 +1.13,1.9118018315449994,1.3482001359079683,3.79853338,0.3909971741689664 +1.13125,1.9443660177282422,1.3382644594807995,3.77906738,0.34572212326749774 +1.1325,2.0246647580595916,1.386725483409845,3.7237954799999997,0.5206257190663 +1.13375,2.1321374890478846,1.5363517461568286,3.76693858,0.3245221848677793 +1.135,2.1481670411865,1.5436613267606216,3.82348568,0.21960023790449762 +1.13625,2.147845982086786,1.5112974076799617,3.9901014000000004,0.33035036854084937 +1.1375,2.147917712037993,1.4737422595206304,4.1604006799999995,0.27461197213571564 +1.13875,2.149005139124529,1.4325428284141914,4.1847565,0.3334513730132477 +1.14,2.1517311714306495,1.3893310492039381,4.3744222399999995,0.407294343324196 +1.14125,2.173674498043983,1.3170389482759994,4.3113224599999995,0.20424726917859393 +1.1425,2.2229374252488783,1.2099466993155905,4.27340772,0.3567256254941634 +1.14375,2.279343858184148,1.1185735608617238,4.362281539999986,0.17894095206804872 +1.145,2.3299774174766665,1.0735874874618763,4.54065038,0.2577459502980927 +1.14625,2.388804795455585,1.071739629013105,4.42681632,0.12231551662173513 +1.1475,2.4391413037039436,1.095854062036026,4.2782402600000005,0.28442501515457963 +1.14875,2.476451123018934,1.117133987245256,4.37033028,0.21153396276760617 +1.15,2.516277621823093,1.1358440369685172,4.44412618,0.11673380779470861 +1.15125,2.5859950849529483,1.0950418083512299,4.52042042,0.1457733855050604 +1.1525,2.6945855130581204,1.0080789496636757,4.6174783,0.1815229061039266 +1.15375,2.8170634040146765,0.9648155560465977,4.8020503999997315,0.15433623119095377 +1.155,2.9209386872841754,0.9946617634208407,4.85282328,0.24343611155694833 +1.15625,2.8847362054619805,1.2018630113340574,4.87822164,0.316063406969271 +1.1575,3.048659982846885,1.1626969484270875,5.085243679999815,0.35518134977940646 +1.15875,3.3057109829629,1.238640516188959,5.02300268,0.18011560906211588 +1.16,3.401744439451004,1.3158010047190318,5.1554167,0.09242636028395793 +1.16125,3.5717940610974446,1.367379143153897,5.3546700000000005,0.06802046847725314 +1.1625,3.8271201180586227,1.578283011320021,5.442106099999999,0.09314179730121191 +1.16375,3.780997613019899,1.5208548497466639,5.63880734,0.14017921745152906 +1.165,3.7444008355107496,1.5528613478606477,5.76735862,0.09633970043262022 +1.16625,3.7830416323967953,1.6044972365985495,5.87910986,0.06571832058789233 +1.1675,3.8460417385500247,1.646851630190114,5.99105074,0.06861122744109009 +1.16875,3.9284866127280114,1.686392381026912,6.079411779999999,0.09191308004134688 +1.17,4.037036947432835,1.7373781787650233,6.220550860000001,0.07317351525455083 +1.17125,4.160194958592686,1.8012368612321354,6.307986959999927,0.07988024675342778 +1.1725,4.286211717437639,1.8559806647900474,6.3586658599999994,0.0956646798850966 +1.17375,4.404128275885065,1.8746771173657508,6.4606983200000005,0.08785601338159511 +1.175,4.50994442391675,1.8788133804356961,6.539888339999966,0.1005323615417 +1.17625,4.6051918453328655,1.8872610227002757,6.651133799999999,0.1417594915909689 +1.1775,4.700203856946926,1.9001987473451025,6.74230902,0.12106345261373068 +1.17875,4.797454643829581,1.9175916714232375,6.757948260000001,0.11023442772749363 +1.18,4.895969987257497,1.9393002001491404,6.81322408,0.1280817990162421 +1.18125,4.992850362926189,1.9620172129639404,6.901521139999852,0.12267269668917744 +1.1825,5.086273959466005,1.9857811434094181,7.034273600000001,0.11423687675862362 +1.18375,5.174778275210201,2.009251613032982,7.11660854,0.11557485133591124 +1.185,5.261310938644837,2.034689205218421,7.24097561999969,0.16794881748197318 +1.18625,5.348722468706114,2.0629070466047725,7.4550687600000005,0.24837574549326064 +1.1875,5.4357582706104575,2.09297184193496,7.39118632,0.16021324515025884 +1.18875,5.843064757294367,1.3698281109375863,7.429706759999853,0.05790664904040652 +1.19,6.112043843454267,1.2637297982798505,7.5564816,0.11879471164544742 +1.19125,6.058100344947957,1.5262572287203389,7.724368180000001,0.1522202715525007 +1.1925,6.143020067688453,1.5257895028343034,7.86454354,0.13389749189651745 +1.19375,6.236097192528194,1.5155933069485938,8.00019436,0.11629800178736052 +1.195,6.347900430331916,1.570952892457254,8.1457491,0.09666463422159666 +1.19625,6.452580567241696,1.6396877908845433,8.2330522,0.15693953070733968 +1.1975,6.5697195276540485,1.731935177069116,8.355431020000001,0.13450738633230094 +1.19875,6.68994755892264,1.8452321752181315,8.394524839999999,0.06820398510415637 +1.2,6.809556539542083,1.9593104475027703,8.46034326,0.03816196377334403 +1.20125,6.916441716072484,2.0414768868160955,8.48936596,0.03884076491385037 +1.2025,6.9492428657633,2.0612664728621213,8.496409220000013,0.210255394648372 +1.20375,6.862458145818185,2.1403554198438925,8.4646665,0.2712269147448591 +1.205,6.554542486123666,2.804952189499856,8.4599982,0.2796182534819478 +1.20625,6.622403067569448,2.9075645772795378,8.483261779999879,0.2522249383805439 +1.2075,6.926238264867693,2.5541857734160147,9.198320439999998,0.965394588876938 +1.20875,7.257413144532567,2.346911388935554,9.9576879,1.7365698783306673 +1.21,7.461462559536916,2.3483431045654672,9.1107346,0.7072794925868163 +1.21125,7.588578482498996,2.36620394052514,9.34531792,1.7829922606333395 +1.2125,7.746812396684654,2.3561104807777875,9.089818740000002,0.3691008555730308 +1.21375,7.928002995186236,2.324936406716453,9.20938656,1.2630004501285155 +1.215,8.11438775267275,2.288420603410446,9.15709288,0.6781603467764225 +1.21625,8.283865131113222,2.2546084886100366,8.970690779999956,0.5773158083639679 +1.2175,8.432733988225253,2.2339518706974513,9.1956445,0.6494378309114432 +1.21875,8.57192843474883,2.232212120734615,9.42153694,0.5566061902928251 +1.22,8.712028047488163,2.235050086440591,9.700741479999511,0.49027453697340323 +1.22125,8.852060442309645,2.2372294660901293,9.994508660000001,0.5113677016337929 +1.2225,8.985387303724957,2.238977433778425,10.358154639999999,0.6836243425200442 +1.22375,9.1068751457456,2.239398432631933,10.624577339999998,0.7890805203914733 +1.225,9.213629545378001,2.240146137164283,10.4120476,0.34635301614725406 +1.22625,9.301748210285323,2.2395914466040647,10.352421,0.23296594968900486 +1.2275,9.381863683591222,2.2404571584068442,10.445915199999998,0.21167329356628783 +1.22875,9.455505156335485,2.243143430985133,10.6764972,0.43658176612714844 +1.23,9.5228718481955,2.247602613011603,11.3231042,1.375636902147038 +1.23125,9.503217071391278,2.3427698612903005,11.283366580000001,1.8388582957189308 +1.2325,9.670625076109165,2.233672216516611,10.86737698,1.437476937727716 +1.23375,9.867348164395509,2.16404734846597,11.274510799999256,0.7660448224865583 +1.235,10.003562079606155,2.1555532912209405,11.377592599999998,2.074820886280621 +1.23625,10.067805642215843,2.134464021504178,10.4081008,0.6884978519291874 +1.2375,10.156389945818844,2.0856525834874238,10.296645539999677,0.649323235331065 +1.23875,10.26882600108417,2.0263567408755407,11.439903,2.0038858862443987 +1.24,10.353728234369418,1.9748578412840163,11.3387386,1.329190752272901 +1.24125,10.478079979187955,1.8135989582008556,10.441850599999999,0.8358422639911196 +1.2425,10.62583635940595,1.6252740718320091,10.745798399999998,0.30830675432562293 +1.24375,10.765225403528433,1.4848999070009428,11.353071000000002,0.5902878753934391 +1.245,10.894488904672889,1.3844634845488415,11.320895400000001,0.5543513269654003 +1.24625,11.026218808610814,1.302307314194056,11.43633192,1.4524730851307908 +1.2475,11.156825502881446,1.2437602316488732,11.63759640000087,1.1843990185347517 +1.24875,11.282494216979588,1.2082640875041333,10.456758,0.22052175901710966 +1.25,11.525394998838706,1.147109920663804,10.5630536,0.29406958868403965 diff --git a/validation/experiments/bergdahl/waveform_T3p50_R0p200.csv b/validation/experiments/bergdahl/waveform_T3p50_R0p200.csv index c84ca777..28be8c39 100644 --- a/validation/experiments/bergdahl/waveform_T3p50_R0p200.csv +++ b/validation/experiments/bergdahl/waveform_T3p50_R0p200.csv @@ -1,1002 +1,1002 @@ time_in_cycle_s,measured_mean_N,measured_std_N,predicted_mean_N,predicted_std_N -0.0,50.43138257264125,0.29396842133734363,51.73450328000001,0.03071437951792937 -0.0035,50.481970479165874,0.27717797526840166,51.756368119999934,0.015323712035012671 -0.007,50.5308589810165,0.2611883793794134,51.83338271999999,0.012235545886148818 -0.0105,50.578236770022635,0.2467071019466795,51.831854199999995,0.018510821529582753 -0.014,50.62411692404025,0.23413247158376044,51.86452543999998,0.020346315979758885 -0.0175,50.66860437905663,0.22444085963860094,51.94295927999998,0.01488751995908857 -0.021,50.71209670886601,0.21870122381765203,51.93769015999999,0.0081172409640448 -0.0245,50.75413025634188,0.2171591504073418,51.96930240000002,0.018684869514656068 -0.028,50.794781735203756,0.21892949851778037,52.0119844,0.016730578301423205 -0.0315,50.83491025309587,0.22193295870695243,52.01092271999998,0.019192824783533746 -0.035,50.874422348283,0.22571467739055118,52.04664248000002,0.01827337122787564 -0.0385,50.91308269554375,0.22997870663011574,52.06164072000003,0.015066003646320167 -0.042,50.95077677024349,0.23436506442610303,52.10613731999998,0.019790093342191742 -0.0455,50.987522456683,0.2383467289512707,52.1178222,0.02229322573563411 -0.049,51.02314554670251,0.24157973469291963,52.13503483999997,0.012868576999333069 -0.0525,51.057327186137,0.24368710768561577,52.192429000000004,0.02059578636325043 -0.056,51.089863836868496,0.24440696895231434,52.16195243999999,0.024816298936945244 -0.0595,51.12041487838737,0.2433659356969614,52.20747767999994,0.011507384557327981 -0.063,51.1487985389205,0.24034678551207247,52.2502598,0.015898482937060202 -0.0665,51.174652431613,0.23497141071686603,52.246840320000004,0.01999454469630977 -0.07,51.19781655103675,0.22706097679885945,52.253926160000006,0.020150086954864012 -0.0735,51.217906743992,0.2162305733736786,52.28621231999998,0.030108508658383288 -0.077,51.235418028308246,0.2034931916885068,52.303962080000005,0.019283749818748717 -0.0805,51.251498020399495,0.1912436768877188,52.296891800000004,0.011268226555230071 -0.084,51.26667776326675,0.17968695563029433,52.30064875999999,0.016904718913624838 -0.0875,51.28106027169213,0.16888430705183957,52.31415103999998,0.028825855179480175 -0.091,51.29461924142025,0.15882326697468244,52.29223900000003,0.011648579610394505 -0.0945,51.307259739970874,0.14953218686774997,52.302019880000024,0.006332331118309831 -0.098,51.31896031255775,0.14097720980218562,52.3242264,0.012870302261408569 -0.1015,51.329621177231004,0.13317132259294215,52.2713672,0.004184095488869256 -0.105,51.339266097629,0.12602138306377506,52.323898959999994,0.025096951509847944 -0.1085,51.34806158227075,0.11921254765856773,52.30284668,0.01422612463435568 -0.112,51.35602225127625,0.11273599225699904,52.33513935999999,0.026950324754766466 -0.1155,51.36303761445262,0.10674502585270589,52.33864100000001,0.021399511501433304 -0.119,51.3692169490215,0.10138590922963682,52.29994844,0.011016423614208041 -0.1225,51.375145417767,0.09653773375373084,52.340401,0.012451935878417284 -0.126,51.380900546101,0.09222323675651625,52.31470555999998,0.009180855503057321 -0.1295,51.386453779746,0.08850447045952221,52.30906855999997,0.02841078787662605 -0.133,51.391792715998506,0.0854229756199629,52.32112119999999,0.0339538824319103 -0.1365,51.396887094039755,0.08301107878680795,52.29449792000001,0.014690687359402618 -0.14,51.401726217707,0.081270157973825,52.29025567999999,0.008197259060915044 -0.1435,51.40618689512338,0.0800137714255277,52.29329347999999,0.015588640159149384 -0.147,51.40923243690625,0.07736306006793592,52.25705380000001,0.01603037224334342 -0.1505,51.41051203059488,0.07301200202326202,52.249370799999994,0.007176257569224053 -0.154,51.410192152851494,0.06776111331331486,52.25914252,0.008760515249231033 -0.1575,51.4083059910525,0.0625195282959143,52.243466520000005,0.005326550704909917 -0.161,51.405012035298,0.058716122561471386,52.221774600000025,0.01619421741426115 -0.1645,51.40035145952662,0.057900116240134095,52.20100448000001,0.006234916799124 -0.168,51.3944311706975,0.06135721492873988,52.19388200000001,0.01143481003340924 -0.1715,51.386768540059,0.06929163218203571,52.16135504000001,0.005345474660681909 -0.175,51.37739949437225,0.08078920701174312,52.143372879999994,0.016119841862500605 -0.1785,51.3663864031965,0.0947282650982513,52.09962228000003,0.006818796679186052 -0.182,51.3539231597305,0.11021903180790807,52.08824188000001,0.020944997258823914 -0.1855,51.34008281114825,0.12659866619253524,52.066262400000014,0.009625376787427989 -0.189,51.324513688966746,0.14253567087396435,52.066044360000014,0.0089026987968776 -0.1925,51.30597199301624,0.15567490557431518,52.02903576,0.010684447287893663 -0.196,51.28483075444325,0.16641734675000364,52.01030632,0.010774349071390722 -0.1995,51.261348201126125,0.1750713612921415,51.98686484000003,0.008369474335202062 -0.203,51.2358153132675,0.1821017835593278,51.9421826,0.005604888116635776 -0.2065,51.20709820442537,0.18654379976532556,51.865498079999995,0.006215629249857251 -0.21,51.17532072152825,0.18825843671749634,51.82033220000003,0.01963778202037951 -0.2135,51.14040358247513,0.18772348610206657,51.77897451999996,0.014051707643262547 -0.217,51.10273993753175,0.18531452446877628,51.70415720000001,0.01831312244701131 -0.2205,51.062525082596494,0.1811590917417979,51.67366860000002,0.018273705160684897 -0.224,51.020158410368,0.1755743136648925,51.57979852000001,0.014818247248296562 -0.2275,50.9758599954365,0.1687059753726196,51.525785039999995,0.01694609830692797 -0.231,50.9300044518085,0.16081890158757736,51.47200552000008,0.008673288945436203 -0.2345,50.882836632766,0.1520471298601412,51.37841167999998,0.007440523630234625 -0.238,50.8347063736245,0.1426046769865972,51.34855180000005,0.010137639404719121 -0.2415,50.78588330635725,0.13265105048258402,51.25348556000004,0.01869337906607984 -0.245,50.7366924875875,0.12245088538091192,51.18612891999997,0.010695647032867014 -0.2485,50.68689174437738,0.11241663286373002,51.11931936000006,0.011329724112642391 -0.252,50.63288173250675,0.10345394466883905,51.051447280000005,0.011214009815063056 -0.2555,50.574107979464884,0.0981571904805209,50.97138460000004,0.00834594759746464 -0.259,50.511486493983,0.1003325004026318,50.89850528000001,0.01079012866427083 -0.2625,50.44561264042325,0.11257252115438746,50.82390512000002,0.006370581041942277 -0.266,50.3773419725935,0.13389220577025046,50.77122679999997,0.004847375304218776 -0.2695,50.307330309779005,0.1615314455735083,50.68856284000009,0.015385305694867759 -0.273,50.23616364631475,0.19233308175637834,50.6001788,0.014334110687447603 -0.2765,50.16189644990887,0.22250412744902917,50.54209511999993,0.011836730006778137 -0.28,50.08439836746275,0.25050194445690527,50.43067700000006,0.01039183596387962 -0.2835,50.0047795440825,0.27517868023282915,50.38558399999998,0.011743064132510283 -0.287,49.924384388585004,0.2958610871663653,50.287931240000006,0.0072185980777882035 -0.2905,49.843708621365,0.31293334740591655,50.203485,0.020098808397515 -0.294,49.76199746603974,0.32925153030425613,50.130028159999995,0.007557577600514534 -0.2975,49.6795833201945,0.3451327684566984,50.03008908000005,0.020011984959299275 -0.301,49.5969027373625,0.36075435976439996,49.95816680000004,0.01071460288297392 -0.3045,49.514370067996,0.37600016320246027,49.887081959999975,0.013535086162561105 -0.308,49.432387829468745,0.39076548884900597,49.811185000000066,0.010369193724596455 -0.3115,49.35139459525274,0.40480193443809326,49.72087296000004,0.011847844649900775 -0.315,49.270944734671,0.41833149354877885,49.65075955999996,0.01337468380217874 -0.3185,49.190280122455874,0.43178802007627703,49.54821720000008,0.003361449702134817 -0.322,49.109341679741,0.4457416520298346,49.48251279999999,0.007114945593623639 -0.3255,49.02788768379163,0.4604183107577486,49.3644312,0.0062737756733883794 -0.329,48.9456942178785,0.4759452950096421,49.247854079999996,0.005386580021883694 -0.3325,48.8625153765375,0.4923764344086726,49.163144040000056,0.007675933417398946 -0.336,48.777335677230994,0.509986685535043,49.04171471999996,0.012987342604672936 -0.3395,48.68913558071513,0.5293348394943522,48.9803862000001,0.014895212330136869 -0.343,48.598216372242,0.5503411002957053,48.851431000000005,0.009792926018305566 -0.3465,48.50465953837437,0.5728859651587792,48.755946399999964,0.014761374340472989 -0.35,48.40875757570525,0.5966713408423252,48.66654512000012,0.013479400046452478 -0.3535,48.31096283188449,0.6213270692510251,48.52877331999994,0.00936974420418141 -0.357,48.21238169906175,0.6464432604647161,48.44356892000012,0.014576874326520177 -0.3605,48.11328237280662,0.6715748331886637,48.3476092,0.0069485248578377 -0.364,48.0139376484305,0.6962634603930055,48.23336768,0.011569990267565623 -0.3675,47.914599871400384,0.7199134066346526,48.11547948000004,0.011166512815191924 -0.371,47.8155208313975,0.7420144774525403,48.006764600000054,0.01322967776626467 -0.3745,47.71702118070763,0.761833145732359,47.91398016,0.008594813145640805 -0.378,47.61944585730975,0.778776297482381,47.80816180000001,0.020352397173306374 -0.3815,47.52287410944949,0.7923309382349514,47.686107920000055,0.007807029228331007 -0.385,47.4268382624065,0.8028289968063328,47.57275179999997,0.01621879483493689 -0.3885,47.330855128836625,0.8104515452682473,47.48313676000009,0.0059815555574814884 -0.392,47.23428128934475,0.8153475431805688,47.34220439999995,0.010657736923944259 -0.3955,47.135747066769,0.816248777491693,47.2514116,0.005423658294914074 -0.399,47.034871009262986,0.8136940873171722,47.12499368000006,0.007971672638285639 -0.4025,46.93124127158387,0.8082284069113157,47.00599912000003,0.007370370490817982 -0.406,46.82458364218075,0.8006119207865251,46.92218211999995,0.013130590781560945 -0.4095,46.71352923433663,0.791247559799533,46.79733560000011,0.005750123941253348 -0.413,46.5980171631285,0.7809419303609363,46.705498,0.013155344009183237 -0.4165,46.47798265391788,0.7705195048205002,46.58674148000006,0.014360263477106805 -0.42,46.353722727107,0.7608194442526607,46.46077224000009,0.007554360463207203 -0.4235,46.22518228496263,0.7526997320864863,46.36047263999994,0.008382124613048 -0.427,46.0926486709805,0.7468769856657427,46.251420440000096,0.006642913516535366 -0.4305,45.95553662849449,0.7447991236607804,46.1240606,0.010773941400433902 -0.434,45.812152120591506,0.747745395680325,46.01316796000003,0.008666129765242295 -0.4375,45.662026590496374,0.7530965980051983,45.902583320000055,0.003993653817219799 -0.441,45.50613648675325,0.7606241737590889,45.77693796000007,0.006652469041525352 -0.4445,45.34480657764526,0.7704072093152411,45.682205200000006,0.008941607745807779 -0.448,45.1801733645295,0.7814303845189523,45.538095999999996,0.013585257193001656 -0.4515,45.01381518369413,0.7927411332897919,45.42521836000002,0.002948493440388021 -0.455,44.846511424861,0.8033362476445185,45.33325103999992,0.006095243551145279 -0.4585,44.67989863764837,0.8120443556952714,45.17122244000009,0.010948781722573043 -0.462,44.51566110987575,0.8178513010536003,45.07530779999997,0.014218689421312488 -0.4655,44.355681067650735,0.8195206998283597,44.952051,0.011304542228680416 -0.469,44.201452572526996,0.8162953276126713,44.840522680000035,0.01123201014832069 -0.4725,44.05279355925387,0.8100009842502489,44.74538188000006,0.007677649992770105 -0.476,43.90914714110825,0.8025959032226946,44.60153319999994,0.010466729140505787 -0.4795,43.771207594207254,0.7947555747049905,44.4993302,0.011465837351905686 -0.483,43.63876283928425,0.7867624703100652,44.3761032,0.009504195399926774 -0.4865,43.51054021142138,0.7790839145804028,44.23349096000005,0.011294303464482765 -0.49,43.385645960599,0.7719081041010387,44.12780356000009,0.008723379365141703 -0.4935,43.26360291398451,0.7652372660179758,44.008128759999906,0.009920238704170052 -0.497,43.14333571303225,0.7590372848255603,43.87723040000011,0.005352610516359411 -0.5005,43.031513057923064,0.7521143934625582,43.738598,0.006438766535602852 -0.504,42.914462269346,0.7460055840006935,43.609428720000054,0.004275432386553704 -0.5075,42.79375238373374,0.7405599333592565,43.48044444000006,0.0065952069966553695 -0.511,42.67099389112675,0.7354255038014327,43.35048492000001,0.010701456335107384 -0.5145,42.54509398758675,0.7305870236608176,43.22702916,0.005802748158245736 -0.518,42.41559064038025,0.7256416255572103,43.087877000000006,0.008516347192310795 -0.5215,42.28236106455377,0.720394495237133,42.98324788000004,0.009240171470925177 -0.525,42.14609032238275,0.7163086547716571,42.837337159999905,0.006974657877482508 -0.5285,42.00597552864512,0.7136848826841068,42.697790640000086,0.01076637480439194 -0.532,41.86166933165625,0.7126253624283638,42.59463203999996,0.00861315186143252 -0.5355,41.71353959013699,0.7128167004846764,42.454239799999996,0.01708787504928451 -0.539,41.562347312116756,0.713747135550174,42.32947240000004,0.010440627238828392 -0.5425,41.40983185243398,0.7145358821940859,42.18780040000003,0.013955256159662791 -0.546,41.25689216729925,0.7146029769209429,42.00922644000012,0.011770178807801651 -0.5495,41.10386038401387,0.7131673541148549,41.85667492,0.009306045717340658 -0.553,40.95107953728925,0.7094583116235187,41.65720159999999,0.010017315873027045 -0.5565,40.79883960100801,0.7023557777717249,41.479156240000066,0.004027154716174317 -0.56,40.64714266232848,0.6911978451571793,41.304521880000095,0.008045755914226387 -0.5635,40.49593985305562,0.6749311260824069,41.13692491999991,0.0027608818214178215 -0.567,40.34381478656575,0.6524259137596867,40.95545536000016,0.012897081835214605 -0.5705,40.189315739800385,0.6233763815619794,40.7550946,0.007852614647364458 -0.574,40.03187241382375,0.5892924157695416,40.580104040000066,0.015454466424566665 -0.5775,39.867260642206375,0.5514264149925122,40.40713688000008,0.008897410632945798 -0.581,39.69410663481275,0.5128975873508048,40.214122519999925,0.008974378958553037 -0.5845,39.51407277749499,0.4779556683573206,40.043579320000006,0.002074139255772894 -0.588,39.32937184409923,0.4507645453398055,39.84060000000009,0.009839310443334711 -0.5915,39.141340854425124,0.43294058635309324,39.65948740000007,0.009574017528698893 -0.595,38.9499910415225,0.4201792471607728,39.49649131999986,0.011711754056222828 -0.5985,38.7574532014719,0.4096758425263038,39.30407248000016,0.008198348212520537 -0.602,38.566524138282,0.39750520002340817,39.13478543999993,0.013324454353855559 -0.6055,38.38007859596889,0.37795588345209463,38.951351400000235,0.015190854495290394 -0.609,38.196861436389995,0.35176363112167885,38.745233320000075,0.010465658670725329 -0.6125,38.01227281402563,0.32090638719289144,38.56817915999992,0.0281097722702744 -0.616,37.827128113333,0.2876544245750597,38.38842260000017,0.01181336250945745 -0.6195,37.643180301690975,0.25646558131367725,38.191673359999996,0.008274571901172317 -0.623,37.460724958355996,0.23129992045739134,38.03273280000007,0.007164338399406566 -0.6265,37.27989362757725,0.21556762313012853,37.82385272000001,0.019430580373042336 -0.63,37.100687932599996,0.20977887018097952,37.65701412000006,0.008769171157636533 -0.6335,36.92324496631913,0.2109990514165394,37.46793995999989,0.0073628600862451305 -0.637,36.74741597820572,0.21496365529931216,37.25089196000014,0.010362825782050101 -0.6405,36.570750858063384,0.22002267170654258,37.093465800000004,0.009108284344486054 -0.644,36.389633236659506,0.22829899073111093,36.905495840000015,0.008409744398599405 -0.6475,36.20169893199524,0.2437760205880415,36.69175740000007,0.006700513299774406 -0.651,36.0061787761,0.27294985756564905,36.528873599999926,0.010414958462744298 -0.6545,35.8025197690275,0.3179456872609438,36.31125552000002,0.017223278892505096 -0.658,35.59082788177375,0.3742311681371412,36.138339000000066,0.00857531815733606 -0.6615,35.36938988330549,0.43698062106895486,35.96530524000001,0.009330944833607187 -0.665,35.132875749724,0.5080842858796147,35.76435068000008,0.012334149957386185 -0.6685,34.87895308101338,0.5785161100996495,35.589061880000145,0.007736457890502556 -0.672,34.60957787946075,0.6362414544539146,35.39545195999992,0.01813275161214981 -0.6755,34.30554421593454,0.6498694429441658,35.16981860000035,0.03188204898185256 -0.679,33.96723170404425,0.5930540325166161,35.00579004000007,0.008265646114372669 -0.6825,33.62476405299239,0.5050130334916625,34.81609595999993,0.013649457839274117 -0.686,33.30874825699625,0.42714862018155486,34.62231180000016,0.009517253285552753 -0.6895,33.032050080863,0.3865297106071883,34.42976856,0.0051012444744934675 -0.693,32.8006177692245,0.3838373605328866,34.20942620000009,0.007411543307616211 -0.6965,32.59288349447972,0.39333696496905957,34.039293400000005,0.0178790979281052 -0.7,32.399389246326244,0.408124031967078,33.826712840000106,0.013537365743946844 -0.7035,32.214689287577755,0.4256392629815747,33.62989431999993,0.022450385234320643 -0.707,32.03263434045075,0.44404358283247536,33.452490200000206,0.012845267056023285 -0.7105,31.847944300554147,0.46131701734312186,33.26066039999999,0.009252784056702929 -0.714,31.654689772475997,0.4785007918480388,33.06742367999988,0.027771786695959578 -0.7175,31.440555044436877,0.5046995897616864,32.868871040000144,0.017953670114160533 -0.721,31.209039897031253,0.545091498189209,32.667924559999925,0.005467945177901651 -0.7245,30.968417306500637,0.5897751789736688,32.46816156000022,0.014793616741380196 -0.728,30.71798238395425,0.6108491674662532,32.29318059999999,0.009524542786928342 -0.7315,30.468698911260887,0.6096001746667424,32.086761040000006,0.013912553043451303 -0.735,30.223140989451498,0.6167326490804896,31.871087360000075,0.01844099749117589 -0.7385,29.99278782298025,0.6343744476912249,31.64494756000018,0.011378531954830524 -0.742,29.77772756198575,0.6528297670093952,31.402672239999895,0.00897272852191504 -0.7455,29.568012108860387,0.6664776986676298,31.154908000000194,0.009446542674452132 -0.749,29.36147594715475,0.6747168423019626,30.94869924000007,0.00565032629039962 -0.7525,29.156516068030527,0.6767618107861278,30.74856043999991,0.00406974473020427 -0.756,28.953162875916746,0.671073480314441,30.500433120000242,0.024660869742466156 -0.7595,28.751288675509386,0.656981453949864,30.266203999999988,0.011222817849371014 -0.763,28.549638194744,0.6349300802777955,30.047965800000004,0.014395569637913198 -0.7665,28.34752370104738,0.6046314807579305,29.79373364,0.01280022008982202 -0.77,28.146467859871997,0.5660396015337505,29.580499840000073,0.010951293046388031 -0.7735,27.944804940414226,0.5200834494776901,29.382529839999894,0.020152089525049457 -0.777,27.735118960224252,0.46325031127942634,29.1079085200003,0.017460536835222126 -0.7805,27.509057876371372,0.3958198058953374,28.8944614,0.030818738582233725 -0.784,27.277418804353,0.34638178897131056,28.68913283999991,0.020341341772127926 -0.7875,27.051961030532155,0.32729600298934436,28.446203200000166,0.011177488124792065 -0.791,26.845273117353997,0.3170967551267719,28.22755095999991,0.007035636028707474 -0.7945,26.648402065762,0.30009358614352216,28.012601880000222,0.007682184123738505 -0.798,26.4534701332005,0.274434856683554,27.7814608,0.008283405803170748 -0.8015,26.25202385514624,0.23787290459718366,27.54526052,0.015687450400562016 -0.805,26.0456436349785,0.20750981927747997,27.333014560000088,0.003917848972038771 -0.8085,25.8403861391626,0.20766871212426877,27.10834152000018,0.0031669031673865196 -0.812,25.64036273309125,0.23737295729168117,26.885249400000003,0.011701863572084746 -0.8155,25.446395047539127,0.27493296015958885,26.657907799999997,0.005298881127181853 -0.819,25.248675299593998,0.3158286952082651,26.456491960000086,0.007258732632350865 -0.8225,25.043029619999388,0.3578946482520627,26.222004519999892,0.005052253114416137 -0.826,24.82466015492625,0.4032366698145659,25.98319036000017,0.013432965585742671 -0.8295,24.575296770036402,0.47026060585581897,25.737919359999914,0.011427024356664334 -0.833,24.30871377378075,0.5566004910909391,25.559503,0.00995000783919264 -0.8365,24.042126347794234,0.638479659026457,25.327980520000086,0.007862756829000136 -0.84,23.7919156994905,0.6837019505043551,25.063189720000118,0.04756283654147429 -0.8435,23.55295856934212,0.6907039182009682,24.893624599999903,0.01320599125561187 -0.847,23.298765948836277,0.6459671967184175,24.64347436000012,0.022714664331016175 -0.8505,23.02334402619674,0.5622835915007076,24.4546574,0.017527259748746898 -0.854,22.737114031359997,0.5060244706124171,24.22613351999984,0.010732413334186537 -0.8575,22.449483161109626,0.5294467696468831,24.02415732000015,0.012534440863907873 -0.861,22.170380111430497,0.6181660122383096,23.794813439999857,0.02847061945694767 -0.8645,21.909909746079656,0.7191796724241643,23.554477800000257,0.04135148687084299 -0.868,21.658801787777,0.8146212891930571,23.3379774,0.010291420616222163 -0.8715,21.40561346834739,0.9076453127430048,23.089564279999983,0.04617424130025086 -0.875,21.151838430168,0.9925757456439734,22.92928804000011,0.011954260391558924 -0.8785,20.89772570596136,1.062481885477872,22.67953972000015,0.02476171012211046 -0.882,20.61747255334475,1.1169872223654116,22.438158039999973,0.034397961468496094 -0.8855,20.31258294851547,1.1704279654415568,22.2510086,0.02225743943718642 -0.889,20.00899001812,1.235021988140904,22.014290880000104,0.0178361127618226 -0.8925,19.730862176959377,1.3024516907469477,21.79322543999991,0.004918563020497261 -0.896,19.48483013038475,1.3576998101173667,21.586787320000134,0.0037129034234397243 -0.8995,19.253469328268267,1.4034566571739249,21.366284399999905,0.011610981549375577 -0.903,19.032800038817726,1.4427158058885812,21.126078,0.03559875695161285 -0.9065,18.820463149529253,1.4764073839612322,20.92013488000003,0.026423412176962802 -0.91,18.6134329558845,1.5061052435531301,20.732784640000062,0.020192695895005497 -0.9135,18.41025363184364,1.5325348370365992,20.49507659999991,0.023097993671646524 -0.917,18.2100565549905,1.5563242853294803,20.285467720000025,0.0268972383913893 -0.9205,18.00978740605322,1.5783152195540964,20.0023924,0.07199470682487696 -0.924,17.806325139566248,1.599549321932043,19.823361880000125,0.010543671625741047 -0.9275,17.59659099559174,1.6205788002587591,19.550827320000064,0.06279347383713048 -0.931,17.38056969861397,1.639098594657082,19.334216999999782,0.028133036895840968 -0.9345,17.155338738820625,1.6471103119357835,19.076305600000182,0.043909570454194066 -0.938,16.918238572635996,1.639390801490406,18.686636799999995,0.059731474590034646 -0.9415,16.674294322447654,1.6211881537247506,18.646142440000105,0.020415628648388993 -0.945,16.426746819252998,1.5991727547339865,18.41370900000011,0.008274733576396716 -0.9485,16.178251282294138,1.5794317418268824,18.13229667999997,0.04042389313889019 -0.952,15.931538773513997,1.5676172872118137,17.894028399999982,0.08740557793396896 -0.9555,15.689471658683999,1.569873012504834,17.625821600000002,0.09617249547193871 -0.959,15.448389027528249,1.585919601868563,17.473802560000113,0.018125929816354906 -0.9625,15.199287695923339,1.6120036178013106,17.182584879999915,0.05388653745126725 -0.966,14.931528382895749,1.6424374673653113,16.88241987999995,0.10866096791809254 -0.9695,14.644309378989375,1.669151375253334,16.75028119999992,0.026102504974011898 -0.973,14.343494839344498,1.6819151246804427,16.504697999999998,0.03559126432848413 -0.9765,14.033864844043666,1.6682011320774757,16.19685260000012,0.043186933616365955 -0.98,13.704678788192249,1.585739082232626,16.03082631999998,0.04788709803251443 -0.9835,13.34153620858999,1.3917748585073921,15.74765844000033,0.05658033474884382 -0.987,12.983159778249751,1.1655160513226586,15.620607479999967,0.06068311333745482 -0.9905,12.67345108144811,0.9866181038686157,15.1807816,0.02521628217640338 -0.994,12.416802875429251,0.8732325410264439,15.080748160000104,0.00869954415172372 -0.9975,12.18305308939038,0.7752090351226639,14.828844880000137,0.028062409846492945 -1.001,11.965281473335022,0.6883080009316256,14.640595359999818,0.038372509096542946 -1.0045,11.758808814340863,0.6105804809475027,14.40947912000019,0.058827866033546866 -1.008,11.5580519829205,0.5394669697248811,14.1783534,0.0445010669344001 -1.0115,11.357901450080375,0.47302295598552757,13.897769880000212,0.04396686550455952 -1.015,11.15386521377375,0.4105221413617631,13.599007559999956,0.07464762019067558 -1.0185,10.944764703416286,0.35641671782011203,13.501256759999936,0.04295247526171493 -1.022,10.7301107364895,0.31597930449591405,13.31914352000003,0.023977230095537413 -1.0255,10.508891150501785,0.29728948645150427,12.965481800000129,0.07032114494376007 -1.029,10.279296103651749,0.30934593867770444,12.684029240000068,0.1035588039552451 -1.0325,10.018374694510836,0.397490140963851,12.574570959999864,0.024950881091157454 -1.036,9.7374115164915,0.5457005119144924,12.123970840000213,0.13756154774442306 -1.0395,9.458295363643078,0.7033723541625938,12.06929139999984,0.10017464849779181 -1.043,9.19683258697325,0.8175169855770239,11.86673740000044,0.04738980249291977 -1.0465,8.973271867122126,0.8498550516671426,11.720122520000075,0.03025180823375866 -1.05,8.7646510511425,0.8578356001977185,11.453227599999863,0.10528451887657622 -1.0535,8.564775370478028,0.8608250582882135,11.020707080000147,0.1336159661273686 -1.057,8.3745681850635,0.8610709114256083,10.867948760000047,0.1162349161389094 -1.0605,8.195758562771513,0.8581716837231458,10.722402200000019,0.11520428777048665 -1.064,8.02901037633825,0.8506210313999198,10.566289239999996,0.0641931398042786 -1.0675,7.8695856848643935,0.8375979572052171,10.29540744000002,0.046221189205849764 -1.071,7.71242479337975,0.8198282796137591,10.026004927999912,0.1045029301219252 -1.0745,7.555075570197602,0.7970952365671834,9.72891625999983,0.10497521044175546 -1.078,7.3950994542215,0.7696680326355213,9.56646336,0.09972413690771181 -1.0815,7.2299025035746265,0.7374711832494971,9.271973092000005,0.09066166699346043 -1.085,7.05860622281675,0.7021459930411443,9.196995056000222,0.06368560400887567 -1.0885,6.883941154181256,0.6619609484374829,9.017284851999912,0.07378718256522368 -1.092,6.708303179294987,0.6168209775475579,8.686749208000029,0.031896525704932316 -1.0955,6.532421768367654,0.5688454716316858,8.445021820000061,0.12246492766260073 -1.099,6.35704586649275,0.5204343795365226,8.05141734800021,0.13535139077600453 -1.1025,6.184080880876146,0.473408952813009,8.023820488000162,0.10344764001147905 -1.106,6.01543279579875,0.4294024881813408,7.860186460000105,0.03426716811506212 -1.1095,5.852228412578986,0.3908150087746613,7.564857023999967,0.09092503851106333 -1.113,5.69334938049576,0.35769639531423064,7.428835700000334,0.03827622478824162 -1.1165,5.536772730225245,0.3291178475532528,7.134862888000038,0.13223537056457751 -1.12,5.381464134063711,0.3052315273505149,6.683074687999836,0.2543729002821533 -1.1235,5.226549188514877,0.2864455979491695,6.650336388000324,0.21995229897184992 -1.127,5.07112199803325,0.27269566654984656,6.431065204000211,0.20440961614831207 -1.1305,4.914218444001399,0.26392108622349086,6.318500579999926,0.050100203809762135 -1.134,4.755191340894498,0.259271866702319,6.082786271999931,0.05124649202325345 -1.1375,4.593580751050141,0.2574886566377837,5.83452447599985,0.07913370412061695 -1.141,4.4291514678545,0.25714922572775234,5.366381603999636,0.2941420650775826 -1.1445,4.260559753449851,0.2569070434116753,5.352582327999382,0.15951368597526006 -1.148,4.0847661484557465,0.25808814549769404,5.23372236,0.19068962778071577 -1.1515,3.9009005993722212,0.2605696063104201,4.979195547999548,0.032824679161449606 -1.155,3.7130887069955003,0.26306536180557766,4.811699636000203,0.06057306191247328 -1.1585,3.525405194324999,0.2640908477846995,4.570247507999824,0.12905467935119347 -1.162,3.341914513983747,0.26166498702260577,3.9266566759993586,0.3095395009667168 -1.1655,3.165988645628881,0.25299212838211654,4.007440440000001,0.36026566176491615 -1.169,2.997077459806738,0.23634009655239058,4.106621751999984,0.06101360495560241 -1.1725,2.8405716980260145,0.21068363382573677,3.842657555999717,0.09868925680104315 -1.176,2.6927441805092487,0.18804224257993596,3.5953391440001696,0.30653597823702383 -1.1795,2.549100875535354,0.17903154136509278,3.426546967999941,0.03381267429050174 -1.183,2.408334133878,0.1759441183121078,2.4597963599997845,0.08719148208076609 -1.1865,2.271567854621475,0.17301224500845627,2.850226756000135,0.24275893730512615 -1.19,2.142132755375749,0.17036478115184442,2.738434508000305,0.3275439224902328 -1.1935,2.0239704854193694,0.16890883377248478,2.921633480000186,0.023221618879316206 -1.197,1.9181741091865,0.17708843494023646,2.4574351120000753,0.36739988350301955 -1.2005,1.8187282360736245,0.20500418740352838,2.4252081199999997,0.10525188364733415 -1.204,1.725637613785,0.24387952209680416,0.7101924652002243,0.3091001544841439 -1.2075,1.640679026860888,0.2847185696903423,1.7262059040004796,0.162354200137534 -1.211,1.5649786970127506,0.3220087502270726,2.0732696519999267,0.2711785776228183 -1.2145,1.5004343673740064,0.35148095248161515,1.698918874799206,0.3691685060977162 -1.218,1.44805130106275,0.3705539097161823,1.8392692,0.2633687149246849 -1.2215,1.4098481998063799,0.3761935095953328,1.7960777279997597,0.13734855349618863 -1.225,1.3865261003875005,0.36689505055495103,1.0286601524024959,0.28384834368611134 -1.2285,1.3723826862583741,0.34814158422433056,0.08098589395999709,0.0017161753750779324 -1.232,1.361115518666,0.3275319954173664,0.655926309279265,0.3868892357917412 -1.2355,1.352539881939625,0.3051496837675395,1.1019174994,0.627968643524797 -1.239,1.3462607815325005,0.28121296064096846,1.7266239335999551,0.45305457795638393 -1.2425,1.3419928018729996,0.25567407150983185,1.7283767920000734,0.22590893532331513 -1.246,1.33946914008825,0.22896803784792438,1.1994604248001859,0.39430209156329765 -1.2495,1.3386309079854992,0.20156035496023014,1.296825822799956,0.24144244448166333 -1.253,1.33928438299675,0.1741332591526348,0.96146083,0.10725284771163954 -1.2565,1.341360151481249,0.1474866447502193,0.711343653199983,0.2728008332130418 -1.26,1.34467501631875,0.1228404988933939,0.7427097291992552,0.17386084363261609 -1.2635,1.3491490384193772,0.10202661229568193,0.775418972000079,0.10481557584487895 -1.267,1.3546095461124978,0.08775948927553467,0.7998003328000067,0.20225337877333838 -1.2705,1.3609660748600012,0.08288133211924696,0.7860265139999999,0.13820198116423266 -1.274,1.368056478438503,0.08795499720386286,0.9925420719998634,0.11078113817341499 -1.2775,1.3757797668622502,0.10022547559121059,1.009099943200063,0.13266113377449226 -1.281,1.38416726698775,0.11597076407828827,1.0451164579997632,0.21938839490308895 -1.2845,1.393556218989747,0.13210834508762845,1.3604120039998069,0.19835656281234243 -1.288,1.403677120196,0.14728773956051755,1.37512472,0.16742734326786948 -1.2915,1.4142803301686229,0.16051301040498303,1.4638818319996305,0.1817846580912249 -1.295,1.4251539979435,0.17134743591983434,1.3262291519997542,0.08526272390372826 -1.2985,1.436987184552251,0.17976890342055915,1.2946339159999662,0.1675257237256827 -1.302,1.4498349906415,0.18593386467944706,1.3784468760002677,0.18190713282733653 -1.3055,1.4649145810907525,0.18885466311703863,1.3948699,0.0747083330797843 -1.309,1.4829398066062502,0.18713892115519196,1.3350692119999779,0.14595918971547261 -1.3125,1.503361999879,0.18119496300985674,1.2953270520002715,0.12074254940559392 -1.316,1.52543240946775,0.17195493047526142,1.2468278400000492,0.17031602423808254 -1.3195,1.548539635289998,0.160179925966386,1.3623864399998902,0.09394423894974259 -1.323,1.5719893319655,0.14701791100557038,1.33624504,0.15738647371771822 -1.3265,1.5951156933504997,0.1336238117133597,1.2398727088002919,0.14434530971467605 -1.33,1.61727878012575,0.12147970057671312,1.4152722119997347,0.13882210850237373 -1.3335,1.6377583800873752,0.11217852341603818,1.3396372420001998,0.2556010826529009 -1.337,1.655968959976,0.10719524758847222,1.4531473679999427,0.11807195784858054 -1.3405,1.6698370932113744,0.10960347148271163,1.2405439,0.2076939037317658 -1.344,1.67574881110725,0.12536856241589273,1.2841973520000092,0.21367802711361697 -1.3475,1.67349970978775,0.15307637586104178,1.5133903680003367,0.2533935308692719 -1.351,1.6631505962140085,0.1882119569204965,1.5587789999998367,0.46353925985721023 -1.3545,1.641049308696251,0.22479645664310566,1.567439261600149,0.42606888004547583 -1.358,1.6086698125652463,0.2622290838195113,1.33966142,0.1742685083399092 -1.3615,1.568175902518758,0.30056305380751186,1.3810543655998995,0.2898424525162037 -1.365,1.5224559488312501,0.3394092588054714,1.3915496080004246,0.2330957962193257 -1.3685,1.4739273589601196,0.3776575257103912,1.5071334479999097,0.27558959555795676 -1.372,1.42523223125675,0.41404675594585677,1.6873947879987465,0.48274788805702445 -1.3755,1.3789987859204929,0.446798546208182,1.41179658,0.2911521019623369 -1.379,1.33765830856075,0.474469894386872,1.429630916000339,0.18088890750861705 -1.3825,1.3039027197182467,0.49569262602839104,1.4256524319998571,0.09151931165015531 -1.386,1.2764882727834992,0.5108110790267568,1.4700475239999302,0.112048576528784 -1.3895,1.256074089212625,0.5188514635032765,1.4367449199999918,0.07310073472730534 -1.393,1.2415201654045,0.5231846517909338,1.5061570400000002,0.05638551847569556 -1.3965,1.2318077236927472,0.5270243515804311,1.538461931999771,0.0931142574866099 -1.4,1.2267183441719993,0.5315441553173451,1.545213719999241,0.15117752247532792 -1.4035,1.2264212069707536,0.5374031555046983,1.6232810840005178,0.20409026614203213 -1.407,1.2307021128295,0.5451154536499881,1.5241491959999942,0.0361098088473945 -1.4105,1.2397283660792564,0.5546694012731086,1.56711912,0.09985669591838592 -1.414,1.2532876432577498,0.56586957869489,1.5345294119999953,0.0791443649349935 -1.4175,1.2715453728988813,0.5780815714869302,1.567703492000034,0.10145400751122982 -1.421,1.29384075187625,0.5907944440400797,1.632489535999958,0.14880524043456236 -1.4245,1.3192268145921249,0.6034767814543118,1.6583158799999638,0.07815621425288108 -1.428,1.34707796904225,0.6155680768663119,1.6655286800000002,0.053993467402659014 -1.4315,1.377001262330625,0.6262414392483036,1.6780898240000024,0.08795377845115625 -1.435,1.4100768900962495,0.6329710872147157,1.720269124000002,0.07747907905801837 -1.4385,1.4512298848301175,0.628401550874639,1.7597230960001586,0.1966580231768443 -1.442,1.4981505342514998,0.6141197764825146,1.6362352960000268,0.09141345498587776 -1.4455,1.5482276244608708,0.5924476400048924,1.7322467799999999,0.08026984266913073 -1.449,1.5985974262944995,0.5665825870167714,1.7545324519999976,0.0433264028399721 -1.4525,1.6464206032237485,0.539240391027518,1.728013599999916,0.08228207597954805 -1.456,1.689061548713744,0.5130684141555654,1.7809498199999994,0.11319519385279361 -1.4595,1.7235835052113775,0.49004442170001905,1.7359105479999755,0.04744618927775942 -1.463,1.7491616973552493,0.46857450766538156,1.6700345799999603,0.07632493953758694 -1.4665,1.7636317972103746,0.4479696629650431,1.8105440240000068,0.1879164316753061 -1.47,1.76771222536925,0.4286749904189692,1.7313651680000715,0.09042572213442715 -1.4735,1.7663700493326282,0.40872133137026606,2.0706967799998752,0.5566733699563287 -1.477,1.7606835716419995,0.38916168239502136,1.8781061359998301,0.3556842430065414 -1.4805,1.7509600070866282,0.37122230089067104,1.7681505800003177,0.10345659366384807 -1.484,1.73782953740325,0.35623233070868915,1.7776888279999443,0.06510021549916566 -1.4875,1.721638435568872,0.34526941830961566,1.7979990959999737,0.04414418132435363 -1.491,1.7029778251329994,0.3391049120102055,1.908139671999908,0.1721370230333784 -1.4945,1.682233037260619,0.33793692039040796,1.8261852000000172,0.04599168222896479 -1.498,1.66009810865125,0.34154809784513407,1.8811493799997883,0.07284057057331564 -1.5015,1.638147458378,0.35047829792542506,1.891469432000078,0.14080010165378082 -1.505,1.6171391430192585,0.36426888624760134,2.0496613200002045,0.3593733047937727 -1.5085,1.5976606074720014,0.3818439207826943,2.0653310920002306,0.16001294406579858 -1.512,1.5801769142477475,0.40190592798991503,2.032591144000412,0.2067042738135286 -1.5155,1.5653193627192525,0.4230736377914386,1.8674683799999996,0.10170796804153064 -1.519,1.5535091609222498,0.4441109995304287,1.9078767919999653,0.06231333762900811 -1.5225,1.545421462704998,0.46376509814558164,1.9411316719999632,0.04102478651989224 -1.526,1.5406072879635002,0.48103413706104503,2.0045172680001384,0.0686782752483432 -1.5295,1.5379152195451233,0.4949544740757772,2.0291415880000065,0.06487215386110555 -1.533,1.5377351859109996,0.5048825484140882,2.0415448799999543,0.07924427523770423 -1.5365,1.540502419898501,0.5102747943647933,2.089439799999953,0.09265509504429027 -1.54,1.54562824090725,0.5121776086286614,2.0771300039999905,0.07291245087573632 -1.5435,1.5526955361655002,0.511267451909304,2.1129807999995482,0.07815585388470564 -1.547,1.56113187496225,0.5084839216017326,2.6455394040001172,1.366376513583764 -1.5505,1.5704789135482502,0.5043804213865278,1.9751640399995227,0.18956081916919934 -1.554,1.58020545219025,0.4996172068878629,1.9882493520000786,0.25206106885066853 -1.5575,1.5898119158269988,0.4944726897031571,1.9889162759999874,0.18641793664836953 -1.561,1.5987916944675,0.4892321406115124,2.0085638199999454,0.1436357499862304 -1.5645,1.6066296007194976,0.48395285485702866,2.0156726519999912,0.11969388044535535 -1.568,1.6130307033204998,0.47885992886544887,2.0927736200000213,0.1049369400748107 -1.5715,1.6175461082351252,0.47379992598557147,2.224666059999931,0.14771520823860937 -1.575,1.6208223741337502,0.4683096361050056,2.1381339919999633,0.039298405602778336 -1.5785,1.6238657490333748,0.46190803339901576,2.1908607880000366,0.11427474890626309 -1.582,1.626803979145,0.4546962405780598,2.196803044000098,0.041878951233772846 -1.5855,1.629739842255124,0.44664417000840095,2.2138667199999995,0.0481359904301553 -1.589,1.6327763055095001,0.4378667818054686,2.21100868800004,0.1281473346934578 -1.5925,1.6360247194003756,0.4283492515298239,2.2884432479998496,0.11703030816323864 -1.596,1.63954733589075,0.4182532601075681,2.2795763680001127,0.18273489590309772 -1.5995,1.6433552476075006,0.4077240260855337,2.217745212000004,0.021653254112779713 -1.603,1.6474848204725001,0.39696872306301034,2.1771119000000003,0.032429121399523024 -1.6065,1.652003415076002,0.3861001593458751,2.227454208000028,0.09952052552483084 -1.61,1.65694727026875,0.37532641668423855,2.295361571999885,0.17828920431568596 -1.6135,1.6623880632836248,0.36478130924413754,2.2620400519999593,0.10694081088418823 -1.617,1.6683577163282501,0.3546695286115481,2.763270176000654,0.6412051980820467 -1.6205,1.6749322232788741,0.34513304168411924,2.3166545999994685,0.07674411516056176 -1.624,1.6821391897002518,0.3363580169022342,2.879683747999348,0.9685936631022454 -1.6275,1.6900589261108738,0.32847440394144334,2.485562920001614,0.11067884511781408 -1.631,1.69866556833125,0.3215778398582602,2.2985908839998688,0.3945057934498878 -1.6345,1.7072348178673726,0.3150437853456438,2.4612982279999867,0.18810409414343687 -1.638,1.7155625184762497,0.3091090335850148,2.4061289799999996,0.21214982299632493 -1.6415,1.7237228147870014,0.3042622559205307,2.318910875999978,0.09878585178919905 -1.645,1.731803243773,0.30106031115815385,2.382648171999966,0.0753247835944716 -1.6485,1.7400291523991287,0.30020775748227413,2.3251497800000798,0.06247435599979913 -1.652,1.748748234443,0.3026461378503314,2.3297090359999926,0.07709095095783217 -1.6555,1.7579904764481251,0.3085873436060875,2.42785504,0.12164545145870838 -1.659,1.767729941166745,0.31797309605382096,2.5195953480004327,0.21136978179377244 -1.6625,1.7779821265754965,0.3305700388534571,2.436594783999924,0.03953974551668658 -1.666,1.78872151299675,0.3459700366246787,2.451068051999985,0.03212906492600706 -1.6695,1.7999631808367482,0.363672565350284,2.731391087998623,0.571126143621119 -1.673,1.8116820279885,0.3831368774491362,3.3921817399999994,0.9381286982468547 -1.6765,1.8238927172872534,0.4037894024834718,2.4190161320000043,0.21418129917404316 -1.68,1.83693864297,0.4249090555074616,2.4967114959999908,0.25945392754709573 -1.6835,1.8515360780942547,0.4456102238586112,2.44225764400004,0.15066811679875677 -1.687,1.8675829380854985,0.4656037988822547,2.479348239999986,0.181676620588002 -1.6905,1.8850661382788751,0.4844864650677768,2.4745094,0.06708247256798897 -1.694,1.9038673014554914,0.5020367448074173,2.539944303999847,0.11178671271415153 -1.6975,1.926447476600749,0.5180041536482374,2.7808674159995044,0.677510098810797 -1.701,1.9539722940805015,0.5328213206700032,2.6403524479993745,0.24610434800850423 -1.7045,1.9858543178849917,0.5468037438941727,2.6123464719999143,0.2326642572566209 -1.708,2.0211575354995,0.5603452608627448,3.15594366,1.1514071508356105 -1.7115,2.059948259633134,0.5721799423285567,2.4349257079997644,0.36369431208952724 -1.715,2.1048984198194995,0.5759902564056814,2.60832819999992,0.18718959520372674 -1.7185,2.1551256157096335,0.571125520427035,2.9036793639989265,0.267369156020514 -1.722,2.2085713889984997,0.5591750026628551,2.9161948720003226,0.5029912975505041 -1.7255,2.26329482819775,0.5407812982146422,2.63217156,0.15907625028376482 -1.729,2.31684152615475,0.5168681466389492,2.913570716000378,0.4317990220114309 -1.7325,2.367460532958124,0.48853977004655424,2.6846819880001656,0.282234625999887 -1.736,2.41374232552525,0.4573292231553292,2.6490374400000176,0.2644489956946221 -1.7395,2.4539159462546207,0.4239251883671791,2.6798319679998124,0.204004069845269 -1.743,2.4866990912919986,0.3890842132003834,2.85319828,0.2881280683757346 -1.7465,2.5100404056872474,0.35264006251079916,2.7038292239999757,0.11985034044605024 -1.75,2.5219982534122503,0.3136843486177948,2.7824720679994708,0.35056047789028877 -1.7535,2.5219131164461244,0.2752278959302241,3.396688151999514,1.48432576617818 -1.757,2.5105876102030003,0.24328038982721073,3.28126531199925,1.251765019622295 -1.7605,2.4893734227834954,0.22370686954235966,2.8884532999999997,0.3190974232001569 -1.764,2.4629121060959998,0.21830160995210612,3.078675428000346,0.8109307355190993 -1.7675,2.43269716611975,0.23034655344047086,3.2021254080014026,0.9538711549808776 -1.771,2.4003866248077497,0.25798198009737866,2.524137403999977,0.4400934945006691 -1.7745,2.3674638706688755,0.295899052123955,2.9229153999997832,0.45972532403646404 -1.778,2.335461269237749,0.3385760247359681,2.9535047,0.44653482561507446 -1.7815,2.3059878654407533,0.3815204198836991,2.6849138520000606,0.18687863891159123 -1.785,2.280490727698749,0.4216305878556061,2.781540632000335,0.3561741727233348 -1.7885,2.2630935443912517,0.45652290232142734,2.8444570519997607,0.14803970697034 -1.792,2.25553033153575,0.4856927593979457,2.708574719999972,0.2708407066965626 -1.7955,2.2578872964187524,0.5094149029721172,2.8129633800000002,0.26984247111783016 -1.799,2.2647069308324954,0.5333905559224293,2.9639589280004115,0.3090917539189799 -1.8025,2.2741242915546276,0.5591706278108824,3.336811871997522,1.1302798254897874 -1.806,2.2844638536667503,0.5858430860432832,3.1427104679989495,1.160783175040185 -1.8095,2.2947961665376244,0.61289856703603,3.0306671559978335,0.5089735911421717 -1.813,2.3045891058340047,0.640246825317831,2.8275537,0.34686070854954865 -1.8165,2.3132655994251228,0.6668577815761929,3.208411816000634,1.009394200349786 -1.82,2.3203378908375,0.6916927680974069,3.299303144000812,0.7909659173596433 -1.8235,2.3251845400813753,0.7128767049394912,3.0885834479996843,0.9974888001910179 -1.827,2.3273621585415,0.7289312946084243,2.6791878280005186,0.5205312829740075 -1.8305,2.3262049383692487,0.7375698883480223,2.6977996000000273,0.23782470894541088 -1.834,2.321324723744,0.7373480161233679,2.8425740719997883,0.2694138627750996 -1.8375,2.315755240618624,0.7314683277658388,2.988685484000432,0.28039806242155374 -1.841,2.312802782752249,0.7234550125545105,2.955529571999693,0.31210620562546953 -1.8445,2.31487761984125,0.7097787038661684,2.767490892000102,0.30827736340290324 -1.848,2.3216868810735,0.691571724614045,2.74824154,0.12484195928418064 -1.8515,2.332778308877126,0.6703795497360431,3.1491814640001357,0.6609993993621026 -1.855,2.3473570723555,0.6482352101265687,3.205701363999915,0.5069396361735703 -1.8585,2.3652808193288735,0.626822253599339,3.2902310159997237,0.7364976506263304 -1.862,2.391827720849,0.6106170704059348,3.2003010440005655,0.6669591047679824 -1.8655,2.427155164648131,0.6038077102263939,3.4236459200000007,0.7117643277971032 -1.869,2.467183959915501,0.6078979486900181,3.864644584000614,1.5104720857329463 -1.8725,2.508226695128757,0.6216791308997247,3.242316947999529,0.7487120566006389 -1.876,2.5465148435697507,0.6410161086054266,2.7836535560002047,0.2858999077993897 -1.8795,2.5780503296223753,0.6597606758285035,2.8119428960007817,0.2706556098037673 -1.883,2.599948016331,0.6726996103637164,3.29466214,0.8485014136902087 -1.8865,2.6162601382915,0.6859664302629774,3.371344104000032,1.0296502541993056 -1.89,2.6316241922629997,0.6989763097362773,2.9304574079998584,0.19498703380712706 -1.8935,2.6473579448886206,0.7102632644641672,2.826504296000224,0.14495744703176766 -1.897,2.663462106829,0.7201406279911531,3.378264868000172,1.022006991091161 -1.9005,2.67996825618588,0.728793343050506,2.970400680000429,0.07696080462338627 -1.904,2.6968758120692495,0.7365915184466358,2.818673048000066,0.24081213578315694 -1.9075,2.714217644131755,0.7437746831365977,3.825768720002715,1.0524741778602433 -1.911,2.7319918799325,0.7507029305564392,4.376612424001,1.5444995248647082 -1.9145,2.75023376297863,0.7576122590532663,4.298011315999617,1.4175225332206778 -1.918,2.7689707408727497,0.7648185044874973,4.192728319995613,1.2890116263832152 -1.9215,2.7882492587332495,0.7725067893672681,3.8707640720003647,2.1584990642267203 -1.925,2.8080489996267497,0.7808691323152774,3.4654943639997837,1.0606926141569475 -1.9285,2.828393080465494,0.7899929250890287,3.078815403999287,0.7551768595733795 -1.932,2.84926107096725,0.7999591387783186,3.3787536800000373,0.6285270918575444 -1.9355,2.8706761999871304,0.8107533214232094,2.67002968,0.3622907307358098 -1.939,2.89261792530025,0.822345893728496,2.697087611999975,0.3740079296084385 -1.9425,2.9151095877046305,0.8346227288333218,3.5298620599999366,1.4479264564844896 -1.946,2.938130533032,0.84746343416682,2.939376139999742,0.5358293199794596 -1.9495,2.961704214023756,0.8606736269395823,3.185562155998947,0.8256677130733407 -1.953,2.9858098645685,0.8740750096276646,3.5456122399999996,1.1745020153821906 -1.9565,3.010538956238375,0.8873024932377547,3.825203315999894,1.3751316052706732 -1.96,3.0370049275865005,0.8981302982631018,4.234736751999892,1.4446042955099965 -1.9635,3.065658548747875,0.9055208824348768,3.6787003399998257,0.6498897116786592 -1.967,3.0962188410155007,0.909772432096579,4.117418523999204,0.976701830737582 -1.9705,3.1285637149418695,0.9109511512630691,3.268239399998997,0.3767469948493271 -1.974,3.1622276368034994,0.9091469004001477,3.679758624001509,0.9643103275868771 -1.9775,3.1966169147007446,0.903888622647223,3.6815526000022607,1.3466516529001893 -1.981,3.2314431161684993,0.8955678973519661,4.078127175999405,1.703278340536538 -1.9845,3.2664736348765016,0.8843962541570461,3.3591568439999286,0.8456418160741702 -1.988,3.3014595191142475,0.8709153758827847,2.631700420002634,0.24755275262270438 -1.9915,3.33878416211125,0.8553951628488692,2.8664301840002544,0.18298811577926755 -1.995,3.384318255918749,0.8384097947359123,4.019268259998711,1.8978820965305088 -1.9985,3.4380676852191243,0.8210820193117806,4.093392883997807,1.1196202906952035 -2.002,3.4981597869962444,0.8049465489789196,4.48161851600125,1.9917404590638634 -2.0055,3.5632408223766165,0.7915045395564623,4.227662680000082,0.9961417787265363 -2.009,3.6315579377987497,0.7820068639296595,4.458276920000111,1.0421843239552264 -2.0125,3.701627953037116,0.7770746398921804,4.046032523998994,0.7312630985650415 -2.016,3.77182745588225,0.7765717395895213,4.679609980001539,1.3502803456693073 -2.0195,3.840543824756501,0.7794966559124611,4.135076808000286,1.2162822388482963 -2.023,3.906283088801997,0.7842924298657712,4.161898519999999,1.0507926592295536 -2.0265,3.9673106594943808,0.7888125583189172,3.564149584000856,0.6993392772512018 -2.03,4.024735568609745,0.7933483787169833,4.561578984002035,1.8471834018245763 -2.0335,4.081012865991001,0.7999267886183599,4.286058667999503,2.014404911764861 -2.037,4.136240951004494,0.8086287422012202,5.10682062799623,1.5295980674040053 -2.0405,4.190373829010246,0.8194603937476532,4.281235100000001,1.308537814421574 -2.044,4.243453121929754,0.8323965238524367,3.3501046800009413,1.2910549865073113 -2.0475,4.2955203386048675,0.847529769197539,3.4575273920004954,0.4957124136893629 -2.051,4.346843691319997,0.865067325131993,3.0646000040002073,0.5126188282971573 -2.0545,4.397345397316379,0.8849241954615862,4.679667380000699,1.8135049335894151 -2.058,4.44712438424725,0.906804356051349,4.241315560000364,1.3617397820676644 -2.0615,4.496593413980618,0.9303004122804014,4.449158595999875,1.1919800006393566 -2.065,4.545942045089997,0.9551808962042821,4.075476692000853,1.6996772019322393 -2.0685,4.59532069911325,0.981329798326759,4.009452584000073,0.6209649434567417 -2.072,4.6448773957525,1.0085972542733164,4.154018083999651,1.214577596028783 -2.0755,4.694774991597374,1.0369084727745665,3.8295453999999998,1.2310039883140487 -2.079,4.745149071299498,1.0661523116490979,4.285136908000349,0.9318519005283665 -2.0825,4.80993744461536,1.0730145130586939,4.052609239999607,1.0009757665971595 -2.086,4.90939927462675,1.0240297569933658,4.276446084001103,0.37464364518060866 -2.0895,5.034652036551777,0.9377753361188353,3.64705420800055,0.8400493900203987 -2.093,5.17388078389625,0.8390680098713971,4.44757338,1.826385604866867 -2.0965,5.316435235618345,0.7498886328533959,4.888400539999763,1.2064481678301275 -2.1,5.45299570480425,0.6850324411810196,4.1122633360006,0.5811882757080208 -2.1035,5.601628275550406,0.6312531110851493,3.9392140480007214,1.2756757204894924 -2.107,5.7630935490884925,0.6059647399439885,4.955685355999291,1.3941990642715547 -2.1105,5.928439622690876,0.625172789072175,4.476350399999999,0.9829654676258366 -2.114,6.088482350124,0.6785494479938075,5.754614232000622,1.3393360907057439 -2.1175,6.233484990868224,0.7375588960447226,6.012244855997624,1.8018286793753886 -2.121,6.355521780882,0.7750900181237291,6.417048399997162,2.28667315317157 -2.1245,6.466796907848355,0.7967809144363802,7.327572531998865,2.923926214495084 -2.128,6.576597036968749,0.812548675357254,8.211366680000001,1.7365183881069521 -2.1315,6.685193373975612,0.8220582410291685,7.443594204000118,2.1096499502388255 -2.135,6.792953427971,0.8257412379044047,8.094907788000047,0.7397025465596186 -2.1385,6.900175017805893,0.8236544155230083,9.064132367999084,0.6941812204705907 -2.142,7.007199039464242,0.8164139699187833,8.398434920000142,0.24319286779623206 -2.1455,7.116862986711631,0.7995752019246083,8.8456229,0.773774413174796 -2.149,7.231180183160772,0.7706039495812028,8.951964124000096,0.5457451811746009 -2.1525,7.3495320103291215,0.7315292265115538,8.864208732000113,0.29320025200353816 -2.156,7.470976796534508,0.6852720326819625,8.833227659999865,0.09087665486663372 -2.1595,7.594830616681611,0.6341863355274281,8.789970488000108,0.20147360563214128 -2.163,7.7202168229595,0.5811570265393261,8.863650100000001,0.4155068197001223 -2.1665,7.8463864664001175,0.5289574164229133,8.967723859999753,0.2685800684525502 -2.17,7.9725279230647494,0.48053544910962587,8.76046385200009,0.43531568283808175 -2.1735,8.097625599642878,0.43880603485332637,9.140123660000167,0.5192161176179538 -2.177,8.219120251302,0.4036861308666943,9.448856623998614,0.8159343073683544 -2.1805,8.338938036816886,0.3711604402276224,9.65999116,0.6213148031697159 -2.184,8.459034921799521,0.340386088988359,9.315505859999252,0.5227617955120091 -2.1875,8.57840908996275,0.31620979197981414,9.035965171999893,0.5907403488762553 -2.191,8.69636582152573,0.3033811332713505,9.12437708799984,0.2118240849035584 -2.1945,8.812096384475614,0.30460531946360697,9.221548279999858,0.28464066780969904 -2.198,8.92497014028975,0.31913825220434133,9.36326644,0.19176530815360696 -2.2015,9.034118383182122,0.34318390076869154,9.693477704000138,0.5028764685879672 -2.205,9.13897044840275,0.3717869506134205,9.817511164000216,0.6129401070560636 -2.2085,9.238597656394006,0.40008826305990297,9.603430347999717,0.17896627151566757 -2.212,9.33248931617675,0.4244190636319778,9.84812169600039,0.2754176737826576 -2.2155,9.422081949569138,0.44430671400999017,9.786888220000002,0.33952064788939856 -2.219,9.510425455419245,0.4621032240055904,10.18062785199961,0.3939083678620223 -2.2225,9.597926514635127,0.4775520500205672,10.223794000000105,0.2242970234552482 -2.226,9.68505112658623,0.4906713890786337,10.149113143999895,0.2803743101647838 -2.2295,9.772233920035621,0.501353044106641,10.699609239999882,0.5676816418220539 -2.233,9.859876644654756,0.5097198265051025,10.627784799999999,0.2443110019651183 -2.2365,9.948023704294235,0.5154365145339285,10.970430759999974,0.29677248813623847 -2.24,10.03697106107025,0.5186613766665109,10.889018199999407,0.38202033733840546 -2.2435,10.127235783980385,0.5195006953878688,11.347090840000053,0.28506845805000175 -2.247,10.2192295527325,0.5183434895062126,11.21826555999987,0.20376949744509487 -2.2505,10.313557078995768,0.5154453859238175,11.527927799999999,0.29130720273741934 -2.254,10.41256532819375,0.5119822188017665,11.776222560000246,0.22244994655069042 -2.2575,10.517513731534393,0.5097837352752737,11.803116079999839,0.30289039166751364 -2.261,10.62712503451725,0.5103771536892105,11.844331160000234,0.12270414532837788 -2.2645,10.740503003430874,0.5146357411156991,11.88758144000008,0.11240595659884117 -2.268,10.856450071287263,0.5226010144647389,12.028659199999714,0.22825263788647593 -2.2715,10.973982762678856,0.5332288379750622,12.094722599999873,0.2419270175191913 -2.275,11.09199075231475,0.5447816861557465,12.180958840000056,0.13812895034811207 -2.2785,11.209403323091395,0.5546434908351306,12.553562320000813,0.24656573320966957 -2.282,11.32546569410275,0.5606552411789572,12.865373080000376,0.7078636576611597 -2.2855,11.442254235581983,0.5644898449635164,12.6617268,0.12583232761973415 -2.289,11.560651636267252,0.5669974200935033,12.807633359999778,0.144965413567368 -2.2925,11.681053935553521,0.567956215822112,12.999898480000036,0.08017238959065447 -2.296,11.803605791931503,0.5674053548556361,13.16820843999965,0.08666902613070662 -2.2995,11.929280824985753,0.5627403308983913,13.343482479999874,0.07612208378954602 -2.303,12.059152751883751,0.5525568103909013,13.5323684,0.1799828212991453 -2.3065,12.192466329075373,0.5388701228275403,13.61749143999993,0.16790762027855732 -2.31,12.328186910598259,0.5240037857020337,13.98548647999966,0.2322481760369277 -2.3135,12.465480434184151,0.509791657535858,14.158190119999901,0.14293640950942954 -2.317,12.6033870021995,0.49786255079423725,14.493224560000527,0.40877731164967696 -2.3205,12.740997804047856,0.4893516881432927,14.4113776,0.07122412951591586 -2.324,12.877427690424003,0.4848150816179381,14.513098559999914,0.08633025264781218 -2.3275,13.011233191739649,0.4836797876221945,14.622878999999944,0.12755531219690872 -2.331,13.140665222671492,0.48385967646875766,14.748404120000055,0.11027008553078223 -2.3345,13.266615499435629,0.4843646065936876,14.843285239999977,0.0810448655187477 -2.338,13.390303702587534,0.48473330697444456,14.973116399999963,0.10612864022171281 -2.3415,13.512405043311873,0.4849161812394411,14.970610920000002,0.05353758821244201 -2.345,13.633784230231756,0.48500300371988153,15.094266960000189,0.03581778681625266 -2.3485,13.75572583481798,0.4852812461026063,15.199979639999906,0.045079372294534924 -2.352,13.879083066580755,0.48593655472721575,15.288786400000015,0.04604338593067357 -2.3555,14.004697806103234,0.4870359640754548,15.384334999999918,0.05310114752054177 -2.359,14.1332313333475,0.48855051315923614,15.449453359999964,0.05255170067797599 -2.3625,14.265588160587146,0.4903390593231986,15.671036000000282,0.26987415715681196 -2.366,14.402366936093749,0.4921820047994061,15.603670559999776,0.11484437942728391 -2.3695,14.545728938894776,0.49232579283365524,15.751829480000007,0.03935565301720643 -2.373,14.699032851992289,0.48728041594707316,15.8415668,0.039655795108659804 -2.3765,14.864100968965253,0.4802223363471562,15.941819439999993,0.03643511358279519 -2.38,15.04219934564452,0.47280462723632555,16.01642395999997,0.05275506648247134 -2.3835,15.230846799476495,0.4654766280563799,16.11041280000004,0.044917638002891044 -2.387,15.426060296279763,0.45954122470058956,16.344055319999107,0.2338773382589166 -2.3905,15.62497078653336,0.4561093204293633,16.330832799999996,0.06818036851029875 -2.394,15.824071605271499,0.45546918755976673,16.45739895999996,0.055605891165482965 -2.3975,16.019501807215523,0.4573173865564568,16.548603399999916,0.06899392672010776 -2.401,16.207694096430505,0.4609512418657391,16.64900108000004,0.07527781096042115 -2.4045,16.38450632765828,0.4655273327064915,16.833948559999904,0.10935672062765485 -2.408,16.549326857931487,0.46898611767975806,16.901000399999955,0.09061492762947634 -2.4115,16.706036701998627,0.47188627372196285,17.037183599999928,0.07162164602783391 -2.415,16.857277567846502,0.4742072270332109,17.125848079999926,0.07519051680841633 -2.4185,17.003378073811625,0.4763429945031163,17.294377199999797,0.08629787572191028 -2.422,17.145077350314743,0.478730945960957,17.397945040000085,0.09279527431602301 -2.4255,17.282699240009602,0.4818225316135482,17.66539259999967,0.05204811820583689 -2.429,17.417193513900997,0.4859486582303637,17.843442039999918,0.08565032986064222 -2.4325,17.549413137741972,0.4914628784839433,17.967946680000093,0.12286933931728324 -2.436,17.68039304928925,0.4986295420484165,18.128625999999798,0.13030712773669023 -2.4395,17.81106487694185,0.5078294136553906,18.337041040000006,0.09117475013792811 -2.443,17.942384895810743,0.5193012390612464,18.551649599999894,0.11677707420040243 -2.4465,18.07536339694052,0.5334477885758939,18.68010084,0.07087004512789238 -2.45,18.210823508274487,0.5503724952483494,18.787024159999948,0.05619507435575589 -2.4535,18.3492490002105,0.5695080549406266,18.921021840000066,0.06200175009152492 -2.457,18.48997155857825,0.5898787186899388,19.053816799999925,0.05827015243943556 -2.4605,18.632911086221725,0.6104396259325355,19.189230600000002,0.06081176036179197 -2.464,18.77697840159675,0.6312783709693669,19.35995468000015,0.06863268425418917 -2.4675,18.921568651472224,0.6520389204393964,19.56745387999992,0.053948863712697234 -2.471,19.066638517816997,0.6717067345146567,19.7167866800001,0.13046076858141062 -2.4745,19.21218465063873,0.6892127040318241,19.85496219999975,0.1372135930510844 -2.478,19.358165598627494,0.7037130220378982,20.059094799999947,0.09602938440755027 -2.4815,19.504786872794774,0.7142323330110882,20.271793160000005,0.051856920450689056 -2.485,19.653810153653488,0.7220307295583557,20.408703280000125,0.04756096353839624 -2.4885,19.805614363317247,0.728080669296456,20.57914851999978,0.06749189314329018 -2.492,19.95973198066825,0.7328678466837987,20.807220440000084,0.06923606398871762 -2.4955,20.11591599545037,0.7366397750069436,20.976534399999796,0.1352494012380982 -2.499,20.274069042603948,0.7396355982374524,21.272835399999874,0.11788493398982464 -2.5025,20.433820892365222,0.7418701846463335,21.459127360000103,0.06336877903363246 -2.506,20.59448109691075,0.7433829391470772,21.59375391999989,0.03155241551242924 -2.5095,20.755517970244856,0.7439179815359616,21.726568000000007,0.02188207793200918 -2.513,20.919045269143503,0.7432952066310552,21.8758862,0.04494563043500438 -2.5165,21.085859721659766,0.741690622736125,22.025966520000008,0.0665472602526136 -2.52,21.25436496885225,0.739392205567249,22.183813999999938,0.07729371918558524 -2.5235,21.423104360891653,0.7360715320000959,22.302431440000046,0.07091567797369018 -2.527,21.591464569392297,0.7297120878642603,22.42468687999978,0.05268796850521123 -2.5305,21.760211293802502,0.715101861820178,22.555566199999998,0.07155414599238867 -2.534,21.92691666908996,0.6932480320024624,22.730617040000133,0.056785571012003704 -2.5375,22.088994163125605,0.6650530643278872,22.855577319999917,0.03548625638229775 -2.541,22.24633259183775,0.6333369758122462,22.94780524000002,0.06182287995482277 -2.5445,22.399307123426972,0.6012582054564815,23.071767279999857,0.0719563913754909 -2.548,22.54732325160475,0.5713024758921792,23.227207,0.07527367965962525 -2.5515,22.689366430753264,0.545827380634369,23.43423347999997,0.06578284755047159 -2.555,22.824783566642992,0.5264129470524598,23.57204355999996,0.03547375317987727 -2.5585,22.95342673738577,0.5112076395703504,23.7138207999999,0.03873832436287632 -2.562,23.078396705734495,0.49661066918355595,23.850313520000004,0.037232763326757595 -2.5655,23.200565125894503,0.48252601202739376,23.989557400000002,0.031143714153903976 -2.569,23.320989433508473,0.46890161003799113,24.151201839999924,0.022171257394845423 -2.5725,23.440581721507748,0.4557161222989056,24.307613720000056,0.01993889025669756 -2.576,23.560320644392007,0.44295920561387475,24.46147507999979,0.022524675436684943 -2.5795,23.68119335277098,0.43069624849837473,24.612655120000035,0.033952707480410384 -2.583,23.803628344539,0.4192453462072704,24.765217800000002,0.04402893419332334 -2.5865,23.928118921925766,0.4090186595499727,24.915068919999943,0.041017705445483846 -2.59,24.055513688662497,0.4002954980935371,25.042271039999957,0.03951246860054289 -2.5935,24.186443521395525,0.3935547643673979,25.188843279999887,0.05486176423373625 -2.597,24.32083133276999,0.3891612461564554,25.344601879999843,0.0639336648883351 -2.6005,24.458666954916502,0.38778580210037233,25.494726,0.05991175278691109 -2.604,24.59850381619575,0.3918218030487775,25.6639527200001,0.03961799378491519 -2.6075,24.74022565080812,0.4016968552115566,25.82887619999989,0.03308069361363615 -2.611,24.883860469131246,0.4165979811625923,25.951022840000064,0.048138165393303824 -2.6145,25.029595696851224,0.4355972577391283,26.150558399999817,0.07607651381973402 -2.618,25.177450726904247,0.45736651937128203,26.384579000000002,0.07515210940818615 -2.6215,25.32762160241927,0.4806553727377548,26.55523155999996,0.09746647292587116 -2.625,25.480596280000498,0.5043653918059422,26.670687159999936,0.09742788488280353 -2.6285,25.64182750947135,0.5312284264325062,26.817304439999873,0.09701749944038288 -2.632,25.81092707578875,0.5610749953402143,27.027227200000006,0.08703991559485638 -2.6355,25.98535370990753,0.5924974428194214,27.194394999999997,0.0533405857063829 -2.639,26.163639416415002,0.6251495227841448,27.302710359999963,0.07142492202704732 -2.6425,26.344055495441875,0.6569314908490489,27.38699648000005,0.02682710244154583 -2.646,26.5244640630835,0.6841487643689612,27.487189559999855,0.014343119413424534 -2.6495,26.701881661921497,0.7036309601573277,27.65639788000008,0.044781663543406444 -2.653,26.87332448647951,0.7130679509415625,27.844259599999997,0.07948802032570826 -2.6565,27.036034197152222,0.7092221369406403,27.956802119999985,0.02158797005908188 -2.66,27.19011255338,0.6921172434835707,28.034421719999933,0.05629863117349447 -2.6635,27.340541351644106,0.6698562293368935,28.205200560000094,0.09205369239236946 -2.667,27.4880921028195,0.6451613576975329,28.412836640000005,0.08220771033051448 -2.6705,27.63219608902515,0.6190594944573536,28.522913199999998,0.025665346066242253 -2.674,27.772560333578745,0.5927470781833728,28.588064279999962,0.033146347306614976 -2.6775,27.908580214659505,0.5673099101695362,28.7455049999998,0.061910367853974406 -2.681,28.040352955696036,0.5431262439477552,28.95315724000008,0.03209793096675076 -2.6845,28.169329865470623,0.5172847980981214,29.061901239999923,0.06223090340884934 -2.688,28.296031138286256,0.4902543428581557,29.2230232,0.1134682188200727 -2.6915,28.420384183438735,0.4629822037481843,29.356269199999947,0.05546669142325289 -2.695,28.54257619390801,0.4365413332613595,29.51003371999994,0.038977286505678076 -2.6985,28.662621957432364,0.41192950581917687,29.608049359999985,0.025991077722718102 -2.702,28.78070796150675,0.3901608374532469,29.676102799999995,0.04284844824216882 -2.7055,28.896857380337647,0.3721660026597705,29.79062019999992,0.07248749776131834 -2.709,29.0112483149515,0.3586253174760712,29.981824799999934,0.05770369635299964 -2.7125,29.123912326023138,0.35002664901870645,30.07488224000001,0.0685107441599389 -2.716,29.235019128111027,0.346368473464798,30.139056439999923,0.025172926213425477 -2.7195,29.344608668357626,0.34745942437729177,30.27504716000006,0.042894121803898316 -2.723,29.452847731520972,0.3526787021646519,30.4384346,0.03906987793428639 -2.7265,29.56050088655586,0.36070779203739783,30.517940359999965,0.03679972548658312 -2.73,29.66838251072175,0.37030916706991035,30.605388759999975,0.054798384764067676 -2.7335,29.77608332902674,0.38101209193079294,30.7064524799999,0.0757361032999501 -2.737,29.883256479779998,0.39230990270438676,30.853716040000013,0.024115694140217327 -2.7405,29.98992572920264,0.40364612387142024,31.021139799999997,0.04089198387459315 -2.744,30.096155155619748,0.4145339278979402,31.132229479999957,0.026742943767873038 -2.7475,30.20197218544102,0.42449415620020736,31.243951479999918,0.03636672084275667 -2.751,30.307437236803032,0.43316782120538155,31.396506560000063,0.027547953508512645 -2.7545,30.412581396304752,0.44012582138337775,31.51097791999993,0.019253509762523123 -2.758,30.51769613217,0.44498630644988924,31.6216238,0.04867916497537683 -2.7615,30.623320897316752,0.4474612299164186,31.77089995999994,0.028982512102805558 -2.765,30.729464195306004,0.4485542125047556,31.92000983999995,0.04183380805978994 -2.7685,30.835643897387108,0.44881924196990275,32.03138952000003,0.02671058362989705 -2.772,30.940667791825003,0.44954723274958996,32.16368124,0.05002732149360194 -2.7755,31.044142281848018,0.45111550075449847,32.275474999999986,0.04316836697746052 -2.779,31.145922866773002,0.4536416060609103,32.401569639999956,0.02742076129593808 -2.7825,31.245723887157894,0.45712809854936887,32.520616920000066,0.04580715992973232 -2.786,31.343418048723752,0.4614322050962345,32.61210759999991,0.07001080852395264 -2.7895,31.438754989999264,0.4663158082469301,32.75090088000008,0.046250483398457415 -2.793,31.53240078436275,0.4714044501509436,32.914788599999895,0.03277708411828214 -2.7965,31.625523502809873,0.4764752032643957,33.00090695999997,0.026873970180966832 -2.8,31.718406241719514,0.4814356227893705,33.082084960000046,0.04602102046640044 -2.8035,31.811245797408986,0.4861181628317313,33.28933499999981,0.04561787012189642 -2.807,31.9042424208525,0.4903907096129575,33.45632587999999,0.054456542184119154 -2.8105,31.99760945200414,0.4940178273753416,33.5413974,0.07487356136380834 -2.814,32.0915305982015,0.4968356892289304,33.65367787999996,0.0773444871045904 -2.8175,32.18622467019827,0.4985383155464451,33.78213147999994,0.05985642229076627 -2.821,32.2815501478825,0.49844684962786556,33.90305904000004,0.05912431763927189 -2.8245,32.37755284164264,0.4959327116908431,33.99984543999993,0.025788392451828797 -2.828,32.47441498238075,0.4909279990660349,34.091065400000005,0.035300703502904145 -2.8315,32.57250898571651,0.48294750349489773,34.151712759999974,0.025551497222045954 -2.835,32.6743589079505,0.46833894105302437,34.21003599999993,0.025540788423620297 -2.8385,32.7806286696465,0.44663339602144836,34.33558204000006,0.022858586068822354 -2.842,32.89010735011601,0.42076098605866435,34.49780436000001,0.04468602017528022 -2.8455,33.00234656159448,0.3935595190054157,34.545094399999996,0.019148701843729028 -2.849,33.11640899082925,0.3681816819634773,34.61750740000001,0.053205649164170365 -2.8525,33.23129098629074,0.34728668260313944,34.78905187999991,0.05853685269175632 -2.856,33.34592333115175,0.3328768597441264,34.90434651999994,0.012438529145854681 -2.8595,33.45921600436888,0.32574696867258407,34.98811420000004,0.017478787015704433 -2.863,33.57018615862924,0.3251293383358455,35.102593399999826,0.018551631459224928 -2.8665,33.67745015880763,0.32953722682117087,35.21323567999995,0.0636141290149561 -2.87,33.78014829669624,0.3378569198765115,35.33214572000004,0.033719639642087164 -2.8735,33.88079803842437,0.3488552764577724,35.44103707999987,0.04907516615350291 -2.877,33.98008729965448,0.3618651172157476,35.584164360000024,0.0842017163294776 -2.8805,34.07816335669436,0.37643843630020896,35.70679119999994,0.03239370710809147 -2.884,34.17524291577325,0.39211037006683813,35.801096959999995,0.018985251116819837 -2.8875,34.27136360125623,0.4084640227814002,35.89500887999994,0.02131302614200456 -2.891,34.36663465881475,0.4251217658533471,36.012079600000035,0.036250880805062405 -2.8945,34.46109453179326,0.44177962207634064,36.08942147999997,0.055502401224360065 -2.898,34.554846558301996,0.4581796377285865,36.215725400000004,0.042604242086909945 -2.9015,34.647935089246516,0.47406789122238474,36.366200000000084,0.060722878738976416 -2.905,34.74045755517574,0.48925022961786874,36.450828799999954,0.039321539557118645 -2.9085,34.832464214556374,0.5034860374728923,36.52552640000004,0.04616886811146982 -2.912,34.92404659037723,0.5166196228244213,36.68974195999975,0.030282249984451455 -2.9155,35.0152608486645,0.5284111094479355,36.81809599999997,0.05054332280831357 -2.919,35.10619066309475,0.5387374702141152,36.85833504000003,0.0668828053114571 -2.9225,35.196382062023986,0.5471331240992041,36.93488784000013,0.06395009484775134 -2.926,35.285381901281994,0.5533204415896997,37.1371443599998,0.030616004739026408 -2.9295,35.37336047459651,0.55713600465255,37.27504068000002,0.030231924652762178 -2.933,35.46057770073125,0.5586129142846625,37.31604679999988,0.03792171914884396 -2.9365,35.547200197564734,0.5575354704538331,37.488172239999905,0.01171552366769124 -2.94,35.633356887548246,0.5537989256095064,37.66302100000006,0.04642638545651717 -2.9435,35.71937636553275,0.5472984240493777,37.69245659999997,0.036698842260724174 -2.947,35.805878427885006,0.5377382539177432,37.84156384000002,0.05584313197931656 -2.9505,35.894636881458375,0.5224230405963497,38.034892,0.0351066439367237 -2.954,35.985760336596,0.5020439647456221,38.11824240000004,0.031879111655737716 -2.9575,36.07923696622711,0.4774674494072873,38.22672987999994,0.054551544039186016 -2.961,36.174866689322,0.449935003857587,38.38725380000009,0.03213985922092433 -2.9645,36.27262884930564,0.42040268689277166,38.499096559999906,0.02876643770626012 -2.968,36.372332194652245,0.390033469184212,38.583155,0.04094665184114575 -2.9715,36.47394723928298,0.3598366002226798,38.705383640000164,0.028249864652437794 -2.975,36.577291561176,0.3308394837976884,38.85393295999991,0.021670931774799396 -2.9785,36.68232684474889,0.3039908283740073,38.94189816000004,0.030517039208745166 -2.982,36.78887849016499,0.28002689919764256,39.05999951999981,0.018825948135719032 -2.9855,36.89670377508625,0.259514807757928,39.2288678,0.03800219395245372 -2.989,37.00539919397775,0.24262653917161317,39.29353380000001,0.030559286443530616 -2.9925,37.11455880246448,0.22971859944248502,39.4289905599999,0.05080856426128337 -2.996,37.224782764928754,0.21954410793653162,39.64998535999985,0.04306053199206922 -2.9995,37.33690184222848,0.2111447395968987,39.73230763999997,0.05318572975439699 -3.003,37.45079850711525,0.2045925995879487,39.796622400000004,0.06920124238985761 -3.0065,37.56650224097798,0.20014176164220146,39.95627311999993,0.03825494320414612 -3.01,37.684778975573,0.19956629218104346,40.08778019999999,0.043190539878595814 -3.0135,37.8064017173014,0.20465541970030218,40.130769479999934,0.02597682207107625 -3.017,37.93057453239675,0.21436468807225673,40.241493360000035,0.020791729761282816 -3.0205,38.056689857955384,0.22790969439402733,40.3580886,0.02583665906807646 -3.024,38.183984730236034,0.24416759858292558,40.39136343999998,0.02625067135805708 -3.0275,38.31179448105825,0.2621968308696597,40.51753087999993,0.0375836883495895 -3.031,38.439413251958,0.2809203900816279,40.69064383999988,0.02124406054283997 -3.0345,38.5661192694776,0.2993274225878379,40.738572959999956,0.041783904964314306 -3.038,38.69133408277125,0.31644842553071484,40.8269678,0.04211980733218069 -3.0415,38.81540358688086,0.33104981204332795,40.9885592000002,0.0378262441923385 -3.045,38.93790944572675,0.34241425096273514,41.124924199999924,0.03893240453840465 -3.0485,39.05805633279776,0.349708501591582,41.19954704000002,0.023607247279310517 -3.052,39.17667837368175,0.3552205860143644,41.290920839999835,0.02267162501239325 -3.0555,39.29433710135739,0.36074907013810475,41.4550936,0.038986253440155376 -3.059,39.41085449652128,0.3665645165816847,41.524263039999994,0.03304308493991412 -3.0625,39.52608761674275,0.3725740334658768,41.6130809999999,0.05060723919504988 -3.066,39.63999967739347,0.378576359868628,41.81682443999986,0.05134447578663854 -3.0695,39.75244380554761,0.3840963418183303,41.86464451999998,0.03503376653021262 -3.073,39.86339056287825,0.38864484798100446,41.9465602,0.028368228367312884 -3.0765,39.97268573015812,0.39148201792660625,42.10753483999996,0.039003323009029346 -3.08,40.080307215362005,0.39201033483247455,42.15556739999995,0.03560208746890108 -3.0835,40.186093452960264,0.38940797126402793,42.23684155999986,0.06017029787152764 -3.087,40.2903639819315,0.38346013016486813,42.41198916000006,0.02695668750810308 -3.0905,40.394481937933016,0.37476602633856704,42.5214344,0.05132659350960124 -3.094,40.498916600527494,0.36352740101616365,42.570013559999964,0.019940326891702043 -3.0975,40.604505797742874,0.3490788818238473,42.701778639999915,0.026222521027352917 -3.101,40.713378270423725,0.3296087884779788,42.83579928000004,0.03473930224562593 -3.1045,40.825215553689375,0.3069786549070487,42.88314107999998,0.027279514352934374 -3.108,40.93907882849176,0.2842717564290451,42.9936264,0.028832827441996525 -3.1115,41.053893477590236,0.26399814833521246,43.08541903999996,0.02319468564968849 -3.115,41.16841561986675,0.24836998435681357,43.20364775999986,0.023303121083838765 -3.1185,41.281760894195884,0.23909649929490834,43.36544640000008,0.028891039671490207 -3.122,41.39314061916025,0.2363038018472223,43.431058719999996,0.01607965962544933 -3.1255,41.50160231756239,0.23818236321516117,43.5326496,0.03837272791058904 -3.129,41.60642695433,0.24180432849764338,43.69608975999995,0.03967760017701831 -3.1325,41.707298334503896,0.2443322624254739,43.76227836000002,0.02269669055804538 -3.136,41.8065197013865,0.24632205436879867,43.84446623999995,0.05823817350939468 -3.1395,41.90471348646513,0.24738183247283516,44.03371336000002,0.039246782330207064 -3.143,42.002231815788264,0.24754455776462547,44.135211199999965,0.0259224674597323 -3.1465,42.09931601302924,0.24687306790711955,44.17680899999995,0.0379291880232063 -3.15,42.19624213242725,0.24564508322329429,44.35246004000013,0.02876482747294051 -3.1535,42.29323211335176,0.244088391427047,44.436511640000006,0.0225560304639011 -3.157,42.389873942096,0.24322666072747381,44.474411000000046,0.029399470948657434 -3.1605,42.486100019577734,0.2438116491862459,44.627760200000004,0.026888646167109426 -3.164,42.581960817872755,0.2460574945480786,44.72942395999998,0.02345353621584853 -3.1675,42.67764666589914,0.25029154965902406,44.810834239999956,0.014284554888719608 -3.171,42.773412065449754,0.25670144846595944,44.933153559999894,0.019002081741361036 -3.1745,42.86951814761013,0.2654661653550355,45.04408463999998,0.01714182048528554 -3.178,42.966192842274495,0.27655521867259764,45.1222504,0.013689268654679858 -3.1815,43.063470566842746,0.2896897092812238,45.232875759999935,0.03396382035266112 -3.185,43.16119062479976,0.3042640777101219,45.40724959999993,0.025524798175485447 -3.1885,43.25925664327965,0.3198144702097128,45.47029732000002,0.033536748809206256 -3.192,43.357546973578,0.33584815495232856,45.54608075999992,0.035919605771120064 -3.1955,43.456041365182365,0.3519118067941004,45.6834834,0.02936075363133535 -3.199,43.55474458111,0.3675620136015097,45.777473799999974,0.026316434159294376 -3.2025,43.653584224119896,0.3822961935261386,45.839730199999984,0.013250609205631599 -3.206,43.75255365763049,0.39575942994051533,45.94820508000002,0.013395771584037323 -3.2095,43.85167064225813,0.40751531971352295,46.03747104,0.0185164562416307 -3.213,43.95094113452952,0.41727708431697524,46.079928799999955,0.024028154334067353 -3.2165,44.05038388327525,0.4246011910773746,46.20089199999994,0.027353951109843597 -3.22,44.150330893186265,0.4287075273195995,46.29489976000004,0.010104307805535423 -3.2235,44.251799008745735,0.4275050809180481,46.357135639999946,0.028268651965837832 -3.227,44.35438442598175,0.421578718855544,46.45344000000002,0.03402743366579955 -3.2305,44.45774770789111,0.4115234669858715,46.545686599999854,0.03247399546244059 -3.234,44.561840675030254,0.39877973015181295,46.71174179999995,0.02974303398512832 -3.2375,44.66647040807577,0.3842371377754477,46.75464756,0.029910473700498087 -3.241,44.771376714580995,0.36894486660853604,46.80700459999993,0.027698946720038392 -3.2445,44.87632244988839,0.35378549447685387,46.95163883999997,0.03324906465586561 -3.248,44.98106731503452,0.339676098793274,47.028266599999945,0.020776155438339845 -3.2515,45.08543252014425,0.3273706753004787,47.10181487999999,0.048358764764386636 -3.255,45.189258671589755,0.31760175442207983,47.24365175999996,0.04631164918746758 -3.2585,45.29328934620225,0.3130637826069527,47.315796799999994,0.02070500760541463 -3.262,45.397124589729756,0.31476511397839607,47.362724999999955,0.02507169547285168 -3.2655,45.49957089620949,0.3225251961339253,47.5018496,0.02350027814303576 -3.269,45.6005999798875,0.33416802155991304,47.566711080000005,0.025082591578463858 -3.2725,45.700299363587014,0.34713510382662355,47.59617632,0.02357236799037626 -3.276,45.79803995533025,0.3597410099441534,47.77615980000005,0.024527491158766193 -3.2795,45.89302291385215,0.3700867129824272,47.83304263999999,0.044252921668615414 -3.283,45.984800589901496,0.37681608352811313,47.87816319999994,0.016949202479684716 -3.2865,46.074366537558745,0.3815201874389419,48.005007559999996,0.029090883721655147 -3.29,46.162399608397,0.38514081283974594,48.071170120000005,0.02586121724342274 -3.2935,46.249057636276,0.3877474823166184,48.142580159999945,0.01628295111180147 -3.297,46.33460845849075,0.3895363943018782,48.23258932000004,0.006229544273226086 -3.3005,46.419240167334486,0.3906089929667213,48.29033019999997,0.04226021958890233 -3.304,46.50316132024225,0.39118613365660126,48.37442479999995,0.02375750707079999 -3.3075,46.586388041448856,0.3914961467272542,48.500050239999965,0.01256119747906671 -3.311,46.668986859795744,0.3918325209101817,48.55079675999997,0.03125950959899332 -3.3145,46.75140420751086,0.392442249720696,48.62899455999998,0.02546039704140367 -3.318,46.83410385631575,0.3935920490514994,48.738875799999946,0.009629899438713915 -3.3215,46.917262431165135,0.39559262839517595,48.79853948000001,0.013896354803040231 -3.325,47.001019842930745,0.3986852465604084,48.862467879999976,0.03148848978076912 -3.3285,47.08538932657075,0.4028395640233195,48.99368724000003,0.023706368328987093 -3.332,47.169965750888,0.40733100662712163,49.07247603999999,0.012526309539795246 -3.3355,47.254685517291115,0.41198212463131234,49.096751,0.02258689247107539 -3.339,47.339473736429504,0.4166907241488736,49.233573960000044,0.015006841825837437 -3.3425,47.42405795358786,0.4216395700101308,49.27226796000001,0.017405043358410154 -3.346,47.5082728488,0.4268682911501357,49.31656076,0.026712149918464028 -3.3495,47.591965616224485,0.43232257539986874,49.425957800000006,0.013798956146711765 -3.353,47.67502522024375,0.4379461180654954,49.47643179999998,0.011355016125074661 -3.3565,47.75728786162189,0.4436521183497347,49.56357356000001,0.017005962835112243 -3.36,47.838653498135244,0.44936270707171216,49.617050679999984,0.02079418369232048 -3.3635,47.918947337153995,0.45496351048374456,49.720082879999964,0.013327604371842123 -3.367,47.998080329848996,0.4603636760253402,49.77132680000001,0.023956591242487748 -3.3705,48.07606403769912,0.4657239217302242,49.83562919999991,0.02424057593579975 -3.374,48.153233870060475,0.47172161256896855,49.966282799999966,0.014867315999860853 -3.3775,48.22916597453924,0.4782391673106188,50.0095016,0.02047737338429292 -3.381,48.303679976254,0.48498655232121896,50.05188199999997,0.023206603584333917 -3.3845,48.37679541455611,0.4918812053964221,50.13567887999999,0.02673055969133151 -3.388,48.44901272919475,0.49908024084318253,50.215553,0.010901558627094252 -3.3915,48.52015887244788,0.5063567271717064,50.22107848000001,0.005990550092598834 -3.395,48.590124460945,0.5134633482435177,50.31751135999997,0.013690527912011233 -3.3985,48.658701731752004,0.5201192650675666,50.3643434,0.023214517031808154 -3.402,48.725793838773015,0.5260846540636683,50.384072039999936,0.010323171473360926 -3.4055,48.791151282561245,0.5310919915545347,50.483705,0.015513366204663459 -3.409,48.854715630577736,0.5348895946386718,50.51285592,0.011774774356750839 -3.4125,48.91632448028774,0.5370707892060276,50.56226287999993,0.015665359488115108 -3.416,48.97624940448325,0.5377945948850008,50.62377268,0.019835933266970224 -3.4195,49.03484562023212,0.5374227139032624,50.67571451999991,0.024618180869260202 -3.423,49.092343177176254,0.5360593600187384,50.7854874,0.0234605739017607 -3.4265,49.14887551059625,0.5337049773770864,50.800347679999994,0.021195161766132085 -3.43,49.204653273655246,0.5304419574669691,50.80783079999998,0.021187625365750216 -3.4335,49.25982423865226,0.5262613086841258,50.93605351999996,0.01990820182316531 -3.437,49.31458472173149,0.521229359550174,50.94528103999999,0.02353712111512789 -3.4405,49.36909141700001,0.5153317277565301,51.004157400000004,0.029532690603803452 -3.444,49.423464299461486,0.5086781388897589,51.10097132,0.0365177885375205 -3.4475,49.47778005381437,0.5013315823435766,51.10041827999997,0.018092072345966135 -3.451,49.5321198353585,0.49341090873217214,51.17099383999996,0.01698090340791399 -3.4545,49.586566801661114,0.484977002197978,51.20806348000001,0.02472639416680972 -3.458,49.641195535506995,0.47613414208888327,51.2569886,0.010462967614401006 -3.4615,49.69609177227001,0.46694684213296106,51.25605191999998,0.013581648711842111 -3.465,49.7511454435875,0.4572926533269684,51.35811499999998,0.006705769026741833 -3.4685,49.80636652310388,0.44710374740374526,51.40529672,0.031365391045097085 -3.472,49.861797989425746,0.43643160664343417,51.40267887999996,0.011015165115939644 -3.4755,49.917527593584,0.4250207081489347,51.4939618,0.018460110798692864 -3.479,49.97399698803726,0.4121404522440832,51.510125959999996,0.02648799023309693 -3.4825,50.031032098546625,0.39792040484229596,51.54984347999997,0.022738902611428184 -3.486,50.088312448575,0.3827683393395308,51.57923516000002,0.0040168573547139765 -3.4895,50.14553799821024,0.3670197618374519,51.60895104000002,0.027078997551366737 -3.493,50.2024130915735,0.35107904089200714,51.63679139999999,0.013653166786500547 -3.4965,50.25861286809514,0.3353153697850922,51.706283039999974,0.02087251027042017 -3.5,50.43138257264125,0.29396842133734363,51.73450328000001,0.03071437951792937 +0.0,50.43138257264125,0.29396842133734363,51.717099759999975,0.01403761338572917 +0.0035,50.481970479165874,0.27717797526840166,51.772954039999966,0.025772418765575657 +0.007,50.5308589810165,0.2611883793794134,51.84187483999999,0.01100727321127292 +0.0105,50.578236770022635,0.2467071019466795,51.83534259999999,0.014785219758260191 +0.014,50.62411692404025,0.23413247158376044,51.87782739999996,0.010827688335927992 +0.0175,50.66860437905663,0.22444085963860094,51.93822260000002,0.014043177901017194 +0.021,50.71209670886601,0.21870122381765203,51.93977635999998,0.01222236010141695 +0.0245,50.75413025634188,0.2171591504073418,51.977904680000016,0.019939221159608722 +0.028,50.794781735203756,0.21892949851778037,52.008359,0.026944776812956702 +0.0315,50.83491025309587,0.22193295870695243,52.044347800000004,0.018096489745246646 +0.035,50.874422348283,0.22571467739055118,52.04676244000001,0.011653501140350788 +0.0385,50.91308269554375,0.22997870663011574,52.070468960000014,0.02358747823800886 +0.042,50.95077677024349,0.23436506442610303,52.106951879999976,0.018128063482125405 +0.0455,50.987522456683,0.2383467289512707,52.12333099999999,0.009444649384705387 +0.049,51.02314554670251,0.24157973469291963,52.15192447999999,0.011342514192720518 +0.0525,51.057327186137,0.24368710768561577,52.18083843999999,0.03546433678033066 +0.056,51.089863836868496,0.24440696895231434,52.18558672000002,0.027468425374086884 +0.0595,51.12041487838737,0.2433659356969614,52.210361079999984,0.021837532826116012 +0.063,51.1487985389205,0.24034678551207247,52.2338118,0.011273283603282024 +0.0665,51.174652431613,0.23497141071686603,52.24535204,0.009543504391359939 +0.07,51.19781655103675,0.22706097679885945,52.258300799999994,0.019661116456625674 +0.0735,51.217906743992,0.2162305733736786,52.288546039999986,0.04073195633637424 +0.077,51.235418028308246,0.2034931916885068,52.31383728000001,0.025954459015996554 +0.0805,51.251498020399495,0.1912436768877188,52.2997886,0.016165769987848414 +0.084,51.26667776326675,0.17968695563029433,52.32146479999999,0.018723377569782054 +0.0875,51.28106027169213,0.16888430705183957,52.31365411999998,0.028244774641182684 +0.091,51.29461924142025,0.15882326697468244,52.302334559999984,0.022361979635678046 +0.0945,51.307259739970874,0.14953218686774997,52.313165160000004,0.01509614031425949 +0.098,51.31896031255775,0.14097720980218562,52.29866840000001,0.021412471116152056 +0.1015,51.329621177231004,0.13317132259294215,52.29305595999998,0.01722140134565001 +0.105,51.339266097629,0.12602138306377506,52.32239896,0.018205848962561715 +0.1085,51.34806158227075,0.11921254765856773,52.31266004000001,0.015920479341676643 +0.112,51.35602225127625,0.11273599225699904,52.33000264,0.01345590477031147 +0.1155,51.36303761445262,0.10674502585270589,52.3317038,0.014759925768783797 +0.119,51.3692169490215,0.10138590922963682,52.30300359999999,0.010920612264880414 +0.1225,51.375145417767,0.09653773375373084,52.33540667999999,0.01576432725339246 +0.126,51.380900546101,0.09222323675651625,52.3003666,0.013282560752336001 +0.1295,51.386453779746,0.08850447045952221,52.30349255999998,0.015051585857540642 +0.133,51.391792715998506,0.0854229756199629,52.317126800000004,0.010424459683840107 +0.1365,51.396887094039755,0.08301107878680795,52.28081099999999,0.01158181500197454 +0.14,51.401726217707,0.081270157973825,52.2906492,0.01254614455439999 +0.1435,51.40618689512338,0.0800137714255277,52.269877599999994,0.023467223000610053 +0.147,51.40923243690625,0.07736306006793592,52.25284596,0.01169205480949398 +0.1505,51.41051203059488,0.07301200202326202,52.2383948,0.017782484997879565 +0.154,51.410192152851494,0.06776111331331486,52.24011112000001,0.01927004784561114 +0.1575,51.4083059910525,0.0625195282959143,52.23566483999999,0.017792548981752653 +0.161,51.405012035298,0.058716122561471386,52.205000040000016,0.006273070875411279 +0.1645,51.40035145952662,0.057900116240134095,52.203650800000005,0.015342176872271716 +0.168,51.3944311706975,0.06135721492873988,52.19141840000001,0.007595404288080319 +0.1715,51.386768540059,0.06929163218203571,52.15788012,0.011617331528886688 +0.175,51.37739949437225,0.08078920701174312,52.142265679999994,0.007270306966829451 +0.1785,51.3663864031965,0.0947282650982513,52.102247920000025,0.006272162226236074 +0.182,51.3539231597305,0.11021903180790807,52.09016964,0.011510565380029779 +0.1855,51.34008281114825,0.12659866619253524,52.084112800000014,0.011761558982540015 +0.189,51.324513688966746,0.14253567087396435,52.0522874,0.009406266737649997 +0.1925,51.30597199301624,0.15567490557431518,52.04253728000001,0.025005340363077718 +0.196,51.28483075444325,0.16641734675000364,52.01428691999998,0.010097032936068449 +0.1995,51.261348201126125,0.1750713612921415,51.995530680000016,0.006576994940863442 +0.203,51.2358153132675,0.1821017835593278,51.92959699999999,0.021944455074118702 +0.2065,51.20709820442537,0.18654379976532556,51.872502839999996,0.020086108998708586 +0.21,51.17532072152825,0.18825843671749634,51.835382280000054,0.013879407381143634 +0.2135,51.14040358247513,0.18772348610206657,51.76645451999998,0.017018894172404236 +0.217,51.10273993753175,0.18531452446877628,51.71351592,0.014675912448358829 +0.2205,51.062525082596494,0.1811590917417979,51.660553200000024,0.015871257533680672 +0.224,51.020158410368,0.1755743136648925,51.577716880000004,0.013319759231029108 +0.2275,50.9758599954365,0.1687059753726196,51.526054320000014,0.019982873995815203 +0.231,50.9300044518085,0.16081890158757736,51.46248284000008,0.012509122087015356 +0.2345,50.882836632766,0.1520471298601412,51.36823867999997,0.012807958399061849 +0.238,50.8347063736245,0.1426046769865972,51.33528840000006,0.0059673825333863 +0.2415,50.78588330635725,0.13265105048258402,51.255176520000035,0.01138262393440279 +0.245,50.7366924875875,0.12245088538091192,51.17542415999999,0.012052063168136248 +0.2485,50.68689174437738,0.11241663286373002,51.119466160000066,0.011231295014760466 +0.252,50.63288173250675,0.10345394466883905,51.03858476,0.009857278441243386 +0.2555,50.574107979464884,0.0981571904805209,50.96578900000003,0.01251915045040937 +0.259,50.511486493983,0.1003325004026318,50.88595664,0.015568011925334042 +0.2625,50.44561264042325,0.11257252115438746,50.82033836000003,0.014616752414545462 +0.266,50.3773419725935,0.13389220577025046,50.75733695999996,0.014515932007553847 +0.2695,50.307330309779005,0.1615314455735083,50.68041988000003,0.02178611100246947 +0.273,50.23616364631475,0.19233308175637834,50.6025572,0.0073481292313070535 +0.2765,50.16189644990887,0.22250412744902917,50.51861135999995,0.016281247022515235 +0.28,50.08439836746275,0.25050194445690527,50.44260476000006,0.014349003765009853 +0.2835,50.0047795440825,0.27517868023282915,50.38406947999996,0.014657151790617249 +0.287,49.924384388585004,0.2958610871663653,50.28075132,0.014077045885815714 +0.2905,49.843708621365,0.31293334740591655,50.208005,0.017121201388920943 +0.294,49.76199746603974,0.32925153030425613,50.13239276,0.009627162584454316 +0.2975,49.6795833201945,0.3451327684566984,50.02455352000004,0.0053014124053886065 +0.301,49.5969027373625,0.36075435976439996,49.97738600000004,0.014506178613294873 +0.3045,49.514370067996,0.37600016320246027,49.891334119999954,0.019163328457558308 +0.308,49.432387829468745,0.39076548884900597,49.80353500000003,0.015053769461451665 +0.3115,49.35139459525274,0.40480193443809326,49.737025720000034,0.023236599617688255 +0.315,49.270944734671,0.41833149354877885,49.642611399999964,0.014676027069358272 +0.3185,49.190280122455874,0.43178802007627703,49.56530372000005,0.00935883586949714 +0.322,49.109341679741,0.4457416520298346,49.480622639999986,0.00917355424732766 +0.3255,49.02788768379163,0.4604183107577486,49.3565332,0.008667709599428435 +0.329,48.9456942178785,0.4759452950096421,49.26620796,0.009276448962188535 +0.3325,48.8625153765375,0.4923764344086726,49.15818812000005,0.009333509447763743 +0.336,48.777335677230994,0.509986685535043,49.05672895999995,0.011908513087159942 +0.3395,48.68913558071513,0.5293348394943522,48.97180540000013,0.022911292739095857 +0.343,48.598216372242,0.5503411002957053,48.8488984,0.012661387830724673 +0.3465,48.50465953837437,0.5728859651587792,48.76178699999996,0.01605732260616806 +0.35,48.40875757570525,0.5966713408423252,48.661124800000124,0.02245201042668719 +0.3535,48.31096283188449,0.6213270692510251,48.52239495999996,0.006556478755252022 +0.357,48.21238169906175,0.6464432604647161,48.4503192000001,0.018714641163035048 +0.3605,48.11328237280662,0.6715748331886637,48.343283400000004,0.010768948755566948 +0.364,48.0139376484305,0.6962634603930055,48.22777448,0.00901642601766026 +0.3675,47.914599871400384,0.7199134066346526,48.12503212000005,0.01397599333544445 +0.371,47.8155208313975,0.7420144774525403,47.993355040000054,0.01159141275285503 +0.3745,47.71702118070763,0.761833145732359,47.91837864,0.013776576164172818 +0.378,47.61944585730975,0.778776297482381,47.801968599999995,0.020835619508427074 +0.3815,47.52287410944949,0.7923309382349514,47.672104840000046,0.011006561338035518 +0.385,47.4268382624065,0.8028289968063328,47.58404203999994,0.01152522433906021 +0.3885,47.330855128836625,0.8104515452682473,47.46784132000009,0.01171679159461707 +0.392,47.23428128934475,0.8153475431805688,47.35317451999997,0.00823878055490712 +0.3955,47.135747066769,0.816248777491693,47.2457604,0.013397566320045278 +0.399,47.034871009262986,0.8136940873171722,47.12057504000004,0.004307881039206058 +0.4025,46.93124127158387,0.8082284069113157,47.01379100000004,0.011549924464697126 +0.406,46.82458364218075,0.8006119207865251,46.91150411999996,0.01570839107905154 +0.4095,46.71352923433663,0.791247559799533,46.78535784000009,0.015518714397349892 +0.413,46.5980171631285,0.7809419303609363,46.6979868,0.020914468071170315 +0.4165,46.47798265391788,0.7705195048205002,46.58420708000007,0.005014603913772531 +0.42,46.353722727107,0.7608194442526607,46.45580860000009,0.009364909571351467 +0.4235,46.22518228496263,0.7526997320864863,46.36890531999994,0.01221450241850038 +0.427,46.0926486709805,0.7468769856657427,46.23718056000011,0.015627185269475555 +0.4305,45.95553662849449,0.7447991236607804,46.126224,0.010791079904253984 +0.434,45.812152120591506,0.747745395680325,46.02582972000003,0.0059757140319757086 +0.4375,45.662026590496374,0.7530965980051983,45.89313060000004,0.007497030241352647 +0.441,45.50613648675325,0.7606241737590889,45.78948068000007,0.00887536266710071 +0.4445,45.34480657764526,0.7704072093152411,45.672029359999996,0.01811939592890984 +0.448,45.1801733645295,0.7814303845189523,45.5400882,0.011254278484203378 +0.4515,45.01381518369413,0.7927411332897919,45.441380920000036,0.011989331653275653 +0.455,44.846511424861,0.8033362476445185,45.31675959999994,0.023941910582129043 +0.4585,44.67989863764837,0.8120443556952714,45.178238000000064,0.004547774825134955 +0.462,44.51566110987575,0.8178513010536003,45.087919679999956,0.019711780096474056 +0.4655,44.355681067650735,0.8195206998283597,44.9657908,0.009472004365496146 +0.469,44.201452572526996,0.8162953276126713,44.844148760000046,0.005083623891279928 +0.4725,44.05279355925387,0.8100009842502489,44.73835120000005,0.011997005829787525 +0.476,43.90914714110825,0.8025959032226946,44.600129079999945,0.019969889337995837 +0.4795,43.771207594207254,0.7947555747049905,44.5048714,0.015481397145587421 +0.483,43.63876283928425,0.7867624703100652,44.379345799999996,0.02787901357114278 +0.4865,43.51054021142138,0.7790839145804028,44.230257440000045,0.011011237394953112 +0.49,43.385645960599,0.7719081041010387,44.146758840000075,0.024574678379753592 +0.4935,43.26360291398451,0.7652372660179758,44.01019579999988,0.015124682195011674 +0.497,43.14333571303225,0.7590372848255603,43.867944400000084,0.006454188452397882 +0.5005,43.031513057923064,0.7521143934625582,43.74856179999999,0.010320694777969932 +0.504,42.914462269346,0.7460055840006935,43.60444040000006,0.006958204979733053 +0.5075,42.79375238373374,0.7405599333592565,43.49487168000005,0.01597212399001406 +0.511,42.67099389112675,0.7354255038014327,43.35964684000002,0.008825481991854473 +0.5145,42.54509398758675,0.7305870236608176,43.21825424000001,0.005459646584574309 +0.518,42.41559064038025,0.7256416255572103,43.1055156,0.010840909569773353 +0.5215,42.28236106455377,0.720394495237133,42.974358920000064,0.01706295761091642 +0.525,42.14609032238275,0.7163086547716571,42.83007039999993,0.010658291545065566 +0.5285,42.00597552864512,0.7136848826841068,42.70825172000009,0.015206454155764717 +0.532,41.86166933165625,0.7126253624283638,42.59171335999996,0.009678171580820362 +0.5355,41.71353959013699,0.7128167004846764,42.4603964,0.01699087800262151 +0.539,41.562347312116756,0.713747135550174,42.32460736000005,0.009080595114195131 +0.5425,41.40983185243398,0.7145358821940859,42.182138600000016,0.00666579607548035 +0.546,41.25689216729925,0.7146029769209429,42.01625104000014,0.011216154331542947 +0.5495,41.10386038401387,0.7131673541148549,41.84959208,0.011618644559222048 +0.553,40.95107953728925,0.7094583116235187,41.660305199999996,0.007677833463940206 +0.5565,40.79883960100801,0.7023557777717249,41.476107760000076,0.008608498621020241 +0.56,40.64714266232848,0.6911978451571793,41.303325160000085,0.01425108946599975 +0.5635,40.49593985305562,0.6749311260824069,41.13319575999993,0.005713630396492173 +0.567,40.34381478656575,0.6524259137596867,40.94845688000016,0.013691644382214162 +0.5705,40.189315739800385,0.6233763815619794,40.7585,0.0066113015738202925 +0.574,40.03187241382375,0.5892924157695416,40.57668168000008,0.00858802843684184 +0.5775,39.867260642206375,0.5514264149925122,40.40587296000007,0.008176616846134287 +0.581,39.69410663481275,0.5128975873508048,40.220852679999915,0.0013067848146396627 +0.5845,39.51407277749499,0.4779556683573206,40.02874932,0.010396673154069063 +0.588,39.32937184409923,0.4507645453398055,39.846873800000076,0.006156006392102975 +0.5915,39.141340854425124,0.43294058635309324,39.66066148000007,0.0150333193604022 +0.595,38.9499910415225,0.4201792471607728,39.48208407999986,0.009910876894210857 +0.5985,38.7574532014719,0.4096758425263038,39.304593280000155,0.01259857729483167 +0.602,38.566524138282,0.39750520002340817,39.129073919999925,0.024628471180567286 +0.6055,38.38007859596889,0.37795588345209463,38.943996400000245,0.006472842520784346 +0.609,38.196861436389995,0.35176363112167885,38.74882932000007,0.010366238863363585 +0.6125,38.01227281402563,0.32090638719289144,38.56923323999992,0.031045377340371254 +0.616,37.827128113333,0.2876544245750597,38.38401832000016,0.019321308084906886 +0.6195,37.643180301690975,0.25646558131367725,38.19813919999999,0.011696684301135442 +0.623,37.460724958355996,0.23129992045739134,38.03417520000007,0.012443269252885962 +0.6265,37.27989362757725,0.21556762313012853,37.828006080000016,0.02171426451052233 +0.63,37.100687932599996,0.20977887018097952,37.64895340000006,0.020122144418479683 +0.6335,36.92324496631913,0.2109990514165394,37.462701279999884,0.00791237703171027 +0.637,36.74741597820572,0.21496365529931216,37.248775880000174,0.010781491096098866 +0.6405,36.570750858063384,0.22002267170654258,37.1017738,0.022728641450821357 +0.644,36.389633236659506,0.22829899073111093,36.90447340000002,0.02368195771473414 +0.6475,36.20169893199524,0.2437760205880415,36.68710272000006,0.0050764076975266335 +0.651,36.0061787761,0.27294985756564905,36.53703315999994,0.012427176222613492 +0.6545,35.8025197690275,0.3179456872609438,36.32117959999998,0.0037936494908706207 +0.658,35.59082788177375,0.3742311681371412,36.133769200000074,0.0045212276208571765 +0.6615,35.36938988330549,0.43698062106895486,35.97441088000001,0.015836611419531306 +0.665,35.132875749724,0.5080842858796147,35.76563180000009,0.008923203432689262 +0.6685,34.87895308101338,0.5785161100996495,35.58327184000012,0.008300172780652764 +0.672,34.60957787946075,0.6362414544539146,35.40187439999992,0.02509650487020691 +0.6755,34.30554421593454,0.6498694429441658,35.17969520000018,0.011675794863664359 +0.679,33.96723170404425,0.5930540325166161,35.00839996000006,0.01820057309669037 +0.6825,33.62476405299239,0.5050130334916625,34.82333679999992,0.007400298335833685 +0.686,33.30874825699625,0.42714862018155486,34.62161788000018,0.011064765179228383 +0.6895,33.032050080863,0.3865297106071883,34.41783632000001,0.007639788870880293 +0.693,32.8006177692245,0.3838373605328866,34.23027580000008,0.008275865555978298 +0.6965,32.59288349447972,0.39333696496905957,34.03644576000001,0.006594608232996125 +0.7,32.399389246326244,0.408124031967078,33.824685440000074,0.005827189783038578 +0.7035,32.214689287577755,0.4256392629815747,33.64354647999993,0.011560921492275411 +0.707,32.03263434045075,0.44404358283247536,33.45966516000024,0.006844160312841257 +0.7105,31.847944300554147,0.46131701734312186,33.2541826,0.011311684901020781 +0.714,31.654689772475997,0.4785007918480388,33.06223379999986,0.021843642813333324 +0.7175,31.440555044436877,0.5046995897616864,32.86460636000017,0.009670092077524388 +0.721,31.209039897031253,0.545091498189209,32.667685679999934,0.013012867719735713 +0.7245,30.968417306500637,0.5897751789736688,32.48064336000023,0.013491309629160599 +0.728,30.71798238395425,0.6108491674662532,32.2915464,0.006878482085462227 +0.7315,30.468698911260887,0.6096001746667424,32.08263871999999,0.013264632424959455 +0.735,30.223140989451498,0.6167326490804896,31.865744440000107,0.016585676372449183 +0.7385,29.99278782298025,0.6343744476912249,31.64167452000019,0.011099295011386925 +0.742,29.77772756198575,0.6528297670093952,31.4003900399999,0.004135604742720537 +0.7455,29.568012108860387,0.6664776986676298,31.16296300000019,0.010011339296254827 +0.749,29.36147594715475,0.6747168423019626,30.948912080000078,0.016918507475893827 +0.7525,29.156516068030527,0.6767618107861278,30.747770519999914,0.017148530752584983 +0.756,28.953162875916746,0.671073480314441,30.491133080000207,0.0115616237030238 +0.7595,28.751288675509386,0.656981453949864,30.262339999999988,0.009937761207675101 +0.763,28.549638194744,0.6349300802777955,30.046034199999998,0.004023111196574411 +0.7665,28.34752370104738,0.6046314807579305,29.800680680000006,0.005041584807632151 +0.77,28.146467859871997,0.5660396015337505,29.582524600000077,0.009960792678334635 +0.7735,27.944804940414226,0.5200834494776901,29.37155067999991,0.008883993725368973 +0.777,27.735118960224252,0.46325031127942634,29.10527800000039,0.025838563240531447 +0.7805,27.509057876371372,0.3958198058953374,28.894998800000003,0.030988895215866456 +0.784,27.277418804353,0.34638178897131056,28.688939919999804,0.012902868931001277 +0.7875,27.051961030532155,0.32729600298934436,28.448883960000206,0.02442345896282036 +0.791,26.845273117353997,0.3170967551267719,28.22604963999989,0.02598725854392378 +0.7945,26.648402065762,0.30009358614352216,28.013873440000275,0.009277358254727227 +0.798,26.4534701332005,0.274434856683554,27.787125200000002,0.013277836427671493 +0.8015,26.25202385514624,0.23787290459718366,27.545469280000002,0.01759195246500912 +0.805,26.0456436349785,0.20750981927747997,27.32107588000009,0.009310599011455506 +0.8085,25.8403861391626,0.20766871212426877,27.117034280000162,0.007540708071013866 +0.812,25.64036273309125,0.23737295729168117,26.89534964,0.007013278330927406 +0.8155,25.446395047539127,0.27493296015958885,26.649723,0.009480109835861818 +0.819,25.248675299593998,0.3158286952082651,26.454593720000076,0.010978550692696204 +0.8225,25.043029619999388,0.3578946482520627,26.226852919999875,0.013718404359505705 +0.826,24.82466015492625,0.4032366698145659,25.971197800000176,0.011625333744002292 +0.8295,24.575296770036402,0.47026060585581897,25.758153119999918,0.044992685487878804 +0.833,24.30871377378075,0.5566004910909391,25.5598636,0.030412663058337775 +0.8365,24.042126347794234,0.638479659026457,25.3114235600001,0.024001823944186138 +0.84,23.7919156994905,0.6837019505043551,25.096329680000085,0.03395750667944409 +0.8435,23.55295856934212,0.6907039182009682,24.88291003999987,0.01032528100467931 +0.847,23.298765948836277,0.6459671967184175,24.675885160000128,0.01581637396590498 +0.8505,23.02334402619674,0.5622835915007076,24.4561638,0.015460999052454032 +0.854,22.737114031359997,0.5060244706124171,24.216349319999836,0.017616498630909055 +0.8575,22.449483161109626,0.5294467696468831,24.051207560000122,0.021264916321240585 +0.861,22.170380111430497,0.6181660122383096,23.78690759999983,0.04044759176068641 +0.8645,21.909909746079656,0.7191796724241643,23.539066920000135,0.018831135929828206 +0.868,21.658801787777,0.8146212891930571,23.358304800000003,0.03867458392407022 +0.8715,21.40561346834739,0.9076453127430048,23.123351280000026,0.031110580475377084 +0.875,21.151838430168,0.9925757456439734,22.90861236000007,0.02811353247727941 +0.8785,20.89772570596136,1.062481885477872,22.65968204000016,0.03837859776629039 +0.882,20.61747255334475,1.1169872223654116,22.458828399999994,0.04150608462424618 +0.8855,20.31258294851547,1.1704279654415568,22.245356199999996,0.02335891651382826 +0.889,20.00899001812,1.235021988140904,22.002427080000096,0.01195999083664089 +0.8925,19.730862176959377,1.3024516907469477,21.79688935999993,0.014029778886569364 +0.896,19.48483013038475,1.3576998101173667,21.59776880000014,0.00732436928079167 +0.8995,19.253469328268267,1.4034566571739249,21.365525759999905,0.013256073827800826 +0.903,19.032800038817726,1.4427158058885812,21.1178722,0.02431459713217681 +0.9065,18.820463149529253,1.4764073839612322,20.925728800000037,0.013757972678431301 +0.91,18.6134329558845,1.5061052435531301,20.73916060000008,0.01657256040147955 +0.9135,18.41025363184364,1.5325348370365992,20.509437319999897,0.014876051521456199 +0.917,18.2100565549905,1.5563242853294803,20.220258519999998,0.06968277494644662 +0.9205,18.00978740605322,1.5783152195540964,20.05323,0.05080856987753187 +0.924,17.806325139566248,1.599549321932043,19.825525480000138,0.034006287961097656 +0.9275,17.59659099559174,1.6205788002587591,19.603115120000247,0.02241879095781829 +0.931,17.38056969861397,1.639098594657082,19.321004519999843,0.03095249768914379 +0.9345,17.155338738820625,1.6471103119357835,19.0926153200002,0.023400017254844748 +0.938,16.918238572635996,1.639390801490406,18.742624799999998,0.11519793261903585 +0.9415,16.674294322447654,1.6211881537247506,18.646466080000135,0.022339239419744576 +0.945,16.426746819252998,1.5991727547339865,18.392481480000093,0.026395560673830185 +0.9485,16.178251282294138,1.5794317418268824,18.167026920000012,0.0182915224181117 +0.952,15.931538773513997,1.5676172872118137,17.85196712000003,0.07269871220071364 +0.9555,15.689471658683999,1.569873012504834,17.6765186,0.05297671334935754 +0.959,15.448389027528249,1.585919601868563,17.416289560000127,0.05331279222350013 +0.9625,15.199287695923339,1.6120036178013106,17.18072891999973,0.021379027397453818 +0.966,14.931528382895749,1.6424374673653113,16.916358920000253,0.04545961174061393 +0.9695,14.644309378989375,1.669151375253334,16.751620559999903,0.023757651598363717 +0.973,14.343494839344498,1.6819151246804427,16.510921000000003,0.024973283935037158 +0.9765,14.033864844043666,1.6682011320774757,16.20169564000011,0.07380453253030725 +0.98,13.704678788192249,1.585739082232626,15.996590480000089,0.06956948575247168 +0.9835,13.34153620858999,1.3917748585073921,15.828792600000202,0.012611752479290403 +0.987,12.983159778249751,1.1655160513226586,15.597305959999934,0.08278883873942863 +0.9905,12.67345108144811,0.9866181038686157,15.1377564,0.057297823892360794 +0.994,12.416802875429251,0.8732325410264439,15.038777840000112,0.043159584621516006 +0.9975,12.18305308939038,0.7752090351226639,14.878084840000124,0.03496857637500347 +1.001,11.965281473335022,0.6883080009316256,14.652044519999844,0.07449393299754702 +1.0045,11.758808814340863,0.6105804809475027,14.324525079999958,0.08684076560958792 +1.008,11.5580519829205,0.5394669697248811,14.194011799999998,0.03977596857651626 +1.0115,11.357901450080375,0.47302295598552757,13.875867080000168,0.08109555516452513 +1.015,11.15386521377375,0.4105221413617631,13.633907559999974,0.08352015064695538 +1.0185,10.944764703416286,0.35641671782011203,13.492693879999939,0.025287675827399544 +1.022,10.7301107364895,0.31597930449591405,13.308095919999966,0.023958604617381633 +1.0255,10.508891150501785,0.29728948645150427,12.972336000000078,0.06381689531393657 +1.029,10.279296103651749,0.30934593867770444,12.70295976000001,0.10623811510300574 +1.0325,10.018374694510836,0.397490140963851,12.487169799999972,0.12940683488444973 +1.036,9.7374115164915,0.5457005119144924,12.202060280000458,0.1419793047577414 +1.0395,9.458295363643078,0.7033723541625938,12.032648959999964,0.06211607986631964 +1.043,9.19683258697325,0.8175169855770239,11.848266400000073,0.07498295823290113 +1.0465,8.973271867122126,0.8498550516671426,11.705030880000075,0.017053436876246962 +1.05,8.7646510511425,0.8578356001977185,11.476767879999674,0.06096912347327935 +1.0535,8.564775370478028,0.8608250582882135,11.127836720000024,0.07346873369848148 +1.057,8.3745681850635,0.8610709114256083,10.785377520000143,0.14723685829510325 +1.0605,8.195758562771513,0.8581716837231458,10.683831800000188,0.11125134794331544 +1.064,8.02901037633825,0.8506210313999198,10.55851028000006,0.05815220255796732 +1.0675,7.8695856848643935,0.8375979572052171,10.292220240000141,0.03713344153172776 +1.071,7.71242479337975,0.8198282796137591,10.09654320000001,0.04332250172995783 +1.0745,7.555075570197602,0.7970952365671834,9.762638188000576,0.16051823767659756 +1.078,7.3950994542215,0.7696680326355213,9.57769032,0.15458781020749018 +1.0815,7.2299025035746265,0.7374711832494971,9.255702344000124,0.06625168148592493 +1.085,7.05860622281675,0.7021459930411443,9.14838443200008,0.017773073479249387 +1.0885,6.883941154181256,0.6619609484374829,9.021479091999959,0.0362604477472571 +1.092,6.708303179294987,0.6168209775475579,8.643662963999967,0.07788178285527159 +1.0955,6.532421768367654,0.5688454716316858,8.447756320000043,0.09559051508488234 +1.099,6.35704586649275,0.5204343795365226,8.16445247200008,0.09363214209388533 +1.1025,6.184080880876146,0.473408952813009,8.105977036000045,0.06627047660700894 +1.106,6.01543279579875,0.4294024881813408,7.822248660000109,0.061742034325016425 +1.1095,5.852228412578986,0.3908150087746613,7.659684836000008,0.04983165159561312 +1.113,5.69334938049576,0.35769639531423064,7.377779600000144,0.09536453671470625 +1.1165,5.536772730225245,0.3291178475532528,7.145987720000254,0.11011255559188776 +1.12,5.381464134063711,0.3052315273505149,6.753619343999743,0.11154067143535047 +1.1235,5.226549188514877,0.2864455979491695,6.634831015999741,0.1336466870387079 +1.127,5.07112199803325,0.27269566654984656,6.500106492000015,0.07563936318503921 +1.1305,4.914218444001399,0.26392108622349086,6.302665300000057,0.06379756100244609 +1.134,4.755191340894498,0.259271866702319,6.036206503999976,0.05315660651632406 +1.1375,4.593580751050141,0.2574886566377837,5.8507452480000754,0.03158829274179227 +1.141,4.4291514678545,0.25714922572775234,5.504701035999875,0.23957369855549634 +1.1445,4.260559753449851,0.2569070434116753,5.056488900000057,0.33128514487764493 +1.148,4.0847661484557465,0.25808814549769404,5.29666478,0.0708142639201099 +1.1515,3.9009005993722212,0.2605696063104201,5.025079735999691,0.05576256467540877 +1.155,3.7130887069955003,0.26306536180557766,4.800298028000077,0.03172303476196872 +1.1585,3.525405194324999,0.2640908477846995,4.6555186199998815,0.07722230403305111 +1.162,3.341914513983747,0.26166498702260577,3.7340830839984194,0.12961723025957242 +1.1655,3.165988645628881,0.25299212838211654,4.00234626,0.26107615537773265 +1.169,2.997077459806738,0.23634009655239058,4.08211923600011,0.21120091948832545 +1.1725,2.8405716980260145,0.21068363382573677,3.8757471120001616,0.2348282712496465 +1.176,2.6927441805092487,0.18804224257993596,3.6945031480000843,0.136398799064501 +1.1795,2.549100875535354,0.17903154136509278,3.3406545799997955,0.08392769392741262 +1.183,2.408334133878,0.1759441183121078,2.6172968399997907,0.11382640255406991 +1.1865,2.271567854621475,0.17301224500845627,3.0079272640000183,0.07362536647183017 +1.19,2.142132755375749,0.17036478115184442,2.8341903040003538,0.29254894500077755 +1.1935,2.0239704854193694,0.16890883377248478,2.6678965880000054,0.29249340393067635 +1.197,1.9181741091865,0.17708843494023646,2.482978864000071,0.23344197535925676 +1.2005,1.8187282360736245,0.20500418740352838,2.2929329800000002,0.18288128391800235 +1.204,1.725637613785,0.24387952209680416,0.6754459800000048,0.3662066739686946 +1.2075,1.640679026860888,0.2847185696903423,1.4984600519995204,0.3019925334065784 +1.211,1.5649786970127506,0.3220087502270726,1.894185208000886,0.31168063022489845 +1.2145,1.5004343673740064,0.35148095248161515,2.0874428200001995,0.17117338996879355 +1.218,1.44805130106275,0.3705539097161823,1.9339274199999998,0.11221708554590522 +1.2215,1.4098481998063799,0.3761935095953328,1.695793587999559,0.18311382864765544 +1.225,1.3865261003875005,0.36689505055495103,1.245256415202327,0.22296832501480282 +1.2285,1.3723826862583741,0.34814158422433056,0.10017394843995689,0.02743399305066571 +1.232,1.361115518666,0.3275319954173664,0.330449468199755,0.36020439548869587 +1.2355,1.352539881939625,0.3051496837675395,1.226423774,0.6227053181386067 +1.239,1.3462607815325005,0.28121296064096846,1.7688747799997055,0.3036455123741678 +1.2425,1.3419928018729996,0.25567407150983185,1.4175972524001828,0.33766731577404374 +1.246,1.33946914008825,0.22896803784792438,1.4487696724004073,0.3929268933187854 +1.2495,1.3386309079854992,0.20156035496023014,1.225703619999963,0.19467964690142894 +1.253,1.33928438299675,0.1741332591526348,0.9376392219999999,0.16468352926032317 +1.2565,1.341360151481249,0.1474866447502193,0.7476467388001398,0.20929986197650716 +1.26,1.34467501631875,0.1228404988933939,0.7588618472003942,0.1478479443498062 +1.2635,1.3491490384193772,0.10202661229568193,0.632183540199999,0.3306400304867707 +1.267,1.3546095461124978,0.08775948927553467,0.7760882088001653,0.13253455818440615 +1.2705,1.3609660748600012,0.08288133211924696,0.732721978,0.24276994446149222 +1.274,1.368056478438503,0.08795499720386286,0.8963925255999788,0.2148718215723108 +1.2775,1.3757797668622502,0.10022547559121059,1.0554505587997078,0.09867389682758997 +1.281,1.38416726698775,0.11597076407828827,1.0378503075998355,0.09114810092545306 +1.2845,1.393556218989747,0.13210834508762845,1.1837178539996618,0.13376325373971892 +1.288,1.403677120196,0.14728773956051755,1.24774314,0.10943515507629617 +1.2915,1.4142803301686229,0.16051301040498303,1.368467959999871,0.023975333992605295 +1.295,1.4251539979435,0.17134743591983434,1.342183392000109,0.140348578232623 +1.2985,1.436987184552251,0.17976890342055915,1.367636067999794,0.07193522410974389 +1.302,1.4498349906415,0.18593386467944706,1.388123216000334,0.13942124615305054 +1.3055,1.4649145810907525,0.18885466311703863,1.29787036,0.062190082014039756 +1.309,1.4829398066062502,0.18713892115519196,1.249016528000024,0.13811800680856806 +1.3125,1.503361999879,0.18119496300985674,1.2798470240000603,0.081300891557754 +1.316,1.52543240946775,0.17195493047526142,1.296674707999961,0.07739562707070193 +1.3195,1.548539635289998,0.160179925966386,1.3775986599999723,0.12312351855216573 +1.323,1.5719893319655,0.14701791100557038,1.3417183799999999,0.16348148920308075 +1.3265,1.5951156933504997,0.1336238117133597,1.2995869452000555,0.21889516478978557 +1.33,1.61727878012575,0.12147970057671312,1.2791276715991373,0.240982527487366 +1.3335,1.6377583800873752,0.11217852341603818,1.2625139947996682,0.22237314410921188 +1.337,1.655968959976,0.10719524758847222,1.4722199244001115,0.2860430085273789 +1.3405,1.6698370932113744,0.10960347148271163,1.46043386,0.10133990115461927 +1.344,1.67574881110725,0.12536856241589273,1.4659516840002254,0.11870159926193195 +1.3475,1.67349970978775,0.15307637586104178,1.4003551400000085,0.28285962888501304 +1.351,1.6631505962140085,0.1882119569204965,1.4541121600001896,0.30966833561524404 +1.3545,1.641049308696251,0.22479645664310566,1.4539571959998163,0.20544330418880136 +1.358,1.6086698125652463,0.2622290838195113,1.62765608,0.3165845087247511 +1.3615,1.568175902518758,0.30056305380751186,1.4004179520001916,0.18554282126551272 +1.365,1.5224559488312501,0.3394092588054714,1.2444281540001216,0.24469964559890242 +1.3685,1.4739273589601196,0.3776575257103912,1.6208165519995448,0.3488101346887418 +1.372,1.42523223125675,0.41404675594585677,1.5840845559999772,0.21820069597000644 +1.3755,1.3789987859204929,0.446798546208182,1.46916224,0.3576286858505732 +1.379,1.33765830856075,0.474469894386872,1.771039012000287,0.355206656564447 +1.3825,1.3039027197182467,0.49569262602839104,1.4388543760001025,0.36709809290031353 +1.386,1.2764882727834992,0.5108110790267568,1.3130120759999055,0.06196419762403158 +1.3895,1.256074089212625,0.5188514635032765,1.4215258079998603,0.12378502483827392 +1.393,1.2415201654045,0.5231846517909338,1.5242673400000002,0.15947527154911195 +1.3965,1.2318077236927472,0.5270243515804311,1.610033243999841,0.1997911325355293 +1.4,1.2267183441719993,0.5315441553173451,1.6435286240002316,0.25554387730974487 +1.4035,1.2264212069707536,0.5374031555046983,1.6549640160002461,0.32667325589917057 +1.407,1.2307021128295,0.5451154536499881,1.4916385439999746,0.1449488412949168 +1.4105,1.2397283660792564,0.5546694012731086,1.53788202,0.09703227307853295 +1.414,1.2532876432577498,0.56586957869489,1.5891150879999523,0.09924256770983363 +1.4175,1.2715453728988813,0.5780815714869302,1.612129788000042,0.07961143273251498 +1.421,1.29384075187625,0.5907944440400797,1.6003443959999946,0.07129478915457321 +1.4245,1.3192268145921249,0.6034767814543118,1.548637767999956,0.09467371095407263 +1.428,1.34707796904225,0.6155680768663119,1.6138260800000002,0.053989258255017734 +1.4315,1.377001262330625,0.6262414392483036,1.5634384599999964,0.03610825363560277 +1.435,1.4100768900962495,0.6329710872147157,1.7284702079999534,0.13845844962642306 +1.4385,1.4512298848301175,0.628401550874639,1.7891852359997362,0.19628131763973933 +1.442,1.4981505342514998,0.6141197764825146,1.7095241319999457,0.06765663100624915 +1.4455,1.5482276244608708,0.5924476400048924,1.7046452199999997,0.07573363821801377 +1.449,1.5985974262944995,0.5665825870167714,1.7082135440000754,0.08050190129530753 +1.4525,1.6464206032237485,0.539240391027518,1.7188552399999781,0.09368241552080747 +1.456,1.689061548713744,0.5130684141555654,1.7380871080002582,0.12153979133763569 +1.4595,1.7235835052113775,0.49004442170001905,1.8868759999994928,0.33497626395877 +1.463,1.7491616973552493,0.46857450766538156,1.7049890800004337,0.10083944761850945 +1.4665,1.7636317972103746,0.4479696629650431,1.7309247959999254,0.0545311326898337 +1.47,1.76771222536925,0.4286749904189692,1.686155100000067,0.16070486439280984 +1.4735,1.7663700493326282,0.40872133137026606,1.7311076439997817,0.17479261381985087 +1.477,1.7606835716419995,0.38916168239502136,1.804822867999836,0.259502805736704 +1.4805,1.7509600070866282,0.37122230089067104,1.7545897200002707,0.14588885880828067 +1.484,1.73782953740325,0.35623233070868915,1.799168843999989,0.1417779556900165 +1.4875,1.721638435568872,0.34526941830961566,1.7989187760000327,0.07764120052268428 +1.491,1.7029778251329994,0.3391049120102055,1.910918555999818,0.11373416460224564 +1.4945,1.682233037260619,0.33793692039040796,1.808211636000081,0.07312156168215618 +1.498,1.66009810865125,0.34154809784513407,1.850706219999901,0.044570515666438965 +1.5015,1.638147458378,0.35047829792542506,1.9051012640000315,0.04786919812104582 +1.505,1.6171391430192585,0.36426888624760134,2.0163446600001276,0.14261667925814242 +1.5085,1.5976606074720014,0.3818439207826943,2.0260260760000213,0.11201481599254016 +1.512,1.5801769142477475,0.40190592798991503,2.028069755999348,0.17768649911037265 +1.5155,1.5653193627192525,0.4230736377914386,1.842455,0.054577352814193916 +1.519,1.5535091609222498,0.4441109995304287,1.9216458239999805,0.07645917749242204 +1.5225,1.545421462704998,0.46376509814558164,1.9283185319999667,0.07682949210557816 +1.526,1.5406072879635002,0.48103413706104503,1.9281736760000754,0.09018868610441422 +1.5295,1.5379152195451233,0.4949544740757772,2.000250900000006,0.1181046043626806 +1.533,1.5377351859109996,0.5048825484140882,1.995570579999954,0.06724714057251605 +1.5365,1.540502419898501,0.5102747943647933,2.058123076000049,0.0883464799981789 +1.54,1.54562824090725,0.5121776086286614,2.0805571439999655,0.06630826711496396 +1.5435,1.5526955361655002,0.511267451909304,2.082594587999904,0.06269807217970935 +1.547,1.56113187496225,0.5084839216017326,2.207632308000059,0.25268649141975214 +1.5505,1.5704789135482502,0.5043804213865278,2.182580340000224,0.2508242563760917 +1.554,1.58020545219025,0.4996172068878629,2.0737871279998967,0.12385421622320271 +1.5575,1.5898119158269988,0.4944726897031571,2.0524869600000244,0.04275383160419151 +1.561,1.5987916944675,0.4892321406115124,2.078769536000071,0.06079923042073709 +1.5645,1.6066296007194976,0.48395285485702866,2.0773819039999974,0.09649693234520282 +1.568,1.6130307033204998,0.47885992886544887,2.1245002199999155,0.07252236064470771 +1.5715,1.6175461082351252,0.47379992598557147,2.1315194960000157,0.060798766597561386 +1.575,1.6208223741337502,0.4683096361050056,2.167772528000036,0.07654641515534236 +1.5785,1.6238657490333748,0.46190803339901576,2.200794584000044,0.111704773609234 +1.582,1.626803979145,0.4546962405780598,2.164943075999947,0.07621435446910442 +1.5855,1.629739842255124,0.44664417000840095,2.55407036,0.6417438976700229 +1.589,1.6327763055095001,0.4378667818054686,2.228474240000378,0.09090081409322334 +1.5925,1.6360247194003756,0.4283492515298239,2.290972032000183,0.24061187860618144 +1.596,1.63954733589075,0.4182532601075681,2.200576363999941,0.06857623716211521 +1.5995,1.6433552476075006,0.4077240260855337,2.178464143999957,0.13555181823242965 +1.603,1.6474848204725001,0.39696872306301034,2.1972598000000003,0.10105424468400621 +1.6065,1.652003415076002,0.3861001593458751,2.229124827999963,0.18522995757762878 +1.61,1.65694727026875,0.37532641668423855,2.1972319679999854,0.09668395562485366 +1.6135,1.6623880632836248,0.36478130924413754,2.217201183999946,0.07153846574985571 +1.617,1.6683577163282501,0.3546695286115481,2.2587888479999902,0.05798639080527304 +1.6205,1.6749322232788741,0.34513304168411924,2.290617639999989,0.09611484709389753 +1.624,1.6821391897002518,0.3363580169022342,2.294532888000003,0.11533737640985389 +1.6275,1.6900589261108738,0.32847440394144334,3.1424044199983827,1.7920007867922454 +1.631,1.69866556833125,0.3215778398582602,2.3861307280000283,0.07603306742407057 +1.6345,1.7072348178673726,0.3150437853456438,2.4200761720000123,0.19598000719198203 +1.638,1.7155625184762497,0.3091090335850148,2.38024462,0.19099711772011638 +1.6415,1.7237228147870014,0.3042622559205307,2.4242239760000137,0.17495264050444118 +1.645,1.731803243773,0.30106031115815385,2.447089695999979,0.23199592535637242 +1.6485,1.7400291523991287,0.30020775748227413,2.391707156000042,0.12243823790293289 +1.652,1.748748234443,0.3026461378503314,2.4288976200002375,0.07174760839370493 +1.6555,1.7579904764481251,0.3085873436060875,2.4788069999999998,0.06141154923151666 +1.659,1.767729941166745,0.31797309605382096,2.454187455999863,0.03626428073781134 +1.6625,1.7779821265754965,0.3305700388534571,2.4145136639999185,0.11363338395586751 +1.666,1.78872151299675,0.3459700366246787,2.671386432000868,0.36329184832963834 +1.6695,1.7999631808367482,0.363672565350284,3.1422942519983996,1.2071513651698826 +1.673,1.8116820279885,0.3831368774491362,2.77892822,0.47171437327346943 +1.6765,1.8238927172872534,0.4037894024834718,2.5222825920002263,0.1705777190061317 +1.68,1.83693864297,0.4249090555074616,2.4713855400000226,0.19510040707302326 +1.6835,1.8515360780942547,0.4456102238586112,2.6427101240002786,0.10530883072402707 +1.687,1.8675829380854985,0.4656037988822547,2.576799999999987,0.07775550695132612 +1.6905,1.8850661382788751,0.4844864650677768,2.54525242,0.07951822230638081 +1.694,1.9038673014554914,0.5020367448074173,2.570564420000012,0.06217173102205773 +1.6975,1.926447476600749,0.5180041536482374,2.5834611360001896,0.09818236977610442 +1.701,1.9539722940805015,0.5328213206700032,2.588889772000006,0.1774731505368388 +1.7045,1.9858543178849917,0.5468037438941727,2.982378460000563,1.031450267169718 +1.708,2.0211575354995,0.5603452608627448,2.58387996,0.08381674906024454 +1.7115,2.059948259633134,0.5721799423285567,2.753542891999925,0.244745371057949 +1.715,2.1048984198194995,0.5759902564056814,2.5545941040000173,0.10965761270241633 +1.7185,2.1551256157096335,0.571125520427035,2.772605052001227,0.355802160018828 +1.722,2.2085713889984997,0.5591750026628551,2.9127127799995094,0.6411879625992011 +1.7255,2.26329482819775,0.5407812982146422,2.68673394,0.1426578228049658 +1.729,2.31684152615475,0.5168681466389492,2.6466007279996133,0.13683251024246826 +1.7325,2.367460532958124,0.48853977004655424,2.6924827840001795,0.12892103298934007 +1.736,2.41374232552525,0.4573292231553292,2.6608522759999973,0.11134047783956393 +1.7395,2.4539159462546207,0.4239251883671791,2.6552649360001226,0.1153855052925607 +1.743,2.4866990912919986,0.3890842132003834,2.63493044,0.04004858845125514 +1.7465,2.5100404056872474,0.35264006251079916,3.141661275999911,1.013556709250273 +1.75,2.5219982534122503,0.3136843486177948,2.6801779079994756,0.20068128501334928 +1.7535,2.5219131164461244,0.2752278959302241,2.72156595199972,0.1252202773231746 +1.757,2.5105876102030003,0.24328038982721073,2.7243991559999947,0.16982545441985447 +1.7605,2.4893734227834954,0.22370686954235966,3.6402453800000005,1.4763141382106069 +1.764,2.4629121060959998,0.21830160995210612,3.1364336360006453,0.6358029888502883 +1.7675,2.43269716611975,0.23034655344047086,3.1176533360007888,0.7132762726743522 +1.771,2.4003866248077497,0.25798198009737866,2.893506059999281,0.5345456182745709 +1.7745,2.3674638706688755,0.295899052123955,2.7836944639995047,0.4093326021343876 +1.778,2.335461269237749,0.3385760247359681,2.70262506,0.3000572151066243 +1.7815,2.3059878654407533,0.3815204198836991,2.697463012000069,0.33777535793711233 +1.785,2.280490727698749,0.4216305878556061,2.670191944000012,0.23058854321704325 +1.7885,2.2630935443912517,0.45652290232142734,2.687712348000006,0.2621374292239593 +1.792,2.25553033153575,0.4856927593979457,2.7271227559999702,0.21725230788237804 +1.7955,2.2578872964187524,0.5094149029721172,2.7113265999999996,0.09223431709347674 +1.799,2.2647069308324954,0.5333905559224293,3.0429873600005948,0.5366623925118899 +1.8025,2.2741242915546276,0.5591706278108824,2.8647700039997956,0.15659386023016184 +1.806,2.2844638536667503,0.5858430860432832,2.9650459680008194,0.506975434917806 +1.8095,2.2947961665376244,0.61289856703603,3.8407691919963343,0.7527146492268779 +1.813,2.3045891058340047,0.640246825317831,3.0134700199999997,0.6569192980936942 +1.8165,2.3132655994251228,0.6668577815761929,3.0595798000004737,0.3983215515695057 +1.82,2.3203378908375,0.6916927680974069,2.807783412000224,0.17897431393623375 +1.8235,2.3251845400813753,0.7128767049394912,2.829231639999872,0.40643832941255464 +1.827,2.3273621585415,0.7289312946084243,2.749994283999988,0.14499782282500562 +1.8305,2.3262049383692487,0.7375698883480223,2.839057559999459,0.30836655510093536 +1.834,2.321324723744,0.7373480161233679,2.9247272000002966,0.3628675486087142 +1.8375,2.315755240618624,0.7314683277658388,2.8827343679998654,0.1950047988773772 +1.841,2.312802782752249,0.7234550125545105,2.7474778200002588,0.19046788823984329 +1.8445,2.31487761984125,0.7097787038661684,3.069923720000265,0.37043740067537123 +1.848,2.3216868810735,0.691571724614045,2.76291886,0.17429477120600323 +1.8515,2.332778308877126,0.6703795497360431,3.052620731999946,0.41576635301462384 +1.855,2.3473570723555,0.6482352101265687,3.0654565280001425,0.41610988191334364 +1.8585,2.3652808193288735,0.626822253599339,3.934188872000206,2.0052510366627985 +1.862,2.391827720849,0.6106170704059348,3.6815237040002358,1.4680857638065965 +1.8655,2.427155164648131,0.6038077102263939,3.08431726,0.6571048692643384 +1.869,2.467183959915501,0.6078979486900181,3.0409957879997926,0.5523519878766644 +1.8725,2.508226695128757,0.6216791308997247,2.929322483999429,0.30358767892439387 +1.876,2.5465148435697507,0.6410161086054266,2.8173239079981185,0.4397584246923312 +1.8795,2.5780503296223753,0.6597606758285035,2.591466047999572,0.13784544663637932 +1.883,2.599948016331,0.6726996103637164,3.0252822,0.5503390230860473 +1.8865,2.6162601382915,0.6859664302629774,2.877217319999944,0.36205037508198085 +1.89,2.6316241922629997,0.6989763097362773,3.100561787999594,0.47945094247852904 +1.8935,2.6473579448886206,0.7102632644641672,3.0409143040000943,0.18942423300208122 +1.897,2.663462106829,0.7201406279911531,3.4107216400004092,0.8380881466000946 +1.9005,2.67996825618588,0.728793343050506,5.080217180000233,2.767695150117725 +1.904,2.6968758120692495,0.7365915184466358,3.301170040001337,0.6193369405036834 +1.9075,2.714217644131755,0.7437746831365977,4.774421103998015,1.3401274904787255 +1.911,2.7319918799325,0.7507029305564392,3.8454877040007083,1.2418329325266655 +1.9145,2.75023376297863,0.7576122590532663,3.40893019999871,1.1331974078616134 +1.918,2.7689707408727497,0.7648185044874973,3.107497020004163,1.0386477700286045 +1.9215,2.7882492587332495,0.7725067893672681,3.5508301720011994,0.6177973696506526 +1.925,2.8080489996267497,0.7808691323152774,3.1672891320009597,1.3864599007737346 +1.9285,2.828393080465494,0.7899929250890287,3.15606442800217,0.4755429478117245 +1.932,2.84926107096725,0.7999591387783186,2.899414380000164,0.36384379477326245 +1.9355,2.8706761999871304,0.8107533214232094,3.1360075199999997,1.0448847274096251 +1.939,2.89261792530025,0.822345893728496,2.7394342079999183,0.2705739474605879 +1.9425,2.9151095877046305,0.8346227288333218,2.9795065959999056,0.1964045918387214 +1.946,2.938130533032,0.84746343416682,3.339095484000301,0.6128690162399225 +1.9495,2.961704214023756,0.8606736269395823,3.2136801079993673,0.2812130557318007 +1.953,2.9858098645685,0.8740750096276646,3.31208456,0.4431216754973548 +1.9565,3.010538956238375,0.8873024932377547,3.3137192239995867,0.414052609492916 +1.96,3.0370049275865005,0.8981302982631018,3.485497864000853,0.6740102109211018 +1.9635,3.065658548747875,0.9055208824348768,3.4800949999988715,0.745224976071939 +1.967,3.0962188410155007,0.909772432096579,4.564705535998398,2.190312445850195 +1.9705,3.1285637149418695,0.9109511512630691,4.890659359996569,1.6304228655925872 +1.974,3.1622276368034994,0.9091469004001477,3.3864058400006583,1.4624422819212657 +1.9775,3.1966169147007446,0.903888622647223,3.7393740600006202,1.0802255179917006 +1.981,3.2314431161684993,0.8955678973519661,4.55323416799766,1.3777515546295291 +1.9845,3.2664736348765016,0.8843962541570461,3.2352557520001097,0.5405313872965869 +1.988,3.3014595191142475,0.8709153758827847,2.8629138000003658,0.3650672096420838 +1.9915,3.33878416211125,0.8553951628488692,3.300542427999461,0.9592073712443002 +1.995,3.384318255918749,0.8384097947359123,3.1139001920005556,0.4615381505136364 +1.9985,3.4380676852191243,0.8210820193117806,3.6467273879983937,0.8308935242016523 +2.002,3.4981597869962444,0.8049465489789196,3.375553499999357,0.30410128261724984 +2.0055,3.5632408223766165,0.7915045395564623,3.6219718199995903,0.42393131218000607 +2.009,3.6315579377987497,0.7820068639296595,5.171663935999738,1.1123074047672175 +2.0125,3.701627953037116,0.7770746398921804,4.46329794800086,1.5883172619155106 +2.016,3.77182745588225,0.7765717395895213,5.217097823998658,1.988500841932716 +2.0195,3.840543824756501,0.7794966559124611,3.9467813959973794,1.1936546461855697 +2.023,3.906283088801997,0.7842924298657712,4.37106598,1.8673449781698659 +2.0265,3.9673106594943808,0.7888125583189172,4.860371420002575,2.160719367275936 +2.03,4.024735568609745,0.7933483787169833,3.943918140005914,0.9047635280467247 +2.0335,4.081012865991001,0.7999267886183599,3.5281004359990673,0.9294947895604885 +2.037,4.136240951004494,0.8086287422012202,3.411194388000508,0.7341668584042544 +2.0405,4.190373829010246,0.8194603937476532,3.31404614,0.3981385714954883 +2.044,4.243453121929754,0.8323965238524367,3.2057470600004327,1.1684934197886483 +2.0475,4.2955203386048675,0.847529769197539,3.046963471998005,0.3548173028729423 +2.051,4.346843691319997,0.865067325131993,3.2047253959986364,0.5280422658164274 +2.0545,4.397345397316379,0.8849241954615862,3.5322207599990056,0.6011325213406338 +2.058,4.44712438424725,0.906804356051349,5.705790680003503,0.9046597477404804 +2.0615,4.496593413980618,0.9303004122804014,5.252138840000038,1.7977089350859314 +2.065,4.545942045089997,0.9551808962042821,4.864659951997632,1.5322895648602577 +2.0685,4.59532069911325,0.981329798326759,3.530530884001781,0.2851973588578306 +2.072,4.6448773957525,1.0085972542733164,5.185048080000103,1.7843469875966755 +2.0755,4.694774991597374,1.0369084727745665,4.57973128,1.9597094056909536 +2.079,4.745149071299498,1.0661523116490979,3.421079852001114,0.7469717588550852 +2.0825,4.80993744461536,1.0730145130586939,4.589201320001262,0.8954150571969782 +2.086,4.90939927462675,1.0240297569933658,3.715579148001818,0.49132163986760885 +2.0895,5.034652036551777,0.9377753361188353,3.9572434800012717,0.977518863811642 +2.093,5.17388078389625,0.8390680098713971,5.5240198,0.4818549952856252 +2.0965,5.316435235618345,0.7498886328533959,5.11863883999672,1.0166140455040427 +2.1,5.45299570480425,0.6850324411810196,4.674048495998581,1.2828170837462851 +2.1035,5.601628275550406,0.6312531110851493,4.667772112000456,1.0832757893208602 +2.107,5.7630935490884925,0.6059647399439885,5.13610211199825,1.0202210291738243 +2.1105,5.928439622690876,0.625172789072175,5.068241899999999,1.22548417792608 +2.114,6.088482350124,0.6785494479938075,4.934280899999337,1.308773641583369 +2.1175,6.233484990868224,0.7375588960447226,4.853571131999601,0.5664696750030407 +2.121,6.355521780882,0.7750900181237291,5.0913333999979224,1.4336512851211596 +2.1245,6.466796907848355,0.7967809144363802,6.146281999997854,2.2248633531087365 +2.128,6.576597036968749,0.812548675357254,8.19040208,1.1846619977940445 +2.1315,6.685193373975612,0.8220582410291685,8.327064632000308,0.28794831671520854 +2.135,6.792953427971,0.8257412379044047,8.1530795760003,0.22092533961283736 +2.1385,6.900175017805893,0.8236544155230083,8.607397495999559,0.36261866321908043 +2.142,7.007199039464242,0.8164139699187833,8.635309755999879,0.805263237154067 +2.1455,7.116862986711631,0.7995752019246083,9.451991940000003,0.40390080104680787 +2.149,7.231180183160772,0.7706039495812028,9.149400275999726,0.6834703273393616 +2.1525,7.3495320103291215,0.7315292265115538,9.215036787999974,0.6994975698009023 +2.156,7.470976796534508,0.6852720326819625,9.389415835999797,1.2318312393917903 +2.1595,7.594830616681611,0.6341863355274281,8.499130804000089,0.3812045885749703 +2.163,7.7202168229595,0.5811570265393261,8.452122480000002,0.45207835038494953 +2.1665,7.8463864664001175,0.5289574164229133,8.594196655999555,0.8932495430372562 +2.17,7.9725279230647494,0.48053544910962587,8.96218801199897,0.54096361113782 +2.1735,8.097625599642878,0.43880603485332637,8.843776168000463,0.48052306730807515 +2.177,8.219120251302,0.4036861308666943,9.306944432001448,0.6539783876390566 +2.1805,8.338938036816886,0.3711604402276224,8.96523754,0.4724989913462967 +2.184,8.459034921799521,0.340386088988359,9.469477607999679,0.8733453818265591 +2.1875,8.57840908996275,0.31620979197981414,9.568862971999769,0.351823081361863 +2.191,8.69636582152573,0.3033811332713505,9.795333387999303,1.0820143923792447 +2.1945,8.812096384475614,0.30460531946360697,8.598799780000002,0.5208608855177584 +2.198,8.92497014028975,0.31913825220434133,9.35181626,0.46591630112852106 +2.2015,9.034118383182122,0.34318390076869154,9.53637758000032,0.47144494821469785 +2.205,9.13897044840275,0.3717869506134205,10.144724483999548,0.7638531440425195 +2.2085,9.238597656394006,0.40008826305990297,9.802938364000003,0.2624975244844415 +2.212,9.33248931617675,0.4244190636319778,9.815989191999291,0.2851688885149768 +2.2155,9.422081949569138,0.44430671400999017,9.74784242,0.4845840997002911 +2.219,9.510425455419245,0.4621032240055904,9.692396987999976,0.37081376620320283 +2.2225,9.597926514635127,0.4775520500205672,9.918736583999422,0.4148834208276457 +2.226,9.68505112658623,0.4906713890786337,10.174200036000391,0.39191497023542127 +2.2295,9.772233920035621,0.501353044106641,10.599371319999756,0.276387098875469 +2.233,9.859876644654756,0.5097198265051025,10.8217548,0.6790816433247916 +2.2365,9.948023704294235,0.5154365145339285,10.591796640000066,0.1908048323551998 +2.24,10.03697106107025,0.5186613766665109,10.672261399999687,0.2367173379907357 +2.2435,10.127235783980385,0.5195006953878688,10.90087056000022,0.3868836630342539 +2.247,10.2192295527325,0.5183434895062126,11.491820240000411,0.44935200335469017 +2.2505,10.313557078995768,0.5154453859238175,11.7992774,0.5458137889264981 +2.254,10.41256532819375,0.5119822188017665,11.777870520000144,0.5314639464332518 +2.2575,10.517513731534393,0.5097837352752737,12.102201720000334,0.932115733648137 +2.261,10.62712503451725,0.5103771536892105,12.348656360000481,0.747340804045136 +2.2645,10.740503003430874,0.5146357411156991,12.294401039999872,0.5322384174239103 +2.268,10.856450071287263,0.5226010144647389,12.183436799999562,0.3956247776815671 +2.2715,10.973982762678856,0.5332288379750622,12.478531159999893,0.3210100575932875 +2.275,11.09199075231475,0.5447816861557465,12.532395839999872,0.3898565947324502 +2.2785,11.209403323091395,0.5546434908351306,12.260621440000092,0.14517367647553728 +2.282,11.32546569410275,0.5606552411789572,12.682821920000265,0.4745698168089675 +2.2855,11.442254235581983,0.5644898449635164,12.758929599999998,0.4076482180401384 +2.289,11.560651636267252,0.5669974200935033,13.07746824000012,0.5253895322608075 +2.2925,11.681053935553521,0.567956215822112,13.09188847999953,0.13157628684713385 +2.296,11.803605791931503,0.5674053548556361,13.163082880000019,0.28978883022531376 +2.2995,11.929280824985753,0.5627403308983913,13.35620475999946,0.34691418482721986 +2.303,12.059152751883751,0.5525568103909013,13.3618594,0.3737048515216252 +2.3065,12.192466329075373,0.5388701228275403,13.355978399999836,0.16804891774719333 +2.31,12.328186910598259,0.5240037857020337,14.267332880000396,0.4273712560497623 +2.3135,12.465480434184151,0.509791657535858,13.8854960399996,0.18076705120172817 +2.317,12.6033870021995,0.49786255079423725,14.203442199999397,0.25632360267844745 +2.3205,12.740997804047856,0.4893516881432927,14.3359648,0.36810130959859366 +2.324,12.877427690424003,0.4848150816179381,14.373824479999637,0.12489984150036401 +2.3275,13.011233191739649,0.4836797876221945,14.507229919999663,0.29236675794277217 +2.331,13.140665222671492,0.48385967646875766,14.588485840000299,0.19278407244208465 +2.3345,13.266615499435629,0.4843646065936876,14.879241120000154,0.22405613347487566 +2.338,13.390303702587534,0.48473330697444456,14.733889399999757,0.21845427713179863 +2.3415,13.512405043311873,0.4849161812394411,14.934872679999582,0.27278170554327114 +2.345,13.633784230231756,0.48500300371988153,14.996744719999805,0.3396058823402434 +2.3485,13.75572583481798,0.4852812461026063,15.137244000000143,0.2670574288080602 +2.352,13.879083066580755,0.48593655472721575,15.343539599999929,0.12550417619699117 +2.3555,14.004697806103234,0.4870359640754548,15.339166000000972,0.05569938036831677 +2.359,14.1332313333475,0.48855051315923614,15.408817319999851,0.2685998588685868 +2.3625,14.265588160587146,0.4903390593231986,15.370891040000107,0.19748136490396476 +2.366,14.402366936093749,0.4921820047994061,15.526993719999666,0.08770333788135454 +2.3695,14.545728938894776,0.49232579283365524,15.700028480000054,0.2110554686180423 +2.373,14.699032851992289,0.48728041594707316,15.859091000000001,0.10029154614173583 +2.3765,14.864100968965253,0.4802223363471562,16.035006759999984,0.34276593907627356 +2.38,15.04219934564452,0.47280462723632555,16.023171999999835,0.124375576674195 +2.3835,15.230846799476495,0.4654766280563799,16.106533520000287,0.17006223897716968 +2.387,15.426060296279763,0.45954122470058956,16.164241240000187,0.06695105126935086 +2.3905,15.62497078653336,0.4561093204293633,16.4069052,0.1714274214505952 +2.394,15.824071605271499,0.45546918755976673,16.347858239999887,0.09840772946821527 +2.3975,16.019501807215523,0.4573173865564568,16.689222599999784,0.29676601658707275 +2.401,16.207694096430505,0.4609512418657391,16.659065679999923,0.13522817340857943 +2.4045,16.38450632765828,0.4655273327064915,16.775570039999998,0.08586575909394678 +2.408,16.549326857931487,0.46898611767975806,16.901937999999962,0.0557956590739475 +2.4115,16.706036701998627,0.47188627372196285,17.014689399999988,0.042342421320256306 +2.415,16.857277567846502,0.4742072270332109,17.11035195999991,0.06937712025186683 +2.4185,17.003378073811625,0.4763429945031163,17.226574239999856,0.03222085521073464 +2.422,17.145077350314743,0.478730945960957,17.54560236000016,0.39154182849350305 +2.4255,17.282699240009602,0.4818225316135482,17.650231399999647,0.26906049378650315 +2.429,17.417193513900997,0.4859486582303637,17.666911119999924,0.10148664843048265 +2.4325,17.549413137741972,0.4914628784839433,17.887261920000224,0.05292733070109507 +2.436,17.68039304928925,0.4986295420484165,18.22229179999984,0.12229088608616936 +2.4395,17.81106487694185,0.5078294136553906,18.437752319999994,0.12719065532717017 +2.443,17.942384895810743,0.5193012390612464,18.597119199999945,0.09316151990867787 +2.4465,18.07536339694052,0.5334477885758939,18.76047831999999,0.06786121016110801 +2.45,18.210823508274487,0.5503724952483494,18.926895759999965,0.14870441704044715 +2.4535,18.3492490002105,0.5695080549406266,19.143473720000117,0.1564571775408883 +2.457,18.48997155857825,0.5898787186899388,19.280557839999517,0.18394097266933812 +2.4605,18.632911086221725,0.6104396259325355,19.3623454,0.07995768220315048 +2.464,18.77697840159675,0.6312783709693669,19.455816160000076,0.08973610232975943 +2.4675,18.921568651472224,0.6520389204393964,19.58776487999989,0.12239806946062451 +2.471,19.066638517816997,0.6717067345146567,19.7475296400001,0.12610209998365612 +2.4745,19.21218465063873,0.6892127040318241,19.917269079999805,0.11095808665665884 +2.478,19.358165598627494,0.7037130220378982,20.118175999999984,0.09563629029557597 +2.4815,19.504786872794774,0.7142323330110882,20.241509479999973,0.05180625284240298 +2.485,19.653810153653488,0.7220307295583557,20.385823880000117,0.04899719627751032 +2.4885,19.805614363317247,0.728080669296456,20.553593439999872,0.0841474228222019 +2.492,19.95973198066825,0.7328678466837987,20.73335656000009,0.09275629392742739 +2.4955,20.11591599545037,0.7366397750069436,20.92812239999978,0.07765293606997443 +2.499,20.274069042603948,0.7396355982374524,21.217539039999927,0.13685555639333385 +2.5025,20.433820892365222,0.7418701846463335,21.373094600000105,0.05895179474554398 +2.506,20.59448109691075,0.7433829391470772,21.50335235999993,0.0602033829575476 +2.5095,20.755517970244856,0.7439179815359616,21.622359240000005,0.04206029947185578 +2.513,20.919045269143503,0.7432952066310552,21.7712374,0.07848864681786737 +2.5165,21.085859721659766,0.741690622736125,21.95618492000001,0.13582924053644965 +2.52,21.25436496885225,0.739392205567249,22.120664599999905,0.11923159833483689 +2.5235,21.423104360891653,0.7360715320000959,22.25285712000008,0.0976413008640267 +2.527,21.591464569392297,0.7297120878642603,22.366263999999877,0.0815089634137213 +2.5305,21.760211293802502,0.715101861820178,22.5272064,0.11643107596041531 +2.534,21.92691666908996,0.6932480320024624,22.72956740000016,0.10175791760383085 +2.5375,22.088994163125605,0.6650530643278872,22.9101741599999,0.08682129158375533 +2.541,22.24633259183775,0.6333369758122462,22.984343600000024,0.07274336402515032 +2.5445,22.399307123426972,0.6012582054564815,23.076206639999867,0.04372369968050979 +2.548,22.54732325160475,0.5713024758921792,23.2269492,0.03364508266745688 +2.5515,22.689366430753264,0.545827380634369,23.439505479999973,0.044720076657924115 +2.555,22.824783566642992,0.5264129470524598,23.556644439999964,0.06599403819492518 +2.5585,22.95342673738577,0.5112076395703504,23.686913599999837,0.058607050429849025 +2.562,23.078396705734495,0.49661066918355595,23.844276399999977,0.09571687514147342 +2.5655,23.200565125894503,0.48252601202739376,24.020557199999995,0.06820441118212199 +2.569,23.320989433508473,0.46890161003799113,24.205058919999935,0.01750111421973353 +2.5725,23.440581721507748,0.4557161222989056,24.34143324000009,0.030241226854571986 +2.576,23.560320644392007,0.44295920561387475,24.4501680799999,0.05358994997229437 +2.5795,23.68119335277098,0.43069624849837473,24.59718364000007,0.0699815542982018 +2.583,23.803628344539,0.4192453462072704,24.7893798,0.06652586649341777 +2.5865,23.928118921925766,0.4090186595499727,24.986407399999926,0.06110883011872234 +2.59,24.055513688662497,0.4002954980935371,25.10854507999997,0.05085649305260429 +2.5935,24.186443521395525,0.3935547643673979,25.212954719999903,0.03570607196921774 +2.597,24.32083133276999,0.3891612461564554,25.356397919999857,0.0636293622335589 +2.6005,24.458666954916502,0.38778580210037233,25.5451074,0.033454427588886275 +2.604,24.59850381619575,0.3918218030487775,25.674954520000124,0.04439032799106292 +2.6075,24.74022565080812,0.4016968552115566,25.785858799999865,0.06529042123732964 +2.611,24.883860469131246,0.4165979811625923,25.976558720000117,0.14368373030526455 +2.6145,25.029595696851224,0.4355972577391283,26.140877319999863,0.1121601967782875 +2.618,25.177450726904247,0.45736651937128203,26.3100324,0.024984461286966974 +2.6215,25.32762160241927,0.4806553727377548,26.49811879999993,0.08837622467461251 +2.625,25.480596280000498,0.5043653918059422,26.713458999999894,0.08813082703601964 +2.6285,25.64182750947135,0.5312284264325062,26.889170439999873,0.10810791541017283 +2.632,25.81092707578875,0.5610749953402143,27.089057920000005,0.11980398005726636 +2.6355,25.98535370990753,0.5924974428194214,27.2807252,0.0696467705726551 +2.639,26.163639416415002,0.6251495227841448,27.355916839999963,0.09360111039581606 +2.6425,26.344055495441875,0.6569314908490489,27.49291844000009,0.07156358631191775 +2.646,26.5244640630835,0.6841487643689612,27.63591119999984,0.10864578995544516 +2.6495,26.701881661921497,0.7036309601573277,27.806854160000064,0.056418033276333185 +2.653,26.87332448647951,0.7130679509415625,27.9005342,0.10160990739686719 +2.6565,27.036034197152222,0.7092221369406403,27.94721463999998,0.09665973505224022 +2.66,27.19011255338,0.6921172434835707,28.05300915999994,0.10224111019239318 +2.6635,27.340541351644106,0.6698562293368935,28.256496880000054,0.03337926015268661 +2.667,27.4880921028195,0.6451613576975329,28.43825672,0.10876336289417683 +2.6705,27.63219608902515,0.6190594944573536,28.4866798,0.07322729279578748 +2.674,27.772560333578745,0.5927470781833728,28.567841399999953,0.05545040032441709 +2.6775,27.908580214659505,0.5673099101695362,28.732973319999825,0.07703329855095785 +2.681,28.040352955696036,0.5431262439477552,28.92218248000011,0.07726421925510876 +2.6845,28.169329865470623,0.5172847980981214,29.01901827999992,0.06881111692909096 +2.688,28.296031138286256,0.4902543428581557,29.1615102,0.08943597097197517 +2.6915,28.420384183438735,0.4629822037481843,29.310571719999928,0.08137235732675573 +2.695,28.54257619390801,0.4365413332613595,29.456070639999943,0.06134856947357898 +2.6985,28.662621957432364,0.41192950581917687,29.52558031999999,0.05136851216525397 +2.702,28.78070796150675,0.3901608374532469,29.596613839999982,0.06752093027813323 +2.7055,28.896857380337647,0.3721660026597705,29.75874959999991,0.1075588858127195 +2.709,29.0112483149515,0.3586253174760712,29.948571319999928,0.11097848947357372 +2.7125,29.123912326023138,0.35002664901870645,30.031295600000078,0.05640172123896282 +2.716,29.235019128111027,0.346368473464798,30.093634239999936,0.0713023912436559 +2.7195,29.344608668357626,0.34745942437729177,30.26199300000011,0.093764296909301 +2.723,29.452847731520972,0.3526787021646519,30.480093999999998,0.06475190919965329 +2.7265,29.56050088655586,0.36070779203739783,30.55493019999999,0.08998352271221331 +2.73,29.66838251072175,0.37030916706991035,30.605999519999955,0.07014139205046743 +2.7335,29.77608332902674,0.38101209193079294,30.7346553999999,0.0349820508809585 +2.737,29.883256479779998,0.39230990270438676,30.88841723999999,0.03334112218363097 +2.7405,29.98992572920264,0.40364612387142024,31.008351599999997,0.06494463173965943 +2.744,30.096155155619748,0.4145339278979402,31.11031235999995,0.03874309403581215 +2.7475,30.20197218544102,0.42449415620020736,31.262099079999906,0.06878824427388008 +2.751,30.307437236803032,0.43316782120538155,31.41145000000004,0.036653851774400836 +2.7545,30.412581396304752,0.44012582138337775,31.52222727999993,0.02143642920009995 +2.758,30.51769613217,0.44498630644988924,31.648238199999998,0.03344915291453494 +2.7615,30.623320897316752,0.4474612299164186,31.807807839999935,0.025166200799257406 +2.765,30.729464195306004,0.4485542125047556,31.925138919999977,0.03294973825859576 +2.7685,30.835643897387108,0.44881924196990275,32.002804320000074,0.030307453620730857 +2.772,30.940667791825003,0.44954723274958996,32.16140803999999,0.08033884815810226 +2.7755,31.044142281848018,0.45111550075449847,32.35355339999993,0.05596641050042233 +2.779,31.145922866773002,0.4536416060609103,32.438778759999984,0.03513356803213578 +2.7825,31.245723887157894,0.45712809854936887,32.5038718000001,0.013872979558058265 +2.786,31.343418048723752,0.4614322050962345,32.643460559999895,0.06933231302097079 +2.7895,31.438754989999264,0.4663158082469301,32.79188648000006,0.02182937247267918 +2.793,31.53240078436275,0.4714044501509436,32.89157739999991,0.05774743775966848 +2.7965,31.625523502809873,0.4764752032643957,32.96161823999995,0.05299103507846625 +2.8,31.718406241719514,0.4814356227893705,33.123719400000056,0.0794009466068258 +2.8035,31.811245797408986,0.4861181628317313,33.278248319999875,0.0786823059895071 +2.807,31.9042424208525,0.4903907096129575,33.39870391999999,0.05733893768648715 +2.8105,31.99760945200414,0.4940178273753416,33.5003054,0.048112785159456856 +2.814,32.0915305982015,0.4968356892289304,33.69602159999995,0.07360203159679332 +2.8175,32.18622467019827,0.4985383155464451,33.84394523999997,0.052847069045215925 +2.821,32.2815501478825,0.49844684962786556,33.93432468000005,0.05133181308770165 +2.8245,32.37755284164264,0.4959327116908431,34.0572265199999,0.034484671205800864 +2.828,32.47441498238075,0.4909279990660349,34.1471338,0.04793775774063557 +2.8315,32.57250898571651,0.48294750349489773,34.20709327999998,0.05158718956342126 +2.835,32.6743589079505,0.46833894105302437,34.3005120399999,0.08173142490173378 +2.8385,32.7806286696465,0.44663339602144836,34.43009708000004,0.022796200342452916 +2.842,32.89010735011601,0.42076098605866435,34.49987208,0.04015255489769985 +2.8455,33.00234656159448,0.3935595190054157,34.5373742,0.06261040684423215 +2.849,33.11640899082925,0.3681816819634773,34.6367212,0.06885427461046832 +2.8525,33.23129098629074,0.34728668260313944,34.81595991999994,0.03771907851302292 +2.856,33.34592333115175,0.3328768597441264,34.91098251999999,0.04225809659455196 +2.8595,33.45921600436888,0.32574696867258407,34.94905048000003,0.036618704471235275 +2.863,33.57018615862924,0.3251293383358455,35.09298339999978,0.054306035316306275 +2.8665,33.67745015880763,0.32953722682117087,35.21992195999995,0.025774372181452652 +2.87,33.78014829669624,0.3378569198765115,35.301704600000036,0.06447645423344066 +2.8735,33.88079803842437,0.3488552764577724,35.38761591999985,0.031988591529592277 +2.877,33.98008729965448,0.3618651172157476,35.561074479999974,0.07399475547766407 +2.8805,34.07816335669436,0.37643843630020896,35.67100259999994,0.04382875203896599 +2.884,34.17524291577325,0.39211037006683813,35.74890303999998,0.05180717347269943 +2.8875,34.27136360125623,0.4084640227814002,35.84299627999995,0.036745709752998415 +2.891,34.36663465881475,0.4251217658533471,35.96196948000003,0.06281105830861872 +2.8945,34.46109453179326,0.44177962207634064,36.061325439999955,0.08301890480391763 +2.898,34.554846558301996,0.4581796377285865,36.1861604,0.08939296556385135 +2.9015,34.647935089246516,0.47406789122238474,36.345228760000104,0.05779964893338439 +2.905,34.74045755517574,0.48925022961786874,36.42288739999998,0.052636727331609304 +2.9085,34.832464214556374,0.5034860374728923,36.50937772000009,0.039867961237457686 +2.912,34.92404659037723,0.5166196228244213,36.718405839999775,0.03371378499404094 +2.9155,35.0152608486645,0.5284111094479355,36.8525352,0.07634832573933521 +2.919,35.10619066309475,0.5387374702141152,36.85916896,0.05719800485883219 +2.9225,35.196382062023986,0.5471331240992041,36.95712960000013,0.05505684526695558 +2.926,35.285381901281994,0.5533204415896997,37.15585483999984,0.030776616059190253 +2.9295,35.37336047459651,0.55713600465255,37.266532440000006,0.06536588148039148 +2.933,35.46057770073125,0.5586129142846625,37.30656379999984,0.03462388986231149 +2.9365,35.547200197564734,0.5575354704538331,37.49580667999991,0.06745090010291505 +2.94,35.633356887548246,0.5537989256095064,37.6780109200001,0.018220017720509296 +2.9435,35.71937636553275,0.5472984240493777,37.71245019999999,0.025160080535261743 +2.947,35.805878427885006,0.5377382539177432,37.846650000000004,0.047890366076070244 +2.9505,35.894636881458375,0.5224230405963497,38.065029599999995,0.022378822987367406 +2.954,35.985760336596,0.5020439647456221,38.12903396000001,0.034078356088414495 +2.9575,36.07923696622711,0.4774674494072873,38.19001971999991,0.024802113085147907 +2.961,36.174866689322,0.449935003857587,38.403743360000064,0.06952442712145461 +2.9645,36.27262884930564,0.42040268689277166,38.55073187999989,0.022031370450548517 +2.968,36.372332194652245,0.390033469184212,38.5916432,0.028076672598440513 +2.9715,36.47394723928298,0.3598366002226798,38.70874900000012,0.032490092847482395 +2.975,36.577291561176,0.3308394837976884,38.8731852399999,0.0263805548328297 +2.9785,36.68232684474889,0.3039908283740073,38.96617944000003,0.010485376624071905 +2.982,36.78887849016499,0.28002689919764256,39.048746599999895,0.038118596952193606 +2.9855,36.89670377508625,0.259514807757928,39.19574279999999,0.049415991072730314 +2.989,37.00539919397775,0.24262653917161317,39.322851839999984,0.05941873636950513 +2.9925,37.11455880246448,0.22971859944248502,39.419839759999945,0.06052444239949717 +2.996,37.224782764928754,0.21954410793653162,39.60803431999985,0.037102315216883626 +2.9995,37.33690184222848,0.2111447395968987,39.71421928,0.054676965701199766 +3.003,37.45079850711525,0.2045925995879487,39.819168000000005,0.053977828138043256 +3.0065,37.56650224097798,0.20014176164220146,39.997676679999934,0.056321191409579356 +3.01,37.684778975573,0.19956629218104346,40.11049156000006,0.016864904943908528 +3.0135,37.8064017173014,0.20465541970030218,40.16949119999991,0.031492825360336804 +3.017,37.93057453239675,0.21436468807225673,40.27717544000003,0.03522331966335407 +3.0205,38.056689857955384,0.22790969439402733,40.3877782,0.04310913910877764 +3.024,38.183984730236034,0.24416759858292558,40.459695759999974,0.059514217052125264 +3.0275,38.31179448105825,0.2621968308696597,40.56464247999996,0.03137267745624436 +3.031,38.439413251958,0.2809203900816279,40.683488519999905,0.037157705866592255 +3.0345,38.5661192694776,0.2993274225878379,40.747997799999965,0.05379625247781638 +3.038,38.69133408277125,0.31644842553071484,40.8232766,0.05062219690807546 +3.0415,38.81540358688086,0.33104981204332795,41.016131040000126,0.037429221638054996 +3.045,38.93790944572675,0.34241425096273514,41.122009359999964,0.04427528036939305 +3.0485,39.05805633279776,0.349708501591582,41.15818184000005,0.021362690600827742 +3.052,39.17667837368175,0.3552205860143644,41.29684591999988,0.04477012391317835 +3.0555,39.29433710135739,0.36074907013810475,41.45124439999999,0.028428144105797123 +3.059,39.41085449652128,0.3665645165816847,41.49296648,0.049788231180604624 +3.0625,39.52608761674275,0.3725740334658768,41.584876759999915,0.03199544824849691 +3.066,39.63999967739347,0.378576359868628,41.78681455999991,0.038316470980626745 +3.0695,39.75244380554761,0.3840963418183303,41.84435631999999,0.0209402774072262 +3.073,39.86339056287825,0.38864484798100446,41.911872,0.04755483725132458 +3.0765,39.97268573015812,0.39148201792660625,42.073099159999956,0.032277320625896576 +3.08,40.080307215362005,0.39201033483247455,42.12084195999998,0.04723962664547459 +3.0835,40.186093452960264,0.38940797126402793,42.216362759999846,0.04890136022309338 +3.087,40.2903639819315,0.38346013016486813,42.39724320000007,0.052375823269696246 +3.0905,40.394481937933016,0.37476602633856704,42.498277200000004,0.04183423669316967 +3.094,40.498916600527494,0.36352740101616365,42.557172599999966,0.03718745820273478 +3.0975,40.604505797742874,0.3490788818238473,42.69344631999993,0.02424436443491473 +3.101,40.713378270423725,0.3296087884779788,42.84951548000005,0.03839985992073574 +3.1045,40.825215553689375,0.3069786549070487,42.919274400000006,0.0399909722605036 +3.108,40.93907882849176,0.2842717564290451,42.988689799999996,0.03055070046169183 +3.1115,41.053893477590236,0.26399814833521246,43.09817203999995,0.017009058880706047 +3.115,41.16841561986675,0.24836998435681357,43.21825559999987,0.018991580093328617 +3.1185,41.281760894195884,0.23909649929490834,43.361867920000066,0.03598725124643144 +3.122,41.39314061916025,0.2363038018472223,43.42082887999993,0.028152090983743917 +3.1255,41.50160231756239,0.23818236321516117,43.535078799999994,0.06077826057645892 +3.129,41.60642695433,0.24180432849764338,43.71831347999995,0.011074876503666412 +3.1325,41.707298334503896,0.2443322624254739,43.76593511999999,0.02451919312483243 +3.136,41.8065197013865,0.24632205436879867,43.85254819999993,0.046158749685156535 +3.1395,41.90471348646513,0.24738183247283516,44.061596239999986,0.01505576545529118 +3.143,42.002231815788264,0.24754455776462547,44.12793960000001,0.040553350142743534 +3.1465,42.09931601302924,0.24687306790711955,44.166851439999945,0.0325128468200765 +3.15,42.19624213242725,0.24564508322329429,44.362685280000065,0.05419840827182394 +3.1535,42.29323211335176,0.244088391427047,44.46671431999996,0.021233100328757602 +3.157,42.389873942096,0.24322666072747381,44.486300040000025,0.031813169848177336 +3.1605,42.486100019577734,0.2438116491862459,44.624040599999994,0.03281988327675778 +3.164,42.581960817872755,0.2460574945480786,44.75032175999997,0.028148321640692947 +3.1675,42.67764666589914,0.25029154965902406,44.822289159999954,0.016613851099193416 +3.171,42.773412065449754,0.25670144846595944,44.92429423999994,0.034031403766397586 +3.1745,42.86951814761013,0.2654661653550355,45.02930980000001,0.04593916862412018 +3.178,42.966192842274495,0.27655521867259764,45.137901600000006,0.04477984886419336 +3.1815,43.063470566842746,0.2896897092812238,45.22404259999995,0.034522587215039806 +3.185,43.16119062479976,0.3042640777101219,45.3821400399999,0.028764793013516712 +3.1885,43.25925664327965,0.3198144702097128,45.47019672000001,0.04295714796296556 +3.192,43.357546973578,0.33584815495232856,45.54469143999992,0.046202907564217875 +3.1955,43.456041365182365,0.3519118067941004,45.702781400000006,0.05495168964918017 +3.199,43.55474458111,0.3675620136015097,45.77864271999998,0.03624097631539259 +3.2025,43.653584224119896,0.3822961935261386,45.862236879999976,0.020657318406591685 +3.206,43.75255365763049,0.39575942994051533,45.977617960000025,0.012836080628812328 +3.2095,43.85167064225813,0.40751531971352295,46.03838644,0.041764245213201795 +3.213,43.95094113452952,0.41727708431697524,46.11226699999994,0.03886511692383804 +3.2165,44.05038388327525,0.4246011910773746,46.212846439999964,0.025642552510393386 +3.22,44.150330893186265,0.4287075273195995,46.27457560000003,0.028827137685192895 +3.2235,44.251799008745735,0.4275050809180481,46.36410839999993,0.026207341574037903 +3.227,44.35438442598175,0.421578718855544,46.46715344000004,0.03329297695231916 +3.2305,44.45774770789111,0.4115234669858715,46.569623199999924,0.017724221032277037 +3.234,44.561840675030254,0.39877973015181295,46.69772835999996,0.023677231582853304 +3.2375,44.66647040807577,0.3842371377754477,46.75448992000001,0.027792612008432922 +3.241,44.771376714580995,0.36894486660853604,46.81232971999994,0.02870935591806398 +3.2445,44.87632244988839,0.35378549447685387,46.95498003999999,0.018647986945765534 +3.248,44.98106731503452,0.339676098793274,47.00730559999996,0.029549648361680312 +3.2515,45.08543252014425,0.3273706753004787,47.07522891999997,0.029264362889225536 +3.255,45.189258671589755,0.31760175442207983,47.23656315999999,0.007999261243878618 +3.2585,45.29328934620225,0.3130637826069527,47.306129479999996,0.025930425574053496 +3.262,45.397124589729756,0.31476511397839607,47.351427759999936,0.028081062538070443 +3.2655,45.49957089620949,0.3225251961339253,47.4875726,0.03431286584941626 +3.269,45.6005999798875,0.33416802155991304,47.53875816000001,0.023096787106179444 +3.2725,45.700299363587014,0.34713510382662355,47.584840519999965,0.03089348371345782 +3.276,45.79803995533025,0.3597410099441534,47.765435080000024,0.045241715093371396 +3.2795,45.89302291385215,0.3700867129824272,47.80070104,0.020881425231248165 +3.283,45.984800589901496,0.37681608352811313,47.84680959999992,0.03257406548620879 +3.2865,46.074366537558745,0.3815201874389419,48.01311288000001,0.012550316258624322 +3.29,46.162399608397,0.38514081283974594,48.061434559999995,0.0323094840830048 +3.2935,46.249057636276,0.3877474823166184,48.14880067999991,0.011831090727868417 +3.297,46.33460845849075,0.3895363943018782,48.236244600000006,0.030418718270175008 +3.3005,46.419240167334486,0.3906089929667213,48.267838599999905,0.026462752186761147 +3.304,46.50316132024225,0.39118613365660126,48.40409807999994,0.025356776595472155 +3.3075,46.586388041448856,0.3914961467272542,48.498109759999984,0.03392196865434197 +3.311,46.668986859795744,0.3918325209101817,48.52542563999994,0.015812341618122817 +3.3145,46.75140420751086,0.392442249720696,48.64417383999996,0.03728419997521517 +3.318,46.83410385631575,0.3935920490514994,48.75796739999996,0.010040016747983573 +3.3215,46.917262431165135,0.39559262839517595,48.79524696,0.02435600341779663 +3.325,47.001019842930745,0.3986852465604084,48.88088183999998,0.02860919305301689 +3.3285,47.08538932657075,0.4028395640233195,49.009103080000024,0.018962023118582333 +3.332,47.169965750888,0.40733100662712163,49.05589899999999,0.036122020129273916 +3.3355,47.254685517291115,0.41198212463131234,49.112666600000004,0.034595579266722326 +3.339,47.339473736429504,0.4166907241488736,49.23854456000002,0.03724601116576258 +3.3425,47.42405795358786,0.4216395700101308,49.29610763999998,0.031086393908722556 +3.346,47.5082728488,0.4268682911501357,49.334480520000014,0.02683214851504112 +3.3495,47.591965616224485,0.43232257539986874,49.420768039999984,0.023923658260593842 +3.353,47.67502522024375,0.4379461180654954,49.48501899999998,0.017170091845966136 +3.3565,47.75728786162189,0.4436521183497347,49.57623324,0.018104588836207053 +3.36,47.838653498135244,0.44936270707171216,49.627576120000015,0.03184901180903027 +3.3635,47.918947337153995,0.45496351048374456,49.71295535999993,0.044554412672734835 +3.367,47.998080329848996,0.4603636760253402,49.79344840000001,0.035210888862110164 +3.3705,48.07606403769912,0.4657239217302242,49.84122079999996,0.028264712570637764 +3.374,48.153233870060475,0.47172161256896855,49.956207799999966,0.016909961414514837 +3.3775,48.22916597453924,0.4782391673106188,49.99080635999998,0.02753435492594654 +3.381,48.303679976254,0.48498655232121896,50.05741343999993,0.02180713178680888 +3.3845,48.37679541455611,0.4918812053964221,50.154734119999986,0.0433166635401521 +3.388,48.44901272919475,0.49908024084318253,50.204047,0.022789407682078114 +3.3915,48.52015887244788,0.5063567271717064,50.25168832000002,0.018365086191785375 +3.395,48.590124460945,0.5134633482435177,50.32459227999997,0.01195881725644751 +3.3985,48.658701731752004,0.5201192650675666,50.374379520000005,0.040228636176648035 +3.402,48.725793838773015,0.5260846540636683,50.40285675999995,0.021671306169815264 +3.4055,48.791151282561245,0.5310919915545347,50.4903694,0.02091954816194812 +3.409,48.854715630577736,0.5348895946386718,50.499528799999965,0.030512057641170244 +3.4125,48.91632448028774,0.5370707892060276,50.5641311199999,0.015368730535452683 +3.416,48.97624940448325,0.5377945948850008,50.64210508000001,0.028957807521163646 +3.4195,49.03484562023212,0.5374227139032624,50.67787935999993,0.01773221287118433 +3.423,49.092343177176254,0.5360593600187384,50.7888712,0.011789459177587114 +3.4265,49.14887551059625,0.5337049773770864,50.78516755999999,0.023745161013310753 +3.43,49.204653273655246,0.5304419574669691,50.821640799999976,0.027547337721049975 +3.4335,49.25982423865226,0.5262613086841258,50.933139239999974,0.018515637702392278 +3.437,49.31458472173149,0.521229359550174,50.92768028,0.01741130873862438 +3.4405,49.36909141700001,0.5153317277565301,50.9912506,0.020507281372722286 +3.444,49.423464299461486,0.5086781388897589,51.08688619999999,0.009773764965445188 +3.4475,49.47778005381437,0.5013315823435766,51.10100188,0.019613479700227362 +3.451,49.5321198353585,0.49341090873217214,51.15200903999995,0.013724899315761615 +3.4545,49.586566801661114,0.484977002197978,51.20616716000002,0.02509695934745397 +3.458,49.641195535506995,0.47613414208888327,51.2313084,0.014839752770851592 +3.4615,49.69609177227001,0.46694684213296106,51.25136063999997,0.021969501037292827 +3.465,49.7511454435875,0.4572926533269684,51.34941983999998,0.041691652218529995 +3.4685,49.80636652310388,0.44710374740374526,51.37743772,0.017434008422398242 +3.472,49.861797989425746,0.43643160664343417,51.38434507999993,0.034898574189341294 +3.4755,49.917527593584,0.4250207081489347,51.4992702,0.012981807027528349 +3.479,49.97399698803726,0.4121404522440832,51.50540860000001,0.03760016005020382 +3.4825,50.031032098546625,0.39792040484229596,51.549331639999934,0.023204012332107414 +3.486,50.088312448575,0.3827683393395308,51.58089003999997,0.023446613012315983 +3.4895,50.14553799821024,0.3670197618374519,51.59375271999996,0.01583516628743084 +3.493,50.2024130915735,0.35107904089200714,51.665871200000005,0.027565003477234677 +3.4965,50.25861286809514,0.3353153697850922,51.69703563999999,0.03557086409757543 +3.5,50.43138257264125,0.29396842133734363,51.717099759999975,0.01403761338572917 diff --git a/validation/experiments/bergdahl/waveform_metrics.json b/validation/experiments/bergdahl/waveform_metrics.json index aa7d9935..03b60bb0 100644 --- a/validation/experiments/bergdahl/waveform_metrics.json +++ b/validation/experiments/bergdahl/waveform_metrics.json @@ -6,12 +6,12 @@ "numerical_cycles": 5, "phase_shift_s": 0.30125, "measured_phase_mean_maximum_N": 71.0195328778505, - "predicted_phase_mean_maximum_N": 67.84045760000001, - "maximum_error_percent": -4.476339323884758, - "mean_bias_N": 2.0719579319066095, - "rmse_N": 4.196177577310751, - "rmse_percent_of_measured_range": 5.946433631630771, - "correlation": 0.9895759130468907 + "predicted_phase_mean_maximum_N": 67.7577418, + "maximum_error_percent": -4.592808408724093, + "mean_bias_N": 2.0711949262398095, + "rmse_N": 4.1822462892277565, + "rmse_percent_of_measured_range": 5.92669150240426, + "correlation": 0.9896597629131386 }, { "period_s": 3.5, @@ -20,11 +20,11 @@ "numerical_cycles": 5, "phase_shift_s": -0.3045, "measured_phase_mean_maximum_N": 51.41051203059488, - "predicted_phase_mean_maximum_N": 52.340401, - "maximum_error_percent": 1.8087525929555692, - "mean_bias_N": 1.0224806395105792, - "rmse_N": 1.2763919162645876, - "rmse_percent_of_measured_range": 2.543419428979128, - "correlation": 0.9992581172582586 + "predicted_phase_mean_maximum_N": 52.33540667999999, + "maximum_error_percent": 1.79903800385162, + "mean_bias_N": 1.0195671548855796, + "rmse_N": 1.283745187531795, + "rmse_percent_of_measured_range": 2.5580720233502228, + "correlation": 0.9992261927440546 } ] diff --git a/validation/experiments/holcombe/provenance.json b/validation/experiments/holcombe/provenance.json index 75353a25..5d3221b4 100644 --- a/validation/experiments/holcombe/provenance.json +++ b/validation/experiments/holcombe/provenance.json @@ -1,9 +1,9 @@ { - "CableDyn_release": "v0.1.1", - "validation_date": "2026-10-09", + "CableDyn_release": "v0.2.0", + "validation_date": "2026-10-20", "executable_name": "cabledyn.exe", - "executable_sha256": "71090e2e28c9e1d99c5180d05a395ebcc891a77cc5294d315a57c691904745ac", - "compiler": "GNU Fortran 15.2.0", + "executable_sha256": "55fe625602eaef9c3bdb7bbee889858d3a50fa4baa66437801d9c102dc2424a3", + "compiler": "GNU Fortran 16.2.0", "build_type": "Release", "platform": "Windows 11 x86-64", "primary_cases": 4, @@ -14,6 +14,6 @@ "marker_curvature_comparison_sha256": "169a2ac11f65f815d75ba84eb6c588693d19971aa524e4b619a34d27a0fb8715", "marker_curvature_summary_sha256": "cd7598043724a79b2bd2f43deac83537319bffc9117f649c92298751236a5a83", "mesh_refinement_summary_sha256": "964fa735d541f5674285fb31aca6053e414b516d579e0b7e41bc5b8cd6286659", - "free_rotation_profile_sha256": "e74e8d9873366c07d6ab9da5a989c9dd49737d3d368843358f3aff69d4c0407a", - "ideal_clamp_profile_sha256": "144c87e7b3c56b8bc5f9a0eae90af24620f004ad102092d40dc8dd9c00fcfb0d" + "free_rotation_profile_sha256": "9fd8b0e476739c981fdd0064efc051f92f971b741ec4fbbf4126773e07afb459", + "ideal_clamp_profile_sha256": "1052900c5b5bde579dbdd27e0d3ec3efa86f413158735b4766e940f14fa7a87e" } From 3c066f4ba82614fbb250b6d43a43a420015cdca2 Mon Sep 17 00:00:00 2001 From: Jae Hoon Seo Date: Tue, 20 Oct 2026 21:46:38 +0900 Subject: [PATCH 25/31] fix: accept seabed recompute inputs equal to rounding (#31) The deck driver stores the seabed recompute inputs of every finite-EI cable with seabed contact (kBot, the contact diameters and cBot/kBot), so that active line control can rebuild the nodal contact coefficients after a length change, and CD_HermiteCable_Dyn_Set_Control_Seabed checked that the inputs reproduce the installed coefficients bit for bit. The deck computes the damping as kn*(cBot/kBot) and the check computes the same product, but the optimised Intel build of the release evaluates the two with different rounding: the release driver stopped examples/buoy_clamped_cable.dat with "the inputs do not reproduce the installed nodal contact damping". The gfortran builds of the test suite round both the same way and did not show it. The check now accepts coefficients within 8 units in the last place, which still rejects inputs that do not belong to the installed coefficients. Built with the release flags (Intel Fortran 2025.3.2, /Qipo, reference LAPACK), the driver of dev stops on that deck and the fixed driver runs it and every other shipped example (51 decks). Signed-off-by: Jae Hoon Seo --- src/CableDyn_HermiteCableDynamic.f90 | 17 ++++++++++++----- tests/test_hermite_cable_control.f90 | 9 +++++++++ 2 files changed, 21 insertions(+), 5 deletions(-) diff --git a/src/CableDyn_HermiteCableDynamic.f90 b/src/CableDyn_HermiteCableDynamic.f90 index fd7c555b..87878b61 100644 --- a/src/CableDyn_HermiteCableDynamic.f90 +++ b/src/CableDyn_HermiteCableDynamic.f90 @@ -1377,9 +1377,11 @@ SUBROUTINE CD_HermiteCable_Dyn_Set_Control_Seabed(model, kbot, diameter_elem, cn !! per-area penalty kbot [N/m^3], the per-element contact diameter [m] and the ratio !! cn/kn, the inputs from which the deck built the installed nodal coefficients with !! CD_Nodal_Seabed_Stiffness. Call after CD_HermiteCable_Dyn_Set_Contact. The inputs - !! must reproduce the installed contact_kn and contact_cn bit for bit at the present - !! lengths, so a length change rebuilds exactly the coefficients a model built with the - !! new lengths would carry; otherwise the call fails and changes nothing. + !! must reproduce the installed contact_kn and contact_cn at the present lengths to within + !! a few units in the last place, so a length change rebuilds the coefficients a model + !! built with the new lengths would carry; otherwise the call fails and changes nothing. + !! (Not bit for bit: an optimising compiler may evaluate the caller's kn*(cBot/kBot) and + !! the same product here with different rounding, as the Intel release build does.) TYPE(CD_HermiteCableDynType), INTENT(INOUT) :: model REAL(wp), INTENT(IN) :: kbot, diameter_elem(:), cn_over_kn INTEGER, INTENT(OUT) :: ErrStat @@ -1405,10 +1407,10 @@ SUBROUTINE CD_HermiteCable_Dyn_Set_Control_Seabed(model, kbot, diameter_elem, cn IF (es /= CD_LINE_OK) THEN CALL fail(TRIM(em)); RETURN END IF - IF (.NOT. ALL(bits_equal(kn_check, model%contact_kn))) THEN + IF (.NOT. ALL(within_ulps(kn_check, model%contact_kn))) THEN CALL fail('the inputs do not reproduce the installed nodal contact stiffness'); RETURN END IF - IF (.NOT. ALL(bits_equal(kn_check*cn_over_kn, model%contact_cn))) THEN + IF (.NOT. ALL(within_ulps(kn_check*cn_over_kn, model%contact_cn))) THEN CALL fail('the inputs do not reproduce the installed nodal contact damping'); RETURN END IF model%seabed_kbot = kbot @@ -1422,6 +1424,11 @@ SUBROUTINE fail(msg) ErrStat = CD_HCDYN_BADINPUT ErrMsg = 'CD_HermiteCable_Dyn_Set_Control_Seabed: '//msg END SUBROUTINE fail + ELEMENTAL LOGICAL FUNCTION within_ulps(x, y) RESULT(close) + !! |x - y| within 8 units in the last place of the larger magnitude (false for a NaN). + REAL(wp), INTENT(IN) :: x, y + close = ABS(x - y) <= 8.0_wp*SPACING(MAX(ABS(x), ABS(y))) + END FUNCTION within_ulps END SUBROUTINE CD_HermiteCable_Dyn_Set_Control_Seabed SUBROUTINE rebuild_length_caches(model, l0_new, ErrStat, ErrMsg) diff --git a/tests/test_hermite_cable_control.f90 b/tests/test_hermite_cable_control.f90 index 1f05ac03..ba874047 100644 --- a/tests/test_hermite_cable_control.f90 +++ b/tests/test_hermite_cable_control.f90 @@ -221,6 +221,15 @@ SUBROUTINE check_model_contract() CALL CD_HermiteCable_Dyn_Set_Control_Seabed(a, 2.0_wp*KBOT, diam, CBOT/KBOT, es, em) CALL require(es /= CD_HCDYN_OK .AND. INDEX(em, 'do not reproduce') > 0 .AND. a%seabed_kbot == KBOT, & 'A: seabed recompute inputs that do not reproduce the installed coefficients fail') + ! a ratio that differs only by rounding (an optimising compiler may evaluate the deck's + ! kn*(cBot/kBot) differently) is accepted; one that differs by 1e-9 is not + CALL CD_HermiteCable_Dyn_Set_Control_Seabed(a, KBOT, diam, NEAREST(CBOT/KBOT, 1.0_wp), es, em) + CALL require(es == CD_HCDYN_OK, 'A: seabed recompute inputs equal to rounding are accepted: '//TRIM(em)) + CALL CD_HermiteCable_Dyn_Set_Control_Seabed(a, KBOT, diam, CBOT/KBOT, es, em) + CALL require(es == CD_HCDYN_OK .AND. a%seabed_cn_over_kn == CBOT/KBOT, 'A: the exact inputs are set again') + CALL CD_HermiteCable_Dyn_Set_Control_Seabed(a, KBOT, diam, (CBOT/KBOT)*(1.0_wp + 1.0e-9_wp), es, em) + CALL require(es /= CD_HCDYN_OK .AND. INDEX(em, 'contact damping') > 0, & + 'A: a damping ratio off by 1e-9 does not reproduce the installed coefficients') ! snapshot/restore: a later command and step roll back exactly, caches included ref = a From e5389b6a79da278901dccd95141f6bdf4058279b Mon Sep 17 00:00:00 2001 From: Jae Hoon Seo Date: Tue, 20 Oct 2026 22:18:44 +0900 Subject: [PATCH 26/31] chore(release): record the builds and checks of 0.2.0 validation/RELEASE_0_2_0.md lists what was built and tested for the release: the source, toolchains and pins; the GNU Release, Debug and NaN-initialised Debug suites (293 of 293 each), Python coverage, the documentation, the metadata and tree audits, the OpenFAST build gate and linearisation check, and the rerun experimental comparisons; the Windows gates of the release workflow; the clean-machine check of the assets (26 checks, every shipped example included); and the asset hashes. The validation README lists it. Signed-off-by: Jae Hoon Seo --- validation/README.md | 3 +- validation/RELEASE_0_2_0.md | 92 +++++++++++++++++++++++++++++++++++++ 2 files changed, 94 insertions(+), 1 deletion(-) create mode 100644 validation/RELEASE_0_2_0.md diff --git a/validation/README.md b/validation/README.md index fb4a2d48..797b0b72 100644 --- a/validation/README.md +++ b/validation/README.md @@ -10,7 +10,8 @@ redistributed. | Path | Contents | | --- | --- | -| [`RELEASE_0_1_1.md`](RELEASE_0_1_1.md) | Toolchains, test results, dependency revisions and asset hashes for v0.1.1 | +| [`RELEASE_0_2_0.md`](RELEASE_0_2_0.md) | Toolchains, test results, dependency revisions and asset hashes for v0.2.0 | +| [`RELEASE_0_1_1.md`](RELEASE_0_1_1.md) | The same for v0.1.1 | | [`RELEASE_0_1_0.md`](RELEASE_0_1_0.md) | The same for v0.1.0 | | [`bodies/`](bodies/README.md) | Rigid-body, rod and shared-anchor cases with MoorDyn-C twins, stored references and pass limits | | [`experiments/`](experiments/README.md) | Holcombe et al. (2025) static lazy-wave and Bergdahl et al. (2016) dynamic-chain comparisons | diff --git a/validation/RELEASE_0_2_0.md b/validation/RELEASE_0_2_0.md new file mode 100644 index 00000000..398432b6 --- /dev/null +++ b/validation/RELEASE_0_2_0.md @@ -0,0 +1,92 @@ + + +# CableDyn v0.2.0 release record + +This record lists what was built and tested for the v0.2.0 release: the source commit, +toolchains, dependency pins, test results and asset hashes. Case definitions and pass criteria +are in [`VALIDATION.md`](../VALIDATION.md). The OpenFAST and r-test pins and the reference +LAPACK are those of [v0.1.1](RELEASE_0_1_1.md). + +## Source and pins + +| Item | Value | +| --- | --- | +| CableDyn | `0.2.0` (2026-10-20), C ABI 1, minor extension 2 | +| Source | The `v0.2.0` tag. The assets and the Windows gates were produced from this tree before this record was completed; every other file is identical. The GNU gates below ran on the release-preparation tree (#30); the one later change (#31, the seabed recompute check) passed the CI matrix (Linux and Windows, Release and Debug) and the GNU Release suite | +| OpenFAST base | `2895884d2be01862173c88d70f86b358d2f1a50a`; the 20 patches of [`integration/openfast/patches`](../integration/openfast/patches) applied to a clean checkout by `prepare_openfast_source.ps1` | +| OpenFAST r-test | `dd5feaaaa500ba7283140107806300d551cff0a7` | +| Reference LAPACK/BLAS | 3.12.1, release-tag archive with SHA-256 `2ca6407a001a474d4d4d35f3a61550156050c48016d949f0da0529c0aa052422` | + +## Toolchains + +| Item | Version | +| --- | --- | +| GNU Fortran (test builds) | conda-forge GCC 16.2.0, with OpenBLAS and LAPACK from the conda environment | +| Intel Fortran (Windows release) | IFX 2025.3.2 | +| Microsoft C/C++ | MSVC 14.44.35207 (`cl` 19.44.35229), Visual Studio 2022, Windows SDK 10.0.22621.0 | +| CMake and Ninja | 4.4.4 and 1.13.2 (local test builds) | +| Python and packaging | Python 3.13.16, build 1.6.1, setuptools 84.2.0, Twine 7.0.0 (release workflow) | + +## Test results + +| Gate | Result | +| --- | --- | +| GNU Release build | 0 compiler warnings in the library, the standalone driver and the OpenFAST module; 169 in the test programs, all reviewed (see below) | +| GNU Release CTest, including the slow tier | 293 of 293 passed | +| GNU Debug build (`-fcheck=all`) | 0 compiler warnings in the library, driver and module | +| GNU Debug CTest | 293 of 293 passed | +| GNU Debug CTest with `-finit-real=snan -finit-integer=-2147483647 -fcheck=all` | 293 of 293 passed | +| Python package tests, native library and driver included | 2103 passed; 99.02% branch coverage (minimum 95%) | +| Ruff, Ruff format and mypy (strict) | passed | +| Sphinx documentation, HTML and EPUB (`-W -n`) | built with no warnings | +| pre-commit, all files | passed | +| Release metadata and release-tree audits | `check_release_metadata.py` passed; `audit_release_tree.py` passed on the working tree and on `--archive-ref HEAD` | +| OpenFAST-tree build gate (`integration/openfast/openfast_build_gate.ps1 -Clean`, GNU CMake build of the patched OpenFAST base) | the CableDyn module compiled from a clean tree, identified itself and ran a 60 s `CompMooring = 5` smoke of the mixed IEA-15 deck (three chain lines and a 248-element finite-EI power cable) with finite output | +| OpenFAST linearisation (`validation/scripts/openfast_lin_ab.py`) | passed: per-fairlead stiffness within 0.07-0.11% of stock MoorDyn (0.29% for the transverse term), platform 6x6 diagonals within 0.11%, gate 0.5% | +| Experimental comparisons ([`experiments`](experiments/README.md)) | Holcombe (12 cases) and Bergdahl (30 primary and 8 refinement cases) re-run with a GNU Release build of 0.2.0: the Holcombe results and the Bergdahl force matrix and refinement are reproduced byte for byte; the Bergdahl waveform RMSEs, now computed from the article supplement, are 5.93% and 2.56% (5.95% and 2.54% before), against a limit of 6.5% | + +The warnings of the test programs are gfortran false positives and deliberate comparisons: +"used uninitialized" reports on the default initialisation of local derived-type variables with +allocatable components, subscripts of loops whose out-of-range iterations a guard skips, and +exact real comparisons in bit-identity assertions. + +## Windows executable gates + +Every gate of `build_static_windows.ps1` passed in the release workflow (`release-windows-static.yml`, +run 39424978495). The smoke runs used a system-only `PATH`. + +| Gate | Result | +| --- | --- | +| Compiler | IFX 2025.3.2 (minimum 2025.3) | +| OpenFAST solution build | 0 errors in all 34 projects; the CableDyn project with 0 warnings | +| `CableDyn_driver.exe` imports | `KERNEL32.dll`, `SHELL32.dll` and `imagehlp.dll` only; stack reserve 268,435,456 bytes | +| `openfast.exe` imports | `KERNEL32.dll` and `imagehlp.dll` only | +| Standalone smoke | the shallow-chain static deck (`chain_catenary_shallow_30m.dat`) converges | +| Memory growth over a 10x longer run | 5.0 -> 5.0 MiB (`dynamic_chain_current.dat`), 21.1 -> 21.2 MiB (`lozon_gomex80_power_cable.dat`); limit +16 MiB | +| Exit contract | a run states the exit contract after the banner; a refused input ends stderr with the closing line | +| `CompMooring = 5` smoke | CableDyn banner, `dtM` 0.025 s (one glue step), equilibrium fairlead tensions 2.437 MN, normal termination | + +## Clean-machine test + +A self-contained check ran the release assets from a folder whose path holds spaces, an accented +letter and Hangul, with a system-only `PATH`. It checks the checksums of the four files and the +manifest, the start of both executables, 13 standalone decks (the torsion example included), +three `CompMooring = 5` runs (a 70 s JONSWAP sea, a 400 s line failure, and a checkpoint at 30 s +with a restart whose last 10 s of output must be bit-identical), and the Python wheel in a new +virtual environment, where it imports as 0.2.0 and runs the release driver. All 26 checks +passed. Every shipped example deck (51) also runs to completion with the release +`CableDyn_driver.exe`. + +The first build of the assets stopped `examples/buoy_clamped_cable.dat` in this check: the +setup check of the seabed recompute inputs compared two products that the optimised Intel +build rounds differently. The fix (#31) accepts agreement within 8 units in the last place; the +assets above were rebuilt from the fixed tree. + +## Assets + +| File | SHA-256 | +| --- | --- | +| `CableDyn_driver.exe` | `80c68e4f90749501cfed11a625358c28a2184c1db2bcb035874b152d61d9bdb7` | +| `openfast.exe` | `dcead60b6bd95a462a9c0361edf17361230b84e1196d7556643e6144476ab608` | +| `cabledyn-0.2.0-py3-none-any.whl` | `b72bb763862694974e8113203c8f6eb9a289067287718103b5b199dc4f9de41a` | +| `cabledyn-0.2.0.tar.gz` | `fdb9985e31df83116f06e7dd3742b0d77e4a02f8fc15b3d5f30c8e171bacdca2` | From 1a56ccddbcfc1c15620a7ab4e0e8476b1b7f4018 Mon Sep 17 00:00:00 2001 From: Jae Hoon Seo Date: Tue, 20 Oct 2026 23:49:45 +0900 Subject: [PATCH 27/31] fix(bathymetry): bound the crease rounding of neighbouring cells CD_Bathymetry_Max_Floor bounds the seabed under a horizontal box by the highest node of the cells the box overlaps, raised by a fraction of their node range for the crease rounding. The rounding band of a grid line reaches into the cells on both sides, and its slope jump depends on the nodes one beyond them, so a box inside a flat cell next to a crease got no allowance: with x = 0, 1, 2 and depths 100, 100, 90 the floor at x = 0.99 is -99.957 m, while the bound of a box around it was -100 m. The explicit sub-step estimate of rods and Rigid6 bodies could then miss a contact already under way and leave its stiffness out. The crease allowance now takes the node range of the cells widened by one node on every side (clamped to the grid); the highest-node part stays on the box's own cells. A test checks that example and a box swept across both cells; it fails without the change. Signed-off-by: Jae Hoon Seo --- src/CableDyn_Bathymetry.f90 | 18 ++++++++++++------ tests/test_bathymetry.f90 | 32 +++++++++++++++++++++++++++++++- 2 files changed, 43 insertions(+), 7 deletions(-) diff --git a/src/CableDyn_Bathymetry.f90 b/src/CableDyn_Bathymetry.f90 index a040656f..2787199f 100644 --- a/src/CableDyn_Bathymetry.f90 +++ b/src/CableDyn_Bathymetry.f90 @@ -192,15 +192,18 @@ SUBROUTINE CD_Bathymetry_Max_Floor(bathy, x_lo, x_hi, y_lo, y_hi, z_max, ErrStat !! An upper bound of the seabed elevation (CD_Bathymetry_Floor) over the horizontal box !! [x_lo, x_hi] x [y_lo, y_hi]: the highest grid node of the cells the box overlaps (the !! bilinear surface of a cell lies within its node range, and outside the grid the floor - !! is clamped to its edge cells), raised by CD_BATHY_CREASE_FRACTION times the node range, - !! which bounds the crease rounding (it moves the surface by at most |J| delta/6 per - !! direction, below a thirtieth of the node range for both directions together). + !! is clamped to its edge cells), raised by CD_BATHY_CREASE_FRACTION times the node range + !! of those cells widened by one node on every side, which bounds the crease rounding (it + !! moves the surface by at most |J| delta/6 per direction, below a thirtieth of the node + !! range for both directions together). The rounding band of a grid line reaches into the + !! cells on both sides and its slope jump J depends on the nodes one beyond them, so a box + !! inside a flat cell next to a crease takes the crease's rise from the widened range. TYPE(CD_BathymetryType), INTENT(IN) :: bathy REAL(wp), INTENT(IN) :: x_lo, x_hi, y_lo, y_hi REAL(wp), INTENT(OUT) :: z_max INTEGER, INTENT(OUT) :: ErrStat CHARACTER(*), INTENT(OUT) :: ErrMsg - INTEGER :: i0, i1, j0, j1 + INTEGER :: i0, i1, j0, j1, iw0, iw1, jw0, jw1 REAL(wp) :: t, z_min LOGICAL :: clamped @@ -220,8 +223,11 @@ SUBROUTINE CD_Bathymetry_Max_Floor(bathy, x_lo, x_hi, y_lo, y_hi, z_max, ErrStat CALL locate_axis(bathy%y, y_lo, j0, t, clamped) CALL locate_axis(bathy%y, y_hi, j1, t, clamped) z_max = -MINVAL(bathy%depth(i0:i1 + 1, j0:j1 + 1)) - z_min = -MAXVAL(bathy%depth(i0:i1 + 1, j0:j1 + 1)) - z_max = z_max + CD_BATHY_CREASE_FRACTION*(z_max - z_min) + ! the crease allowance: the node range of the cells widened by one node on every side + iw0 = MAX(1, i0 - 1); iw1 = MIN(SIZE(bathy%x), i1 + 2) + jw0 = MAX(1, j0 - 1); jw1 = MIN(SIZE(bathy%y), j1 + 2) + z_min = -MAXVAL(bathy%depth(iw0:iw1, jw0:jw1)) + z_max = z_max + CD_BATHY_CREASE_FRACTION*(-MINVAL(bathy%depth(iw0:iw1, jw0:jw1)) - z_min) END SUBROUTINE CD_Bathymetry_Max_Floor SUBROUTINE CD_Bathymetry_Floor_Gradient(bathy, xq, yq, z_floor, dfdx, dfdy, ErrStat, ErrMsg, crease_curvature) diff --git a/tests/test_bathymetry.f90 b/tests/test_bathymetry.f90 index f539d032..afb6f2bb 100644 --- a/tests/test_bathymetry.f90 +++ b/tests/test_bathymetry.f90 @@ -8,7 +8,7 @@ PROGRAM test_bathymetry !! C2 rounding of the creases of a non-planar grid. USE CableDyn_Precision, ONLY: wp USE CableDyn_Bathymetry, ONLY: CD_BathymetryType, CD_Init_Bathymetry, CD_End_Bathymetry, & - CD_Bathymetry_Depth, CD_Bathymetry_Floor, & + CD_Bathymetry_Depth, CD_Bathymetry_Floor, CD_Bathymetry_Max_Floor, & CD_Bathymetry_Floor_Gradient, CD_Bathymetry_Seabed_Load, & CD_Bathymetry_Is_Initialized, CD_BATHY_OK, CD_BATHY_BADINPUT, & CD_Bathymetry_Grid_Floor, CD_Bathymetry_Rotate_Curvature, & @@ -31,6 +31,7 @@ PROGRAM test_bathymetry CALL case_crease_contact_tangent_fd() CALL case_as_laid_tension_sink() CALL case_as_laid_seed_from_last() + CALL case_max_floor_crease_band() IF (nfail > 0) THEN WRITE (*, '(A,I0,A)') 'FAIL: ', nfail, ' assertion(s) failed' @@ -265,6 +266,35 @@ SUBROUTINE case_fail_closed_inputs() CALL CD_End_Bathymetry(bathy) END SUBROUTINE case_fail_closed_inputs + SUBROUTINE case_max_floor_crease_band() + !! The maximum-floor bound covers the crease rounding of a neighbouring cell: a box inside a + !! flat cell next to a crease (x = 0, 1, 2 with depths 100, 100, 90) lies in the rounding band + !! of the crease at x = 1, where the floor rises above the flat cell's nodes. + TYPE(CD_BathymetryType) :: bathy + REAL(wp) :: z_floor, z_max, xq + INTEGER :: es, k + CHARACTER(160) :: em + CALL CD_Init_Bathymetry(bathy, [0.0_wp, 1.0_wp, 2.0_wp], [0.0_wp, 1.0_wp], & + RESHAPE([100.0_wp, 100.0_wp, 90.0_wp, 100.0_wp, 100.0_wp, 90.0_wp], [3, 2]), es, em) + CALL expect_es(es, CD_BATHY_OK, 'maxfloor:init') + CALL CD_Bathymetry_Floor(bathy, 0.99_wp, 0.5_wp, z_floor, es, em) + CALL require(es == CD_BATHY_OK .AND. z_floor > -100.0_wp, 'maxfloor:the crease rounding raises the flat cell') + CALL CD_Bathymetry_Max_Floor(bathy, 0.989_wp, 0.991_wp, 0.49_wp, 0.51_wp, z_max, es, em) +CALL require(es == CD_BATHY_OK .AND. z_max >= z_floor, 'maxfloor:a box in the band of a neighbouring crease is bounded') + ! the bound holds at every point of a box sweeping across both cells + DO k = 0, 200 + xq = 0.01_wp*REAL(k, wp) + CALL CD_Bathymetry_Floor(bathy, xq, 0.5_wp, z_floor, es, em) + CALL CD_Bathymetry_Max_Floor(bathy, MAX(0.0_wp, xq - 1.0e-3_wp), MIN(2.0_wp, xq + 1.0e-3_wp), & + 0.49_wp, 0.51_wp, z_max, es, em) + IF (.NOT. (z_max >= z_floor)) THEN + CALL require(.FALSE., 'maxfloor:sweep bound fails') + EXIT + END IF + END DO + CALL CD_End_Bathymetry(bathy) + END SUBROUTINE case_max_floor_crease_band + SUBROUTINE init_creased_bathy(bathy) !! A non-planar grid with creases along every interior line (non-uniform spacing). TYPE(CD_BathymetryType), INTENT(OUT) :: bathy From abe441f5e97532976381e0b5a44d1185ed64953e Mon Sep 17 00:00:00 2001 From: Jae Hoon Seo Date: Wed, 21 Oct 2026 01:23:56 +0900 Subject: [PATCH 28/31] fix(python): per-line friction options follow their line The per-line OPTIONS layAzimuth and asLaidTension carry the LINE id in the keyword, but DeckModel treated them as opaque scalar options: renaming the line left the keyword naming the old id, so to_text() failed with "OPTION layAzimuth1 names no LINE", and removing the line with cascade=True left the rows behind. DeckModel.references(line) now lists these rows, so remove() refuses a line they name unless cascade is true, removes them with it, and names them in the error ("OPTION layAzimuth2"); rename() rewrites their keywords to the new id. A test covers rename, the error, the cascade and a global layAzimuth row that stays; it fails without the change. Signed-off-by: Jae Hoon Seo --- python/cabledyn/builder.py | 35 +++++++++++++++++++++++++++++------ python/tests/test_builder.py | 30 ++++++++++++++++++++++++++++++ 2 files changed, 59 insertions(+), 6 deletions(-) diff --git a/python/cabledyn/builder.py b/python/cabledyn/builder.py index 3e81cf8a..d7a7463f 100644 --- a/python/cabledyn/builder.py +++ b/python/cabledyn/builder.py @@ -36,6 +36,7 @@ from cabledyn.deck import _check_free_text from cabledyn.deck_file import ( + _LINE_OPTION_PATTERN, _PINNED_END_CONNECTIONS, _RIGID_END_CONNECTIONS, _ROD_ATTACHMENT_ALIASES, @@ -2168,6 +2169,15 @@ def _is_member(self, obj: object) -> bool: items = self._registry(obj) return items is not None and any(item is obj for item in items) + def _line_options(self, line_id: int) -> list[Option]: + """The ``layAzimuth``/``asLaidTension`` rows that name LINE ``line_id``.""" + rows: list[Option] = [] + for row in self.options: + match = _LINE_OPTION_PATTERN.match(row.keyword.lower()) + if match is not None and int(match.group(2)) == line_id: + rows.append(row) + return rows + def _section_owner(self, section: Section) -> Line | None: for line in self._lines: if any(item is section for item in line.sections): @@ -2185,8 +2195,9 @@ def references(self, obj: object) -> tuple[object, ...]: Returns ------- tuple[object, ...] - Referring objects (lines, sections, points, rows, ...) and output - channel names, in deck order. + Referring objects (lines, sections, points, rows, the per-line + ``layAzimuth``/``asLaidTension`` options of a line, ...) and + output channel names, in deck order. Raises ------ @@ -2225,6 +2236,7 @@ def references(self, obj: object) -> tuple[object, ...]: found.extend(row for row in self._attachments if row.line is obj) for rows in (self._syrope_ic, self._failures, self._controls): found.extend(row for row in rows if any(line is obj for line in row.lines)) + found.extend(self._line_options(obj.id)) kind = _object_kind(obj) if kind is not None: object_id = getattr(obj, "id") # noqa: B009 (every referenced kind has an id) @@ -2245,9 +2257,9 @@ def remove(self, obj: object, *, cascade: bool = False) -> None: cascade : bool Also remove what uses ``obj``: lines on a removed point, the rows of a removed line (a line is dropped from multi-line rows, and a - row left without lines is removed), output channels that name it, - and so on recursively. A line left without sections by a removed - line type is removed too. + row left without lines is removed), the per-line options and output + channels that name it, and so on recursively. A line left without + sections by a removed line type is removed too. Raises ------ @@ -2264,6 +2276,9 @@ def remove(self, obj: object, *, cascade: bool = False) -> None: referrers, ) for ref in referrers: + if isinstance(ref, Option): + self.options._rows[:] = [row for row in self.options._rows if row is not ref] + continue if not self._is_member(ref): continue if isinstance(ref, (SyropeIC, Failure, Control)) and isinstance(obj, Line): @@ -2300,7 +2315,8 @@ def rename( Rows that use the object follow it automatically; output channels that name the object by id (``FairTen``, ``Point

pz``, ``BodyPx``, - ``RodPz``, ...) are rewritten. + ``RodPz``, ...) and the per-line options of a line + (``layAzimuth``, ``asLaidTension``) are rewritten. Parameters ---------- @@ -2340,11 +2356,16 @@ def rename( if any(item is not obj and getattr(item, "id") == new for item in registry): # noqa: B009 raise ValueError(f"id {new} is already used by another {type(obj).__name__}") old = obj.id + line_options = self._line_options(old) if isinstance(obj, Line) else [] if isinstance(obj, Turbine): for point in self._points: if point.turbine == old: point.turbine = new obj.id = new + for row in line_options: + match = _LINE_OPTION_PATTERN.match(row.keyword.lower()) + assert match is not None + row.keyword = f"{row.keyword[: len(match.group(1))]}{new}" if kind is None: return for index, channel in enumerate(self.outputs): @@ -2818,6 +2839,8 @@ def __repr__(self) -> str: def _describe(obj: object) -> str: if isinstance(obj, str): return f"output channel {obj!r}" + if isinstance(obj, Option): + return f"OPTION {obj.keyword}" name = getattr(obj, "name", None) if isinstance(name, str): return f"{type(obj).__name__} {name!r}" diff --git a/python/tests/test_builder.py b/python/tests/test_builder.py index e5e5f161..c24acc98 100644 --- a/python/tests/test_builder.py +++ b/python/tests/test_builder.py @@ -15,6 +15,7 @@ DeckReferenceError, Line, MoorDynBody, + Option, Point, RodEnd, SyropeEA, @@ -282,6 +283,35 @@ def test_rename_propagates_to_rows_and_output_channels() -> None: model.rename(Point(1, "Fixed", 0.0, 0.0, 0.0), 3) +def test_per_line_options_follow_rename_and_removal() -> None: + model = _chain_model() + model.options.set("layAzimuth1", 30) + model.options.set("asLaidTension01", 5.0e3) + model.options.set("layAzimuth", 10) + + def friction_keywords() -> list[str]: + return [ + row.keyword + for row in model.options + if row.keyword.lower().startswith(("layazimuth", "aslaidtension")) + ] + + model.rename(model.lines[1], 2) + assert friction_keywords() == ["layAzimuth2", "asLaidTension2", "layAzimuth"] + text = model.to_text() + assert "layAzimuth2" in text and "asLaidTension2" in text + line = model.lines[2] + assert [ref.keyword for ref in model.references(line) if isinstance(ref, Option)] == [ + "layAzimuth2", + "asLaidTension2", + ] + with pytest.raises(DeckReferenceError) as caught: + model.remove(line) + assert "OPTION layAzimuth2" in str(caught.value) + model.remove(line, cascade=True) + assert friction_keywords() == ["layAzimuth"] + + def test_remove_reports_referential_integrity_and_cascades() -> None: model = _chain_model() model.add_line_type("finite", diam=0.2, mass=100.0, ea=1.0e9, ei=1.0e4) From fff7d864e6c6a42338f88e0620be4d76fa630acf Mon Sep 17 00:00:00 2001 From: Jae Hoon Seo Date: Wed, 21 Oct 2026 02:56:19 +0900 Subject: [PATCH 29/31] chore(release): record the final 0.2.0 builds and checks The release review found two more defects, fixed on this branch (the crease bound of CD_Bathymetry_Max_Floor and the per-line friction options of the Python DeckModel), so the assets were rebuilt from the final tree (release workflow run 39457117645). The record gives their hashes and Windows gates, the Python suite of the final head (2104 passed, 99.02% branch coverage), and the clean-machine check of these assets: 26 checks and all 51 shipped examples pass. Signed-off-by: Jae Hoon Seo --- validation/RELEASE_0_2_0.md | 23 +++++++++++++---------- 1 file changed, 13 insertions(+), 10 deletions(-) diff --git a/validation/RELEASE_0_2_0.md b/validation/RELEASE_0_2_0.md index 398432b6..372fc814 100644 --- a/validation/RELEASE_0_2_0.md +++ b/validation/RELEASE_0_2_0.md @@ -12,7 +12,7 @@ LAPACK are those of [v0.1.1](RELEASE_0_1_1.md). | Item | Value | | --- | --- | | CableDyn | `0.2.0` (2026-10-20), C ABI 1, minor extension 2 | -| Source | The `v0.2.0` tag. The assets and the Windows gates were produced from this tree before this record was completed; every other file is identical. The GNU gates below ran on the release-preparation tree (#30); the one later change (#31, the seabed recompute check) passed the CI matrix (Linux and Windows, Release and Debug) and the GNU Release suite | +| Source | The `v0.2.0` tag. The assets and the Windows gates were produced from this tree before this record was completed; every other file is identical. The GNU gates below ran on the release-preparation tree (#30). The later changes (#31, the seabed recompute check; and, on the release branch, the crease bound of `CD_Bathymetry_Max_Floor` and the per-line friction options of the Python `DeckModel`) passed the CI matrix (Linux and Windows, Release and Debug; Python on three platforms with coverage and strict type checks) and the GNU Release and Python suites | | OpenFAST base | `2895884d2be01862173c88d70f86b358d2f1a50a`; the 20 patches of [`integration/openfast/patches`](../integration/openfast/patches) applied to a clean checkout by `prepare_openfast_source.ps1` | | OpenFAST r-test | `dd5feaaaa500ba7283140107806300d551cff0a7` | | Reference LAPACK/BLAS | 3.12.1, release-tag archive with SHA-256 `2ca6407a001a474d4d4d35f3a61550156050c48016d949f0da0529c0aa052422` | @@ -36,7 +36,7 @@ LAPACK are those of [v0.1.1](RELEASE_0_1_1.md). | GNU Debug build (`-fcheck=all`) | 0 compiler warnings in the library, driver and module | | GNU Debug CTest | 293 of 293 passed | | GNU Debug CTest with `-finit-real=snan -finit-integer=-2147483647 -fcheck=all` | 293 of 293 passed | -| Python package tests, native library and driver included | 2103 passed; 99.02% branch coverage (minimum 95%) | +| Python package tests, native library and driver included | 2104 passed; 99.02% branch coverage (minimum 95%), on the release head | | Ruff, Ruff format and mypy (strict) | passed | | Sphinx documentation, HTML and EPUB (`-W -n`) | built with no warnings | | pre-commit, all files | passed | @@ -53,7 +53,7 @@ exact real comparisons in bit-identity assertions. ## Windows executable gates Every gate of `build_static_windows.ps1` passed in the release workflow (`release-windows-static.yml`, -run 39424978495). The smoke runs used a system-only `PATH`. +run 39457117645). The smoke runs used a system-only `PATH`. | Gate | Result | | --- | --- | @@ -62,7 +62,7 @@ run 39424978495). The smoke runs used a system-only `PATH`. | `CableDyn_driver.exe` imports | `KERNEL32.dll`, `SHELL32.dll` and `imagehlp.dll` only; stack reserve 268,435,456 bytes | | `openfast.exe` imports | `KERNEL32.dll` and `imagehlp.dll` only | | Standalone smoke | the shallow-chain static deck (`chain_catenary_shallow_30m.dat`) converges | -| Memory growth over a 10x longer run | 5.0 -> 5.0 MiB (`dynamic_chain_current.dat`), 21.1 -> 21.2 MiB (`lozon_gomex80_power_cable.dat`); limit +16 MiB | +| Memory growth over a 10x longer run | 5.0 -> 5.0 MiB (`dynamic_chain_current.dat`), 21.2 -> 21.2 MiB (`lozon_gomex80_power_cable.dat`); limit +16 MiB | | Exit contract | a run states the exit contract after the banner; a refused input ends stderr with the closing line | | `CompMooring = 5` smoke | CableDyn banner, `dtM` 0.025 s (one glue step), equilibrium fairlead tensions 2.437 MN, normal termination | @@ -79,14 +79,17 @@ passed. Every shipped example deck (51) also runs to completion with the release The first build of the assets stopped `examples/buoy_clamped_cable.dat` in this check: the setup check of the seabed recompute inputs compared two products that the optimised Intel -build rounds differently. The fix (#31) accepts agreement within 8 units in the last place; the -assets above were rebuilt from the fixed tree. +build rounds differently. The fix (#31) accepts agreement within 8 units in the last place. The +review of the release found two more defects, fixed on the release branch: the seabed bound of the +explicit object sub-step estimate left out the crease rounding of neighbouring cells, and the +Python `DeckModel` did not rename or remove the per-line friction options with their line. The +assets above were built from the final tree. ## Assets | File | SHA-256 | | --- | --- | -| `CableDyn_driver.exe` | `80c68e4f90749501cfed11a625358c28a2184c1db2bcb035874b152d61d9bdb7` | -| `openfast.exe` | `dcead60b6bd95a462a9c0361edf17361230b84e1196d7556643e6144476ab608` | -| `cabledyn-0.2.0-py3-none-any.whl` | `b72bb763862694974e8113203c8f6eb9a289067287718103b5b199dc4f9de41a` | -| `cabledyn-0.2.0.tar.gz` | `fdb9985e31df83116f06e7dd3742b0d77e4a02f8fc15b3d5f30c8e171bacdca2` | +| `CableDyn_driver.exe` | `f68a7279723abfa400a3e49ce90490eaa41fd84409273868887f51fd835a45c1` | +| `openfast.exe` | `380ce2249fe4f52511281160e9a6d48141d380d10abb3a87764a0d3777036e73` | +| `cabledyn-0.2.0-py3-none-any.whl` | `f1e754acd6a53b019ef805aace11d0a7d1606ef6703cf92fe6c03592b919060c` | +| `cabledyn-0.2.0.tar.gz` | `5b292b1043dc1e8d9503a3cae1fcf1ff5b3b4e70b02485eb40b3444c5844afaa` | From 9e482818299e3947a03d18fd2c35060ea2fd33e0 Mon Sep 17 00:00:00 2001 From: Jae Hoon Seo Date: Wed, 21 Oct 2026 04:34:56 +0900 Subject: [PATCH 30/31] fix(outputs): keep the touchdown point continuous on steep stencils The touchdown point lies where the parabola through the last grounded node and the next two crosses the contact-onset height. Where the line rises sharply beyond the element, the parabola dips below that height inside the element, and its crossing lay near the suspended node: with clearances -0.001, h, 0.01, 1, 2 on unit spacing the TDP approached x = 1 as h fell to zero but jumped to about 1.97 once node 2 grounded, an artificial jump in the touchdown excursion and grounded-length histories that contradicted the documented continuity. The parabola's curvature is now limited to |qa| <= d1/l1, the bound at which it rises monotonically over the element, so it crosses once, and the crossing reaches a node exactly when the node reaches the onset height from either side. Stencils that already rise monotonically give the same result as before. The driver (TDP channels, range graphs) and cabledyn.touchdown_history change together. On a convex stencil the TDP now lies at the monotone crossing (0.58 of the chord for -0.005, 0.01, 1 instead of 0.97); tests sweep a node through the grounding in both languages and fail without the change. The manual no longer quotes the surge figures measured with the unlimited parabola. Signed-off-by: Jae Hoon Seo --- doc/outputs.rst | 17 ++++++----- doc/python_postprocessing.rst | 6 ++-- python/cabledyn/touchdown.py | 17 +++++++---- python/tests/test_touchdown.py | 51 +++++++++++++++++++++++++------- src/CableDyn_RangeOutput.f90 | 21 ++++++++----- tests/test_range_tdp_locator.f90 | 50 +++++++++++++++++++++---------- 6 files changed, 112 insertions(+), 50 deletions(-) diff --git a/doc/outputs.rst b/doc/outputs.rst index 989ed591..fc24a612 100644 --- a/doc/outputs.rst +++ b/doc/outputs.rst @@ -691,14 +691,15 @@ A node is grounded when its centreline is at most 1e-6 m (the height at which th law engages) above the seabed; the grounded end is the end grounded in the initial state. Walking from that end, the TDP lies between the last grounded node and the next one, where the parabola through the last grounded node and the next two nodes (clearance against chord arc) crosses that -height, the crossing nearest the suspended node; the TDP sits on that height. With fewer than two -suspended nodes, or no crossing inside the element, the clearance is interpolated linearly. The -crossing reaches a node exactly when the node reaches the onset height, so the TDP moves -continuously as nodes ground and lift off, and between nodes it follows the lift-off of the line -instead of resting on the last grounded node until the next one grounds: on a 450 m cable with -5 m elements in a 10 m surge the largest step between output rows falls from 4.6 m (a whole -element) to 0.08 m, and the error against a 1 m mesh from 3.0 m to 1.9 m. The definitions are -those of :func:`cabledyn.touchdown_history` with ``tolerance = 1e-6``. +height; the TDP sits on that height. The parabola's curvature is limited so that it rises +monotonically over the element, so it crosses once: where the line rises sharply beyond the +element, an unlimited parabola would dip below the onset height and put the crossing near the +suspended node. With fewer than two suspended nodes, or no crossing inside the element, the +clearance is interpolated linearly. The crossing reaches a node exactly when the node reaches +the onset height, from either side, so the TDP moves continuously as nodes ground and lift off, +and between nodes it follows the lift-off of the line instead of resting on the last grounded +node until the next one grounds. The definitions are those of :func:`cabledyn.touchdown_history` +with ``tolerance = 1e-6``. .. list-table:: :header-rows: 1 diff --git a/doc/python_postprocessing.rst b/doc/python_postprocessing.rst index b756e574..862b731f 100644 --- a/doc/python_postprocessing.rst +++ b/doc/python_postprocessing.rst @@ -398,9 +398,9 @@ Touchdown time histories every output time, from a CableDyn ``.Line.p.out`` file, a MoorDyn-F line file, or the ``LNpx``/``py``/``pz`` channels of a main output. A node is grounded as in :meth:`~cabledyn.LineGeometry.touchdown`. Between the last grounded node and the next, the TDP is -placed where the parabola through the last grounded node and the next two nodes crosses -``seabed_z + tolerance`` (the crossing nearest the suspended node; the chord crossing when there -is none), so it moves continuously as nodes ground and lift off. The :class:`~cabledyn.TouchdownHistory` +placed where the parabola through the last grounded node and the next two nodes, its curvature +limited so that it rises monotonically over the element, crosses ``seabed_z + tolerance`` (the +chord crossing when there is none), so it moves continuously as nodes ground and lift off. The :class:`~cabledyn.TouchdownHistory` holds the TDP arc length from End A, its coordinates, the layback, and two excursions from a reference TDP (a static profile, or the first sample): the horizontal excursion, positive towards the suspended end, and the arc-length excursion. Samples without a touchdown are ``nan``. diff --git a/python/cabledyn/touchdown.py b/python/cabledyn/touchdown.py index 738685d9..2c7e9d37 100644 --- a/python/cabledyn/touchdown.py +++ b/python/cabledyn/touchdown.py @@ -15,9 +15,10 @@ must start at one end of the line (as for :meth:`cabledyn.LineGeometry.touchdown`). Between the last grounded node and the next one the touchdown point (TDP) is placed where the parabola through the last grounded node and the next two -nodes (height against chord arc) crosses ``seabed_z + tolerance``, the crossing -nearest the suspended node; with fewer than two suspended nodes, or no crossing -inside the element, where the chord crosses that height. The crossing reaches a +nodes (height against chord arc), its curvature limited so that it rises +monotonically over the element, crosses ``seabed_z + tolerance``; with fewer than +two suspended nodes, or no crossing inside the element, where the chord crosses +that height. The crossing reaches a node exactly when the node reaches that height, so the TDP moves continuously as nodes ground and lift off, and the parabola follows a tangential lift-off between nodes instead of holding the TDP at the last grounded node (the behaviour of the @@ -311,8 +312,12 @@ def _locate( def _quadratic_fraction(xyz: npt.NDArray[Any], last: int, level: float, linear: float) -> float: """Crossing of ``level`` by the quadratic height through the last grounded node and the - first two suspended nodes, nearest the suspended node, as a fraction of the first chord - (the linear fraction when the quadratic has no crossing in the element).""" + first two suspended nodes, as a fraction of the first chord (the linear fraction when the + quadratic has no crossing in the element). The curvature is limited to ``|qa| <= d1/l1`` + so that the height rises monotonically over the element and the crossing is unique: an + unlimited parabola can dip below ``level`` when the line rises sharply beyond the element, + and its crossing then jumps by almost an element as the next node grounds. The monotone + crossing reaches a node exactly when the node reaches ``level``, from either side.""" g0, g1, g2 = (xyz[last + k, 2] - level for k in range(3)) l1 = float(np.linalg.norm(xyz[last + 1] - xyz[last])) l2 = float(np.linalg.norm(xyz[last + 2] - xyz[last + 1])) @@ -320,6 +325,8 @@ def _quadratic_fraction(xyz: npt.NDArray[Any], last: int, level: float, linear: return linear d1 = (g1 - g0) / l1 qa = ((g2 - g1) / l2 - d1) / (l1 + l2) + if d1 > 0.0: # monotone over the element: q'(0) >= 0 and q'(l1) >= 0 + qa = min(max(qa, -d1 / l1), d1 / l1) qb = d1 - qa * l1 if abs(qa) * l1 <= 1e-12 * max(abs(qb), np.finfo(float).tiny): return float(np.clip(-g0 / qb / l1, 0.0, 1.0)) if qb != 0.0 else linear diff --git a/python/tests/test_touchdown.py b/python/tests/test_touchdown.py index c710fa71..36f240b4 100644 --- a/python/tests/test_touchdown.py +++ b/python/tests/test_touchdown.py @@ -33,14 +33,19 @@ def _frames(kinks=None) -> np.ndarray: def _expected(xyz: np.ndarray) -> tuple[float, np.ndarray]: """Straightforward scalar TDP: last grounded node from End A, then the crossing of the - level by the parabola through that node and the next two, in chord arc (on a straight - rise this is the chord crossing).""" + level by the parabola through that node and the next two, in chord arc, its curvature + limited so that it rises monotonically over the first chord (on a straight rise this is the + chord crossing).""" level = SEABED + TOLERANCE last = int(np.argmax(xyz[:, 2] > level)) - 1 low, high = xyz[last], xyz[last + 1] chords = np.linalg.norm(np.diff(xyz, axis=0), axis=1) arcs = np.array([0.0, chords[last], chords[last] + chords[last + 1]]) - coefficients = np.polyfit(arcs, xyz[last : last + 3, 2] - level, 2) + heights = xyz[last : last + 3, 2] - level + curvature = np.polyfit(arcs, heights, 2)[0] + rise = (heights[1] - heights[0]) / chords[last] + curvature = float(np.clip(curvature, -rise / chords[last], rise / chords[last])) + coefficients = [curvature, rise - curvature * chords[last], heights[0]] roots = [r.real for r in np.roots(coefficients) if abs(r.imag) < 1e-12] inside = [r for r in roots if -1e-9 <= r <= chords[last] * (1.0 + 1e-9)] fraction = max(inside) / chords[last] @@ -122,11 +127,11 @@ def test_touchdown_history_grounded_at_end_b(tmp_path): np.testing.assert_allclose(backward.layback, forward.layback) -def test_touchdown_on_a_convex_stencil_lies_just_before_the_barely_lifted_node(tmp_path): - # Clearance above the onset height -0.005, 0.01, 1.0, 2.0 m on 1 m spacing: node 2 is barely off - # the seabed and the line rises sharply beyond it, so the line leaves the seabed just before - # node 2. The chord crossing (a third of the way) would put the TDP a node behind. The - # parabola through the first three nodes crosses zero once inside the element, at 0.97 chord. +def test_touchdown_on_a_convex_stencil_takes_the_monotone_crossing(tmp_path): + # Clearance above the onset height -0.005, 0.01, 1.0, 2.0 m on 1 m spacing: the line rises + # sharply beyond node 2. The unlimited parabola dips below the onset height inside the + # element; limited to rise monotonically it crosses once, at sqrt(0.005 / 0.015) of the chord, + # beyond the chord crossing (a third of the way). level = SEABED + TOLERANCE z = level + np.array([-0.005, 0.01, 1.0, 2.0]) frame = np.column_stack([np.arange(4.0), np.zeros(4), z])[None, :, :] @@ -138,8 +143,8 @@ def test_touchdown_on_a_convex_stencil_lies_just_before_the_barely_lifted_node(t arc, point = _expected(frame[0]) assert history.arc_length[0] == pytest.approx(arc) np.testing.assert_allclose(history.coordinates[0], point) - assert 0.95 < history.coordinates[0, 0] < 1.0 - # the same stencil with node 1 exactly at the onset height: the second crossing, still inside + assert history.coordinates[0, 0] == pytest.approx(np.sqrt(0.005 / 0.015), abs=1e-6) + # the same stencil with node 1 exactly at the onset height: the TDP is that node z = level + np.array([0.0, 0.01, 1.0, 2.0]) frame = np.column_stack([np.arange(4.0), np.zeros(4), z])[None, :, :] history = touchdown_history( @@ -147,7 +152,7 @@ def test_touchdown_on_a_convex_stencil_lies_just_before_the_barely_lifted_node(t seabed_z=SEABED, tolerance=TOLERANCE, ) - assert 0.95 < history.coordinates[0, 0] < 1.0 + assert history.coordinates[0, 0] == pytest.approx(0.0, abs=1e-6) # a node reaching the onset height maps to that node z = level + np.array([-0.5, 1e-12, 1.0, 2.0]) frame = np.column_stack([np.arange(4.0), np.zeros(4), z])[None, :, :] @@ -159,6 +164,30 @@ def test_touchdown_on_a_convex_stencil_lies_just_before_the_barely_lifted_node(t assert history.coordinates[0, 0] == pytest.approx(1.0, abs=1e-6) +def test_touchdown_is_continuous_as_a_node_grounds_on_a_steep_stencil(tmp_path): + # Clearances -0.001, h, 0.01, 1, 2 m: node 2 grounds as h falls through zero while the line + # rises sharply beyond node 3. The TDP reaches node 2 from either side, without the jump of + # almost an element that the unlimited parabola makes when the grounded stencil changes. + level = SEABED + TOLERANCE + steps = 1.0e-6 * np.arange(40, -41, -1) + frames = np.stack( + [ + np.column_stack( + [np.arange(5.0), np.zeros(5), level + np.array([-0.001, h, 0.01, 1.0, 2.0])] + ) + for h in steps + ] + ) + history = touchdown_history( + _write_line(tmp_path / "steep.p.out", frames, times=list(range(len(steps)))), + seabed_z=SEABED, + tolerance=TOLERANCE, + ) + x = history.coordinates[:, 0] + assert np.max(np.abs(np.diff(x))) < 0.05 + assert x[40] == pytest.approx(1.0, abs=1e-6) + + def test_touchdown_history_from_main_output_node_channels(tmp_path): frames = _frames() times = np.linspace(0.0, 10.0, 201) diff --git a/src/CableDyn_RangeOutput.f90 b/src/CableDyn_RangeOutput.f90 index 53059acd..de2b6b96 100644 --- a/src/CableDyn_RangeOutput.f90 +++ b/src/CableDyn_RangeOutput.f90 @@ -16,8 +16,9 @@ MODULE CableDyn_RangeOutput !! the normal contact law activates). The grounded end is the end grounded in the !! initial state; walking from it, the TDP lies between the last grounded node and the !! next one, where the parabola through the last grounded node and the next two (clearance - !! against chord arc) crosses that height, the crossing nearest the suspended node; it - !! reaches a node exactly when the node does, so the TDP moves continuously as nodes ground + !! against chord arc), its curvature limited so that it rises monotonically over the + !! element, crosses that height; it reaches a node exactly when the node does, from either + !! side, so the TDP moves continuously as nodes ground !! and lift off (linear clearance when there is no such crossing). The TDP sits on that !! height. Arc length is the deformed chord !! length from End A, layback the horizontal distance from the TDP to the suspended end, @@ -365,11 +366,15 @@ END FUNCTION node_of PURE SUBROUTINE quadratic_fraction(f) !! Quadratic clearance g(x) through the last grounded node (x = 0) and the first two - !! suspended nodes (x = l1, l1 + l2), g measured from the contact-onset height; the - !! touchdown is its crossing nearest the suspended node inside the element [0, l1]. The - !! crossing reaches a node exactly when that node reaches the onset height, so the - !! location is continuous as nodes ground and lift off. Keeps f (linear) when the line - !! has fewer than two suspended nodes or the quadratic has no crossing in the element. + !! suspended nodes (x = l1, l1 + l2), g measured from the contact-onset height, with its + !! curvature limited to |qa| <= d1/l1 so that it rises monotonically over the element + !! [0, l1]; the touchdown is its crossing inside the element, which is then unique. An + !! unlimited parabola can dip below the onset height inside the element when the line + !! rises sharply beyond it, and its crossing then lies near the suspended node: the + !! location jumped by almost an element when the next node grounded. The monotone + !! crossing reaches a node exactly when that node reaches the onset height, from either + !! side, so the location is continuous as nodes ground and lift off. Keeps f (linear) when + !! the line has fewer than two suspended nodes or the quadratic has no crossing. REAL(wp), INTENT(INOUT) :: f REAL(wp) :: g0, g1, g2, l1, l2, d1, qa, qb, disc, x1, x2, xc IF (last + 2 > nn) RETURN @@ -381,6 +386,8 @@ PURE SUBROUTINE quadratic_fraction(f) IF (.NOT. (l1 > CD_ZERO) .OR. .NOT. (l2 > CD_ZERO)) RETURN d1 = (g1 - g0)/l1 qa = ((g2 - g1)/l2 - d1)/(l1 + l2) + ! monotone over the element: q'(0) = d1 - qa l1 >= 0 and q'(l1) = d1 + qa l1 >= 0 + IF (d1 > CD_ZERO) qa = MAX(-d1/l1, MIN(d1/l1, qa)) qb = d1 - qa*l1 ! qa x^2 + qb x + g0 = 0 IF (ABS(qa)*l1 <= 1.0e-12_wp*MAX(ABS(qb), TINY(CD_ONE))) THEN diff --git a/tests/test_range_tdp_locator.f90 b/tests/test_range_tdp_locator.f90 index f1d2b678..ad4914f9 100644 --- a/tests/test_range_tdp_locator.f90 +++ b/tests/test_range_tdp_locator.f90 @@ -3,9 +3,10 @@ ! Copyright (c) 2026 Jae Hoon Seo, SMI Lab, Inha University PROGRAM test_range_tdp_locator !! Unit tests of the touchdown locator of CableDyn_RangeOutput on prescribed node - !! configurations: the quadratic crossing inside the element on convex and concave stencils, a - !! node reaching the onset height maps to that node, and the grounded length TDPGrd is - !! continuous with the touchdown point. + !! configurations: the monotone quadratic crossing inside the element on convex and concave + !! stencils, a node reaching the onset height maps to that node from either side (the + !! location is continuous as a node grounds), and the grounded length TDPGrd is continuous + !! with the touchdown point. USE CableDyn_Precision, ONLY: wp USE CableDyn_RangeOutput, ONLY: CD_RangeLine, CD_Range_TDP_Evaluate, CD_TDP_S, CD_TDP_X, CD_TDP_GRD, CD_TDP_N USE CableDyn_SeabedContact, ONLY: CD_SEABED_CONTACT_BLEND @@ -17,6 +18,7 @@ PROGRAM test_range_tdp_locator CALL case_convex_stencil() CALL case_concave_stencil() CALL case_node_at_onset() + CALL case_grounding_on_a_steep_stencil() CALL case_grounded_length_continuity() CALL case_end_b() @@ -58,27 +60,43 @@ SUBROUTINE locate(clearance, grounded_end, tdp) END SUBROUTINE locate SUBROUTINE case_convex_stencil() - !! Clearances from the onset height -0.005, 0.01, 1.0 on unit spacing: node 2 is barely off the - !! floor and the line rises sharply beyond it, so the line leaves the floor just before node 2. - !! The parabola crosses once inside the element, at 0.97 chord; the chord crossing (a third of - !! the way) would put the TDP a node behind. + !! Clearances from the onset height -0.005, 0.01, 1.0 on unit spacing: the line rises sharply + !! beyond node 2. The unlimited parabola dips below the onset height inside the element; + !! limited to rise monotonically (zero slope at the grounded node) it crosses once, at + !! sqrt(0.005/0.015) of the chord, beyond the chord crossing (a third of the way). REAL(wp) :: tdp(CD_TDP_N), c(4) c = CD_SEABED_CONTACT_BLEND + [-0.005_wp, 0.01_wp, 1.0_wp, 2.0_wp] CALL locate(c, 1, tdp) - IF (.NOT. (tdp(CD_TDP_X) > 0.95_wp .AND. tdp(CD_TDP_X) < 1.0_wp)) THEN - WRITE (*, '(A,ES23.15)') 'MISMATCH [convex: TDP just before the barely lifted node]: x = ', tdp(CD_TDP_X) - nfail = nfail + 1 - END IF + CALL expect(tdp(CD_TDP_X), SQRT(0.005_wp/0.015_wp), 1.0e-9_wp, 'convex: the monotone crossing') CALL expect(tdp(CD_TDP_GRD), tdp(CD_TDP_S), 1.0e-12_wp, 'convex: grounded length equals the arc from End A') - ! the same with the first node exactly at the onset height: the crossing stays inside the element + ! the same with the first node exactly at the onset height: the TDP is that node c(1) = CD_SEABED_CONTACT_BLEND CALL locate(c, 1, tdp) - IF (.NOT. (tdp(CD_TDP_X) > 0.95_wp .AND. tdp(CD_TDP_X) < 1.0_wp)) THEN - WRITE (*, '(A,ES23.15)') 'MISMATCH [convex, node at onset: TDP inside the element]: x = ', tdp(CD_TDP_X) - nfail = nfail + 1 - END IF + CALL expect(tdp(CD_TDP_X), 0.0_wp, 1.0e-9_wp, 'convex, node at onset: TDP at the grounded node') END SUBROUTINE case_convex_stencil + SUBROUTINE case_grounding_on_a_steep_stencil() + !! Node 2 grounds on a stencil that rises sharply beyond node 3 (clearances -0.001, h, 0.01, 1, + !! 2): the TDP reaches node 2 as h falls to zero from above and stays there as h turns + !! negative, with no jump while the grounded stencil changes (on the grounded side the + !! crossing grows as sqrt(-h): continuous but steep, hence the 1e-6 steps). + REAL(wp) :: tdp(CD_TDP_N), c(5), h, prev + INTEGER :: k + prev = -1.0_wp + DO k = -40, 40 + h = 1.0e-6_wp*REAL(-k, wp) + c = CD_SEABED_CONTACT_BLEND + [-1.0e-3_wp, h, 0.01_wp, 1.0_wp, 2.0_wp] + CALL locate(c, 1, tdp) + IF (prev >= 0.0_wp .AND. ABS(tdp(CD_TDP_X) - prev) > 0.05_wp) THEN + WRITE (*, '(A,ES12.4,A,ES23.15,A,ES23.15)') 'MISMATCH [steep stencil: TDP jumps] h = ', h, & + ': ', prev, ' -> ', tdp(CD_TDP_X) + nfail = nfail + 1 + END IF + IF (k == 0) CALL expect(tdp(CD_TDP_X), 1.0_wp, 1.0e-9_wp, 'steep stencil: node 2 at the onset height') + prev = tdp(CD_TDP_X) + END DO + END SUBROUTINE case_grounding_on_a_steep_stencil + SUBROUTINE case_concave_stencil() !! A stencil with the line rising more gently: g = -0.5, 0.5, 1.0, 1.5. REAL(wp) :: tdp(CD_TDP_N), c(4) From d3ddfebd5b598fc593231ff17d9c8af0ca703f57 Mon Sep 17 00:00:00 2001 From: Jae Hoon Seo Date: Wed, 21 Oct 2026 06:07:11 +0900 Subject: [PATCH 31/31] chore(release): record the 0.2.0 assets of the final tree The release review found a third defect, the touchdown jump on steep stencils, fixed on this branch, so the assets were rebuilt from the final tree (release workflow run 39484701335). The record gives their hashes, the Python suite of the final head (2105 passed, 99.01% branch coverage), and the clean-machine check of these assets: 26 checks and all 51 shipped examples pass. Signed-off-by: Jae Hoon Seo --- validation/RELEASE_0_2_0.md | 24 +++++++++++++----------- 1 file changed, 13 insertions(+), 11 deletions(-) diff --git a/validation/RELEASE_0_2_0.md b/validation/RELEASE_0_2_0.md index 372fc814..6eb25c64 100644 --- a/validation/RELEASE_0_2_0.md +++ b/validation/RELEASE_0_2_0.md @@ -12,7 +12,7 @@ LAPACK are those of [v0.1.1](RELEASE_0_1_1.md). | Item | Value | | --- | --- | | CableDyn | `0.2.0` (2026-10-20), C ABI 1, minor extension 2 | -| Source | The `v0.2.0` tag. The assets and the Windows gates were produced from this tree before this record was completed; every other file is identical. The GNU gates below ran on the release-preparation tree (#30). The later changes (#31, the seabed recompute check; and, on the release branch, the crease bound of `CD_Bathymetry_Max_Floor` and the per-line friction options of the Python `DeckModel`) passed the CI matrix (Linux and Windows, Release and Debug; Python on three platforms with coverage and strict type checks) and the GNU Release and Python suites | +| Source | The `v0.2.0` tag. The assets and the Windows gates were produced from this tree before this record was completed; every other file is identical. The GNU gates below ran on the release-preparation tree (#30). The later changes (#31, the seabed recompute check; and, on the release branch, the crease bound of `CD_Bathymetry_Max_Floor`, the per-line friction options of the Python `DeckModel`, and the monotone touchdown parabola) passed the CI matrix (Linux and Windows, Release and Debug; Python on three platforms with coverage and strict type checks) and the GNU Release and Python suites | | OpenFAST base | `2895884d2be01862173c88d70f86b358d2f1a50a`; the 20 patches of [`integration/openfast/patches`](../integration/openfast/patches) applied to a clean checkout by `prepare_openfast_source.ps1` | | OpenFAST r-test | `dd5feaaaa500ba7283140107806300d551cff0a7` | | Reference LAPACK/BLAS | 3.12.1, release-tag archive with SHA-256 `2ca6407a001a474d4d4d35f3a61550156050c48016d949f0da0529c0aa052422` | @@ -36,7 +36,7 @@ LAPACK are those of [v0.1.1](RELEASE_0_1_1.md). | GNU Debug build (`-fcheck=all`) | 0 compiler warnings in the library, driver and module | | GNU Debug CTest | 293 of 293 passed | | GNU Debug CTest with `-finit-real=snan -finit-integer=-2147483647 -fcheck=all` | 293 of 293 passed | -| Python package tests, native library and driver included | 2104 passed; 99.02% branch coverage (minimum 95%), on the release head | +| Python package tests, native library and driver included | 2105 passed; 99.01% branch coverage (minimum 95%), on the release head | | Ruff, Ruff format and mypy (strict) | passed | | Sphinx documentation, HTML and EPUB (`-W -n`) | built with no warnings | | pre-commit, all files | passed | @@ -53,7 +53,7 @@ exact real comparisons in bit-identity assertions. ## Windows executable gates Every gate of `build_static_windows.ps1` passed in the release workflow (`release-windows-static.yml`, -run 39457117645). The smoke runs used a system-only `PATH`. +run 39484701335). The smoke runs used a system-only `PATH`. | Gate | Result | | --- | --- | @@ -80,16 +80,18 @@ passed. Every shipped example deck (51) also runs to completion with the release The first build of the assets stopped `examples/buoy_clamped_cable.dat` in this check: the setup check of the seabed recompute inputs compared two products that the optimised Intel build rounds differently. The fix (#31) accepts agreement within 8 units in the last place. The -review of the release found two more defects, fixed on the release branch: the seabed bound of the -explicit object sub-step estimate left out the crease rounding of neighbouring cells, and the -Python `DeckModel` did not rename or remove the per-line friction options with their line. The -assets above were built from the final tree. +review of the release found three more defects, fixed on the release branch: the seabed bound +of the explicit object sub-step estimate left out the crease rounding of neighbouring cells, the +Python `DeckModel` did not rename or remove the per-line friction options with their line, and the +touchdown point could jump by almost an element as a node grounded on a steep stencil (its +parabola is now limited to rise monotonically over the element). The assets above were built from +the final tree. ## Assets | File | SHA-256 | | --- | --- | -| `CableDyn_driver.exe` | `f68a7279723abfa400a3e49ce90490eaa41fd84409273868887f51fd835a45c1` | -| `openfast.exe` | `380ce2249fe4f52511281160e9a6d48141d380d10abb3a87764a0d3777036e73` | -| `cabledyn-0.2.0-py3-none-any.whl` | `f1e754acd6a53b019ef805aace11d0a7d1606ef6703cf92fe6c03592b919060c` | -| `cabledyn-0.2.0.tar.gz` | `5b292b1043dc1e8d9503a3cae1fcf1ff5b3b4e70b02485eb40b3444c5844afaa` | +| `CableDyn_driver.exe` | `3eb0727e9a329f155de8aad2dd68ba280985b35a2c9482236930ee007ddbcc89` | +| `openfast.exe` | `1ba18e46d4b00e7c5340534add6d6c179b8e3e2dd9645b553fcc9035dece77f9` | +| `cabledyn-0.2.0-py3-none-any.whl` | `8bc843121685e6a9e0af877765f6d1d0a9e7de47c6ab0c5361a2f644eeb0ac73` | +| `cabledyn-0.2.0.tar.gz` | `b1034bcd4fff0e690f9635121807f0f41693c16be0de1caf9af4426af127dc7b` |