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
3 changes: 3 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,9 @@ All notable changes to CableDyn are recorded in this file. The format follows
and in-line phases, on `EI = 0` lines and finite-EI cables. On the in-line example `Chh` 1.0
raises the quarter-span in-line response at four times the cross-flow frequency fourfold. The
Python deck reader and builder take the column.
- The cross-flow VIV columns `Cl [dF cF]` may follow the 14-column finite-EI `LINE TYPES` row
(15 or 17 columns), so a line restrained in torsion can carry VIV; such a row free in torsion
runs as the 13-column one. The Python deck reader and builder take it.
- Load power channels `VIVPow<L>`, `DragPow<L>` and `DampPow<L>` [W], and `<name><L>N<J>` per
unit length about a node [W/m]: the power the VIV loads, the drag and the structural damping
(`BA`, `Bb`) deliver to a line at the committed state, on `EI = 0` lines and finite-EI cables,
Expand Down
4 changes: 2 additions & 2 deletions doc/cli.rst
Original file line number Diff line number Diff line change
Expand Up @@ -1016,8 +1016,8 @@ native reader's rules.
- ``LINE TYPES`` row ``NAME``; fields ``name``, ``diam``, ``mass``, ``ea``, ``ba``,
``ei`` followed by ``cdn``, ``cdt``, ``can``, ``cat`` (CableDyn columns), ``cd``,
``ca``, ``cdax``, ``caax`` (MoorDyn-style columns), or ``gas``, ``gj``, ``irt``,
``irn``, ``cdn``, ``cdt``, ``can``, ``cat`` (14-column rows); an 11- or 13-column row
adds ``cl`` or ``cl``, ``df``, ``cf`` (VIV).
``irn``, ``cdn``, ``cdt``, ``can``, ``cat`` (14-column rows); an 11- or 13-column row, or
a 15- or 17-column one, adds ``cl`` or ``cl``, ``df``, ``cf`` (VIV).
* - ``section.LINE.OCCURRENCE.FIELD``
- The ``OCCURRENCE``-th section (1-based, End A to End B) of line ``LINE``; fields
``lineid``, ``linetype``, ``length``, ``numsegs``. A 7-column ``LINES`` row counts as a
Expand Down
7 changes: 4 additions & 3 deletions doc/driver_format.md
Original file line number Diff line number Diff line change
Expand Up @@ -291,12 +291,13 @@ frequency `f` [Hz], `Bb = ζ EI/(π f)`, set once per line type (it does not dep
rates).

**Cross-flow VIV columns (MoorDyn v2).** A 10-column row may end with `Cl` (11 columns) or
`Cl dF cF` (13 columns): the lift coefficient of the vortex-shedding synchronisation model and
`Cl dF cF` (13 columns), and a 14-column row likewise (15 or 17 columns, so a line restrained in
torsion can carry VIV): the lift coefficient of the vortex-shedding synchronisation model and
the half-range and centre of its band in non-dimensional frequency (MoorDyn's `dF = 0.08` and
`cF = 0.18` when only `Cl` is given). `Cl = 0` is no VIV; `Cl > 0` needs `cF > 0` and
`0 <= dF < cF`, and the line's drag in water. It acts in the dynamics on `EI = 0` lines and
finite-EI cables (see [Cross-flow VIV](theory.rst)); the 14-column row has no VIV columns. The
in-line force of a type is a [VIV](#viv-optional) section row.
finite-EI cables (see [Cross-flow VIV](theory.rst)). The in-line force of a type is a
[VIV](#viv-optional) section row.

**Viscoelastic axial stiffness (MoorDyn `ElasticMod`).** The EA and BA columns accept
bar-separated parts:
Expand Down
11 changes: 6 additions & 5 deletions python/cabledyn/builder.py
Original file line number Diff line number Diff line change
Expand Up @@ -206,8 +206,9 @@ class LineType:
cl, df, cf : float | None
Optional cross-flow VIV columns of a type (MoorDyn's lift
coefficient and the half-range and centre of the synchronisation band
in non-dimensional frequency). ``cl`` set writes the 13-column row, with
MoorDyn's ``df = 0.08`` and ``cf = 0.18`` where they are ``None``.
in non-dimensional frequency). ``cl`` set writes them after the ten or
fourteen columns (the 13- or 17-column row), with MoorDyn's
``df = 0.08`` and ``cf = 0.18`` where they are ``None``.
clx, il_alpha : float | None
Optional in-line VIV of a type, a ``VIV`` section row
``Name ClX [alpha]``: the in-line shedding coefficient (it needs ``cl``,
Expand Down Expand Up @@ -2717,9 +2718,6 @@ def _line_type_table(self) -> tuple[str, str, list[list[str]]]:
raise ValueError(f"{what}: give all of gas, gj, irt, irn or none")
row += [_num(v, what) for v in (item.cdn, item.cdt, item.can, item.cat)]
if item.cl is not None:
if all(value is not None for value in extra):
# a LINE TYPES row has 10, 11, 13 or 14 columns: no VIV on the wide row
raise ValueError(f"{what}: cl, df and cf do not combine with gas, gj, irt, irn")
viv = True
df = 0.08 if item.df is None else item.df
cf = 0.18 if item.cf is None else item.cf
Expand All @@ -2730,6 +2728,9 @@ def _line_type_table(self) -> tuple[str, str, list[list[str]]]:
if wide:
header = "Name Diam Mass EA BA EI GAs GJ Irt Irn Cd_n Cd_t Ca_n Ca_t"
units = "(-) (m) (kg/m) (N) (N-s) (N-m^2) (N) (N-m^2) (kg-m) (kg-m) (-) (-) (-) (-)"
if viv:
header += " Cl dF cF"
units += " (-) (-) (-)"
elif viv:
header = "Name Diam Mass EA BA EI Cd_n Cd_t Ca_n Ca_t Cl dF cF"
units = "(-) (m) (kg/m) (N) (N-s) (N-m^2) (-) (-) (-) (-) (-) (-) (-)"
Expand Down
41 changes: 25 additions & 16 deletions python/cabledyn/deck_file.py
Original file line number Diff line number Diff line change
Expand Up @@ -3780,7 +3780,11 @@ def effective(key: str, default: float) -> float:
raise DeckFormatError(
f"{self._label}: standalone OPTION frictionMu requires dtM and TMax"
)
allowed_widths = {"LINE TYPES": {10, 11, 13, 14}, "POINTS": {5, 9}, "LINES": {3, 4, 7}}
allowed_widths = {
"LINE TYPES": {10, 11, 13, 14, 15, 17},
"POINTS": {5, 9},
"LINES": {3, 4, 7},
}
# Every row present is checked, also in a line-free deck of bodies and rods: the
# native reader parses each table row whether or not a line uses it.
for name in sorted(allowed_widths):
Expand Down Expand Up @@ -3808,7 +3812,7 @@ def numeric(token: str, row: DeckRecord, field: str) -> float:
viv_type_names: set[str] = set()
for row in self.line_types:
for index in (1, 2, *range(5, len(row.tokens))):
if len(row.tokens) == 14 and index == 7:
if len(row.tokens) >= 14 and index == 7:
continue # the GJ column, GJ, GJ|K or GJ|K|Bt, is read below
if index == 5:
continue # the EI column, EI, EI|Bb or EI|-zeta|f, is read below
Expand Down Expand Up @@ -3861,9 +3865,9 @@ def numeric(token: str, row: DeckRecord, field: str) -> float:
f"{self._at(row)}: Syrope BA_s and BA_d must be non-negative "
"with a positive sum"
)
# Native append_type: drag and added-mass coefficients (columns 7-10, the last
# four of a 14-column row, in either column order) must be non-negative.
hydro_start = len(row.tokens) - 4 if len(row.tokens) == 14 else 6
# Native append_type: drag and added-mass coefficients (columns 7-10, or 11-14 of
# a 14-column row, in either column order) must be non-negative.
hydro_start = 10 if len(row.tokens) >= 14 else 6
hydro = [
numeric(row.tokens[index], row, f"LINE TYPES column {index + 1}")
for index in range(hydro_start, hydro_start + 4)
Expand Down Expand Up @@ -3910,12 +3914,14 @@ def numeric(token: str, row: DeckRecord, field: str) -> float:
f"{self._at(row)}: LINE TYPES {row.tokens[0]}: bending damping (EI|Bb) needs "
"a finite-EI cable (EI > 0)"
)
if len(row.tokens) in (11, 13):
# Native check_viv_columns: MoorDyn's cross-flow VIV columns Cl [dF cF]
cl = numeric(row.tokens[10], row, "Cl")
if len(row.tokens) in (11, 13, 15, 17):
# Native check_viv_columns: MoorDyn's cross-flow VIV columns Cl [dF cF], after
# the ten standard columns or the fourteen of a finite-EI row
at = 10 if len(row.tokens) in (11, 13) else 14
cl = numeric(row.tokens[at], row, "Cl")
d_f, c_f = (
(numeric(row.tokens[11], row, "dF"), numeric(row.tokens[12], row, "cF"))
if len(row.tokens) == 13
(numeric(row.tokens[at + 1], row, "dF"), numeric(row.tokens[at + 2], row, "cF"))
if len(row.tokens) in (13, 17)
else (0.08, 0.18)
)
if cl < 0.0:
Expand All @@ -3934,7 +3940,7 @@ def numeric(token: str, row: DeckRecord, field: str) -> float:
model = "Syrope" if is_syrope else "viscoelastic stiffness"
raise DeckFormatError(f"{self._at(row)}: {model} is not supported with EI > 0")
gj_value = 0.0
if len(row.tokens) == 14:
if len(row.tokens) >= 14:
# the GJ column is GJ, GJ|K or GJ|K|Bt (K the torque-tension coupling, N m;
# Bt the torsional damping, N m^2 s, negative: -zeta)
gj_parts = row.tokens[7].split("|")
Expand Down Expand Up @@ -4091,7 +4097,7 @@ def unique(records: tuple[DeckRecord, ...], label: str, numeric: bool) -> set[st

type_names = unique(self.line_types, "line type", False)
if any(
len(row.tokens) == 14 and self._stock_line_type_columns(row) for row in self.line_types
len(row.tokens) >= 14 and self._stock_line_type_columns(row) for row in self.line_types
):
raise DeckFormatError(
f"{self._label}: 14-column LINE TYPES rows require CableDyn hydro-column order"
Expand Down Expand Up @@ -6185,10 +6191,13 @@ def _check_torsion_lines(

def _line_type_fields(self, record: DeckRecord) -> tuple[str, ...]:
fields = _FIELDS["line_type"]
if len(record.tokens) == 14:
return (*fields[:6], "gas", "gj", "irt", "irn", "cdn", "cdt", "can", "cat")
# MoorDyn's optional cross-flow VIV columns follow the ten standard ones
viv = {11: ("cl",), 13: ("cl", "df", "cf")}.get(len(record.tokens), ())
# MoorDyn's optional cross-flow VIV columns follow the ten standard ones, or the
# fourteen of a finite-EI row
viv = {11: ("cl",), 13: ("cl", "df", "cf"), 15: ("cl",), 17: ("cl", "df", "cf")}.get(
len(record.tokens), ()
)
if len(record.tokens) >= 14:
return (*fields[:6], "gas", "gj", "irt", "irn", "cdn", "cdt", "can", "cat", *viv)
if self._stock_line_type_columns(record):
return (*fields[:6], "cd", "ca", "cdax", "caax", *viv)
return (*fields, *viv)
Expand Down
18 changes: 14 additions & 4 deletions python/tests/test_builder.py
Original file line number Diff line number Diff line change
Expand Up @@ -185,7 +185,7 @@ def test_build_single_catenary_validates_and_saves(tmp_path: Path) -> None:
assert model.save(target, overwrite=True) == target


def test_viv_columns_do_not_combine_with_the_wide_finite_ei_row(tmp_path: Path) -> None:
def test_viv_columns_follow_the_wide_finite_ei_row(tmp_path: Path) -> None:
model = _chain_model(tmp_path)
model.add_line_type(
"cable",
Expand All @@ -197,10 +197,20 @@ def test_viv_columns_do_not_combine_with_the_wide_finite_ei_row(tmp_path: Path)
gj=1.0e3,
irt=0.1,
irn=0.05,
cl=0.0,
cl=0.8,
cf=0.17,
)
with pytest.raises(ValueError, match="do not combine with gas, gj, irt, irn"):
model.to_text(validate=False)
text = model.to_text()
deck = DeckFile.from_text(text, path=tmp_path / "deck.dat")
rows = {row.tokens[0].upper(): row.tokens for row in deck.line_types}
# the 14 finite-EI columns, then Cl dF cF (MoorDyn's dF = 0.08 where df is None)
assert len(rows["CABLE"]) == 17
assert [float(value) for value in rows["CABLE"][14:]] == [0.8, 0.08, 0.17]
assert len(rows["CHAIN"]) == 10
loaded = DeckModel.from_text(text, path=tmp_path / "deck.dat")
cable = loaded.line_types["CABLE"]
assert (cable.gj, cable.irn, cable.cl, cable.df, cable.cf) == (1.0e3, 0.05, 0.8, 0.08, 0.17)
assert loaded.to_text() == text


def test_build_spread_mooring_with_multi_section_lines() -> None:
Expand Down
46 changes: 44 additions & 2 deletions python/tests/test_deck_file.py
Original file line number Diff line number Diff line change
Expand Up @@ -4614,7 +4614,7 @@ def test_line_free_object_deck_checks_line_type_rows_without_crashing():
("1 2 1 -\n", ""),
("1 chain 410.0 41\n", ""),
)
with pytest.raises(DeckFormatError, match="LINE TYPES row needs 10, 11, 13, 14 fields"):
with pytest.raises(DeckFormatError, match="LINE TYPES row needs 10, 11, 13, 14, 15, 17 fields"):
DeckFile.from_text(_with_section(no_lines, "BODIES", *body_rows))
# a header-only LINES section does not make the deck a line deck (the rule counts rows)
with pytest.raises(DeckFormatError) as caught:
Expand Down Expand Up @@ -4791,7 +4791,7 @@ def test_line_type_viv_columns_are_read_and_kept(tmp_path, columns, expected):
(" -0.1", "Cl must be non-negative"),
(" 0.8 0.2 0.18", "needs cF > 0 and 0 <= dF < cF"),
(" 0.8 0.05 0.0", "needs cF > 0 and 0 <= dF < cF"),
(" 0.8 0.08", "LINE TYPES row needs 10, 11, 13, 14 fields"),
(" 0.8 0.08", "LINE TYPES row needs 10, 11, 13, 14, 15, 17 fields"),
],
)
def test_line_type_viv_columns_follow_the_native_checks(columns, message):
Expand All @@ -4811,6 +4811,48 @@ def test_line_type_viv_is_accepted_on_a_finite_ei_line_type(tmp_path):
assert (line_type.ei, line_type.cl) == (1.0e4, 0.8)


# the 14-column finite-EI row (GAs GJ Irt Irn) takes the same VIV columns after its last
_WIDE_VIV_ROW = (
"chain 0.252 390.0 1.674e9 -1.0 1.0e4 1.0e8 1.0e3|0|-0.01 0.1 0.05 1.37 0.64 1.0 0.0"
)


@pytest.mark.parametrize(
"columns, expected",
[
(" 0.8", (0.8, None, None)),
(" 0.8 0.05 0.2", (0.8, 0.05, 0.2)),
],
)
def test_line_type_viv_columns_follow_the_finite_ei_row(tmp_path, columns, expected):
from cabledyn import DeckModel

row = "chain 0.252 390.0 1.674e9 -1.0 1.0e4 1.37 0.64 1.0 0.0"
text = _edit(_DYNAMIC, (row, _WIDE_VIV_ROW + columns))
record = DeckFile.from_text(text).line_types[0]
assert len(record.tokens) == 14 + len(columns.split())
path = tmp_path / "viv_wide.dat"
path.write_text(text, encoding="utf-8")
line_type = DeckModel.load(path).line_types["chain"]
assert (line_type.gj, line_type.irn) == ((1.0e3, 0.0, -0.01), 0.05)
assert (line_type.cl, line_type.df, line_type.cf) == expected
assert (line_type.cdn, line_type.cdt, line_type.can, line_type.cat) == (1.37, 0.64, 1.0, 0.0)


@pytest.mark.parametrize(
"columns, message",
[
(" -0.1", "Cl must be non-negative"),
(" 0.8 0.2 0.18", "needs cF > 0 and 0 <= dF < cF"),
(" 0.8 0.08", "LINE TYPES row needs 10, 11, 13, 14, 15, 17 fields"),
],
)
def test_finite_ei_row_viv_columns_follow_the_native_checks(columns, message):
row = "chain 0.252 390.0 1.674e9 -1.0 1.0e4 1.37 0.64 1.0 0.0"
with pytest.raises(DeckFormatError, match=re.escape(message)):
DeckFile.from_text(_edit(_DYNAMIC, (row, _WIDE_VIV_ROW + columns)))


def test_viv_is_accepted_on_the_coupled_route():
text = _edit(_STATIC, (_VIV_ROW, _VIV_ROW + " 0.8"))
DeckFile.from_text(text)
Expand Down
30 changes: 20 additions & 10 deletions src/CableDyn_DeckDriver.f90
Original file line number Diff line number Diff line change
Expand Up @@ -15833,11 +15833,11 @@ SUBROUTINE append_type(line, types, nt, stock_cols, ErrStat, ErrMsg)
INTEGER :: ios, ntok
ErrStat = 0; ErrMsg = ''
ntok = count_tokens(line)
IF (ntok /= 10 .AND. ntok /= 11 .AND. ntok /= 13 .AND. ntok /= 14) THEN
IF (ntok /= 10 .AND. ntok /= 11 .AND. ntok /= 13 .AND. ntok /= 14 .AND. ntok /= 15 .AND. ntok /= 17) THEN
CALL fail(ErrStat, ErrMsg, 'LINE TYPES row needs 10 cols '// &
'(Name Diam MassDenInAir EA BA/-zeta EI Cd_n Cd_t Ca_n Ca_t), 11 or 13 cols (the same '// &
'followed by MoorDyn''s VIV columns Cl [dF cF]) or 14 cols '// &
'(Name Diam MassDenInAir EA BA/-zeta EI GAs GJ Irt Irn Cd_n Cd_t Ca_n Ca_t)'); RETURN
'(Name Diam MassDenInAir EA BA/-zeta EI Cd_n Cd_t Ca_n Ca_t) or 14 cols '// &
'(Name Diam MassDenInAir EA BA/-zeta EI GAs GJ Irt Irn Cd_n Cd_t Ca_n Ca_t), either '// &
'followed by MoorDyn''s VIV columns Cl [dF cF] (11, 13, 15 or 17 cols)'); RETURN
END IF
! EA and BA read as STRINGS: MoorDyn's viscoelastic syntax carries
! bar-separated parts (Es|Ed[|alpha], Bs|Bd) that a numeric read cannot see.
Expand Down Expand Up @@ -15868,18 +15868,28 @@ SUBROUTINE append_type(line, types, nt, stock_cols, ErrStat, ErrMsg)
END IF
ELSE
IF (stock_cols) THEN
CALL fail(ErrStat, ErrMsg, 'the 14-column LINE TYPES row is a CableDyn form (... Cd_n Cd_t '// &
'Ca_n Ca_t); it does not combine with a stock-order header (Cd Ca CdAx CaAx)'); RETURN
CALL fail(ErrStat, ErrMsg, 'the 14-column LINE TYPES row (15 or 17 with VIV) is a CableDyn form '// &
'(... Cd_n Cd_t Ca_n Ca_t); it does not combine with a stock-order header (Cd Ca CdAx CaAx)')
RETURN
END IF
! the CableDyn finite-EI row, with MoorDyn's VIV columns Cl or Cl dF cF after it
IF (ntok == 14) THEN
READ (line, *, IOSTAT=ios) t%name, t%diam, t%mass, ea_str, ba_str, ei_str, t%gas, gj_str, t%i_rt, t%i_rn, &
t%cdn, t%cdt, t%can, t%cat
ELSE IF (ntok == 15) THEN
READ (line, *, IOSTAT=ios) t%name, t%diam, t%mass, ea_str, ba_str, ei_str, t%gas, gj_str, t%i_rt, t%i_rn, &
t%cdn, t%cdt, t%can, t%cat, t%cl
ELSE
READ (line, *, IOSTAT=ios) t%name, t%diam, t%mass, ea_str, ba_str, ei_str, t%gas, gj_str, t%i_rt, t%i_rn, &
t%cdn, t%cdt, t%can, t%cat, t%cl, t%viv_df, t%viv_cf
END IF
READ (line, *, IOSTAT=ios) t%name, t%diam, t%mass, ea_str, ba_str, ei_str, t%gas, gj_str, t%i_rt, t%i_rn, &
t%cdn, t%cdt, t%can, t%cat
END IF
IF (ios /= 0) THEN
CALL fail(ErrStat, ErrMsg, 'malformed LINE TYPES row'); RETURN
END IF
CALL parse_ei_column(ei_str, t, ErrStat, ErrMsg)
IF (ErrStat /= 0) RETURN
IF (ntok == 14) THEN
IF (ntok >= 14) THEN
CALL parse_gj_column(gj_str, t, ErrStat, ErrMsg)
IF (ErrStat /= 0) RETURN
END IF
Expand All @@ -15891,7 +15901,7 @@ SUBROUTINE append_type(line, types, nt, stock_cols, ErrStat, ErrMsg)
END IF
CALL parse_stiffness_columns(ea_str, ba_str, t, ErrStat, ErrMsg)
IF (ErrStat /= 0) RETURN
IF (ntok == 11 .OR. ntok == 13) THEN
IF (ntok == 11 .OR. ntok == 13 .OR. ntok == 15 .OR. ntok == 17) THEN
CALL check_viv_columns(t, ErrStat, ErrMsg)
IF (ErrStat /= 0) RETURN
END IF
Expand Down
Loading
Loading