From 049c8f33f93b345ffa03a66ebbac24639e7de7fa Mon Sep 17 00:00:00 2001 From: Jae Hoon Seo Date: Sat, 31 Oct 2026 22:50:46 +0900 Subject: [PATCH 1/4] fix(driver): the standalone TURBINES deck of EI = 0 and finite-EI lines runs A standalone TURBINES deck that mixes EI = 0 lines and finite-EI cables (a power cable shared by two turbines beside their chain legs) stopped with the internal message "no farm init was given (pass n_turbines + turbine_ref_pos)": the driver called the aggregate without the deck's TURBINES context. The driver now passes deck_turbines to CD_AGG_Init_From_Deck. The aggregate's parse then places the Turbine points from the TURBINES rows as the single-route parse does, a finite-EI end on a Turbine point starts turned by its turbine's PtfmInit rotation (turbine_end_dcm), and the per-turbine motionFile records move the points and turn each moving column's frames with its own turbine (col_turb). A Turbine point in a run without a farm is refused by point, naming FAST.Farm and the TURBINES section. Gate 9 (ctest mixed_route_turbines): a two-turbine deck (PtfmInit offsets and yaws, heave and roll records) with a clamped cable restrained in torsion and two chains, against its cable-only and legs-only decks. The chains agree bit for bit; the cable agrees within the coupled Newton controls (4.2e-3 of the range) and, marched through the library with the single-cable route's controls, to 0.44 printed units. With the coupled controls given to the single-cable route, a trial wrote the mixed run's cable byte for byte. The gate fails on the old code (the mixed deck does not run). The IEA 15 MW FAST.Farm twin (60 s) reproduces the split decks to 3.2e-6 of the channel maxima and FAST.Farm to 2.3e-5. Signed-off-by: Jae Hoon Seo --- CHANGELOG.md | 13 ++ CMakeLists.txt | 4 + app/cabledyn.f90 | 7 +- doc/driver_format.md | 7 +- doc/standalone_driver.rst | 4 + src/CableDyn_DeckDriver.f90 | 79 +++++++-- src/CableDyn_OpenFAST_Aggregate.f90 | 12 +- tests/test_mixed_route_torsion.f90 | 265 +++++++++++++++++++++++++++- 8 files changed, 366 insertions(+), 25 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 339d5a95..a90ab88f 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -483,6 +483,19 @@ All notable changes to CableDyn are recorded in this file. The format follows start with the same torques on every kernel, proportional to the pretwist. - The "unresolved/kinked equilibrium" refusal names the element and the factor to refine its section's `NumSegs` by. +- A standalone `TURBINES` deck that mixes `EI = 0` lines and finite-EI cables (a power cable + shared by two turbines beside their chain legs, the usual farm deck) runs. It stopped with the + internal message `no farm init was given (pass n_turbines + turbine_ref_pos)`: the mixed route + did not take the `TURBINES` rows. It now places the `Turbine` points from them and moves the + points and turns the cable end frames with the per-turbine `motionFile` records, as the decks of + the cables alone and of the `EI = 0` lines alone do. The IEA 15 MW two-turbine deck (a 1530 m + cable restrained in torsion and four chains, 60 s of FAST.Farm platform motion) reproduces those + two decks to 3.2e-6 of the channel maxima and the FAST.Farm `Mod_SharedMooring = 5` run to + 2.3e-5. On a two-turbine test deck whose turbines heave and roll, the chains match their deck + bit for bit and the cable, marched with the single-cable route's Newton controls, matches its + deck to 0.44 of the last printed digit. A `Turbine` point in a run without a farm + (single-turbine OpenFAST, the C API) is now refused by point, naming FAST.Farm and the + `TURBINES` section. - A rod numbered as a body no longer joins the body's attachment points. A `RodA/B` end point keeps its rod's id where a `Body` point keeps its body's, and the body's point list took every point with its id: a rod end POINT row listed before the body's points became the body's diff --git a/CMakeLists.txt b/CMakeLists.txt index 9521cb50..b3969a5b 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -2388,6 +2388,10 @@ add_executable(test_mixed_route_torsion tests/test_mixed_route_torsion.f90) target_link_libraries(test_mixed_route_torsion PRIVATE cabledyn_core) add_test(NAME mixed_route_torsion COMMAND test_mixed_route_torsion $) set_tests_properties(mixed_route_torsion PROPERTIES LABELS "fortran;driver;integration;dynamic") +# A standalone TURBINES deck of a finite-EI cable between two turbines and chain legs on the mixed +# route, against its cable-only and legs-only decks (gate 9). +add_test(NAME mixed_route_turbines COMMAND test_mixed_route_torsion $ turbines) +set_tests_properties(mixed_route_turbines PROPERTIES LABELS "fortran;driver;integration;dynamic") # Deck currents on the standalone mixed route (the aggregate samples the deck current at every # node before each step): OPTION uniform and profile and MoorDyn-C Currents 1/2/5 against the diff --git a/app/cabledyn.f90 b/app/cabledyn.f90 index 3f83766b..4c51b0fa 100644 --- a/app/cabledyn.f90 +++ b/app/cabledyn.f90 @@ -533,10 +533,13 @@ SUBROUTINE run_mixed_held_deck(deck, root, dt, has_dt, run_time, has_run_time, h ! name instead of silently holding zero fluid. The deck's own current is the aggregate's ! (deck_current), sampled at the nodes before every step at the step's t_committed. The ! driver holds the line end frames or turns them with the deck's vesselMotion table - ! (host_orientation), and marches the deck's prescribed motion (prescribed_motion). + ! (host_orientation), and marches the deck's prescribed motion (prescribed_motion). A + ! TURBINES section places the Turbine points and its records move and turn them + ! (deck_turbines), as on the single-route decks. CALL CD_AGG_Init_From_Deck(aggregate, deck, step_dt, es, em, forbid_deck_ambient=.TRUE., & run_tmax=MAX(CD_ZERO, run_time), range_files=.TRUE., host_orientation=.TRUE., & - prescribed_motion=has_motion, static_run=nstep == 0, deck_current=.TRUE.) + prescribed_motion=has_motion, static_run=nstep == 0, deck_current=.TRUE., & + deck_turbines=.TRUE.) IF (es /= CD_AGG_OK) THEN CALL set_aggregate_error(es, em, run_stat, run_msg) EXIT mixed_run diff --git a/doc/driver_format.md b/doc/driver_format.md index 41d49e02..8da2e336 100644 --- a/doc/driver_format.md +++ b/doc/driver_format.md @@ -596,8 +596,11 @@ follows `x + R(q) p`, with the rigid-body velocity and acceleration. A finite-EI `Turbine` point takes its `END CONNECTIONS` direction `Ez` and torsion normal `Nx` in that turbine's axes: turned by the `PtfmInit` rotation at the static start and by `R(q)`, with the row's angular velocity and acceleration, in the run (End A and End B alike), as the FAST.Farm -host's orientations turn them. In FAST.Farm the host supplies the turbine positions and the -section is not used. +host's orientations turn them. A `TURBINES` deck that mixes `EI = 0` lines and finite-EI cables (a +power cable shared by two turbines beside their chain legs) runs on the standalone mixed route, +the aggregate of FAST.Farm, with the same placement, records and end frames as the decks of its +cables alone and of its `EI = 0` lines alone. In FAST.Farm the host supplies the turbine positions +and the section is not used. ### ROD TYPES + RODS (rigid cylindrical rods) diff --git a/doc/standalone_driver.rst b/doc/standalone_driver.rst index 3ca77654..4be5b596 100644 --- a/doc/standalone_driver.rst +++ b/doc/standalone_driver.rst @@ -102,6 +102,10 @@ formerly NREL) and advances the objects atomically. Every ``Coupled``/``Vessel`` at its initialised position, or follows the deck's ``motionFile`` or ``vesselMotion`` (a vessel turns the end connection and torsion frames of the power cables on its points, and the ``motionFile`` roll column twists a cable restrained in torsion, as on the single-cable route). +A ``TURBINES`` deck (:doc:`driver_format`) places its ``Turbine`` points from the section, and +its per-turbine ``motionFile`` records move them and turn the frames of the cable ends on them +with their turbine, so a FAST.Farm shared-mooring deck of power cables and chain legs runs here +as a whole. A mixed deck that also has bodies, rods or ``Connect``/``Free`` points runs on the multibody march instead (:doc:`driver_format`), which accepts deck waves and current. ``examples/iea15mw_umaine_mixed_cabledyn.dat`` is the maintained four-line example; its ``TMax = 0`` setting writes the common static configuration. Give a positive ``TMax`` diff --git a/src/CableDyn_DeckDriver.f90 b/src/CableDyn_DeckDriver.f90 index 467f8277..e1d5373b 100644 --- a/src/CableDyn_DeckDriver.f90 +++ b/src/CableDyn_DeckDriver.f90 @@ -1097,6 +1097,9 @@ MODULE CableDyn_DeckDriver ! End A of a finite-EI line restrained in torsion at both ends, as on the standalone ! cubic-Hermite route) LOGICAL, ALLOCATABLE :: col_roll(:) + ! per aggregate moving column of a TURBINES deck: the turbine whose motionFile records turn the + ! column's frames (its point's Turbine; 0 for a column whose frames are held) + INTEGER, ALLOCATABLE :: col_turb(:) END TYPE !> Opaque deck current of a standalone mixed deck, which the standalone driver marches on the @@ -7354,7 +7357,7 @@ SUBROUTINE CD_Init_Deck_Aggregate(deck_path, dt, agg, ErrStat, ErrMsg, env_gravi ptfm_init, external_fluid, coupled_positions, & n_turbines, turbine_ref_pos, farm_ptfm_init, forbid_deck_ambient, run_tmax, & range_files, host_orientation, static_current, prescribed_motion, & - static_run, deck_current) + static_run, deck_current, deck_turbines) !! 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 @@ -7455,8 +7458,16 @@ SUBROUTINE CD_Init_Deck_Aggregate(deck_path, dt, agg, ErrStat, ErrMsg, env_gravi ! supplying its own field and passes no deck_current. LOGICAL, INTENT(IN), OPTIONAL :: deck_current + ! deck_turbines: the caller is the standalone driver, which runs a TURBINES deck by itself: the + ! deck's TURBINES rows place every Turbine point at ref_J + PtfmInit_J(p) as the parse of + ! the single-route decks does (place_standalone_turbine_points), the end frames of a finite-EI + ! line on a Turbine point start turned by turbine J's PtfmInit rotation (turbine_end_dcm), + ! and the per-turbine motionFile records move the points and turn those frames + ! (build_aggregate_motion). Ignored in FAST.Farm mode (n_turbines >= 1). + LOGICAL, INTENT(IN), OPTIONAL :: deck_turbines + INTEGER :: nturb - LOGICAL :: host_turns, own_motion, dynamic_points, static_only, own_current + LOGICAL :: host_turns, own_motion, dynamic_points, static_only, own_current, own_turbines TYPE(DeckLineType), ALLOCATABLE :: types(:) TYPE(DeckBody), ALLOCATABLE :: bodies(:) TYPE(DeckRodType), ALLOCATABLE :: rod_types(:) @@ -7486,9 +7497,15 @@ SUBROUTINE CD_Init_Deck_Aggregate(deck_path, dt, agg, ErrStat, ErrMsg, env_gravi IF (.NOT. (dt > CD_ZERO)) THEN CALL fail(ErrStat, ErrMsg, 'CD_Init_Deck_Aggregate requires a positive coupling dt'); RETURN END IF + nturb = 0 + IF (PRESENT(n_turbines)) nturb = MAX(0, n_turbines) + ! a standalone TURBINES deck: the parse places the Turbine points from the TURBINES rows (and + ! refuses Turbine points without them), as for the single-route decks + own_turbines = .FALSE. + IF (PRESENT(deck_turbines)) own_turbines = deck_turbines .AND. nturb == 0 CALL parse_deck(deck_path, types, bodies, rod_types, rods, points, lines, sections, opts, channels, & ErrStat, ErrMsg, caller_driven=.TRUE., env_gravity=env_gravity, & - env_rho_water=env_rho_water, env_wtrdpth=env_wtrdpth, allow_turbine=.TRUE., & + env_rho_water=env_rho_water, env_wtrdpth=env_wtrdpth, allow_turbine=.NOT. own_turbines, & failures=fails, controls=ctrls, run_tmax=run_tmax, host_coupled_objects=.TRUE., & static_run=static_run) IF (ErrStat == CD_DECKDRV_OK) THEN @@ -7529,8 +7546,6 @@ SUBROUTINE CD_Init_Deck_Aggregate(deck_path, dt, agg, ErrStat, ErrMsg, env_gravi END IF END IF ! ---- FAST.Farm mode ------------------------------------------------------- - nturb = 0 - IF (PRESENT(n_turbines)) nturb = MAX(0, n_turbines) IF (nturb > 0) THEN IF (PRESENT(ptfm_init)) THEN IF (MAXVAL(ABS(ptfm_init)) > CD_ZERO) THEN @@ -7571,11 +7586,15 @@ SUBROUTINE CD_Init_Deck_Aggregate(deck_path, dt, agg, ErrStat, ErrMsg, env_gravi END DO CALL revalidate_ptfm_points(points, lines, ErrStat, ErrMsg) IF (ErrStat /= CD_DECKDRV_OK) RETURN - ELSE + ELSE IF (.NOT. own_turbines) THEN + ! Turbine coordinates are turbine-local: only a farm context (FAST.Farm) or the standalone + ! driver's TURBINES rows place them DO i = 1, SIZE(points) IF (points(i)%turbine_id > 0) THEN - CALL fail(ErrStat, ErrMsg, 'the deck carries Turbine points but no farm init was '// & - 'given (pass n_turbines + turbine_ref_pos)'); RETURN + CALL fail(ErrStat, ErrMsg, 'POINT '//TRIM(int_to_str(points(i)%id))//' is a Turbine point, whose '// & + 'coordinates are local to turbine J of a farm, but this run has no farm: run the deck in '// & + 'FAST.Farm (Mod_SharedMooring = 5) or with the standalone driver and a TURBINES section; '// & + 'a single-turbine OpenFAST model and the C API take Coupled/Vessel points'); RETURN END IF END DO END IF @@ -8124,6 +8143,10 @@ SUBROUTINE CD_Init_Deck_Aggregate(deck_path, dt, agg, ErrStat, ErrMsg, env_gravi j = find_point(points, lines(i)%nodeA) IF (j > 0 .AND. points(j)%turbine_id > 0) & fairlead_dcm = ptfm_zyx_dcm(farm_ptfm_init(4:6, points(j)%turbine_id)) + ELSE IF (own_turbines) THEN + ! a standalone TURBINES deck: the PtfmInit rotation of the end's turbine, as on the + ! standalone cubic-Hermite route + fairlead_dcm = turbine_end_dcm(points, opts, lines(i)%nodeA) ELSE IF (PRESENT(ptfm_init)) THEN fairlead_dcm = ptfm_zyx_dcm(ptfm_init(4:6)) END IF @@ -8137,6 +8160,8 @@ SUBROUTINE CD_Init_Deck_Aggregate(deck_path, dt, agg, ErrStat, ErrMsg, env_gravi j = find_point(points, lines(i)%nodeB) IF (j > 0 .AND. points(j)%turbine_id > 0) & end_b_dcm = ptfm_zyx_dcm(farm_ptfm_init(4:6, points(j)%turbine_id)) + ELSE IF (own_turbines) THEN + end_b_dcm = turbine_end_dcm(points, opts, lines(i)%nodeB) ELSE IF (PRESENT(ptfm_init)) THEN end_b_dcm = ptfm_zyx_dcm(ptfm_init(4:6)) END IF @@ -8848,7 +8873,9 @@ SUBROUTINE build_aggregate_motion(points, lines, is_fin, opts, rt, ErrStat, ErrM !! POINT order, then one coupled fairlead per finite-EI cable in deck LINE order, then the !! moving End B of each cable between two moving points). The roll column of a motionFile !! drives a moving end restrained in torsion of a line solved in torsion, as on the - !! standalone cubic-Hermite route (check_motion_roll_lines). + !! standalone cubic-Hermite route (check_motion_roll_lines). On a TURBINES deck the + !! per-turbine records also turn the frames of each column with the column's turbine when a + !! line carries end-connection or torsion frames (with_turbine_frames, as on that route). TYPE(DeckPoint), INTENT(IN) :: points(:) TYPE(DeckLine), INTENT(IN) :: lines(:) LOGICAL, INTENT(IN) :: is_fin(:) @@ -8863,7 +8890,10 @@ SUBROUTINE build_aggregate_motion(points, lines, is_fin, opts, rt, ErrStat, ErrM ErrMsg = '' CALL CD_Motion_End(rt) CALL read_motion_file(opts%motion_file, points, opts, rt%motion, ErrStat, ErrMsg, & - with_roll=ANY([(line_torsion_active(lines(i)), i=1, SIZE(lines))])) + with_roll=ANY([(line_torsion_active(lines(i)), i=1, SIZE(lines))]), & + with_turbine_frames=ANY([(line_torsion_active(lines(i)) .OR. & + ANY(lines(i)%endconn_mode /= CD_ENDCONN_PINNED), & + i=1, SIZE(lines))])) IF (ErrStat /= CD_DECKDRV_OK) RETURN CALL check_motion_roll_lines(rt%motion, lines, points, ErrStat, ErrMsg) IF (ErrStat /= CD_DECKDRV_OK) RETURN @@ -8905,7 +8935,7 @@ SUBROUTINE build_aggregate_motion(points, lines, is_fin, opts, rt, ErrStat, ErrM IF (pass == 2) CALL set_column(n, find_point(points, lines(l)%nodeB), & rt%motion%has_roll .AND. line_torsion_at_b(lines(l))) END DO - IF (pass == 1) ALLOCATE (rt%col_point(n), rt%col_pos(3, n), rt%col_roll(n)) + IF (pass == 1) ALLOCATE (rt%col_point(n), rt%col_pos(3, n), rt%col_roll(n), rt%col_turb(n)) END DO IF (ErrStat /= CD_DECKDRV_OK) RETURN rt%active = .TRUE. @@ -8923,6 +8953,8 @@ SUBROUTINE set_column(col, ipt, takes_roll) rt%col_point(col) = ip rt%col_pos(:, col) = points(ipt)%pos rt%col_roll(col) = takes_roll + rt%col_turb(col) = 0 + IF (rt%motion%has_turb_rot) rt%col_turb(col) = points(ipt)%turbine_id END SUBROUTINE set_column END SUBROUTINE build_aggregate_motion @@ -8940,10 +8972,11 @@ INTEGER FUNCTION CD_Motion_NColumns(rt) RESULT(n) END FUNCTION CD_Motion_NColumns LOGICAL FUNCTION CD_Motion_Has_Rotation(rt) RESULT(has) - !! A vesselMotion table: the moving points turn with the vessel. + !! A vesselMotion table (the moving points turn with the vessel), or the per-turbine records of + !! a TURBINES deck whose lines carry end frames (each point turns with its turbine). TYPE(CD_MotionRuntimeType), INTENT(IN) :: rt has = .FALSE. - IF (rt%active) has = rt%motion%has_rot + IF (rt%active) has = rt%motion%has_rot .OR. rt%motion%has_turb_rot END FUNCTION CD_Motion_Has_Rotation LOGICAL FUNCTION CD_Motion_Has_Roll(rt) RESULT(has) @@ -8978,16 +9011,17 @@ SUBROUTINE CD_Motion_Kinematics(rt, time_index, position, velocity, acceleration !! Grid row time_index (1 = t 0) of the moving surface, columns in the aggregate moving-set !! order: position, velocity and acceleration of each driving point (3, n); the !! global-to-parent DCM (3, 3, n) and the global-axis angular velocity and acceleration - !! (3, n) -- the vessel's under a vesselMotion table, the identity and zero otherwise, so a - !! motionFile turns no frame -- and the motionFile roll [rad] of each column that takes one - !! (zero elsewhere). Allocation free. + !! (3, n) -- the vessel's under a vesselMotion table, the column's turbine's under the + !! records of a TURBINES deck, the identity and zero otherwise, so motionFile point rows turn + !! no frame -- and the motionFile roll [rad] of each column that takes one (zero elsewhere). + !! Allocation free. TYPE(CD_MotionRuntimeType), INTENT(IN) :: rt INTEGER, INTENT(IN) :: time_index REAL(wp), INTENT(OUT) :: position(:, :), velocity(:, :), acceleration(:, :) REAL(wp), INTENT(OUT) :: orientation(:, :, :), angular_velocity(:, :), angular_acceleration(:, :), roll(:) INTEGER, INTENT(OUT) :: ErrStat CHARACTER(*), INTENT(OUT) :: ErrMsg - INTEGER :: col, ip, n + INTEGER :: col, ip, n, j ErrStat = CD_DECKDRV_BADINPUT ErrMsg = '' @@ -9025,6 +9059,16 @@ SUBROUTINE CD_Motion_Kinematics(rt, time_index, position, velocity, acceleration orientation(3, 3, col) = CD_ONE angular_velocity(:, col) = CD_ZERO angular_acceleration(:, col) = CD_ZERO + IF (rt%motion%has_turb_rot) THEN + ! TURBINES records: the column turns with its own turbine J (turbine_end_rotation), the + ! parent DCM being the transpose of the record's turbine-to-global rotation + j = rt%col_turb(col) + IF (j >= 1 .AND. j <= SIZE(rt%motion%turb_rot, 3)) THEN + orientation(:, :, col) = TRANSPOSE(rt%motion%turb_rot(:, :, j, time_index)) + angular_velocity(:, col) = rt%motion%turb_omega(:, j, time_index) + angular_acceleration(:, col) = rt%motion%turb_alpha(:, j, time_index) + END IF + END IF END IF roll(col) = CD_ZERO IF (rt%col_roll(col)) roll(col) = rt%motion%roll(ip, time_index) @@ -9040,6 +9084,7 @@ SUBROUTINE CD_Motion_End(rt) IF (ALLOCATED(rt%col_point)) DEALLOCATE (rt%col_point) IF (ALLOCATED(rt%col_pos)) DEALLOCATE (rt%col_pos) IF (ALLOCATED(rt%col_roll)) DEALLOCATE (rt%col_roll) + IF (ALLOCATED(rt%col_turb)) DEALLOCATE (rt%col_turb) rt%active = .FALSE. END SUBROUTINE CD_Motion_End diff --git a/src/CableDyn_OpenFAST_Aggregate.f90 b/src/CableDyn_OpenFAST_Aggregate.f90 index 8d5007e7..be68b088 100644 --- a/src/CableDyn_OpenFAST_Aggregate.f90 +++ b/src/CableDyn_OpenFAST_Aggregate.f90 @@ -292,7 +292,7 @@ SUBROUTINE CD_AGG_Init_From_Deck(self, deck_path, dt, ErrStat, ErrMsg, env_gravi ptfm_init, external_fluid, coupled_positions, & n_turbines, turbine_ref_pos, farm_ptfm_init, forbid_deck_ambient, run_tmax, & range_files, host_orientation, static_current, prescribed_motion, static_run, & - deck_current) + deck_current, deck_turbines) !! 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 @@ -343,6 +343,9 @@ SUBROUTINE CD_AGG_Init_From_Deck(self, deck_path, dt, ErrStat, ErrMsg, env_gravi ! deck_current: the caller marches the deck's own current (the standalone driver; see ! CD_Init_Deck_Aggregate): every step samples it at the nodes, at its t_committed LOGICAL, INTENT(IN), OPTIONAL :: deck_current + ! deck_turbines: the standalone driver runs a TURBINES deck, whose TURBINES rows place the + ! Turbine points and whose per-turbine records move them (see CD_Init_Deck_Aggregate) + LOGICAL, INTENT(IN), OPTIONAL :: deck_turbines ! 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. @@ -383,7 +386,8 @@ SUBROUTINE CD_AGG_Init_From_Deck(self, deck_path, dt, ErrStat, ErrMsg, env_gravi forbid_deck_ambient=forbid_deck_ambient, run_tmax=run_tmax, & range_files=range_files, host_orientation=host_orientation, & static_current=static_current, prescribed_motion=prescribed_motion, & - static_run=static_run, deck_current=deck_current) + static_run=static_run, deck_current=deck_current, & + deck_turbines=deck_turbines) IF (PRESENT(external_fluid)) THEN candidate%built_extfluid = external_fluid END IF @@ -1522,7 +1526,9 @@ SUBROUTINE CD_AGG_MotionKinematics(self, time_index, position, velocity, acceler !! DCM (3, 3, ncp_total) with the global-axis angular velocity and acceleration (3, !! ncp_total), and the roll (ncp_total). has_rotation: a vesselMotion table, whose !! orientation and rates the step takes (the fairlead end connection and torsion frames - !! turn with the vessel, as on the standalone cubic-Hermite route); has_roll: a motionFile + !! turn with the vessel, as on the standalone cubic-Hermite route), or the per-turbine + !! records of a TURBINES deck whose lines carry end frames (each column turns with its + !! turbine); has_roll: a motionFile !! roll column the step takes as roll. Without them (motionFile point rows) the frames are !! held and the step takes the translations alone. TYPE(CD_AGG_ModuleType), INTENT(IN) :: self diff --git a/tests/test_mixed_route_torsion.f90 b/tests/test_mixed_route_torsion.f90 index f33803a1..328f669e 100644 --- a/tests/test_mixed_route_torsion.f90 +++ b/tests/test_mixed_route_torsion.f90 @@ -42,6 +42,19 @@ !> with End B's point listed first in POINTS (the moving columns follow the cables, End A !> columns then End B columns, not the POINTS order). Fails if the roll of a two-moving-end !> cable is dropped or an end's motion is read from another moving column. +!> 9. Run alone (second argument "turbines", ctest mixed_route_turbines): a TURBINES deck (two +!> turbines, PtfmInit offsets and yaws, per-turbine motionFile records of heave and roll from +!> rest) with a finite-EI cable between the turbines, clamped (Rigid) and restrained in torsion +!> at both ends, and an EI = 0 chain from each turbine to an anchor. The driver runs it on the +!> mixed route (it used to stop for want of a farm context) and the deck's cable alone on the +!> standalone cubic-Hermite route and its chains alone on the standalone EI = 0 route, both of +!> which consume the TURBINES rows. The chains' tensions agree to LOAD_TOL of their range; the +!> cable's channels agree to the coupled cable's Newton controls (relative tolerance 5e-3; the +!> standalone route given those controls writes the mixed run's cable byte for byte, about 1e-2 +!> of the range from its own). The aggregate library marched with the standalone controls, as +!> in gate 1, reproduces the cable-only run's cable channels to the printed precision. Each +!> turbine's yaw and roll turn the clamped end on it (End A on turbine 1, End B on turbine 2), +!> so the end bend moments and the torque carry each end's own turbine. PROGRAM test_mixed_route_torsion USE CableDyn_Precision, ONLY: wp USE CableDyn_OpenFAST_Aggregate, ONLY: CD_AGG_ModuleType, CD_AGG_Init_From_Deck, CD_AGG_NMovingPoints, & @@ -66,20 +79,46 @@ PROGRAM test_mixed_route_torsion ! the gate 1 and 2 channels of line 1 (the same in both decks) and the chain's CHARACTER(16), PARAMETER :: OUTS(10) = [LOADS, EXACT(1:3), [CHARACTER(16) :: 'L1N21px', 'L1N21py', 'L1N21pz']] CHARACTER(16), PARAMETER :: CHAIN_OUTS(2) = [CHARACTER(16) :: 'FairTen2', 'Point3pz'] + ! gate 9: the cable's end loads and bend moments (compared to LOAD_TOL), its torque, twist and + ! mid node (to TURB_TOL), and the chains' tensions (to LOAD_TOL) + CHARACTER(16), PARAMETER :: TURB_LOADS(4) = [CHARACTER(16) :: 'FairTen1', 'AnchTen1', 'BendMom1N1', 'BendMom1N41'] + CHARACTER(16), PARAMETER :: TURB_TWIST(4) = [CHARACTER(16) :: 'Torq1N1', 'Twist1', 'L1N21py', 'L1N21pz'] + CHARACTER(16), PARAMETER :: TURB_CABLE(8) = [TURB_LOADS, TURB_TWIST] + CHARACTER(16), PARAMETER :: TURB_CHAINS(4) = [CHARACTER(16) :: 'FairTen2', 'AnchTen2', 'FairTen3', 'AnchTen3'] + ! gate 9: the driver's mixed run against the cable-only run (the coupled cable's Newton controls) + REAL(wp), PARAMETER :: TURB_TOL = 5.0e-2_wp REAL(wp), PARAMETER :: LOAD_TOL = 5.0e-5_wp, POS_TOL = 1.0e-6_wp ! printed precision of ES15.7E3: half a unit in the 8th significant digit of each value, with a ! unit of the 8th digit of the channel's range for a value that crosses zero REAL(wp), PARAMETER :: PRINT_TOL = 6.0e-8_wp, PRINT_FLOOR = 1.0e-7_wp CHARACTER(1024) :: driver + ! the run's gates: 1-8, or with the second argument "turbines" gate 9 alone + CHARACTER(16) :: mode + LOGICAL :: turbines_only CHARACTER(160) :: neutral_t INTEGER :: n_fail = 0 IF (COMMAND_ARGUMENT_COUNT() < 1) ERROR STOP 'usage: test_mixed_route_torsion ' CALL GET_COMMAND_ARGUMENT(1, driver) + ! "turbines": gate 9 alone (its own ctest entry, mixed_route_turbines); the other gates otherwise + turbines_only = .FALSE. + IF (COMMAND_ARGUMENT_COUNT() >= 2) THEN + CALL GET_COMMAND_ARGUMENT(2, mode) + turbines_only = TRIM(mode) == 'turbines' + END IF ! neutral 0.2 m section of test_torsion_deck: EA 1e7, EI 1e6, GAs 1e8, GJ 5e4, Irn 1e-12 WRITE (neutral_t, '(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.0e-12 0.0 0.0 0.0 0.0' + IF (turbines_only) THEN + CALL check_turbines() + IF (n_fail > 0) THEN + WRITE (*, '(A,I0,A)') 'FAIL: ', n_fail, ' mixed-route TURBINES gate(s) failed' + ERROR STOP 1 + END IF + WRITE (*, '(A)') 'PASS: the standalone TURBINES deck of EI = 0 and finite-EI lines on the mixed route' + STOP + END IF CALL check_vessel_routes() CALL check_roll_routes() CALL check_quasi_static(QS_HELD) @@ -109,10 +148,12 @@ SUBROUTINE require(cond, msg) END IF END SUBROUTINE require - SUBROUTINE write_deck(path, types, points, lines, sections, endconns, options, outs, atts) + SUBROUTINE write_deck(path, types, points, lines, sections, endconns, options, outs, atts, turbs) CHARACTER(*), INTENT(IN) :: path, types(:), points(:), lines(:), sections(:), endconns(:), options(:), outs(:) ! ATTACHMENTS rows (none when absent) CHARACTER(*), INTENT(IN), OPTIONAL :: atts(:) + ! TURBINES rows (none when absent) + CHARACTER(*), INTENT(IN), OPTIONAL :: turbs(:) INTEGER :: u, i OPEN (NEWUNIT=u, FILE=path, STATUS='REPLACE', ACTION='WRITE') WRITE (u, '(A)') 'mixed-route torsion gate' @@ -128,6 +169,13 @@ SUBROUTINE write_deck(path, types, points, lines, sections, endconns, options, o DO i = 1, SIZE(points) WRITE (u, '(A)') TRIM(points(i)) END DO + IF (PRESENT(turbs)) THEN + WRITE (u, '(A)') '--- TURBINES ---' + WRITE (u, '(A)') 'J X0 Y0 Z0 PtfmSurge PtfmSway PtfmHeave PtfmRoll PtfmPitch PtfmYaw' + DO i = 1, SIZE(turbs) + WRITE (u, '(A)') TRIM(turbs(i)) + END DO + END IF WRITE (u, '(A)') '--- LINES ---' WRITE (u, '(A)') 'ID NodeA NodeB Outputs' WRITE (u, '(A)') '(-) (-) (-) (-)' @@ -883,4 +931,219 @@ SUBROUTINE check_static_blend() CALL require(log_has('tmrt_blend_d1', 'torsion in a dynamic run needs the force-blended'), & '6: the configuration blend of a dynamic one-end torsion run is named') END SUBROUTINE check_static_blend + + PURE SUBROUTINE smooth_start(amplitude, t, f, df, d2f) + !! f = F (1 - cos w t)^2 / 4 and its rates, w = 2 pi / PERIOD: a motion from rest with no + !! acceleration at t = 0 (f'' = F w^2 (sin^2 w t + (1 - cos w t) cos w t) / 2). + REAL(wp), INTENT(IN) :: amplitude, t + REAL(wp), INTENT(OUT) :: f, df, d2f + REAL(wp) :: w, c, sn + w = 2.0_wp*PI/PERIOD + c = COS(w*t) + sn = SIN(w*t) + f = 0.25_wp*amplitude*(1.0_wp - c)**2 + df = 0.5_wp*amplitude*w*(1.0_wp - c)*sn + d2f = 0.5_wp*amplitude*w*w*(sn*sn + (1.0_wp - c)*c) + END SUBROUTINE smooth_start + + SUBROUTINE turbine_record(j, t, row) + !! Gate 9: the motionFile record of turbine j at time t (time J x y z q0 q1 q2 q3 vx vy vz wx wy + !! wz ax ay az alx aly alz). Turbine 1 at (0, 0, 0) with PtfmInit surge 2 m, heave -0.5 m and + !! yaw 180 deg, turbine 2 at (300, 0, 0) with PtfmInit sway 1 m and yaw 5 deg; from rest, with + !! no acceleration at t = 0 (smooth_start), each heaves 1 m (turbine 2: -0.8 m) and rolls 10 deg + !! (turbine 2: -8 deg) about its own x axis: + !! R = Rz(yaw) Rx(roll), the quaternion [cz cx, cz sx, sz sx, sz cx] of the half angles, the + !! global angular velocity Rz(yaw) (roll', 0, 0) and acceleration Rz(yaw) (roll'', 0, 0). + INTEGER, INTENT(IN) :: j + REAL(wp), INTENT(IN) :: t + REAL(wp), INTENT(OUT) :: row(21) + REAL(wp) :: x0(3), yaw, zh, vz, az, ro, dro, d2ro, ex(3) + IF (j == 1) THEN + x0 = [2.0_wp, 0.0_wp, -0.5_wp] + yaw = 180.0_wp*D2R + CALL smooth_start(1.0_wp, t, zh, vz, az) + CALL smooth_start(10.0_wp*D2R, t, ro, dro, d2ro) + ELSE + x0 = [300.0_wp, 1.0_wp, 0.0_wp] + yaw = 5.0_wp*D2R + CALL smooth_start(-0.8_wp, t, zh, vz, az) + CALL smooth_start(-8.0_wp*D2R, t, ro, dro, d2ro) + END IF + ex = [COS(yaw), SIN(yaw), 0.0_wp] + row = 0.0_wp + row(1) = t + row(2) = REAL(j, wp) + row(3:5) = x0 + [0.0_wp, 0.0_wp, zh] + row(6:9) = [COS(0.5_wp*yaw)*COS(0.5_wp*ro), COS(0.5_wp*yaw)*SIN(0.5_wp*ro), SIN(0.5_wp*yaw)*SIN(0.5_wp*ro), & + SIN(0.5_wp*yaw)*COS(0.5_wp*ro)] + row(10:12) = [0.0_wp, 0.0_wp, vz] + row(13:15) = dro*ex + row(16:18) = [0.0_wp, 0.0_wp, az] + row(19:21) = d2ro*ex + END SUBROUTINE turbine_record + + SUBROUTINE turbine_deck(path, cable, chains) + !! Gate 9: the TURBINES deck (the turbines of turbine_record) with the finite-EI cable (line + !! 1, 300 m, 40 elements) from point 1 on turbine 1 to point 2 on turbine 2, both clamped and + !! restrained in torsion (Pretwist 30 deg at End B), and/or the chains 2 and 3 from points 3 (on + !! turbine 1) and 5 (on turbine 2) to the anchors 4 and 6. Coordinates of a Turbine point and + !! its Ez and Nx are in its turbine's axes. + CHARACTER(*), INTENT(IN) :: path + LOGICAL, INTENT(IN) :: cable, chains + CHARACTER(48) :: pts(6), opts(5) + CHARACTER(96) :: turbs(2), ec(2) + pts(1) = '1 Turbine1 -20.0 0.0 -15.0 0 0 0 0' + pts(2) = '2 Turbine2 -20.0 0.0 -15.0 0 0 0 0' + pts(3) = '3 Turbine1 20.0 0.0 -15.0 0 0 0 0' + pts(4) = '4 Fixed -250.0 0.0 -200.0 0 0 0 0' + pts(5) = '5 Turbine2 20.0 0.0 -15.0 0 0 0 0' + pts(6) = '6 Fixed 550.0 0.0 -200.0 0 0 0 0' + turbs(1) = '1 0.0 0.0 0.0 2.0 0.0 -0.5 0.0 0.0 180.0' + turbs(2) = '2 300.0 0.0 0.0 0.0 1.0 0.0 0.0 0.0 5.0' + ec(1) = '1 A Rigid -1 0 -0.4 Rigid 0 -1 0 0' + ec(2) = '1 B Rigid 1 0 0.4 Rigid 0 1 0 30' + opts = [CHARACTER(48) :: '200.0 WtrDpth', '0.05 dtM', '10.0 TMax', 'tmrt_turb.txt motionFile', '3.0e6 kBot'] + IF (cable .AND. chains) THEN + CALL write_deck(path, [CHARACTER(96) :: CAB_T, CHAIN_T], pts, & + [CHARACTER(16) :: '1 1 2 -', '2 3 4 -', '3 5 6 -'], & + [CHARACTER(24) :: '1 cab 300.0 40', '2 chain 320.0 20', '3 chain 320.0 20'], ec, opts, & + [TURB_CABLE, TURB_CHAINS], turbs=turbs) + ELSE IF (cable) THEN + CALL write_deck(path, [CHARACTER(96) :: CAB_T], pts(1:2), [CHARACTER(16) :: '1 1 2 -'], & + [CHARACTER(24) :: '1 cab 300.0 40'], ec, opts, TURB_CABLE, turbs=turbs) + ELSE + CALL write_deck(path, [CHARACTER(96) :: CHAIN_T], pts(3:6), [CHARACTER(16) :: '2 3 4 -', '3 5 6 -'], & + [CHARACTER(24) :: '2 chain 320.0 20', '3 chain 320.0 20'], [CHARACTER(8) ::], opts, & + TURB_CHAINS, turbs=turbs) + END IF + END SUBROUTINE turbine_deck + + SUBROUTINE check_turbines() + !! Gate 9. + CHARACTER(32) :: nm(MAXCOL), nc(MAXCOL), nl(MAXCOL) + REAL(wp), ALLOCATABLE :: vm(:, :), vc(:, :), vl(:, :) + REAL(wp) :: row(21), e, e_turb, e_leg + INTEGER :: u, k, j, rm, rc, rl, cm, cx + LOGICAL :: ok + OPEN (NEWUNIT=u, FILE='tmrt_turb.txt', STATUS='REPLACE', ACTION='WRITE') + DO k = 0, NSTEP + DO j = 1, 2 + CALL turbine_record(j, DT*k, row) + WRITE (u, '(F8.3,I3,19ES25.16E3)') row(1), j, row(3:21) + END DO + END DO + CLOSE (u) + CALL turbine_deck('tmrt_turb_m.dat', .TRUE., .TRUE.) + CALL turbine_deck('tmrt_turb_c.dat', .TRUE., .FALSE.) + CALL turbine_deck('tmrt_turb_l.dat', .FALSE., .TRUE.) + CALL run_driver('tmrt_turb_c.dat', 'tmrt_turb_c', ok) + CALL require(ok, '9: the cable of the TURBINES deck runs on the standalone cubic-Hermite route') + CALL run_driver('tmrt_turb_l.dat', 'tmrt_turb_l', ok) + CALL require(ok, '9: the chains of the TURBINES deck run on the standalone EI = 0 route') + CALL run_driver('tmrt_turb_m.dat', 'tmrt_turb_m', ok) + CALL require(ok, '9: the TURBINES deck of the cable and the chains runs on the mixed route') + CALL require(log_has('tmrt_turb_m', 'mixed standalone aggregate'), '9: the TURBINES deck runs on the aggregate') + ALLOCATE (vm(MAXROW, MAXCOL), vc(MAXROW, MAXCOL), vl(MAXROW, MAXCOL)) + CALL read_out('tmrt_turb_m.out', nm, vm, rm) + CALL read_out('tmrt_turb_c.out', nc, vc, rc) + CALL read_out('tmrt_turb_l.out', nl, vl, rl) + CALL require(rm == NSTEP + 1 .AND. rc == NSTEP + 1 .AND. rl == NSTEP + 1, '9: the three runs write every row') + IF (rm /= NSTEP + 1 .OR. rc /= NSTEP + 1 .OR. rl /= NSTEP + 1) RETURN + e_turb = 0.0_wp + DO k = 1, SIZE(TURB_CABLE) + cm = col_of(nm, TURB_CABLE(k)) + cx = col_of(nc, TURB_CABLE(k)) + CALL require(cm > 0 .AND. cx > 0, '9: channel '//TRIM(TURB_CABLE(k))//' in both outputs') + IF (cm == 0 .OR. cx == 0) CYCLE + e = range_error(vc(:, cx), vm(:, cm), rm) + WRITE (*, '(A,A,A,ES10.3,A)') ' 9 TURBINES driver: ', TRIM(TURB_CABLE(k)), ' difference ', e, & + ' of its range (the coupled Newton controls)' + e_turb = MAX(e_turb, e) + END DO + e_leg = 0.0_wp + DO k = 1, SIZE(TURB_CHAINS) + cm = col_of(nm, TURB_CHAINS(k)) + cx = col_of(nl, TURB_CHAINS(k)) + CALL require(cm > 0 .AND. cx > 0, '9: channel '//TRIM(TURB_CHAINS(k))//' in both outputs') + IF (cm == 0 .OR. cx == 0) CYCLE + e = range_error(vl(:, cx), vm(:, cm), rm) + WRITE (*, '(A,A,A,ES10.3,A)') ' 9 TURBINES driver: ', TRIM(TURB_CHAINS(k)), ' difference ', e, ' of its range' + e_leg = MAX(e_leg, e) + END DO + CALL require(e_turb <= TURB_TOL, '9: the cable agrees with the cable-only deck within the coupled Newton controls') + CALL require(e_leg <= LOAD_TOL, '9: the chain tensions agree with the legs-only deck') + CALL march_turbines(nc, vc, rc) + END SUBROUTINE check_turbines + + SUBROUTINE march_turbines(nc, vc, rc) + !! Gate 9: the mixed route's march of the TURBINES deck (deck_turbines, the driver's call) + !! through the aggregate library, its cable given the standalone route's Newton controls (as + !! march_library): every cable channel is compared at every step with the cable-only run's + !! output (nc, vc, rc rows) to its printed precision. + CHARACTER(32), INTENT(IN) :: nc(:) + REAL(wp), INTENT(IN) :: vc(:, :) + INTEGER, INTENT(IN) :: rc + TYPE(CD_AGG_ModuleType), ALLOCATABLE :: agg + REAL(wp), ALLOCATABLE :: pos(:, :), vel(:, :), acc(:, :), load(:, :), orient(:, :, :), omega(:, :), alpha(:, :) + REAL(wp), ALLOCATABLE :: roll(:), got(:, :) + CHARACTER(2048) :: em + INTEGER :: es, n, c, step, k, cx, nch, n_iter + LOGICAL :: turns, rolls, conv, stalled + REAL(wp) :: worst, v + ALLOCATE (agg) + CALL CD_AGG_Init_From_Deck(agg, 'tmrt_turb_m.dat', DT, es, em, forbid_deck_ambient=.TRUE., run_tmax=TMAX, & + host_orientation=.TRUE., prescribed_motion=.TRUE., deck_turbines=.TRUE.) + CALL require(es == CD_AGG_OK .AND. CD_AGG_HasMotion(agg), '9: the aggregate takes the TURBINES deck and its '// & + 'records: '//TRIM(em)) + IF (es /= CD_AGG_OK) RETURN + DO c = 1, agg%ncable + agg%cables(c)%tol = 1.0e-8_wp + agg%cables(c)%max_iter = 30 + agg%cables(c)%line%tangent_reuse = .TRUE. + END DO + n = CD_AGG_NMovingPoints(agg, es, em) + nch = CD_AGG_NumChannels(agg) + ALLOCATE (pos(3, n), vel(3, n), acc(3, n), load(3, n), orient(3, 3, n), omega(3, n), alpha(3, n), roll(n), & + got(NSTEP + 1, nch)) + CALL CD_AGG_GetMovingPointMesh(agg, pos, vel, acc, load, es, em) + CALL CD_AGG_MotionKinematics(agg, 1, pos, vel, acc, orient, omega, alpha, roll, turns, rolls, es, em) + CALL require(turns, '9: the TURBINES records turn the moving columns') + CALL CD_AGG_UpdateStates_Moving(agg, pos, vel, acc, es, em, orientation=orient, angular_velocity=omega, & + angular_acceleration=alpha) + IF (es == CD_AGG_OK) CALL CD_AGG_Refresh_Accelerations(agg, es, em) + CALL require(es == CD_AGG_OK, '9: the first TURBINES records install: '//TRIM(em)) + DO step = 0, NSTEP + IF (step > 0) THEN + CALL CD_AGG_MotionKinematics(agg, step + 1, pos, vel, acc, orient, omega, alpha, roll, turns, rolls, es, em) + CALL CD_AGG_Step_Moving(agg, DT, pos, vel, acc, conv, stalled, n_iter, es, em, t_committed=DT*step, & + orientation=orient, angular_velocity=omega, angular_acceleration=alpha) + IF (es /= CD_AGG_OK .OR. .NOT. conv) THEN + CALL require(.FALSE., '9: library march step: '//TRIM(em)) + EXIT + END IF + END IF + CALL CD_AGG_CalcOutput(agg, es, em) + DO k = 1, nch + CALL CD_AGG_EvalChannel(agg, k, v, es, em) + got(step + 1, k) = v + END DO + END DO + ! the mixed deck's channels are TURB_CABLE then TURB_CHAINS, in OUTPUTS order + worst = HUGE(1.0_wp) + IF (rc == NSTEP + 1) THEN + worst = 0.0_wp + DO k = 1, SIZE(TURB_CABLE) + cx = col_of(nc, TURB_CABLE(k)) + IF (cx > 0) THEN + worst = MAX(worst, print_error(vc(:, cx), got(:, k), rc)) + ELSE + worst = HUGE(1.0_wp) + END IF + END DO + END IF + WRITE (*, '(A,ES10.3,A)') ' 9 TURBINES library march with the standalone Newton controls: largest cable '// & + 'difference ', worst, ' printed units' + CALL require(worst <= 2.0_wp, '9: with the same Newton controls the mixed route reproduces the cable-only deck') + CALL CD_AGG_End(agg, es, em) + END SUBROUTINE march_turbines END PROGRAM test_mixed_route_torsion From 0c7624dcb7bc6df101505d1bed99758966f11417 Mon Sep 17 00:00:00 2001 From: Jae Hoon Seo Date: Sat, 31 Oct 2026 23:57:02 +0900 Subject: [PATCH 2/4] docs(coupled): state that a coupled deck takes bodies or rods, not both A coupled deck with both bodies (Rigid6 or Point3) and rods stops at init, in OpenFAST CompMooring = 5, FAST.Farm and the C API: the aggregate step advances either the body march or the rod march. MoorDyn-F runs such a deck, and the OpenFAST and capability pages listed coupled bodies and coupled rods without the limit; the message spoke of "one body/rod family per step". The message now says what the coupled route takes (bodies or rods; a rod fixed to a body counts as a rod, a zero-length rod is a point) and where such a deck runs (MoorDyn CompMooring = 3, or the standalone multibody march for a deck without CoupledPinned objects). doc/openfast.rst, doc/coupling.rst, doc/capabilities.rst and doc/troubleshooting.rst state the limit, and the Python validator refuses the deck with caller_driven=True. The lift itself is left for a later release. Gates: test_deck_native_parity (the validator refuses a buoy with a body-fixed rod for the coupled route, accepts it standalone, and accepts the buoy alone and with a zero-length rod) and test_objects (the C API refusal names the limit and the routes; it fails on the old message). Signed-off-by: Jae Hoon Seo --- CHANGELOG.md | 6 +++++ doc/capabilities.rst | 4 +++- doc/coupling.rst | 1 + doc/openfast.rst | 8 ++++++- doc/troubleshooting.rst | 6 +++++ python/cabledyn/deck_file.py | 14 +++++++++++- python/tests/test_deck_native_parity.py | 21 ++++++++++++++++++ python/tests/test_objects.py | 29 +++++++++++++++++++++++++ src/CableDyn_DeckDriver.f90 | 15 +++++++++---- 9 files changed, 97 insertions(+), 7 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index a90ab88f..e865c82e 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -496,6 +496,12 @@ All notable changes to CableDyn are recorded in this file. The format follows deck to 0.44 of the last printed digit. A `Turbine` point in a run without a farm (single-turbine OpenFAST, the C API) is now refused by point, naming FAST.Farm and the `TURBINES` section. +- A coupled deck with both bodies and rods stopped at init with `a coupled deck mixing RODs and + Rigid6/point3 bodies is not supported (the aggregate marches one body/rod family per step)`, + a limit the OpenFAST and capability pages did not state. The message now says what the coupled + route takes (bodies or rods, a rod fixed to a body counting as a rod) and where such a deck runs + (MoorDyn `CompMooring = 3`, the standalone driver); the OpenFAST, capability and troubleshooting + pages state the limit, and the Python validator (`caller_driven=True`) refuses the deck. - A rod numbered as a body no longer joins the body's attachment points. A `RodA/B` end point keeps its rod's id where a `Body` point keeps its body's, and the body's point list took every point with its id: a rod end POINT row listed before the body's points became the body's diff --git a/doc/capabilities.rst b/doc/capabilities.rst index 793046d3..cfba7e1d 100644 --- a/doc/capabilities.rst +++ b/doc/capabilities.rst @@ -218,7 +218,9 @@ rigid rods. In OpenFAST, ``Coupled``/``Vessel`` bodies and rods are platform-bor 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, as do ``CoupledPinned``/``VesselPinned`` bodies about a node at their reference point, and ``Pinned`` -rods turn about a fixed End A. The C API and Python +rods turn about a fixed End A. A coupled deck (OpenFAST, the C API and Python) carries bodies or +rods, not both, a rod fixed to a body counting as a rod; the standalone driver's multibody march +takes both, as does MoorDyn (``CompMooring = 3``). 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` diff --git a/doc/coupling.rst b/doc/coupling.rst index a5097995..31eed549 100644 --- a/doc/coupling.rst +++ b/doc/coupling.rst @@ -57,6 +57,7 @@ is their zero-frequency reduction ``D − C A⁻¹ B``, not a derivative CableDy 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, + - a deck with both bodies (Rigid6 or Point3) and rods, a rod fixed to a body included, - 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 Rigid6 bodies or rods in a SeaState without waves or current (a WaterKin ``CurrentMod 1`` diff --git a/doc/openfast.rst b/doc/openfast.rst index c8259a5d..a3cfed4c 100644 --- a/doc/openfast.rst +++ b/doc/openfast.rst @@ -427,7 +427,13 @@ without an auxiliary process: 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. + with the node at the body reference point, and may share a deck with ``Free`` bodies. A deck + carries bodies (Rigid6 or Point3) or rods, not both: the coupled march advances one of the two + families, and a rod fixed to a body (``RODS`` type ``Body`` or ``BodyPinned``) counts as a + rod, so such a deck stops at init (``a coupled deck with both BODIES and RODS is not + supported``). MoorDyn (``CompMooring = 3``) in the same binary runs it, and so does the + standalone driver's multibody march when the deck has no ``CoupledPinned`` objects (those run in + OpenFAST only). ``CoupledPinned``/``VesselPinned`` bodies are pinned to the platform like ``CoupledPinned`` rods: the node at the body reference point follows the platform position only, the body turns about it with its own three rotations (its inertia about the node, its weight and buoyancy at the diff --git a/doc/troubleshooting.rst b/doc/troubleshooting.rst index fdefde91..7147a80f 100644 --- a/doc/troubleshooting.rst +++ b/doc/troubleshooting.rst @@ -901,6 +901,12 @@ aborts with a CableDyn fatal error, check whether the deck uses one of these com * - a finite-EI cable in the same deck as Rigid6 bodies, rods, or ``Connect``/``Free`` points - model the cable and the body/point system in separate decks or use the supported combinations in :doc:`capabilities` + * - ``a coupled deck with both BODIES and RODS is not supported``: bodies (Rigid6 or Point3) + and rods in one deck, a rod fixed to a body (``Body``, ``BodyPinned``) included + - the coupled march advances the bodies or the rods of a deck, not both (also in the C API and + Python). Run the deck with stock MoorDyn (``CompMooring = 3``) in the same binary, or, without + ``CoupledPinned`` objects, with the standalone driver, whose multibody march takes both; a + deck with only bodies or only rods runs coupled * - OpenFAST linearisation of a cable with a ``Rigid`` ``END CONNECTIONS`` row (``formal OpenFAST linearization of a cable with a rigid end connection is not supported``), of a deck with ``Free`` or ``Connect`` points or a line with VIV (``Cl > 0``), or with a ``CONTROL`` diff --git a/python/cabledyn/deck_file.py b/python/cabledyn/deck_file.py index 9fb70d1a..bfe968c5 100644 --- a/python/cabledyn/deck_file.py +++ b/python/cabledyn/deck_file.py @@ -1624,7 +1624,9 @@ class DeckFile: rejected otherwise. The native C API (:class:`cabledyn.CableDyn`) reads decks with the standalone rules, so it rejects the ``CoupledPinned``/``VesselPinned`` bodies and rods that ``caller_driven=True`` accepts; FAST.Farm, in turn, refuses bodies and rods when it - initialises the module. + initialises the module. A coupled deck carries bodies or rods, not both (a rod fixed to a + body counts as a rod): ``caller_driven=True`` rejects a deck with both, as the coupled + route and the C API do, while the standalone driver's multibody march takes them. """ def __init__( @@ -3730,6 +3732,16 @@ def end_key(token: str) -> str: "single-turbine pure EI=0 deck without Rigid6 bodies or rods; remove the " "deck current OPTION (the host SeaState supplies the current)" ) + # native CD_Init_Deck_Aggregate: the coupled march advances the bodies or the rods + # of a deck, not both (a rod fixed to a body counts; a zero-length rod is a point) + if has_rods and body_types: + raise DeckFormatError( + f"{self._label}: a coupled deck with both BODIES and RODS is not " + "supported: the coupled march advances the bodies (Rigid6, Point3) or the " + "rods of a deck, not both, and a rod fixed to a body counts as a rod; run " + "the deck with MoorDyn (CompMooring = 3) or, without CoupledPinned objects, " + "with the standalone driver, whose multibody march takes both" + ) if has_viv_ei0 and not self.caller_driven: # native init_one_model: the lift acts with the line's Morison drag, which the # deck switches on with water (a depth or bathymetry, a current, or waves); on the diff --git a/python/tests/test_deck_native_parity.py b/python/tests/test_deck_native_parity.py index 55f4d6a0..c51115fa 100644 --- a/python/tests/test_deck_native_parity.py +++ b/python/tests/test_deck_native_parity.py @@ -443,6 +443,27 @@ def test_body_fixed_rod_ends_resolve_to_body_points(): assert keys["rod1b"] == "rod1b" and types["rod1b"] == "body1" and merged == {} +def test_coupled_decks_take_bodies_or_rods_not_both(): + # native CD_Init_Deck_Aggregate (OpenFAST CompMooring = 5, FAST.Farm, the C API): the coupled + # march advances the bodies or the rods of a deck; a rod fixed to the body counts as a rod + rods = ( + f"{_BAR} ROD TYPES {_BAR}\nName Diam Mass Cd Ca CdEnd CaEnd\n" + "spar 1.0 300.0 0.8 1.0 0.0 0.0\n" + f"{_BAR} RODS {_BAR}\nID RodType Type XA YA ZA XB YB ZB NumSegs Outputs\n" + "1 spar Body1 0 0 -2 0 0 -8 2 -\n" + ) + # (in still water: a coupled deck current on a deck with bodies is refused first) + still = ("uniform 0.6 0.0 0.0 current", "none current") + text = _buoy(still, (f"{_BAR} POINTS", rods + f"{_BAR} POINTS")) + DeckFile.from_text(text) # the standalone multibody march + _rejects(text, "a coupled deck with both BODIES and RODS", caller_driven=True) + DeckFile.from_text(_buoy(still), caller_driven=True) + # a zero-length rod is a point, not a rod + zero = rods.replace("0 0 -8 2 -", "0 0 -2 0 -") + zero_text = _buoy(still, (f"{_BAR} POINTS", zero + f"{_BAR} POINTS")) + DeckFile.from_text(zero_text, caller_driven=True) + + # --------------------------------------------------------------------------- dispatch gates diff --git a/python/tests/test_objects.py b/python/tests/test_objects.py index e4f99a45..bfd122d6 100644 --- a/python/tests/test_objects.py +++ b/python/tests/test_objects.py @@ -476,3 +476,32 @@ def test_zero_length_rod_axis_is_a_value_error(tmp_path, monkeypatch): monkeypatch.setattr(type(rod), "node_positions", lambda self, out=None: np.zeros((3, 3))) with pytest.raises(ValueError, match="zero length"): rod.axis() + + +def test_c_api_takes_bodies_or_rods_not_both(tmp_path): + # the C API runs a deck with bodies or rods on the coupled aggregate, which marches one of the + # two families: a rod fixed to the buoy is refused by name, saying where such a deck runs + bar = "-" * 21 + base = (EXAMPLES / "rigid6_buoy.dat").read_text(encoding="utf-8") + # still water and a fluid-inert buoy (the aggregate refuses CdA/Ca without a host field) + base = base.replace("uniform 0.6 0.0 0.0 current", "none current", 1) + base = base.replace("0.0 0.0 0.0 8.0 0.5 3.5e4", "0.0 0.0 0.0 0.0 0.0 3.5e4", 1) + marker = f"{bar} POINTS" + rods = ( + f"{bar} ROD TYPES {bar}\nName Diam Mass Cd Ca CdEnd CaEnd\n" + "spar 1.0 300.0 0.8 1.0 0.0 0.0\n" + f"{bar} RODS {bar}\nID RodType Type XA YA ZA XB YB ZB NumSegs Outputs\n" + "1 spar Body1 0 0 -2 0 0 -8 2 -\n" + ) + assert base.count(marker) == 1 + deck = tmp_path / "buoy_rod.dat" + deck.write_text(base.replace(marker, rods + marker), encoding="utf-8") + with CableDyn() as model, pytest.raises(CableDynError) as err: + model.init_deck(deck) + message = str(err.value) + assert "a coupled deck with both BODIES and RODS is not supported" in message + assert "CompMooring = 3" in message and "standalone driver" in message + still = tmp_path / "buoy.dat" + still.write_text(base, encoding="utf-8") + with CableDyn() as model: + model.init_deck(still) diff --git a/src/CableDyn_DeckDriver.f90 b/src/CableDyn_DeckDriver.f90 index e1d5373b..00f2718c 100644 --- a/src/CableDyn_DeckDriver.f90 +++ b/src/CableDyn_DeckDriver.f90 @@ -7803,8 +7803,8 @@ SUBROUTINE CD_Init_Deck_Aggregate(deck_path, dt, agg, ErrStat, ErrMsg, env_gravi END SELECT END DO ! RODS are marched on the coupled aggregate (the rod twin of the Rigid6 march), scope-validated - ! 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). + ! below (n_rod block) and built into agg%rod. A rod deck with Rigid6 or Point3 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' .OR. & rods%rod_type == 'coupledpinned') @@ -7909,9 +7909,16 @@ SUBROUTINE CD_Init_Deck_Aggregate(deck_path, dt, agg, ErrStat, ErrMsg, env_gravi ! field, another dynamic point, a Rigid6/point3 body, or line FAILURE is not composed with a rod march ! yet -- fail closed by name. IF (n_rod > 0) THEN + ! The step replaces the mooring step with either the body march or the rod march: a deck + ! with both (a rod fixed to a body included; a zero-length rod is a point by now) has no + ! coupled march. The standalone multibody march and MoorDyn-F take it. IF (n_rigid6 > 0 .OR. n_point3 > 0) THEN - CALL fail(ErrStat, ErrMsg, 'CD_Init_Deck_Aggregate: a coupled deck mixing RODs and Rigid6/point3 '// & - 'bodies is not supported (the aggregate marches one body/rod family per step)'); RETURN + CALL fail(ErrStat, ErrMsg, 'CD_Init_Deck_Aggregate: a coupled deck with both BODIES and RODS is not '// & + 'supported: the coupled march advances the bodies (Rigid6, Point3) or the rods of a deck, '// & + 'not both, and a rod fixed to a body counts as a rod. Coupled runs (OpenFAST CompMooring = 5, '// & + 'the C API and Python) take a deck with bodies or a deck with rods; run this one with MoorDyn '// & + '(CompMooring = 3) in the same OpenFAST binary, or, without CoupledPinned objects, with the '// & + 'standalone driver, whose multibody march takes both'); RETURN END IF IF (n_fin > 0) THEN CALL fail(ErrStat, ErrMsg, 'CD_Init_Deck_Aggregate: a coupled ROD with a finite-EI cable in the '// & From 42c288a003f008524b2873566130806639a332a7 Mon Sep 17 00:00:00 2001 From: Jae Hoon Seo Date: Sun, 1 Nov 2026 00:38:17 +0900 Subject: [PATCH 3/4] fix(openfast): FAST.Farm.exe of the CMake route gets a stack reserve on Windows GNU FAST.Farm.exe built through integration/openfast with the GNU compilers on Windows has MinGW's 2 MiB stack reserve and stops with 0xC00000FD (stack overflow) while it initialises the turbines of a farm, before any output. The release does not ship FAST.Farm.exe, so FAST.Farm users always take this route. The new patch 0022 (numbered after 0021 of the version-stamp branch) links openfast.exe and FAST.Farm.exe with a 256 MiB reserve on WIN32 with the GNU compilers (-Wl,--stack,268435456, the CableDyn driver's reserve); the Visual Studio projects of the release keep their own. integration/openfast/README.md and NOTICE name it, and tests/test_documentation.py checks the patch. Checked on the two-turbine IEA 15 MW shared-mooring farm: the patched build has the 256 MiB reserve; the same FAST.Farm.exe with its header set back to 2 MiB stops with 0xC00000FD after "Running ElastoDyn", and with the reserve it runs to normal termination. The full series, 0022 included, applies to a clean OpenFAST 2895884d2 checkout, and 0021 applies on top of it. Signed-off-by: Jae Hoon Seo --- CHANGELOG.md | 5 +++ NOTICE | 7 ++-- integration/openfast/README.md | 8 +++- .../patches/0022-glue-stack-cmake.patch | 40 +++++++++++++++++++ tests/test_documentation.py | 10 +++++ 5 files changed, 66 insertions(+), 4 deletions(-) create mode 100644 integration/openfast/patches/0022-glue-stack-cmake.patch diff --git a/CHANGELOG.md b/CHANGELOG.md index e865c82e..c7bd247f 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -502,6 +502,11 @@ All notable changes to CableDyn are recorded in this file. The format follows route takes (bodies or rods, a rod fixed to a body counting as a rod) and where such a deck runs (MoorDyn `CompMooring = 3`, the standalone driver); the OpenFAST, capability and troubleshooting pages state the limit, and the Python validator (`caller_driven=True`) refuses the deck. +- `FAST.Farm.exe` built through the CMake route of `integration/openfast` with the GNU compilers + on Windows stopped at start with `0xC00000FD` (stack overflow) while initialising the first + turbine: MinGW links it with a 2 MiB stack. The new patch `0022` gives `openfast.exe` and + `FAST.Farm.exe` a 256 MiB stack reserve on that toolchain, and the shared-mooring farm (two IEA + 15 MW turbines) runs to normal termination. - A rod numbered as a body no longer joins the body's attachment points. A `RodA/B` end point keeps its rod's id where a `Body` point keeps its body's, and the body's point list took every point with its id: a rod end POINT row listed before the body's points became the body's diff --git a/NOTICE b/NOTICE index b56bb457..d4121b94 100644 --- a/NOTICE +++ b/NOTICE @@ -22,9 +22,10 @@ OpenFAST (Apache License, Version 2.0) https://github.com/OpenFAST/openfast * integration/openfast/patches/ contains patches that MODIFY OpenFAST source - files (the root, openfast-library, and version CMakeLists.txt; - FAST_AeroMap.f90, FAST_Funcs.f90, FAST_Mapping.f90, FAST_ModGlue.f90, - FAST_Registry.txt, FAST_Solver.f90, FAST_Subs.f90, and FAST_Types.f90 in + files (the root, openfast-library, version, glue-codes/openfast and + glue-codes/fast-farm CMakeLists.txt; FAST_AeroMap.f90, FAST_Funcs.f90, + FAST_Mapping.f90, FAST_ModGlue.f90, FAST_Registry.txt, FAST_Solver.f90, + FAST_Subs.f90, and FAST_Types.f90 in modules/openfast-library/src; FAST_Farm_IO.f90, FAST_Farm_Registry.txt, FAST_Farm_Subs.f90, and FAST_Farm_Types.f90 in glue-codes/fast-farm/src). The modified files remain under the Apache License, Version 2.0, and diff --git a/integration/openfast/README.md b/integration/openfast/README.md index 74cb9fb4..9cc201ac 100644 --- a/integration/openfast/README.md +++ b/integration/openfast/README.md @@ -39,7 +39,13 @@ check the build: ``` The script fails unless `openfast.exe` builds, the smoke case initialises the CableDyn module, and -the output is finite to the last row. An `openfast.exe` built through CMake does not embed the +the output is finite to the last row. Configure with `-DBUILD_FASTFARM=ON` to build `FAST.Farm` +as well (target `FAST.Farm`); the release does not ship it, so FAST.Farm users take this route. +On Windows with the GNU compilers, patch `0022` links `openfast.exe` and `FAST.Farm.exe` with a +256 MiB stack reserve (`-Wl,--stack,268435456`, as the CableDyn driver): with the MinGW default +of 2 MiB, `FAST.Farm.exe` stops with `0xC00000FD` (stack overflow) while it initialises the +turbines of a farm, before any output. The reserve is address space, not committed memory; the +Visual Studio projects of the release set their own. An `openfast.exe` built through CMake does not embed the UTF-8 active-code-page manifest, so on Windows it may not open input files in folders whose names the system code page cannot spell; the static release build embeds it. diff --git a/integration/openfast/patches/0022-glue-stack-cmake.patch b/integration/openfast/patches/0022-glue-stack-cmake.patch new file mode 100644 index 00000000..f3003f41 --- /dev/null +++ b/integration/openfast/patches/0022-glue-stack-cmake.patch @@ -0,0 +1,40 @@ +diff --git a/glue-codes/fast-farm/CMakeLists.txt b/glue-codes/fast-farm/CMakeLists.txt +index 96672632b..2c58cef73 100644 +--- a/glue-codes/fast-farm/CMakeLists.txt ++++ b/glue-codes/fast-farm/CMakeLists.txt +@@ -49,6 +49,15 @@ if (${_build_type} STREQUAL "RELEASE" AND NOT WIN32) + set_source_files_properties(src/FAST_Farm_Types.f90 PROPERTIES COMPILE_FLAGS "-O2") + endif() + ++# CableDyn integration: MinGW-w64 gives an executable a 2 MiB stack reserve, which the GNU ++# build of FAST.Farm overflows while it initialises its turbines (STATUS_STACK_OVERFLOW, ++# 0xC00000FD). Reserve 256 MiB for openfast and FAST.Farm, as for the CableDyn driver (the ++# Visual Studio projects set a reserve of their own). A reserve is address space, not ++# committed memory. ++if (WIN32 AND ${_compiler_id} STREQUAL "GNU") ++ target_link_options(FAST.Farm PRIVATE "LINKER:--stack,268435456") ++endif() ++ + install(TARGETS FAST.Farm + RUNTIME DESTINATION bin + ) +diff --git a/glue-codes/openfast/CMakeLists.txt b/glue-codes/openfast/CMakeLists.txt +index 08fde158b..3a87962be 100644 +--- a/glue-codes/openfast/CMakeLists.txt ++++ b/glue-codes/openfast/CMakeLists.txt +@@ -30,6 +30,15 @@ if (${_compiler_id} STREQUAL "GNU" AND NOT ${VARIABLE_TRACKING}) + set_source_files_properties(src/FAST_Prog.f90 PROPERTIES COMPILE_FLAGS "-fno-var-tracking -fno-var-tracking-assignments") + endif() + ++# CableDyn integration: MinGW-w64 gives an executable a 2 MiB stack reserve, which the GNU ++# build of FAST.Farm overflows while it initialises its turbines (STATUS_STACK_OVERFLOW, ++# 0xC00000FD). Reserve 256 MiB for openfast and FAST.Farm, as for the CableDyn driver (the ++# Visual Studio projects set a reserve of their own). A reserve is address space, not ++# committed memory. ++if (WIN32 AND ${_compiler_id} STREQUAL "GNU") ++ target_link_options(openfast PRIVATE "LINKER:--stack,268435456") ++endif() ++ + install(TARGETS openfast + RUNTIME DESTINATION bin) + diff --git a/tests/test_documentation.py b/tests/test_documentation.py index ca217be3..51f6dab9 100644 --- a/tests/test_documentation.py +++ b/tests/test_documentation.py @@ -199,6 +199,16 @@ def test_windows_release_is_publicly_reproducible(self) -> None: ).read_text(encoding="utf-8") self.assertIn("usefrom CableDyn_Registry.txt", farm_registry) self.assertIn("USE CableDyn_Types", farm_types) + # the CMake route links openfast.exe and FAST.Farm.exe with a stack reserve on Windows + # GNU: MinGW's 2 MiB default overflows while FAST.Farm initialises its turbines + stack_patch = ( + ROOT / "integration" / "openfast" / "patches" / "0022-glue-stack-cmake.patch" + ).read_text(encoding="utf-8") + for target in ("openfast", "FAST.Farm"): + self.assertIn( + f'target_link_options({target} PRIVATE "LINKER:--stack,268435456")', + stack_patch, + ) def test_public_documentation_has_one_source_tree(self) -> None: self.assertFalse( From 7ab9af0ab53452cdc9c9b04e6a4d90049071ffdd Mon Sep 17 00:00:00 2001 From: Jae Hoon Seo Date: Tue, 3 Nov 2026 07:58:13 +0900 Subject: [PATCH 4/4] fix(messages): console messages that say what happens From the OpenFAST/FAST.Farm end-to-end validation of 0.4.0: - OpenFAST printed "SeaState wave/current kinematics drive the mooring hydro" also for a WaterKin file with WaveKinMod 0 and CurrentMod 0, which correctly gives still water; it is printed only when a SeaState component is taken. - The body/rod static start reported "largest move 0.000E+00 m" for a pinned rod that had turned (only translations were counted); it now reports the move of every point the objects carry and the largest turn of a body or rod. - A mixed or FAST.Farm deck refused for a deck current said "Remove the current OPTION" also when the current came from the CurrentMod 1 table of its WaterKin file; the refusal names the declaring input. - The torsion note reported the pretwist as the imposed twist, leaving out the PtfmInit/TURBINES turn of the end frames; it reports the line's total twist Twist beside Pretwist(B) - Pretwist(A). - In FAST.Farm the time-step messages called DT_Mooring the glue DT. Test needles updated and added (driver_cli_torsion_nmodes, mixed_route_torsion, openfast_aggregate, msg_pinned_rod_turn). Signed-off-by: Jae Hoon Seo --- CHANGELOG.md | 14 ++++++ CMakeLists.txt | 7 ++- doc/openfast.rst | 4 +- doc/troubleshooting.rst | 14 ++++-- src/CableDyn_DeckDriver.f90 | 81 ++++++++++++++++++++++++++---- src/openfast/CableDyn_OF.f90 | 68 ++++++++++++++++++++----- tests/data/msg_pinned_rod_turn.dat | 36 +++++++++++++ tests/test_mixed_route_torsion.f90 | 37 +++++++++++++- tests/test_openfast_aggregate.f90 | 35 +++++++++++++ 9 files changed, 264 insertions(+), 32 deletions(-) create mode 100644 tests/data/msg_pinned_rod_turn.dat diff --git a/CHANGELOG.md b/CHANGELOG.md index c7bd247f..fb90fd13 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -483,6 +483,20 @@ All notable changes to CableDyn are recorded in this file. The format follows start with the same torques on every kernel, proportional to the pretwist. - The "unresolved/kinked equilibrium" refusal names the element and the factor to refine its section's `NumSegs` by. +- Console messages that said something untrue now say what happens: + - OpenFAST: "SeaState wave/current kinematics drive the mooring hydro" is printed only when the + deck's `WaterKin` policy takes a SeaState component (a `WaterKin` file with `WaveKinMod 0` and + `CurrentMod 0` gives still water and says so); + - the body/rod static start reports the largest turn of a body or rod and the move of every + point the objects carry, so a pinned rod that only rotated no longer reads "largest move + 0.000E+00 m"; + - a mixed or FAST.Farm deck refused for a deck current names the input that declares it (the + `CurrentMod 1` table of its `WaterKin` file, or the `current` OPTION), not always "the current + OPTION"; + - the torsion note reports the line's total twist `Twist` at the static state, beside the + imposed `Pretwist(B) - Pretwist(A)` and with the end frames' turn (a `PtfmInit` or `TURBINES` + rotation) and the shape's geometric twist, not the pretwist alone; + - in FAST.Farm the time-step messages name the farm's `DT_Mooring`, not a "glue DT". - A standalone `TURBINES` deck that mixes `EI = 0` lines and finite-EI cables (a power cable shared by two turbines beside their chain legs, the usual farm deck) runs. It stopped with the internal message `no farm init was given (pass n_turbines + turbine_ref_pos)`: the mixed route diff --git a/CMakeLists.txt b/CMakeLists.txt index b3969a5b..27306b1d 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -2627,7 +2627,7 @@ set_tests_properties(driver_cli_mixed_nmodes PROPERTIES LABELS "fortran;driver;c add_test(NAME driver_cli_torsion_nmodes COMMAND ${CMAKE_COMMAND} -DDRIVER=$ -DEXPECT_RC=0 "-DARGS=${CMAKE_CURRENT_SOURCE_DIR}/tests/data/torsion_lazy_wave_modes.dat|${CMAKE_CURRENT_BINARY_DIR}/driver_cli_torsion_nmodes" - "-DMUST_MATCH=torsion solved, imposed twist 7.20000E\\+02 deg;converged run written" + "-DMUST_MATCH=torsion solved, total twist Twist1 =;imposed Pretwist.B. - Pretwist.A. = +7.20000E\\+02 deg;converged run written" -P ${CMAKE_CURRENT_SOURCE_DIR}/tests/check_driver_output.cmake) set_tests_properties(driver_cli_torsion_nmodes PROPERTIES LABELS "fortran;driver;cli") # Non-ASCII, reserved-device, input-clobbering, and concurrently used output paths. @@ -2902,6 +2902,11 @@ cabledyn_msg_test(mixed_waves msg_mixed_waves.dat 1 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") +# A Pinned rod that its line turns at the static start: the completion line reports the move of its +# End B and its turn, not the zero translation of its pin. +cabledyn_msg_test(pinned_rod_turn msg_pinned_rod_turn.dat 0 + "body/rod static equilibrium .1 object.s., largest move [1-9].[0-9]+E[-+][0-9]+ m, largest turn [1-9]" + "largest move 0.000E\\+00") # 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." diff --git a/doc/openfast.rst b/doc/openfast.rst index a3cfed4c..9b170d51 100644 --- a/doc/openfast.rst +++ b/doc/openfast.rst @@ -81,7 +81,9 @@ solves once per that many glue steps, which is faster. Between commits the coupl extrapolated from the last two commits (deck ``OPTIONS predictLoads``, the default) or, with ``predictLoads False``, held at the last commit, which delays them (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`` +example ``CableDyn time step dtM = 2.50000E-02 s (1 x glue DT; deck dtM)``; in FAST.Farm the +coupling step is the farm's mooring step ``DT_Mooring``, and the line reads ``1 x FAST.Farm +DT_Mooring``. 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 diff --git a/doc/troubleshooting.rst b/doc/troubleshooting.rst index 7147a80f..542ad635 100644 --- a/doc/troubleshooting.rst +++ b/doc/troubleshooting.rst @@ -681,11 +681,15 @@ Warnings and notes that do not stop a run torque–tension coupling (``GJ|K``) its stretch twists it by :math:`-\sum (K/GJ)(l - L)`, so a free End B turns by :math:`+x` and a free End A by :math:`-x` about the End A → End B tangent. - * - ``Note: line : torsion solved, imposed twist ... deg, torque ... N m ( twist - stage(s), buckling descent(s))`` - - 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. + * - ``Note: line : torsion solved, total twist Twist = ... deg (imposed Pretwist(B) - + Pretwist(A) = ... deg, with the end frames' turn and the shape's geometric twist), torque + ... N m ( twist stage(s), buckling descent(s))`` + - the static twist stage of a torsional line. The total twist is the ``Twist`` channel at + the static state: the imposed pretwist difference plus the turn of the end frames (a + ``PtfmInit`` or ``TURBINES`` rotation of a parent turns its end) less the geometric twist the + line takes up by its shape; the torque follows from it. 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. * - ``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 diff --git a/src/CableDyn_DeckDriver.f90 b/src/CableDyn_DeckDriver.f90 index 00f2718c..af3746b7 100644 --- a/src/CableDyn_DeckDriver.f90 +++ b/src/CableDyn_DeckDriver.f90 @@ -111,7 +111,8 @@ MODULE CableDyn_DeckDriver CD_HermiteCable_Dyn_Node_Torque, CD_HermiteCable_Dyn_End_Twist USE CableDyn_HermiteTorsion, ONLY: CD_HermiteTorsionType, CD_HermiteTorsion_Compliance, CD_HTORS_MAX_STEP, & CD_HTORS_MAX_TWIST, CD_HermiteTorsion_Zeta_Damping, CD_HermiteTorsion_Line, & - CD_HermiteTorsion_Unwrap, CD_HermiteTorsion_Element_Stretch, CD_HTORS_OK + CD_HermiteTorsion_Unwrap, CD_HermiteTorsion_Element_Stretch, CD_HTORS_OK, & + CD_HermiteTorsion_Coupling_Twist USE CableDyn_EndConnection, ONLY: CD_ENDCONN_PINNED, CD_ENDCONN_FINITE, CD_ENDCONN_RIGID USE CableDyn_Vessel, ONLY: CD_VesselRAOType, CD_Vessel_Euler_DCM, CD_Vessel_Euler_Angular, & CD_Vessel_Point_Kinematics, CD_Vessel_RAO_Set, CD_Vessel_RAO_Eval, & @@ -3484,18 +3485,35 @@ END SUBROUTINE torsion_stage SUBROUTINE torsion_note() !! The notes of the accepted torsion stage: a residual floor above the tolerance, and the - !! imposed twist and torque. A line restrained at one end only solves no twist stage; its - !! note is one_end_state's. + !! twist and torque. The twist is the line's total twist Twist = Phi - Theta (the Twist + !! channel at the static state): the imposed Phi = Pretwist(B) - Pretwist(A), which the note + !! also gives, with the turn of the end frames (a PtfmInit or TURBINES rotation of a parent) + !! and the shape's geometric twist, both in the holonomy Theta. The accepted theta is + !! Theta_eff = Theta + tw_K under torque-tension coupling, tw_K = -sum (K/GJ)(l - L) + !! (CD_HermiteTorsion_Coupling_Twist), so Phi - Theta = Phi - Theta_eff + tw_K. A line + !! restrained at one end only solves no twist stage; its note is one_end_state's. CHARACTER(320) :: tnote + REAL(wp) :: twist IF (ln%tors_free_end > 0) RETURN + twist = tors%phi - tors%theta + IF (ALLOCATED(tors%couple)) THEN + ! the final mesh of the stage: l0 after the attachment polish, l0_am otherwise + IF (has_att) THEN + twist = twist + CD_HermiteTorsion_Coupling_Twist(q_static, l0, tors%couple, tors%quadrature_order) + ELSE + twist = twist + CD_HermiteTorsion_Coupling_Twist(q_static, l0_am, tors%couple, tors%quadrature_order) + END IF + END IF IF (tors_tol_used > static_tol_target) THEN WRITE (tnote, '(A,I0,A,ES9.2,A,ES9.2)') 'line ', ln%id, ': torsion static residual floor above the '// & 'tolerance ', static_tol_target, '; twisted equilibrium accepted at ', tors_tol_used CALL report_note(tnote) END IF - WRITE (tnote, '(A,I0,A,ES12.5,A,ES12.5,A,I0,A,I0,A)') 'line ', ln%id, ': torsion solved, imposed twist ', & - tors%phi*45.0_wp/QUARTER_PI, ' deg, torque ', tors%torque, ' N m (', tors%ramp_steps, & - ' twist stage(s), ', tors%descents, ' buckling descent(s))' + WRITE (tnote, '(A,I0,A,I0,A,ES12.5,A,ES12.5,A,ES12.5,A,I0,A,I0,A)') 'line ', ln%id, & + ': torsion solved, total twist Twist', ln%id, ' =', twist*45.0_wp/QUARTER_PI, & + ' deg (imposed Pretwist(B) - Pretwist(A) =', tors%phi*45.0_wp/QUARTER_PI, & + ' deg, with the end frames'' turn and the shape''s geometric twist), torque ', tors%torque, ' N m (', & + tors%ramp_steps, ' twist stage(s), ', tors%descents, ' buckling descent(s))' CALL report_note(tnote) IF (tors%untwisted_instability) THEN WRITE (tnote, '(A,I0,A,I0,A)') 'line ', ln%id, ': the twisted static state keeps the instability of '// & @@ -7717,9 +7735,9 @@ SUBROUTINE CD_Init_Deck_Aggregate(deck_path, dt, agg, ErrStat, ErrMsg, env_gravi END IF IF ((opts%has_current .OR. opts%has_current_profile) .AND. .NOT. own_current) THEN 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 + CALL fail(ErrStat, ErrMsg, 'CD_Init_Deck_Aggregate: the deck '//deck_current_source(opts)// & + ' is not supported in FAST.Farm: the shared mooring of a farm runs in STILL WATER (no '// & + 'fluid field spans the farm). Remove the '//deck_current_source(opts)); RETURN END IF ! (the standalone mixed route passes deck_current; this is a library caller without it) CALL fail(ErrStat, ErrMsg, 'CD_Init_Deck_Aggregate: the deck current OPTION is not marched by a '// & @@ -26483,8 +26501,11 @@ 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 + ! the completion line: the deck pose of every point, and the largest turn of a body or rod + REAL(wp), ALLOCATABLE :: pos_deck(:, :) + REAL(wp) :: turn_rot(3, 3), turn_max CHARACTER(1024) :: lin_msg - CHARACTER(24) :: b1 + CHARACTER(24) :: b1, b2 ErrStat = CD_DECKDRV_OK ErrMsg = '' @@ -26884,15 +26905,41 @@ SUBROUTINE solve_body_equilibrium_core(types, bodies, rod_types, rods, points, l END DO END IF END IF + ALLOCATE (pos_deck(3, SIZE(points))) + DO i = 1, SIZE(points) + pos_deck(:, i) = points(i)%pos + END DO CALL apply_state(x, bodies, rods, points) IF (only_points .OR. silent) RETURN + ! The largest move from the deck pose: of a body reference point or rod centre (the + ! translation unknowns) and of every point the objects carry (attachment points, rod ends, + ! Free/Connect points), so a pinned rod that only turns reports its End B's move. The largest + ! turn: the rotation angle |log(R R0^T)| of a body or rod from its deck orientation R0. dmax = CD_ZERO DO k = 1, nobj IF (ndof(k) >= 3) dmax = MAX(dmax, NORM2(x(off(k) + 1:off(k) + 3))) END DO + DO i = 1, SIZE(points) + dmax = MAX(dmax, NORM2(points(i)%pos - pos_deck(:, i))) + END DO + turn_max = CD_ZERO + DO k = 1, nobj + SELECT CASE (okind(k)) + CASE (OBJ_BODY) + turn_rot = MATMUL(CD_Exp_SO3(x(off(k) + 4:off(k) + 6)/lsc(k)), base_rot(:, :, k)) + CASE (OBJ_ROD) + turn_rot = MATMUL(CD_Exp_SO3((x(off(k) + 4)*e1(:, k) + x(off(k) + 5)*e2(:, k))/lsc(k)), base_rot(:, :, k)) + CASE (OBJ_PIN) + turn_rot = MATMUL(CD_Exp_SO3((x(off(k) + 1)*e1(:, k) + x(off(k) + 2)*e2(:, k))/lsc(k)), base_rot(:, :, k)) + CASE DEFAULT + CYCLE + END SELECT + turn_max = MAX(turn_max, NORM2(CD_Log_SO3(MATMUL(turn_rot, TRANSPOSE(base_rot0(:, :, k)))))) + END DO WRITE (b1, '(ES10.3)') dmax + WRITE (b2, '(ES10.3)') turn_max*45.0_wp/QUARTER_PI WRITE (output_unit, '(A)') ' Initial conditions: body/rod static equilibrium ('//TRIM(int_to_str(nobj))// & - ' object(s), largest move '//TRIM(ADJUSTL(b1))//' m) completed.' + ' object(s), largest move '//TRIM(ADJUSTL(b1))//' m, largest turn '//TRIM(ADJUSTL(b2))//' deg) completed.' CONTAINS @@ -31380,6 +31427,18 @@ PURE SUBROUTINE turbine_end_rotation(points, motion, point_id, time_index, dcm, alpha = motion%turb_alpha(:, k, time_index) END SUBROUTINE turbine_end_rotation + PURE FUNCTION deck_current_source(opts) RESULT(src) + !! The deck input that declares the deck's current, for a refusal: the CurrentMod 1 table of + !! its WaterKin file, or its current OPTION. + TYPE(DeckOptions), INTENT(IN) :: opts + CHARACTER(:), ALLOCATABLE :: src + IF (opts%has_waterkin_file .AND. opts%waterkin_current_mode == 1 .AND. opts%has_current_profile) THEN + src = 'WaterKin current table (CurrentMod 1)' + ELSE + src = 'current OPTION' + END IF + END FUNCTION deck_current_source + PURE FUNCTION turbine_end_dcm(points, opts, point_id) RESULT(dcm) !! The global-to-parent DCM, at the static start, of a line end on point point_id: on a !! TURBINES deck a Turbine point's parent is turbine J, turned by its PtfmInit rotation diff --git a/src/openfast/CableDyn_OF.f90 b/src/openfast/CableDyn_OF.f90 index c4a56e8f..595c40d3 100644 --- a/src/openfast/CableDyn_OF.f90 +++ b/src/openfast/CableDyn_OF.f90 @@ -552,6 +552,12 @@ SUBROUTINE CD_Init(InitInp, u, p, x, xd, z, other, y, m, DTcoupling, InitOut, Er REAL(wp) :: cval, dtC, deck_dtm, dt_moor REAL(wp) :: fair_ten, fair_force(3), fair_incl, fair_decl, fair_azi, force_incl LOGICAL :: has_dtm, has_ptfm, use_extf + ! the coupling step's name on the console: the glue DT, or FAST.Farm's DT_Mooring + CHARACTER(24) :: dtc_name, dtc_short + ! the deck's WaterKin policy takes SeaState waves or current (host_seastate), or a + ! WaterKin current table (host_table); neither is still water + LOGICAL :: host_seastate, host_table + CHARACTER(16) :: host_kin REAL(wp), ALLOCATABLE :: static_cur(:,:) ! the host's steady current for the static start CHARACTER(ChanLen) :: chan_hdr, chan_unt CHARACTER(1024) :: native_root, init_note @@ -559,6 +565,7 @@ SUBROUTINE CD_Init(InitInp, u, p, x, xd, z, other, y, m, DTcoupling, InitOut, Er ErrStat = ErrID_None ErrMsg = '' + host_seastate = .FALSE. profile_requested = profile_environment_requested() IF (profile_requested) THEN CALL SYSTEM_CLOCK(prof_c0, prof_rate) @@ -663,6 +670,14 @@ SUBROUTINE CD_Init(InitInp, u, p, x, xd, z, other, y, m, DTcoupling, InitOut, Er ! endpoint motion into a lagged line interior creates nonphysical stiff-EA chatter. ! ------------------------------------------------------------------------------ dtC = REAL(DTcoupling, wp) + ! In FAST.Farm the coupling step is the farm's mooring step DT_Mooring, not a turbine's DT. + IF (nT > 0_IntKi) THEN + dtc_name = 'FAST.Farm DT_Mooring' + dtc_short = 'DT_Mooring' + ELSE + dtc_name = 'glue DT' + dtc_short = 'DT' + END IF CALL CD_Deck_Query_dtM( TRIM(InitInp%FileName), deck_dtm, has_dtm, es, em, & env_gravity=REAL(InitInp%g, wp), env_rho_water=REAL(InitInp%rhoW, wp), & env_wtrdpth=REAL(InitInp%WtrDepth, wp) ) @@ -678,25 +693,26 @@ SUBROUTINE CD_Init(InitInp, u, p, x, xd, z, other, y, m, DTcoupling, InitOut, Er ! documented implicit-solver floor for MoorDyn-migrated explicit dtM values). nsuper = MAX(1_IntKi, FLOOR(deck_dtm/dtC*(1.0_wp + 1.0e-6_wp), IntKi)) IF (deck_dtm < dtC*(1.0_wp - 1.0e-6_wp)) THEN - CALL WrScr( ' CableDyn: deck dtM = '//TRIM(Num2LStr(deck_dtm))//' s is below the glue DT = '// & - TRIM(Num2LStr(dtC))//' s; the implicit mooring step uses dtM = DT.' ) + CALL WrScr( ' CableDyn: deck dtM = '//TRIM(Num2LStr(deck_dtm))//' s is below the '// & + TRIM(dtc_name)//' = '//TRIM(Num2LStr(dtC))//' s; the implicit mooring step uses dtM = '// & + TRIM(dtc_short)//'.' ) ELSE IF (ABS(REAL(nsuper, wp)*dtC - deck_dtm) > 1.0e-6_wp*MAX(dtC, deck_dtm)) THEN CALL SetErrStat( ErrID_Warn, 'CableDyn mooring module: deck dtM = '//TRIM(Num2LStr(deck_dtm))// & - ' s is not an integer multiple of the glue DT = '//TRIM(Num2LStr(dtC))// & + ' s is not an integer multiple of the '//TRIM(dtc_name)//' = '//TRIM(Num2LStr(dtC))// & ' s; using dtM = '//TRIM(Num2LStr(REAL(nsuper, wp)*dtC))//' s ('// & - TRIM(Num2LStr(nsuper))//' x DT), the largest multiple not exceeding the '// & - 'requested step. Set dtM to a multiple of DT to silence this warning.', & - ErrStat, ErrMsg, RoutineName ) + TRIM(Num2LStr(nsuper))//' x '//TRIM(dtc_short)//'), the largest multiple not '// & + 'exceeding the requested step. Set dtM to a multiple of '//TRIM(dtc_short)// & + ' to silence this warning.', ErrStat, ErrMsg, RoutineName ) CALL WrScr( ' WARNING: CableDyn deck dtM = '//TRIM(Num2LStr(deck_dtm))//' s changed to '// & TRIM(Num2LStr(REAL(nsuper, wp)*dtC))//' s ('//TRIM(Num2LStr(nsuper))// & - ' x glue DT = '//TRIM(Num2LStr(dtC))//' s).' ) + ' x '//TRIM(dtc_name)//' = '//TRIM(Num2LStr(dtC))//' s).' ) END IF ELSE 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))//')' ) + ' x '//TRIM(dtc_name)//TRIM(MERGE('; deck dtM ', '; the default', has_dtm))//')' ) ! 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 -- ! and the held (zero-order-hold) loads -- up to dtM stale at TMax, silently. Fail @@ -707,7 +723,8 @@ SUBROUTINE CD_Init(InitInp, u, p, x, xd, z, other, y, m, DTcoupling, InitOut, Er MOD(nglue, nsuper) /= 0_IntKi) THEN CALL SetErrStat( ErrID_Fatal, 'CableDyn mooring module: TMax = '//TRIM(Num2LStr(InitInp%Tmax))// & ' s is not a whole number of CableDyn steps (dtM = '//TRIM(Num2LStr(dt_moor))// & - ' s = '//TRIM(Num2LStr(nsuper))//' x DT): the run would end inside a mooring '// & + ' s = '//TRIM(Num2LStr(nsuper))//' x '//TRIM(dtc_short)//'): the run would end '// & + 'inside a mooring '// & 'interval with the committed state up to dtM stale. Choose TMax as a multiple '// & 'of dtM, or set the deck OPTIONS dtM accordingly.', ErrStat, ErrMsg, RoutineName ) RETURN @@ -930,8 +947,32 @@ SUBROUTINE CD_Init(InitInp, u, p, x, xd, z, other, y, m, DTcoupling, InitOut, Er ErrStat, ErrMsg, RoutineName ) RETURN END IF - CALL WrScr( ' CableDyn: SeaState wave/current kinematics drive the mooring hydro ('// & - TRIM(Num2LStr(Inst(id)%nfluid))//' sampling nodes, refreshed every mooring step).' ) + ! Say what the lines take, as the deck's WaterKin policy decides it (sample_wavefield): an + ! explicit WaterKin file may take no SeaState component (WaveKinMod 0, CurrentMod 0), and its + ! CurrentMod 1 table gives the current itself. + host_seastate = Inst(id)%agg%host_wave_enabled .OR. Inst(id)%agg%host_current_enabled + host_table = ALLOCATED(Inst(id)%agg%host_current_profile_z) + IF (Inst(id)%agg%host_wave_enabled .AND. Inst(id)%agg%host_current_enabled) THEN + host_kin = 'wave/current' + ELSE IF (Inst(id)%agg%host_wave_enabled) THEN + host_kin = 'wave' + ELSE + host_kin = 'current' + END IF + IF (host_seastate .AND. host_table) THEN + CALL WrScr( ' CableDyn: SeaState '//TRIM(host_kin)//' kinematics drive the mooring hydro ('// & + TRIM(Num2LStr(Inst(id)%nfluid))//' sampling nodes, refreshed every mooring step); '// & + 'the WaterKin current table gives the current.' ) + ELSE IF (host_seastate) THEN + CALL WrScr( ' CableDyn: SeaState '//TRIM(host_kin)//' kinematics drive the mooring hydro ('// & + TRIM(Num2LStr(Inst(id)%nfluid))//' sampling nodes, refreshed every mooring step).' ) + ELSE IF (host_table) THEN + CALL WrScr( ' CableDyn: the WaterKin current table gives the mooring lines their current; '// & + 'no SeaState kinematics are sampled (WaterKin WaveKinMod 0).' ) + ELSE + CALL WrScr( ' CableDyn: the WaterKin file takes no SeaState waves or current (WaveKinMod 0, '// & + 'CurrentMod 0): the mooring lines are in still water.' ) + END IF ! Seed the held fields at t = 0 (the static-IC positions): with supercycling ! (nsuper > 1) the first mooring advance happens only at the END of the first ! interval, and every CalcOutput before it would otherwise serve loads from the @@ -1297,10 +1338,11 @@ SUBROUTINE CD_Init(InitInp, u, p, x, xd, z, other, y, m, DTcoupling, InitOut, Er TRIM(Num2LStr(npoints))//' point(s), '//TRIM(Num2LStr(nsections))//' section(s) [EI=0: '// & TRIM(Num2LStr(nei0))//', finite-EI: '//TRIM(Num2LStr(nfinite))//'].' ) CALL WrScr( ' Initial conditions: Newton static equilibrium with load continuation completed.' ) - IF (use_extf) THEN + IF (use_extf .AND. host_seastate) THEN ! The equilibrium is solved at zero SeaState fields and the SeaState kinematics act ! from t = 0, so the t = 0 outputs below differ from these equilibrium values by - ! the hydrodynamic load of the t = 0 kinematics on the line end nodes. + ! the hydrodynamic load of the t = 0 kinematics on the line end nodes (none when the + ! WaterKin policy takes no SeaState component). CALL WrScr( ' Line results below are at this equilibrium; SeaState kinematics act from t = 0.' ) END IF CALL WrScr( ' Fairlead convention: force is on End A toward End B; inclinations are signed below horizontal.' ) diff --git a/tests/data/msg_pinned_rod_turn.dat b/tests/data/msg_pinned_rod_turn.dat new file mode 100644 index 00000000..6b871001 --- /dev/null +++ b/tests/data/msg_pinned_rod_turn.dat @@ -0,0 +1,36 @@ +--------------------- CableDyn Input File ------------------------------------ +message test: a Pinned rod that its line turns at the static start (bodyIC static) +-- Rod 1 hangs from a fixed pin at End A (0, 0, -10) to End B (0, 0, -30); the rope from End B to +-- the anchor at (80, 0, -60) pulls it aside, so the static solve turns the rod about its pin and +-- moves End B while End A stays put. The completion line reports both the move and the turn. +--------------------- 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) (-) (-) (-) (-) +rope 0.10 20.0 1.0e8 -0.8 0.0 1.2 0.05 1.0 0.0 +--------------------- ROD TYPES ---------------------------------------- +Name Diam Mass Cd Ca CdEnd CaEnd +(-) (m) (kg/m) (-) (-) (-) (-) +arm 0.6 400.0 1.0 1.0 0.0 0.0 +--------------------- RODS --------------------------------------------- +ID RodType Attachment XA YA ZA XB YB ZB NumSegs Outputs +(-) (-) (-) (m) (m) (m) (m) (m) (m) (-) (-) +1 arm Pinned 0.0 0.0 -10.0 0.0 0.0 -30.0 6 - +--------------------- POINTS ------------------------------------------- +ID Type X Y Z Mass Vol CdA Ca +(-) (-) (m) (m) (m) (kg) (m^3) (m^2) (-) +1 Fixed 80.0 0.0 -60.0 0 0 0 0 +--------------------- LINES -------------------------------------------- +ID LineType AttachA AttachB UnstrLen NumSegs Outputs +(-) (-) (-) (-) (m) (-) (-) +1 rope R1B 1 88.0 20 - +--------------------- OPTIONS ------------------------------------------ +9.80665 g +1025.0 rhoW +100.0 WtrDpth +0.01 dtM +0.02 TMax +static bodyIC +--------------------- OUTPUTS ------------------------------------------ +"Rod1Ry" +"FairTen1" +--------------------- need this line ----------------------------------- diff --git a/tests/test_mixed_route_torsion.f90 b/tests/test_mixed_route_torsion.f90 index 328f669e..75279167 100644 --- a/tests/test_mixed_route_torsion.f90 +++ b/tests/test_mixed_route_torsion.f90 @@ -54,7 +54,9 @@ !> of the range from its own). The aggregate library marched with the standalone controls, as !> in gate 1, reproduces the cable-only run's cable channels to the printed precision. Each !> turbine's yaw and roll turn the clamped end on it (End A on turbine 1, End B on turbine 2), -!> so the end bend moments and the torque carry each end's own turbine. +!> so the end bend moments and the torque carry each end's own turbine. The torsion note of +!> the cable-only run gives the line's total twist (Twist1 at t = 0, to 1e-5 of it), which the +!> turbines' PtfmInit yaws turn away from the 30 deg Pretwist(B) - Pretwist(A) it also names. PROGRAM test_mixed_route_torsion USE CableDyn_Precision, ONLY: wp USE CableDyn_OpenFAST_Aggregate, ONLY: CD_AGG_ModuleType, CD_AGG_Init_From_Deck, CD_AGG_NMovingPoints, & @@ -378,6 +380,27 @@ LOGICAL FUNCTION log_has(root, text) RESULT(found) CLOSE (u) END FUNCTION log_has + REAL(wp) FUNCTION log_value(root, needle) RESULT(v) + !! The number after needle on the first line of .log that carries it (HUGE when none). + CHARACTER(*), INTENT(IN) :: root, needle + CHARACTER(4096) :: line + INTEGER :: u, ios, k + v = HUGE(1.0_wp) + OPEN (NEWUNIT=u, FILE=root//'.log', STATUS='OLD', ACTION='READ', IOSTAT=ios) + IF (ios /= 0) RETURN + DO + READ (u, '(A)', IOSTAT=ios) line + IF (ios /= 0) EXIT + k = INDEX(line, needle) + IF (k > 0) THEN + READ (line(k + LEN(needle):), *, IOSTAT=ios) v + IF (ios /= 0) v = HUGE(1.0_wp) + EXIT + END IF + END DO + CLOSE (u) + END FUNCTION log_value + SUBROUTINE read_out(path, names, vals, nrow) !! The channel names and rows of a driver .out file (Time first). CHARACTER(*), INTENT(IN) :: path @@ -1071,6 +1094,18 @@ SUBROUTINE check_turbines() e_leg = MAX(e_leg, e) END DO CALL require(e_turb <= TURB_TOL, '9: the cable agrees with the cable-only deck within the coupled Newton controls') + ! the torsion note: the total twist (Twist1), not the Pretwist difference alone + BLOCK + REAL(wp) :: tw_note, tw_out, pre_note + tw_note = log_value('tmrt_turb_c', 'total twist Twist1 =') + pre_note = log_value('tmrt_turb_c', 'Pretwist(B) - Pretwist(A) =') + tw_out = vc(1, col_of(nc, 'Twist1')) + WRITE (*, '(A,3F12.6,A)') ' 9 TURBINES torsion note: total twist, Twist1 at t = 0, pretwist ', tw_note, & + tw_out, pre_note, ' deg' + CALL require(ABS(tw_note - tw_out) <= 1.0e-5_wp*ABS(tw_out), '9: the torsion note gives the total twist Twist1') + CALL require(ABS(pre_note - 30.0_wp) <= 1.0e-9_wp .AND. ABS(tw_note - 30.0_wp) > 1.0_wp, & + '9: the note names the pretwist and a total twist that carries the end frames'' turn') + END BLOCK CALL require(e_leg <= LOAD_TOL, '9: the chain tensions agree with the legs-only deck') CALL march_turbines(nc, vc, rc) END SUBROUTINE check_turbines diff --git a/tests/test_openfast_aggregate.f90 b/tests/test_openfast_aggregate.f90 index 7ffb2192..90d71e7a 100644 --- a/tests/test_openfast_aggregate.f90 +++ b/tests/test_openfast_aggregate.f90 @@ -2727,6 +2727,13 @@ SUBROUTINE case_farm_partition() turbine_ref_pos=refpos, forbid_deck_ambient=.TRUE.) CALL require(es /= CD_AGG_OK .AND. INDEX(em, 'STILL WATER') > 0, & 'farm: forbid_deck_ambient rejects a deck current OPTION') + ! a WaterKin CurrentMod 1 table is named as such, not as a current OPTION the deck lacks + CALL write_farm_deck('agg_farm_wk.dat', plain_coupled=.FALSE., ambient='waterkin') + CALL CD_AGG_Init_From_Deck(agg, 'agg_farm_wk.dat', DT, es, em, n_turbines=2, & + turbine_ref_pos=refpos, forbid_deck_ambient=.TRUE., external_fluid=.FALSE.) + CALL require(es /= CD_AGG_OK .AND. INDEX(em, 'WaterKin current table') > 0 .AND. & + INDEX(em, 'current OPTION') == 0, 'farm: a WaterKin current table is refused by its name: '// & + TRIM(em)) CALL write_farm_deck('agg_farm_wav.dat', plain_coupled=.FALSE., ambient='waves') CALL CD_AGG_Init_From_Deck(agg, 'agg_farm_wav.dat', DT, es, em, n_turbines=2, & turbine_ref_pos=refpos, forbid_deck_ambient=.TRUE.) @@ -4100,6 +4107,34 @@ SUBROUTINE write_farm_deck(path, plain_coupled, y_shift, stock_order, ambient, c WRITE (u, '(A)') 'uniform 0.5 0.0 0.0 current' CASE ('waves') WRITE (u, '(A)') 'airy 2.0 8.0 0.0 waves' + CASE ('waterkin') + ! a WaterKin file without waves and with a CurrentMod 1 depth table + WRITE (u, '(A)') 'agg_farm_wk_kin.dat WaterKin' + BLOCK + INTEGER :: uk + OPEN (NEWUNIT=uk, FILE='agg_farm_wk_kin.dat', STATUS='REPLACE', ACTION='WRITE') + WRITE (uk, '(A)') 'WaterKin file: no waves, a current table' + WRITE (uk, '(A)') '-' + WRITE (uk, '(A)') '--- WAVES ---' + WRITE (uk, '(A)') '0 WaveKinMod' + WRITE (uk, '(A)') '"" WaveKinFile' + WRITE (uk, '(A)') '0.0 dtWave' + WRITE (uk, '(A)') '0.0 WaveDir' + WRITE (uk, '(A)') '1 X grid type' + WRITE (uk, '(A)') '0' + WRITE (uk, '(A)') '1 Y grid type' + WRITE (uk, '(A)') '0' + WRITE (uk, '(A)') '1 Z grid type' + WRITE (uk, '(A)') '0' + WRITE (uk, '(A)') '--- CURRENT ---' + WRITE (uk, '(A)') '1 CurrentMod' + WRITE (uk, '(A)') 'z-depth x-current y-current' + WRITE (uk, '(A)') '(m) (m/s) (m/s)' + WRITE (uk, '(A)') '0.0 0.3 0.0' + WRITE (uk, '(A)') '-200.0 0.1 0.0' + WRITE (uk, '(A)') '--- need this line ---' + CLOSE (uk) + END BLOCK END SELECT END IF WRITE (u, '(A)') '--- need this line ---'