Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
45 changes: 45 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -463,6 +463,51 @@ All notable changes to CableXSec are recorded in this file. The format follows
one end is restrained, and `section_channels` lists `Twist`/`Torq` for a line restrained at
either end. `tests/data/cabledyn/lw24g.*` is a CableDyn 0.4.2 run of a deck with these
tokens.
- CableDyn reader, remaining differences from CableDyn's deck reader:
- `EQUIVALENT BUOYANCY` (also `EQUIVALENT SECTIONS`, `BUOYANCY SECTIONS`) was ignored, so a
line type showed the `Diam` and `MassDenInAir` of its LINE TYPES row, not the values CableDyn
ran with. As in CableDyn, a row now replaces the diameter and sets the mass to
`rhoW π D²/4 + w/g` (deck `rhoW` and `g`); `line_types_diameter_m`, `line_types_mass_kg_m`
and `equivalent_submerged_weight_N_m` keep the row's values. CableDyn 0.4.2 gives
byte-identical output for the `lw24` deck with the row `buoy 0.30 -100.0` and for the deck
with `buoy` written with this diameter and mass. Its checks are mirrored (three columns, a
known type, one row per type, `D > 0`, a non-negative mass).
- Records are cut and split as CableDyn cuts and splits them: `--` starts a comment at the
start of a record or after a separator (a LINES row ending in `-- comment` was refused for
its column count), a record holding `---` is a section header named by its other
characters, a byte-order mark is dropped, a section header met again continues the section
(it was refused as a duplicate), and a token opening with a quote runs past its closing
quote to the next separator. `#` and `!` still cut a record anywhere, inside quotes too, as
CableDyn does (its `doc/options.rst` says so for file paths). OUTPUTS rows split on spaces,
tabs and commas with the quotes dropped, and only an unquoted `END` closes the list (CableDyn
reads a quoted one as a channel name).
- LINE TYPES rows with a negative `Cd_n`, `Cd_t`, `Ca_n` or `Ca_t`, or a 14-column row whose
`GAs`, `GJ`, `Irt` and `Irn` are neither all zero nor all positive, are refused, as by
CableDyn.
- A line restrained in torsion at one end only is solved in torsion by CableDyn only when
every section gives `GJ`, End B is `Fixed`, a dynamic run is force-blended and a restrained
End A is on a `Fixed` rod's end or a Rigid6 body if on either; otherwise it runs as without
the torsion columns. `CableDynLine.torsion_solved` and `torsion_note` follow these rules (the
deck's BODIES and RODS rows are read for them), `section_channels` lists `Twist`/`Torq` only
on a solved line (CableDyn refuses them on any other), and `checks["torsion"]` records the
result. A solved line restrained at one end without torque–tension coupling twists in the
dynamics (torsional waves of its polar inertia, the roll of the restrained end's vessel or
body), so a dynamic run of it is now refused without its `Twist` channels, where it was
read twist-free: `tests/data/cabledyn/lw24k.*`, the `lw24g` deck with `K = 0` run by
CableDyn 0.4.2, twists by up to −1.7e-3° in 1 s (0.18° in a 30 s run). Its statics stay
twist-free and are read without them.
- The anchor-first swap of a line from a `Fixed` NodeA to a `Free` or `Connect` NodeB applies
only when NodeA is not above NodeB, as in CableDyn; a weight hung from an overhead point
keeps its written order. A line end on a rod fixed to a body is a point of that body, and a
zero-length rod is the point it collapses to.
- `run_sea_state_batch` compares the deck's `GJ` and torque–tension coupling `K` with the
section's lay torsional stiffness `K_tt` and coupling `K_et` (on a 14-column LINE TYPES row;
the check compared `EA` and `EI` only). `GJ` must lie within `torsion_rtol` (new option,
default 25 %) of `K_tt`, and the coupling ratio `K/sqrt(EA GJ)` within `torsion_rtol` of
`K_et/sqrt(EA_fixed K_tt)`. A mismatch stops the batch, as one of `EA` or `EI` does, unless
`allow_property_mismatch=True`, and the manifest records both values and the ratios. The
tolerance is wider than `property_rtol` because `K_tt` leaves out the components' own torsion
and the radial relaxation of the layers.
- `read_cabledyn_sections` closes every output file it reads. The per-line `.p.out` and
`.t.out` readers were left open after a read (and after a failed one) until garbage
collection, which raised `ResourceWarning`. The files of one run must now also end on the same
Expand Down
72 changes: 56 additions & 16 deletions doc/global_local_guide.md
Original file line number Diff line number Diff line change
Expand Up @@ -80,10 +80,31 @@ changed a channel, the item says so.
resolves them (`bending_damping_Nm2s`, `mass_damping_1_s`,
`torque_tension_coupling_Nm`, `torsional_damping`), and they leave the
reconstructed histories unchanged, since these come from CableDyn's
solution. A line solved in torsion whose type couples torque and tension
twists as it stretches, so the reader needs its `Twist` channels even when
only one end is restrained. `TorsStiffness` `Free`, `Zero` or `0` leaves an
end free in torsion.
solution. `TorsStiffness` `Free`, `Zero` or `0` leaves an end free in
torsion. `CableDynLine.torsion_solved` tells whether CableDyn solves a
line's torsion: restrained at both ends, or at one end when every section
gives `GJ`, End B is `Fixed`, a dynamic run is force-blended and a
restrained End A on a rod or body is on a `Fixed` rod or a Rigid6 body
(CableDyn's rules; otherwise `torsion_note` gives the reason and the line
runs as without the torsion columns). A LINE TYPES row with a negative drag
or added-mass coefficient, or a 14-column row whose `GAs`, `GJ`, `Irt` and
`Irn` are neither all zero nor all positive, is refused, as by CableDyn.
- **Equivalent buoyancy.** An `EQUIVALENT BUOYANCY` row
(`LineType Diam SubmergedWeight`) makes CableDyn run the type with the
row's diameter `D` and the dry mass `rhoW π D²/4 + w/g` of its submerged
weight `w` [N/m]. The line type's `diameter_m` and `mass_kg_m` are these
values; `line_types_diameter_m` and `line_types_mass_kg_m` keep the LINE
TYPES row, and `equivalent_submerged_weight_N_m` the row's `w`. The deck's
`rhoW` and `g` (or CableDyn's defaults) resolve it; in a coupled run whose
host sets other values, CableDyn uses the host's.
- **Records.** As in CableDyn, `#` and `!` start a comment anywhere in a
record, inside a quoted token too (a quoted file path cannot hold them),
and `--` starts one at the start of a record or after a space or tab,
unless the record holds a `---` rule. A record holding `---` is a section
header, named by its other characters; a section met again continues. A
token that opens with a quote runs to its closing quote, spaces included,
and on to the next separator. OUTPUTS names are separated by spaces, tabs
or commas, with the quotes dropped; an unquoted `END` closes the list.

## 2. Section history

Expand Down Expand Up @@ -124,13 +145,24 @@ time; this is the material frame of a torque-free isotropic rod.
`frame="section"` transports the section's own axes in time and needs only
the channels near the section. Where `Twist` channels bracket a section the
axes are turned right-handed about `t` by the material twist from End A. A
line restrained in torsion at both ends without these channels is rejected; a
line restrained at one end only is read with its `Twist` channels when they
are written; restrained at End B only, its End A turns freely with the line's
twist, which the reader, whose axes start at End A, does not represent. The
line restrained in torsion at both ends without these channels is rejected.
So is a dynamic run of a line restrained at one end whose torsion CableDyn
solves: its statics are twist-free (a free end carries no torque), but in the
dynamics its polar inertia `Irn` carries torsional waves and a roll of the
restrained end's vessel or body twists it (CableDyn `doc/theory.rst`, a free
end). The CableDyn 0.4.2 run `tests/data/cabledyn/lw24k`, a lazy wave clamped
and restrained at End A on a vessel, free in torsion at End B and without
torque–tension coupling, twists by up to −1.7e-3° at the sag bend in 1 s and
0.18° in a 30 s run. With coupling (`GJ|K`) the stretch twists the line in
the statics too, so its channels are needed in any run. A line restrained at
one end whose torsion CableDyn does not solve runs as one without the torsion
columns and is read twist-free; `checks["torsion"]` records which case was
read. Restrained at End B only, a line's End A turns freely with its twist,
which the reader, whose axes start at End A, does not represent. The
hang-off's rotation about its own
tangent (vessel yaw at a vertical hang-off) is not visible in the geometry and
is not represented.
tangent (vessel yaw at a vertical hang-off, the roll of a restrained End A)
is not visible in the geometry and is not represented: the `Twist` channels
start at 0 at End A.

`rotation_curvature_x/y` are the components of `κ` on (`e1`, `e2`): a lazy
wave in the `x–z` plane bends about `e2` (sag bend `κ·e2 < 0`, hog bend
Expand Down Expand Up @@ -206,9 +238,9 @@ nodes cannot be placed: the positions are read at the deck nodes,
**Deck outputs.** `section_channels(deck, sections)` lists the `OUTPUTS`
channels the tangent source needs for the section frame: `Dec`/`Azi` on the
window, `Ten`, `Curv` and `p{x,y,z}` at the bracketing nodes, and
`Twist`/`Torq` on a line restrained at both ends (request them too on a line
restrained at one end). The arc frame also needs the line's `p`
flag. Adding `t` gives the element tensions.
`Twist`/`Torq` on a line CableDyn solves in torsion (`torsion_solved`;
CableDyn refuses them on any other line). The arc frame also needs the
line's `p` flag. Adding `t` gives the element tensions.

### 2.1 CableDyn 0.4.0 signed curvature components

Expand Down Expand Up @@ -303,9 +335,17 @@ result.sections["sag"].long_term.annual_damage, result.sections["sag"].life_year
probability among its seeds).
- Before reading, the deck `EA` at each section is compared with the
section's `EA_fixed` and the deck `EI` with the section's full-slip to
no-slip range (`property_rtol`, default 5%); a mismatch stops the batch
unless `allow_property_mismatch=True` is declared, and the comparison is
written to the manifest either way.
no-slip range (`property_rtol`, default 5%). On a 14-column LINE TYPES row
the deck `GJ` is compared with the section's lay torsional stiffness
`K_tt` and its torque–tension coupling `K` with `K_et`, as the coupling
ratio `c = K/sqrt(EA GJ)` against `K_et/sqrt(EA_fixed K_tt)` (`|c| < 1`;
the free-twist axial stiffness is `EA (1 − c²)`), both within
`torsion_rtol` (default 25 %). `K_tt` leaves out the components' own
torsion and the radial relaxation of the layers, which move a section's
torsional stiffness by tens of percent either way (benchmark CH-GJ), hence
the wider tolerance; a 10-column row gives no `GJ` and is not compared. A
mismatch stops the batch unless `allow_property_mismatch=True` is
declared, and the comparison is written to the manifest either way.
- Workers: `workers` processes (at most `MAX_WORKERS = 8`), one numerical
thread each, spawned; results do not depend on the worker count.
- Output folder (must not exist): `manifest.json` (SHA-256 of every CableDyn
Expand Down
83 changes: 77 additions & 6 deletions src/cablexsec/analysis/sea_state_batch.py
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,7 @@
from cablexsec.cables.schema import CableData
from cablexsec.exceptions import CableInputError, CableSchemaError
from cablexsec.io.cabledyn import (
CableDynLineType,
CableDynRead,
CableDynSectionHistory,
CurvatureSource,
Expand Down Expand Up @@ -189,6 +190,17 @@ class SeaStateBatchOptions:
model of :func:`cablexsec.compute_fatigue`, with its notice on non-planar
paths (:class:`~cablexsec.provenance.DirectionTiedFrictionWarning`); the
manifest and the assessment digests record the model it resolves to.

The property check compares the deck's ``EA`` with ``EA_fixed`` and its
``EI`` with the full-slip to no-slip range within ``property_rtol``, and,
on a 14-column ``LINE TYPES`` row, its ``GJ`` with the lay torsional
stiffness ``K_tt`` and its torque-tension coupling ``K`` with ``K_et``
within ``torsion_rtol``: ``GJ`` relative to ``K_tt``, ``K`` as the
coupling ratio ``c = K/sqrt(EA GJ)`` (``|c| < 1``; the free-twist axial
stiffness is ``EA (1 - c^2)``), against ``K_et/sqrt(EA_fixed K_tt)``.
``K_tt`` leaves out the components' own torsion and the radial relaxation
of the layers, which move a section's torsional stiffness by tens of
percent either way, hence the wider default.
"""

n_fibres: int = 32
Expand All @@ -209,6 +221,7 @@ class SeaStateBatchOptions:
exposure_years: float = 1.0
design_fatigue_factor: float = 1.0
property_rtol: float = 0.05
torsion_rtol: float = 0.25
allow_property_mismatch: bool = False
workers: int = 1
chunk_rows: int = 4096
Expand All @@ -228,6 +241,8 @@ def __post_init__(self) -> None:
raise CableInputError("external_diameter_m must be positive")
if not math.isfinite(self.property_rtol) or self.property_rtol <= 0:
raise CableInputError("property_rtol must be positive")
if not math.isfinite(self.torsion_rtol) or self.torsion_rtol <= 0:
raise CableInputError("torsion_rtol must be positive")
object.__setattr__(
self, "reference_vector", tuple(float(v) for v in self.reference_vector)
)
Expand Down Expand Up @@ -644,22 +659,78 @@ def _property_check(
"local_EI_range_Nm2": [stiffness.ei_min_Nm2, stiffness.ei_max_Nm2],
"EA_match": ea_ok,
"EI_within_bounds": ei_ok,
**_torsion_check(line_type, stiffness, options.torsion_rtol),
}
)
bad = [r for r in records if not (r["EA_match"] and r["EI_within_bounds"])]
bad = [r for r in records if _mismatches(r)]
if bad and not options.allow_property_mismatch:
first = bad[0]
raise CableInputError(
"the global line properties do not describe the local section "
f"({first['run']}/{first['section']}: EA {first['global_EA_N']} N "
f"against {first['local_EA_fixed_N']:.4g} N, EI {first['global_EI_Nm2']} "
f"N·m² against [{first['local_EI_range_Nm2'][0]:.4g}, "
f"{first['local_EI_range_Nm2'][1]:.4g}]); set allow_property_mismatch "
"only for a documented comparison"
f"({first['run']}/{first['section']}: {'; '.join(_mismatches(first))}); "
"set allow_property_mismatch only for a documented comparison"
)
return records


def _torsion_check(
line_type: CableDynLineType, stiffness: Any, rtol: float
) -> dict[str, Any]:
"""``GJ`` and coupling ``K`` of a 14-column row against ``K_tt`` and ``K_et``.

``None`` matches where the deck gives no ``GJ`` (a 10-column row, or a
14-column row without the finite-EI columns) or CableXSec computes no
lay torsional stiffness.
"""
gj, k = line_type.gj_Nm2, line_type.torque_tension_coupling_Nm
local_gj = float(stiffness.gj_Nm2)
local_k = float(stiffness.axial_torsion_coupling_Nm)
record: dict[str, Any] = {
"global_GJ_Nm2": gj,
"local_GJ_Nm2": local_gj,
"global_K_Nm": k if gj is not None else None,
"local_K_Nm": local_k,
"global_coupling_ratio": None,
"local_coupling_ratio": None,
"GJ_match": None,
"K_match": None,
}
if gj is None or not gj > 0.0 or not local_gj > 0.0:
return record
record["GJ_match"] = math.isclose(gj, local_gj, rel_tol=rtol)
ea = line_type.ea_N
local_ratio = local_k / math.sqrt(float(stiffness.ea_fixed_N) * local_gj)
# CableDyn takes K only with a linear-elastic EA, so K = 0 elsewhere.
ratio = 0.0 if k == 0.0 or ea is None or not ea > 0.0 else k / math.sqrt(ea * gj)
record["global_coupling_ratio"] = ratio
record["local_coupling_ratio"] = local_ratio
record["K_match"] = abs(ratio - local_ratio) <= rtol
return record


def _mismatches(record: Mapping[str, Any]) -> list[str]:
"""The quantities of a property-check record that do not match."""
out = []
if not record["EA_match"]:
out.append(
f"EA {record['global_EA_N']} N against {record['local_EA_fixed_N']:.4g} N"
)
if not record["EI_within_bounds"]:
low, high = record["local_EI_range_Nm2"]
out.append(f"EI {record['global_EI_Nm2']} N·m² against [{low:.4g}, {high:.4g}]")
if record["GJ_match"] is False:
out.append(
f"GJ {record['global_GJ_Nm2']} N·m² against {record['local_GJ_Nm2']:.4g}"
)
if record["K_match"] is False:
out.append(
f"K {record['global_K_Nm']} N·m (coupling ratio "
f"{record['global_coupling_ratio']:.3g}) against "
f"{record['local_K_Nm']:.4g} N·m ({record['local_coupling_ratio']:.3g})"
)
return out


_SPEC_KEYS = {"cable", "runs", "sections", "options"}
_RUN_KEYS = {
"name",
Expand Down
Loading
Loading