Skip to content

Commit f9f2fd7

Browse files
committed
fix(python): refuse a coupled finite-EI cable without a Fixed End B
The native aggregate builds every finite-EI line of a coupled deck (OpenFAST, FAST.Farm, the C API, the standalone mixed deck) held at a Fixed End B and refuses any other. The Python validator accepted such a line, for example a finite-EI cable shared by two turbines, together with its AnchFz and AnchFH channels, so a deck it reported valid failed at initialisation. It now refuses the line with the native message. An EI = 0 line shared by two turbines keeps its end-force channels. Signed-off-by: Jae Hoon Seo <jaehoon.seo@inha.ac.kr>
1 parent 9396001 commit f9f2fd7

2 files changed

Lines changed: 46 additions & 0 deletions

File tree

‎python/cabledyn/deck_file.py‎

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2894,6 +2894,26 @@ def end_key(token: str) -> str:
28942894
)
28952895
mixed_route = any(finite_lines) and not all(finite_lines) and not has_objects
28962896
mixed_static = mixed_route and not has_tmax
2897+
finite_line_ids = [
2898+
line_id
2899+
for line_id, section_types in section_types_by_line.items()
2900+
if any(line_type_meta[line_type][3] > 0.0 for line_type in section_types)
2901+
]
2902+
# Native build_one_hermite_cable, which builds every finite-EI line of the coupled
2903+
# aggregate (OpenFAST, FAST.Farm, the C API and the standalone mixed deck): the cable
2904+
# is held at a Fixed End B (the anchor) and driven at End A. A finite-EI line shared by
2905+
# two turbines is refused here, before its end-force channels (AnchFz, AnchFH) could be
2906+
# accepted for an end the aggregate cannot hold. (A standalone line's moving End B is
2907+
# refused by the static LINE checks above.)
2908+
if self.caller_driven or mixed_route:
2909+
for line_id in finite_line_ids:
2910+
end_b = normalized_line_endpoints[line_id][1]
2911+
end_b_type = point_types.get(end_b, end_b)
2912+
if end_b_type != "fixed":
2913+
raise DeckFormatError(
2914+
f"{self._label}: line {line_id}: finite-EI coupled cable requires End B "
2915+
f'(the anchor) to be a Fixed point; got "{end_b_type}"'
2916+
)
28972917
for line_type in used_type_names:
28982918
_, _, ea_static, ei = line_type_meta[line_type]
28992919
if ea_static <= 0.0:

‎python/tests/test_deck_file.py‎

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2032,6 +2032,32 @@ def test_invalid_output_channels_fail_before_case_generation(tmp_path, channel,
20322032
DeckFile.read(path)
20332033

20342034

2035+
@pytest.mark.parametrize("channel", ["FairTen1", "AnchFz1", "AnchFH1"])
2036+
def test_finite_ei_cable_shared_by_two_turbines_is_refused(tmp_path, channel):
2037+
# native build_one_hermite_cable: the coupled aggregate holds a finite-EI cable at a Fixed
2038+
# anchor, so a cable between two turbines (End B moving) is refused, end-force channels
2039+
# included
2040+
path = _chain_variant(
2041+
tmp_path,
2042+
("1.607e9 -1.0 0.0 ", "1.607e9 -1.0 2.0e5 "),
2043+
("1 Fixed 500.0", "1 Turbine2 500.0"),
2044+
("2 Coupled 0.0", "2 Turbine1 0.0"),
2045+
('"FairTen1"', f'"{channel}"'),
2046+
)
2047+
with pytest.raises(DeckFormatError, match=r"requires End B \(the anchor\) to be a Fixed point"):
2048+
DeckFile.read(path, caller_driven=True)
2049+
2050+
2051+
def test_ei0_line_shared_by_two_turbines_keeps_its_end_force_channels(tmp_path):
2052+
path = _chain_variant(
2053+
tmp_path,
2054+
("1 Fixed 500.0", "1 Turbine2 500.0"),
2055+
("2 Coupled 0.0", "2 Turbine1 0.0"),
2056+
('"FairTen1"', '"AnchFz1"'),
2057+
)
2058+
assert "AnchFz1" in DeckFile.read(path, caller_driven=True).outputs
2059+
2060+
20352061
def test_case_generation_records_changes_hashes_and_working_directory(tmp_path):
20362062
source = ROOT / "examples/chain_catenary_r3_100m.dat"
20372063
cases = generate_deck_cases(

0 commit comments

Comments
 (0)