diff --git a/CHANGELOG.md b/CHANGELOG.md index 4308e25..8f2d000 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -95,6 +95,11 @@ All notable changes to CableDyn are recorded in this file. The format follows the Delta Flume vertical riser of Chaplin et al. (2005), modes 1-7 at five top tensions, from CableDyn's modal analysis with no fitted parameter: 1.87 % high on average over 34 of the 35 measured values (largest 4.88 %), the 35th, an outlier in the measurements, reported apart. +- Validation case L3-W (`validation/experiments/wang_scr`): cross-flow VIV of the SJTU truncated + steel catenary riser of Wang et al. (2014) in a 0.2 m/s uniform current, with the coefficient set + Thorsen et al. (2017) use for it: dominant strain frequency 0.992 Hz against the measured + 1.00 Hz, largest r.m.s. strain 7.3 % above the measured largest, station mean 3.6 % above; + converged in mesh and time step to 0.2 %. ## [0.4.2] - 2026-11-09 diff --git a/VALIDATION.md b/VALIDATION.md index 00255e7..8ebb5fc 100644 --- a/VALIDATION.md +++ b/VALIDATION.md @@ -82,6 +82,7 @@ article's methods, are compared in | **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-C** | Chaplin Delta Flume riser, still-water natural frequencies | measured modes 1–7 at five tensions | mean error +1.87%, mean absolute 2.28%, largest 4.88% (34 of 35; one outlier reported) | full published table, no fitted parameter | Pass | +| **L3-W** | SJTU steel catenary riser in 0.2 m/s current, cross-flow VIV | measured r.m.s. strain (25 stations) and dominant frequency | frequency 0.992 vs 1.00 Hz; max r.m.s. strain +7.3%, station mean +3.6% | published coefficient set, no fitted parameter | 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 | @@ -338,6 +339,18 @@ scripts, results, and source provenance are in separately. 128 elements and ten times the unpublished axial stiffness change no frequency by more than 3e-6 and 1.2e-4. +- **L3-W SJTU steel catenary riser, cross-flow VIV in uniform current** + ([Wang et al., 2014](https://cabledyn.readthedocs.io/en/latest/references.html#ref-wang2014); + [Thorsen et al., 2017](https://cabledyn.readthedocs.io/en/latest/references.html#ref-thorsen2017)): + the 23.71 m truncated catenary in a 0.2 m/s in-plane current, run with Thorsen et al.'s coefficient + set for this case (C_v 0.7, f̂0 0.18 ± 0.08, C_D 1.2, C_M 2). The dominant cross-flow strain + frequency 8.25 m from the lower end is 0.992 Hz against the measured 1.00 Hz (their model 1.02 Hz; + [Davies et al., 2026](https://cabledyn.readthedocs.io/en/latest/references.html#ref-davies2026), + 1.04 Hz). The largest r.m.s. strain is 7.3% above the measured largest (theirs 0.4% below) and the + mean over the 25 stations 3.6% above. The response has one r.m.s. peak more along the span than + the test, as theirs, so the station-by-station ratio scatters. 400 elements and half the time step + change the largest r.m.s. strain by 0.2% and 0.1%. + ## L4 coupled OpenFAST - **L4-1 synthetic** (`l4_platform_mooring`): 6-DOF platform moored by three taut diff --git a/doc/references.rst b/doc/references.rst index 5d1f666..fd0781f 100644 --- a/doc/references.rst +++ b/doc/references.rst @@ -89,6 +89,12 @@ Hydrodynamics and ocean environment vortex-induced vibrations in stationary and oscillating flows. *Journal of Fluids and Structures* **61**, 1–19. https://doi.org/10.1016/j.jfluidstructs.2015.11.006 +.. _ref-thorsen2017: + +- **Thorsen, M. J., Sævik, S. & Larsen, C. M. (2017).** Non-linear time domain analysis of + cross-flow vortex-induced vibrations. *Marine Structures* **51**, 134–151. + https://doi.org/10.1016/j.marstruc.2016.10.007 + .. _ref-ulveseter2018: - **Ulveseter, J. V., Thorsen, M. J., Sævik, S. & Larsen, C. M. (2018).** Time domain @@ -247,6 +253,19 @@ Verification and validation references experiment of a mooring cable. *Journal of Marine Science and Engineering* **4**\ (1), 5. https://doi.org/10.3390/jmse4010005 +.. _ref-wang2014: + +- **Wang, J., Fu, S., Baarholm, R., Wu, J. & Larsen, C. M. (2014).** Fatigue damage of a steel + catenary riser from vortex-induced vibration caused by vessel motions. *Marine Structures* + **39**, 131–156. https://doi.org/10.1016/j.marstruc.2014.07.002 + +.. _ref-davies2026: + +- **Davies, R., Lekkala, M. R., Michaloliakos, A., Wong, W.-Y., Hall, M., Vakakis, A. & Zuo, L. + (2026).** Time-domain vortex induced vibration modeling of reference dynamic power cable for the + Gulf of Maine. *Journal of Fluids and Structures* **146**, 104651. + https://doi.org/10.1016/j.jfluidstructs.2026.104651 + .. _ref-chaplin2005: - **Chaplin, J. R., Bearman, P. W., Huera Huarte, F. J. & Pattenden, R. J. (2005).** Laboratory diff --git a/validation/README.md b/validation/README.md index 46fe90e..2e17086 100644 --- a/validation/README.md +++ b/validation/README.md @@ -16,7 +16,7 @@ redistributed. | [`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, Bergdahl et al. (2016) dynamic-chain and Chaplin et al. (2005) riser natural-frequency comparisons | +| [`experiments/`](experiments/README.md) | Holcombe et al. (2025) static lazy-wave, Bergdahl et al. (2016) dynamic-chain, Chaplin et al. (2005) riser natural-frequency and Wang et al. (2014) catenary-riser VIV comparisons | | [`PERFORMANCE_0_1_0.md`](PERFORMANCE_0_1_0.md) | Wall time of CableDyn 0.1.0, MoorDyn-C and MoorDyn-F at equal accuracy on five mooring, cable, buoy and coupled cases | | [`performance/`](performance/README.md) | Same-host wall-clock records of the L5 cases: the resolved lazy-wave spans, the one-hour VolturnUS-S mooring and the tension-only chain | | [`PAPER_REPRODUCTION.md`](PAPER_REPRODUCTION.md) | Every CableDyn result in the journal article, re-run with the release defaults and in paper mode | diff --git a/validation/experiments/README.md b/validation/experiments/README.md index eca2335..997d8c3 100644 --- a/validation/experiments/README.md +++ b/validation/experiments/README.md @@ -2,7 +2,7 @@ # Experimental comparisons -This directory lets reviewers reproduce CableDyn's comparisons with three published physical +This directory lets reviewers reproduce CableDyn's comparisons with four published physical experiments. Each subdirectory gives the data source, the translation of the published parameters into a CableDyn model, the assessed quantity, the reproduction commands and the committed results. @@ -12,5 +12,6 @@ committed results. | [`holcombe/`](holcombe/README.md) | Holcombe et al. (2025), 1:70 static lazy-wave cable | Finite-EI power cable | | [`bergdahl/`](bergdahl/README.md) | Bergdahl et al. (2016), 33 m dynamically scaled chain | Tension-only mooring chain | | [`chaplin/`](chaplin/README.md) | Chaplin et al. (2005), 13.12 m vertical tension riser, still-water natural frequencies | Finite-EI riser, modal analysis | +| [`wang_scr/`](wang_scr/README.md) | Wang et al. (2014), truncated steel catenary riser in uniform current, cross-flow VIV | Finite-EI riser, synchronisation VIV | -The results are summarised as cases L3-H, L3-B and L3-C in [`VALIDATION.md`](../../VALIDATION.md). +The results are summarised as cases L3-H, L3-B, L3-C and L3-W in [`VALIDATION.md`](../../VALIDATION.md). diff --git a/validation/experiments/wang_scr/README.md b/validation/experiments/wang_scr/README.md new file mode 100644 index 0000000..c420ee2 --- /dev/null +++ b/validation/experiments/wang_scr/README.md @@ -0,0 +1,61 @@ + + +# Steel catenary riser in uniform current: cross-flow VIV + +This directory compares CableDyn's cross-flow VIV with the SJTU model test of a truncated steel +catenary riser in a 0.2 m/s uniform current: Wang et al. (2014), +, as Thorsen et al. (2017), +, use it to verify the time-domain synchronisation +model that CableDyn's cross-flow VIV implements. The model runs with their coefficient set for this +case; nothing is fitted to the measurements. + +## Model and data + +- **Riser (Thorsen et al. 2017, Table 1):** + - length 23.71 m, between universal joints (pinned); + - the top 21.0425 m horizontally and 9 m vertically from the lower end, with a 2.626 m flowline on + the seabed; + - D 0.024 m, 0.69 kg/m (a solid section: no internal water is added), EI 10.5 N m², EA 6.66e5 N. +- **Seabed:** 1 (kN/m)/m in compression (`kBot` = 1000/D), friction 0.2. +- **Current:** 0.2 m/s along the riser plane, from the lower end towards the top. +- **VIV (their set for this case):** C_v 0.7 (their choice for Re ≈ 3000), f̂0 0.18, Δf̂ 0.08, + cross-flow only; C_D 1.2, C_M 2. +- **Measurements:** `measured_rms_strain.csv` holds the 25 measured r.m.s. dynamic cross-flow strains + at the outer surface (Thorsen et al. 2017, Fig. 17), read from the vector figure. The axes are + calibrated on its tick marks; as a check, the simulated maximum of the same figure reads 99.6 % of + the measured one, as their text states. The measured dominant strain frequency 8.25 m from the + lower end is 1.00 Hz (their Fig. 18). +- **Assumed:** the top joint 0.5 m below the surface (not given; the current is uniform). +- **CableDyn:** 200 elements, dt 0.005 s, 150 s, statistics over t > 30 s. The cross-flow curvature + is the section component with no static mean (the in-plane one carries the catenary curvature); + strain = κ D/2. + +## Reproduce + +From the repository root, with `path/to/cabledyn.exe` the release executable or a local build: + +```powershell +python validation/experiments/wang_scr/wang_scr_uniform_current.py ` + path/to/cabledyn.exe validation/experiments/wang_scr/work ` + --summary validation/experiments/wang_scr +``` + +`--segments` and `--dt` change the mesh and the time step. + +## Results + +| | CableDyn | Measured | Thorsen et al. (2017) | Davies et al. (2026) | +| --- | --- | --- | --- | --- | +| Dominant cross-flow strain frequency, 8.25 m from the lower end | **0.992 Hz** (±0.008) | 1.00 Hz | 1.02 Hz | 1.04 Hz | +| Maximum r.m.s. strain / measured maximum | **1.073** | 1 | 0.996 | - | +| Mean ratio at the 25 stations | 1.036 | 1 | - | - | +| r.m.s. peaks along the span | 7 | 6 | 7 | - | + +- **Frequency:** within the 0.008 Hz resolution of the measured value. +- **Strain magnitude:** the largest r.m.s. strain is 7 % above the measured largest, and the mean + over the stations 4 % above. +- **Spatial pattern:** the predicted response has one r.m.s. peak more along the span than the test + (7 against 6), as in Thorsen et al. (2017). So the peaks and troughs fall at different stations, + and the station-by-station ratio scatters (`rms_strain_comparison.csv`, r.m.s. log error 0.34). +- **Convergence:** 400 elements and half the time step change the maximum ratio by 0.2 % and 0.1 % + and leave the frequency unchanged (`provenance.json`). diff --git a/validation/experiments/wang_scr/measured_rms_strain.csv b/validation/experiments/wang_scr/measured_rms_strain.csv new file mode 100644 index 0000000..6e123aa --- /dev/null +++ b/validation/experiments/wang_scr/measured_rms_strain.csv @@ -0,0 +1,26 @@ +s_m,rms_strain +1.044,4.5870e-05 +1.9427,3.5715e-05 +2.8415,3.9650e-05 +3.7493,5.3852e-05 +4.6479,4.5683e-05 +5.5467,2.5858e-05 +6.4454,2.9980e-05 +7.3441,4.7144e-05 +8.2428,5.1266e-05 +9.1416,3.9199e-05 +10.0493,2.9081e-05 +10.9479,4.0136e-05 +11.8468,4.8156e-05 +12.7454,4.5607e-05 +13.6441,3.3653e-05 +14.5428,3.3615e-05 +15.4416,4.0436e-05 +16.3494,4.2572e-05 +17.2481,3.9012e-05 +18.1467,2.5709e-05 +19.0456,2.8369e-05 +19.9442,3.7176e-05 +20.8429,3.3653e-05 +21.7416,2.8107e-05 +22.6495,2.2223e-05 diff --git a/validation/experiments/wang_scr/provenance.json b/validation/experiments/wang_scr/provenance.json new file mode 100644 index 0000000..a719dbb --- /dev/null +++ b/validation/experiments/wang_scr/provenance.json @@ -0,0 +1,19 @@ +{ + "source": "Wang, Fu, Baarholm, Wu & Larsen (2014), Marine Structures 39, 131-156 (the model riser, Table 2); Thorsen, Saevik & Larsen (2017), Marine Structures 51, 134-151 (Table 1, Sec. 5.1, Figs. 17-18)", + "doi": ["10.1016/j.marstruc.2014.07.002", "10.1016/j.marstruc.2016.10.007"], + "data_used": "the model riser properties; the 25 measured r.m.s. dynamic cross-flow strains of Fig. 17 (read from the vector figure, axes calibrated on its tick marks; the simulated maximum of the same figure reads 99.6 % of the measured one, as the text states); the measured dominant frequency 1.00 Hz 8.25 m from the lower end", + "coefficients": "Thorsen et al. (2017) for this case, not tuned: Cv 0.7, f0 0.18, df 0.08 (cross-flow only), CD 1.2, CM 2", + "CableDyn_commit": "1847a0d (dev)", + "validation_date": "2026-11-14", + "executable_name": "cabledyn.exe", + "executable_sha256": "see summary.json", + "compiler": "GNU Fortran 16.2.0", + "build_type": "Release", + "platform": "Windows 11 x86-64", + "segments": 200, + "dt_s": 0.005, + "sensitivity": { + "segments_400": {"max_ratio": 1.0753, "mean_ratio_at_stations": 1.0367, "dominant_frequency_hz": 0.9917}, + "dt_0p0025": {"max_ratio": 1.0742, "mean_ratio_at_stations": 1.0366, "dominant_frequency_hz": 0.9917} + } +} diff --git a/validation/experiments/wang_scr/rms_strain_comparison.csv b/validation/experiments/wang_scr/rms_strain_comparison.csv new file mode 100644 index 0000000..7d03e87 --- /dev/null +++ b/validation/experiments/wang_scr/rms_strain_comparison.csv @@ -0,0 +1,26 @@ +s_m,measured_rms_strain,cabledyn_rms_strain,ratio +1.0440,4.5870e-05,1.8708e-05,0.4079 +1.9427,3.5715e-05,4.0653e-05,1.1383 +2.8415,3.9650e-05,3.2249e-05,0.8134 +3.7493,5.3852e-05,4.7770e-05,0.8871 +4.6479,4.5683e-05,3.2998e-05,0.7223 +5.5467,2.5858e-05,1.8495e-05,0.7153 +6.4454,2.9980e-05,4.1456e-05,1.3828 +7.3441,4.7144e-05,4.9755e-05,1.0554 +8.2428,5.1266e-05,3.4480e-05,0.6726 +9.1416,3.9199e-05,2.6913e-05,0.6866 +10.0493,2.9081e-05,4.7323e-05,1.6273 +10.9479,4.0136e-05,5.3446e-05,1.3316 +11.8468,4.8156e-05,4.1079e-05,0.8531 +12.7454,4.5607e-05,4.0281e-05,0.8832 +13.6441,3.3653e-05,5.5683e-05,1.6546 +14.5428,3.3615e-05,5.4886e-05,1.6328 +15.4416,4.0436e-05,4.0594e-05,1.0039 +16.3494,4.2572e-05,3.8404e-05,0.9021 +17.2481,3.9012e-05,4.6681e-05,1.1966 +18.1467,2.5709e-05,4.3938e-05,1.7090 +19.0456,2.8369e-05,3.0334e-05,1.0693 +19.9442,3.7176e-05,2.5013e-05,0.6728 +20.8429,3.3653e-05,2.9946e-05,0.8899 +21.7416,2.8107e-05,2.9305e-05,1.0426 +22.6495,2.2223e-05,2.1199e-05,0.9539 diff --git a/validation/experiments/wang_scr/summary.json b/validation/experiments/wang_scr/summary.json new file mode 100644 index 0000000..4fd4d16 --- /dev/null +++ b/validation/experiments/wang_scr/summary.json @@ -0,0 +1,17 @@ +{ + "segments": 200, + "dt_s": 0.005, + "analysis_window_s": [ + 30.0, + 150.0 + ], + "frequency_resolution_hz": 0.00833333333332907, + "max_rms_strain": 5.777620876413861e-05, + "measured_max_rms_strain": 5.3852e-05, + "max_ratio": 1.072870251135308, + "mean_ratio_at_stations": 1.0361663237798966, + "rms_log_error_at_stations": 0.3385758147803219, + "dominant_frequency_hz": 0.9916666666661592, + "measured_dominant_frequency_hz": 1.0, + "executable_sha256": "dd80f0b2b0ba5a526b46da7961b8ea7e18ed8c650c42583107b4df6eee3a8a74" +} diff --git a/validation/experiments/wang_scr/wang_scr_uniform_current.py b/validation/experiments/wang_scr/wang_scr_uniform_current.py new file mode 100644 index 0000000..69b982b --- /dev/null +++ b/validation/experiments/wang_scr/wang_scr_uniform_current.py @@ -0,0 +1,207 @@ +#!/usr/bin/env python3 +# SPDX-License-Identifier: Apache-2.0 +# Copyright (c) 2026 Jae Hoon Seo, SMI Lab, Inha University +"""Cross-flow VIV of the SJTU truncated steel catenary riser in a 0.2 m/s uniform current. + +The model test of Wang et al. (2014), as used by Thorsen et al. (2017, Sec. 5.1) to verify the +time-domain synchronisation model that CableDyn's cross-flow VIV implements: writes the deck, runs +it, and compares the r.m.s. of the dynamic cross-flow strain along the riser with the 25 measured +values (Thorsen et al. 2017, Fig. 17) and the dominant strain frequency 8.25 m from the lower end +with the measured 1.00 Hz. + + python wang_scr_uniform_current.py path/to/cabledyn.exe WORKDIR [--segments 200] + [--dt 0.005] [--tmax 150] [--t0 30] [--summary DIR] + +Sources: + J. Wang, S. Fu, R. Baarholm, J. Wu, C.M. Larsen (2014), Fatigue damage of a steel catenary + riser from vortex-induced vibration caused by vessel motions, Marine Structures 39, 131-156, + https://doi.org/10.1016/j.marstruc.2014.07.002 (Table 2: the model riser) + M.J. Thorsen, S. Saevik, C.M. Larsen (2017), Non-linear time domain analysis of cross-flow + vortex-induced vibrations, Marine Structures 51, 134-151, + https://doi.org/10.1016/j.marstruc.2016.10.007 (Table 1, Sec. 5.1, Fig. 17: the measured + r.m.s. strains, read from the vector figure) +""" + +from __future__ import annotations + +import argparse +import csv +import hashlib +import json +import os +import shutil +import subprocess +from pathlib import Path + +import numpy as np + +HERE = Path(__file__).resolve().parent + +# Thorsen et al. (2017) Table 1 / Wang et al. (2014) Table 2: the truncated model riser. The +# outer coating, PPR pipe and copper core are solid: no internal water is added to the 0.69 kg/m. +LENGTH = 23.71 # m +X_TOP = 21.0425 # m, horizontal distance of the top joint from the lower end +H_TOP = 9.0 # m, height of the top joint above the fake seabed +DIAMETER = 0.024 # m +MASS = 0.69 # kg/m +EI = 10.5 # N m^2 +EA = 6.66e5 # N +# Thorsen et al. (2017) Sec. 5.1: seabed springs of 1 (kN/m)/m in compression, friction 0.2; +# their coefficient set for this case: Cv 0.7 (Re about 3000), f0 0.18, df 0.08, CD 1.2, CM 2 +SEABED_K_PER_LENGTH = 1000.0 # N/m per m of riser +FRICTION = 0.2 +CV, F0, DF, CD, CA = 0.7, 0.18, 0.08, 1.2, 1.0 +CURRENT = 0.2 # m/s, uniform, in the riser plane from the lower end towards the top +WATER_DEPTH = ( + 9.5 # m: the top joint 0.5 m below the surface (not given; the current is uniform) +) +MEASURED_FREQUENCY = ( + 1.00 # Hz, 8.25 m from the lower end (Thorsen et al. 2017, Fig. 18) +) +FREQUENCY_STATION = 8.25 # m from the lower end + + +def write_deck(case: Path, segments: int, dt: float, tmax: float) -> Path: + case.mkdir(parents=True, exist_ok=True) + (case / "current_profile.txt").write_text( + f"z ux uy uz\n(m) (m/s) (m/s) (m/s)\n{-WATER_DEPTH:.2f} {CURRENT} 0 0\n0.0 {CURRENT} 0 0\n", + encoding="utf-8", + ) + outs = "".join(f"CurvX1N{j}\nCurvY1N{j}\n" for j in range(1, segments + 2)) + text = f"""--------------------- CableDyn Input File --------------------------------- +Wang et al. (2014) truncated SCR, 0.2 m/s uniform current (Thorsen et al. 2017, case 1) +----------------------- LINE TYPES ------------------------------------------ +TypeName Diam Mass EA BA EI Cd_n Cd_t Ca_n Ca_t Cl dF cF +(-) (m) (kg/m) (N) (N-s) (N-m^2) (-) (-) (-) (-) (-) (-) (-) +scr {DIAMETER} {MASS} {EA:.6e} 0.0 {EI} {CD} 0.0 {CA} 0.0 {CV} {DF} {F0} +----------------------- POINTS ---------------------------------------------- +ID Attachment X Y Z M V CdA CA +(-) (-) (m) (m) (m) (kg) (m^3) (m^2) (-) +1 Coupled {X_TOP} 0.0 {-(WATER_DEPTH - H_TOP):.4f} 0 0 0 0 +2 Fixed 0.0 0.0 {-WATER_DEPTH:.4f} 0 0 0 0 +----------------------- LINES ----------------------------------------------- +ID LineType AttachA AttachB UnstrLen NumSegs Outputs +(-) (-) (-) (-) (m) (-) (-) +1 scr 1 2 {LENGTH} {segments} - +---------------------- OPTIONS ---------------------------------------------- +1025.0 rhoW +9.80665 g +{WATER_DEPTH} WtrDpth +{SEABED_K_PER_LENGTH / DIAMETER:.6e} kBot +{FRICTION} frictionMu +{dt:.6f} dtM +{round(tmax / dt) * dt:.6f} TMax +1 Currents +---------------------- OUTPUTS ----------------------------------------------- +{outs}END +------------------------- need this line -------------------------------------- +""" + deck = case / "wang_scr.dat" + deck.write_text(text, encoding="utf-8") + return deck + + +def cross_flow_strain(out: Path, t0: float): + """Arc length from the lower end, r.m.s. dynamic cross-flow strain, the strain histories. + + The cross-flow (out-of-plane) curvature is the section component with no static mean (the + in-plane one carries the catenary curvature); the strain is kappa D/2 at the outer surface, + as Fig. 17 reports it. + """ + lines = out.read_text(encoding="utf-8").splitlines() + head = lines[1].split() + a = np.loadtxt(lines[3:]) + t = a[:, 0] + keep = t > t0 + nodes = sorted({int(c[7:]) for c in head if c.startswith("CurvX1N")}) + cx = np.array([a[keep, head.index(f"CurvX1N{j}")] for j in nodes]) + cy = np.array([a[keep, head.index(f"CurvY1N{j}")] for j in nodes]) + cf = cx if np.abs(cx.mean(axis=1)).mean() < np.abs(cy.mean(axis=1)).mean() else cy + strain = (cf - cf.mean(axis=1, keepdims=True)) * DIAMETER / 2.0 + s = LENGTH - (np.array(nodes) - 1) * LENGTH / (len(nodes) - 1) + order = np.argsort(s) + return ( + s[order], + np.sqrt((strain[order] ** 2).mean(axis=1)), + strain[order], + t[keep][1] - t[keep][0], + ) + + +def main() -> None: + ap = argparse.ArgumentParser(description=__doc__.split("\n\n")[0]) + ap.add_argument("exe") + ap.add_argument("workdir") + ap.add_argument("--segments", type=int, default=200) + ap.add_argument("--dt", type=float, default=0.005) + ap.add_argument("--tmax", type=float, default=150.0) + ap.add_argument("--t0", type=float, default=30.0) + ap.add_argument( + "--summary", + default=None, + help="directory for the comparison CSV and summary JSON", + ) + a = ap.parse_args() + # the run starts in the case folder: resolve the executable against the invocation directory + # (or PATH, for a bare name) first + found = a.exe if Path(a.exe).is_file() else shutil.which(a.exe) + if found is None: + raise SystemExit(f"CableDyn executable not found: {a.exe}") + exe = Path(found).resolve() + case = Path(a.workdir) / f"wang_scr_n{a.segments}_dt{a.dt:g}" + deck = write_deck(case, a.segments, a.dt, a.tmax) + env = dict(os.environ, OMP_NUM_THREADS="1") + proc = subprocess.run( + [str(exe), deck.name, "out"], + cwd=case, + capture_output=True, + text=True, + env=env, + check=False, + ) + if proc.returncode != 0: + raise SystemExit(f"CableDyn failed ({proc.returncode}):\n{proc.stderr[-2000:]}") + s, rms, strain, dt = cross_flow_strain(case / "out.out", a.t0) + with open(HERE / "measured_rms_strain.csv", encoding="utf-8") as fh: + measured = [ + (float(r["s_m"]), float(r["rms_strain"])) for r in csv.DictReader(fh) + ] + sm = np.array([m[0] for m in measured]) + em = np.array([m[1] for m in measured]) + at = np.interp(sm, s, rms) + j = int(np.argmin(np.abs(s - FREQUENCY_STATION))) + spec = np.abs(np.fft.rfft(strain[j] * np.hanning(strain.shape[1]))) + freq = np.fft.rfftfreq(strain.shape[1], dt) + f_dom = float(freq[1 + int(np.argmax(spec[1:]))]) + summary = { + "segments": a.segments, + "dt_s": a.dt, + "analysis_window_s": [a.t0, a.tmax], + "frequency_resolution_hz": float(freq[1]), + "max_rms_strain": float(rms.max()), + "measured_max_rms_strain": float(em.max()), + "max_ratio": float(rms.max() / em.max()), + "mean_ratio_at_stations": float(np.mean(at / em)), + "rms_log_error_at_stations": float(np.sqrt(np.mean(np.log(at / em) ** 2))), + "dominant_frequency_hz": f_dom, + "measured_dominant_frequency_hz": MEASURED_FREQUENCY, + "executable_sha256": hashlib.sha256(exe.read_bytes()).hexdigest(), + } + print(json.dumps(summary, indent=2)) + if a.summary: + out = Path(a.summary) + out.mkdir(parents=True, exist_ok=True) + with open( + out / "rms_strain_comparison.csv", "w", newline="", encoding="utf-8" + ) as fh: + w = csv.writer(fh, lineterminator="\n") + w.writerow(["s_m", "measured_rms_strain", "cabledyn_rms_strain", "ratio"]) + for x, m, c in zip(sm, em, at, strict=True): + w.writerow([f"{x:.4f}", f"{m:.4e}", f"{c:.4e}", f"{c / m:.4f}"]) + (out / "summary.json").write_text( + json.dumps(summary, indent=2) + "\n", encoding="utf-8", newline="\n" + ) + + +if __name__ == "__main__": + main()