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

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 14 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,20 @@ All notable changes to CableDyn are recorded in this file. The format follows
The r-test `MD_Shared` SeaState file of the OpenFAST tutorial, which covers only the platform, now stops
until its grid is enlarged as the tutorial describes. Runs that pass the checks give the same results,
bit for bit.
- In OpenFAST, CableDyn evaluates its output channels only at the steps OpenFAST writes (`DT_Out`, from
`TStart`) and when it linearizes, as AeroDyn and BeamDyn can, where it evaluated them at every output
call of every step (two to four per step in the tightly coupled solver). The loads are evaluated as
before. On the IEA-15 MW lazy-wave cable deck with 17 stations and torsion channels at DT = 0.025 s,
`DT_Out` = 0.05 s, the channels cost 12.6 s where they cost 53.1 s and the run 10 % less CPU time; the
`.out` and `.CD.out` are the same as before, bit for bit, also with the mooring supercycled and after a
restart from a checkpoint. This needs the OpenFAST integration patches of this release.
- The nodal twist of a finite-EI line costs less. Its residual no longer forms the Hessian of the
torque-tension coupling term, which only the tangent uses. An element's reference twist is taken
from the last evaluation when every input it reads is the same, bit for bit; in OpenFAST every output
call moves only the fairlead end, so all elements but the end ones are taken over. On the IEA-15 MW
lazy-wave cable deck (237 elements, torsion, DT = 0.0125 s, 400 s, operating rotor) the run takes
9.00 min of CPU time where it took 9.79 min after the change above (11.23 min before both); the
`.out` and `.CD.out` are the same, bit for bit.

- In OpenFAST, the lines on the SeaState grid route take the wave and current kinematics at their
positions at the sample time (the end of the CableDyn step): their committed positions advanced by
Expand Down
32 changes: 17 additions & 15 deletions integration/openfast/patches/0009-fast-funcs.patch
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
diff --git a/modules/openfast-library/src/FAST_Funcs.f90 b/modules/openfast-library/src/FAST_Funcs.f90
index ff46ce942..46e7a09e1 100644
index ff46ce942..323baf77c 100644
--- a/modules/openfast-library/src/FAST_Funcs.f90
+++ b/modules/openfast-library/src/FAST_Funcs.f90
@@ -104,6 +104,13 @@ use MoorDyn, only: MD_JacobianPInput, &
Expand Down Expand Up @@ -60,19 +60,22 @@ index ff46ce942..46e7a09e1 100644
case (Module_Orca)
call FAST_CopyStates(ModData, T, STATE_CURR, STATE_PRED, MESH_UPDATECOPY, ErrStat2, ErrMsg2)
if (Failed()) return
@@ -827,6 +857,11 @@ subroutine FAST_CalcOutput(ModData, Mappings, ThisTime, iInput, iState, T, ErrSt
@@ -827,6 +857,14 @@ subroutine FAST_CalcOutput(ModData, Mappings, ThisTime, iInput, iState, T, ErrSt
T%MD%x(iState), T%MD%xd(iState), T%MD%z(iState), T%MD%OtherSt(iState), &
T%MD%y, T%MD%m, ErrStat2, ErrMsg2)

+ case (Module_CD)
+ ! CableDyn evaluates its deck channels only when this step's outputs are written (or the
+ ! glue linearizes); its loads are evaluated on every call.
+ call CD_CalcOutput(ThisTime, T%CD%Input(iInput), T%CD%p, &
+ T%CD%x(iState), T%CD%xd(iState), T%CD%z(iState), T%CD%OtherSt(iState), &
+ T%CD%y, T%CD%m, ErrStat2, ErrMsg2)
+ T%CD%y, T%CD%m, ErrStat2, ErrMsg2, &
+ CalcWriteOutput=CalcWriteOutputLoc .and. (T%y_FAST%WriteThisStep .or. T%p_FAST%Linearize))
+
case (Module_Orca)
call Orca_CalcOutput(ThisTime, T%Orca%Input(iInput), T%Orca%p, &
T%Orca%x(iState), T%Orca%xd(iState), T%Orca%z(iState), T%Orca%OtherSt(iState), &
@@ -937,6 +972,8 @@ subroutine FAST_GetOP(ModData, ThisTime, iInput, iState, T, ErrStat, ErrMsg, &
@@ -937,6 +975,8 @@ subroutine FAST_GetOP(ModData, ThisTime, iInput, iState, T, ErrStat, ErrMsg, &
call MAP_VarsPackInput(ModData%Vars, T%MAP%Input(iInput), u_op)
case (Module_MD)
call MD_VarsPackInput(ModData%Vars, T%MD%Input(iInput), u_op)
Expand All @@ -81,7 +84,7 @@ index ff46ce942..46e7a09e1 100644
case (Module_ExtInfw)
! call ExtInfw_VarsPackInput(ModData%Vars, T%ExtInfw%Input(iIndex), u_op)
case (Module_Orca)
@@ -994,6 +1031,8 @@ subroutine FAST_GetOP(ModData, ThisTime, iInput, iState, T, ErrStat, ErrMsg, &
@@ -994,6 +1034,8 @@ subroutine FAST_GetOP(ModData, ThisTime, iInput, iState, T, ErrStat, ErrMsg, &
call MAP_VarsPackOutput(ModData%Vars, T%MAP%y, y_op)
case (Module_MD)
call MD_VarsPackOutput(ModData%Vars, T%MD%y, y_op)
Expand All @@ -90,7 +93,7 @@ index ff46ce942..46e7a09e1 100644
case (Module_ExtInfw)
call ExtInfw_VarsPackOutput(ModData%Vars, T%ExtInfw%y, y_op)
case (Module_Orca)
@@ -1050,6 +1089,8 @@ subroutine FAST_GetOP(ModData, ThisTime, iInput, iState, T, ErrStat, ErrMsg, &
@@ -1050,6 +1092,8 @@ subroutine FAST_GetOP(ModData, ThisTime, iInput, iState, T, ErrStat, ErrMsg, &
call MAP_VarsPackContState(ModData%Vars, T%MAP%x(iState), x_op)
case (Module_MD)
call MD_VarsPackContState(ModData%Vars, T%MD%x(iState), x_op)
Expand All @@ -99,7 +102,7 @@ index ff46ce942..46e7a09e1 100644
case (Module_ExtInfw)
! call ExtInfw_VarsPackContState(ModData%Vars, T%ExtInfw%x(StateIndex), x_op)
case (Module_Orca)
@@ -1181,6 +1222,13 @@ subroutine FAST_GetOP(ModData, ThisTime, iInput, iState, T, ErrStat, ErrMsg, &
@@ -1181,6 +1225,13 @@ subroutine FAST_GetOP(ModData, ThisTime, iInput, iState, T, ErrStat, ErrMsg, &
if (Failed()) return
call MD_VarsPackContStateDeriv(ModData%Vars, T%MD%m%dxdt_lin, dx_op)

Expand All @@ -113,7 +116,7 @@ index ff46ce942..46e7a09e1 100644
! case (Module_ExtInfw)
! call ExtInfw_VarsPackContStateDeriv(ModData%Vars, T%ExtInfw%x(StateIndex), dx_op)

@@ -1274,6 +1322,8 @@ subroutine FAST_SetOP(ModData, iInput, iState, T, ErrStat, ErrMsg, &
@@ -1274,6 +1325,8 @@ subroutine FAST_SetOP(ModData, iInput, iState, T, ErrStat, ErrMsg, &
call MAP_VarsUnpackInput(ModData%Vars, u_op, T%MAP%Input(iInput))
case (Module_MD)
call MD_VarsUnpackInput(ModData%Vars, u_op, T%MD%Input(iInput))
Expand All @@ -122,7 +125,7 @@ index ff46ce942..46e7a09e1 100644
case (Module_ExtInfw)
! call ExtInfw_VarsUnpackInput(ModData%Vu_op, ars, T%ExtInfw%Input(InputIndex))
case (Module_Orca)
@@ -1325,6 +1375,8 @@ subroutine FAST_SetOP(ModData, iInput, iState, T, ErrStat, ErrMsg, &
@@ -1325,6 +1378,8 @@ subroutine FAST_SetOP(ModData, iInput, iState, T, ErrStat, ErrMsg, &
call MAP_VarsUnpackContState(ModData%Vars, x_op, T%MAP%x(iState))
case (Module_MD)
call MD_VarsUnpackContState(ModData%Vars, x_op, T%MD%x(iState))
Expand All @@ -131,7 +134,7 @@ index ff46ce942..46e7a09e1 100644
case (Module_ExtInfw)
! call ExtInfw_VarsUnpackContState(ModData%Vars, x_op, T%ExtInfw%x(StateIndex))
case (Module_Orca)
@@ -1426,6 +1478,11 @@ subroutine FAST_JacobianPInput(ModData, ThisTime, iInput, iState, T, ErrStat, Er
@@ -1426,6 +1481,11 @@ subroutine FAST_JacobianPInput(ModData, ThisTime, iInput, iState, T, ErrStat, Er
T%MD%z(iState), T%MD%OtherSt(iState), T%MD%y, T%MD%m, ErrStat2, ErrMsg2, &
dYdu=dYdu, dXdu=dXdu)

Expand All @@ -143,7 +146,7 @@ index ff46ce942..46e7a09e1 100644
case (Module_SD)
call SD_JacobianPInput(ModData%Vars, ThisTime, T%SD%Input(iInput), T%SD%p, T%SD%x(iState), T%SD%xd(iState), &
T%SD%z(iState), T%SD%OtherSt(iState), T%SD%y, T%SD%m, ErrStat2, ErrMsg2, &
@@ -1545,6 +1602,13 @@ subroutine FAST_JacobianPContState(ModData, ThisTime, iInput, iState, T, ErrStat
@@ -1545,6 +1605,13 @@ subroutine FAST_JacobianPContState(ModData, ThisTime, iInput, iState, T, ErrStat
T%MD%y, T%MD%m, ErrStat2, ErrMsg2, &
dYdx=dYdx, dXdx=dXdx)

Expand All @@ -157,7 +160,7 @@ index ff46ce942..46e7a09e1 100644
case (Module_SD)
call SD_JacobianPContState(ModData%Vars, ThisTime, T%SD%Input(iInput), T%SD%p, &
T%SD%x(iState), T%SD%xd(iState), &
@@ -1715,6 +1779,13 @@ subroutine FAST_CopyStates(ModData, T, iSrc, iDst, CtrlCode, ErrStat, ErrMsg)
@@ -1715,6 +1782,13 @@ subroutine FAST_CopyStates(ModData, T, iSrc, iDst, CtrlCode, ErrStat, ErrMsg)
call MD_CopyConstrState(T%MD%z(iSrc), T%MD%z(iDst), CtrlCode, ErrStat2, ErrMsg2); if (Failed()) return
call MD_CopyOtherState(T%MD%OtherSt(iSrc), T%MD%OtherSt(iDst), CtrlCode, ErrStat2, ErrMsg2); if (Failed()) return

Expand All @@ -171,7 +174,7 @@ index ff46ce942..46e7a09e1 100644
case (Module_Orca)

call Orca_CopyContState(T%Orca%x(iSrc), T%Orca%x(iDst), CtrlCode, ErrStat2, ErrMsg2); if (Failed()) return
@@ -1842,6 +1913,9 @@ subroutine FAST_CopyInput(ModData, T, iSrc, iDst, CtrlCode, ErrStat, ErrMsg)
@@ -1842,6 +1916,9 @@ subroutine FAST_CopyInput(ModData, T, iSrc, iDst, CtrlCode, ErrStat, ErrMsg)
case (Module_MD)
call MD_CopyInput(T%MD%Input(iSrc), T%MD%Input(iDst), CtrlCode, ErrStat2, ErrMsg2)

Expand All @@ -181,7 +184,7 @@ index ff46ce942..46e7a09e1 100644
! case (Module_ExtInfw)

case (Module_Orca)
@@ -2004,6 +2078,10 @@ subroutine FAST_ModEnd(Mods, T, ErrStat, ErrMsg)
@@ -2004,6 +2081,10 @@ subroutine FAST_ModEnd(Mods, T, ErrStat, ErrMsg)
call MD_End(T%MD%Input(1), T%MD%p, T%MD%x(STATE_CURR), T%MD%xd(STATE_CURR), T%MD%z(STATE_CURR), &
T%MD%OtherSt(STATE_CURR), T%MD%y, T%MD%m, ErrStat2, ErrMsg2)

Expand All @@ -192,4 +195,3 @@ index ff46ce942..46e7a09e1 100644
case (Module_Orca)
call Orca_End(T%Orca%Input(1), T%Orca%p, T%Orca%x(STATE_CURR), T%Orca%xd(STATE_CURR), &
T%Orca%z(STATE_CURR), T%Orca%OtherSt(STATE_CURR), T%Orca%y, T%Orca%m, ErrStat2, ErrMsg2)

62 changes: 60 additions & 2 deletions src/CableDyn_HermiteCableDynamic.f90
Original file line number Diff line number Diff line change
Expand Up @@ -195,6 +195,9 @@ MODULE CableDyn_HermiteCableDynamic
INTEGER, PARAMETER :: KL_D = 11, KU_D = 11
! Half-bandwidth of the nodal-twist tangent in 7-DOF-per-node order ([r, m, phi] per node).
INTEGER, PARAMETER :: KB7 = 13
! Inputs of the twist_reference memo per element (tw_mk): 12 DOFs, 2 unit tangents, tw_beta,
! l0 and the coupling.
INTEGER, PARAMETER :: TW_MEMO_KEY = 21
INTEGER, PARAMETER :: LDAB_D = 2*KL_D + KU_D + 1
! First row of the stored band. Rows 1..KL_D are the factorization's fill-in space: every
! band array is allocated with them zero and only an LU factor (ws_Keffb) ever writes them,
Expand Down Expand Up @@ -652,6 +655,16 @@ MODULE CableDyn_HermiteCableDynamic
! and whose unit node tangents are the reference's, bit for bit, keeps its reference twist.
REAL(wp), ALLOCATABLE :: tw_sq(:), tw_rq(:)
LOGICAL :: tw_rq_ok = .FALSE.
! A memo of twist_reference without the Hessian at an element away from a rigid end, for
! assemble_twist: tw_mk(:, e) the inputs it reads there (the element's 12 DOFs, the reference
! unit tangents of its two nodes, tw_beta, l0, the coupling), tw_mqo(e) the quadrature order,
! tw_mv(:, e) the results (rho, beta, g). An assembly takes the results only when every input
! is bitwise the memo's (tw_mo), so it can never be stale. A host's frame-only transfer
! (CD_HermiteCable_Dyn_Set_Torsion_Frames, every OpenFAST output call) assembles every element
! at the committed shape; all but the elements at the moved end nodes then hit.
REAL(wp), ALLOCATABLE :: tw_mk(:, :), tw_mv(:, :)
INTEGER, ALLOCATABLE :: tw_mqo(:)
LOGICAL, ALLOCATABLE :: tw_mo(:)
! tw_som(:, k): the angular velocity of end frame k over the running step, log(R_{n+1}
! R_n^T)/dt (R = [d n d x n]); tw_om: that of the committed step. A turning frame twists
! the element at a rigid end through rho, and the torsional damping takes that rate.
Expand Down Expand Up @@ -11115,7 +11128,8 @@ SUBROUTINE twist_reference(model, e, q_cfg, ends, want_hess, rho, beta, g, h, Er
cpl = CD_ZERO
IF (ALLOCATED(model%torsion%couple)) cpl = model%torsion%couple(e)
IF (ABS(cpl) > CD_ZERO) THEN
CALL CD_HermiteTorsion_Stretch_Derivatives(qe, model%l0(e), ls, gs, hs, model%torsion%quadrature_order)
CALL CD_HermiteTorsion_Stretch_Derivatives(qe, model%l0(e), ls, gs, hs, model%torsion%quadrature_order, &
want_hess=want_hess)
rho = rho + cpl*(ls - model%l0(e))
g = g + cpl*gs
IF (want_hess) h = h + cpl*hs
Expand Down Expand Up @@ -11252,7 +11266,8 @@ SUBROUTINE assemble_twist(model, q_cfg, v_cfg, want_residual, want_tangent, R, K
! length-rate share of the damping (active line control): l0_dot/l0, the element's tangent
! handles (m in the 12-DOF layout, the r slots zero) and the angle stiffness it leaves
REAL(wp) :: rr, mv(12), gmv(12), kel_t, cpl
LOGICAL :: ctrl_rate, one_node
LOGICAL :: ctrl_rate, one_node, memo
REAL(wp) :: key(TW_MEMO_KEY)
INTEGER :: e, iend, node, b, i, j, es, e_lo, e_hi
CHARACTER(1024) :: em

Expand Down Expand Up @@ -11288,8 +11303,31 @@ SUBROUTINE assemble_twist(model, q_cfg, v_cfg, want_residual, want_tangent, R, K
! an element at a rigid end twists through rho as its end frame turns: its damping rate
! takes d rho/dw . omega of the frames (the tangent keeps the rate's q-dependence through
! g only, as the frame's share of it is of order omega dt)
memo = .NOT. want_tangent .AND. ALLOCATED(model%tw_mo) .AND. &
.NOT. ((e == 1 .AND. model%tw_rigid(1)) .OR. (e == model%ne .AND. model%tw_rigid(2)))
IF (turning .AND. kd > CD_ZERO .AND. (e == 1 .OR. e == model%ne)) THEN
CALL twist_reference(model, e, q_cfg, ends, want_tangent, rho, beta, g, h, es, em, end_w=ew)
ELSE IF (memo) THEN
! (twist_reference reads, away from a rigid end, exactly the inputs of the key)
CALL tw_memo_inputs(model, e, q_cfg, key)
IF (model%tw_mo(e) .AND. model%tw_mqo(e) == model%torsion%quadrature_order .AND. &
ALL(bits_equal(key, model%tw_mk(:, e)))) THEN
rho = model%tw_mv(1, e)
beta = model%tw_mv(2, e)
g = model%tw_mv(3:14, e)
es = CD_HCDYN_OK
ELSE
CALL twist_reference(model, e, q_cfg, ends, .FALSE., rho, beta, g, h, es, em)
model%tw_mo(e) = es == CD_HCDYN_OK
IF (model%tw_mo(e)) THEN
model%tw_mk(:, e) = key
model%tw_mqo(e) = model%torsion%quadrature_order
model%tw_mv(1, e) = rho
model%tw_mv(2, e) = beta
model%tw_mv(3:14, e) = g
END IF
END IF
ew = CD_ZERO
ELSE
CALL twist_reference(model, e, q_cfg, ends, want_tangent, rho, beta, g, h, es, em)
ew = CD_ZERO
Expand Down Expand Up @@ -11573,8 +11611,10 @@ SUBROUTINE tw_init(model, mt, ErrStat, ErrMsg)
ALLOCATE (model%tw_eg(12, ne), model%tw_ehv(12, ne), model%tw_ek(ne), model%tw_ed(ne), model%tw_me(ne))
ALLOCATE (model%tw_K7(3*KB7 + 1, 7*nn), model%tw_x7(7*nn), model%tw_ipiv(7*nn))
ALLOCATE (model%tw_su(3, nn), model%tw_stn(3, nn), model%tw_sbeta(ne), model%tw_sq(6*nn), model%tw_rq(6*nn))
ALLOCATE (model%tw_mk(TW_MEMO_KEY, ne), model%tw_mv(14, ne), model%tw_mqo(ne), model%tw_mo(ne))
ALLOCATE (model%ws_recovery_tw(tw_pack_size(model)))
END IF
model%tw_mo = .FALSE.
model%tw_pn = CD_ZERO; model%tw_wn = CD_ZERO; model%tw_an = CD_ZERO; model%tw_pk = CD_ZERO
model%tw_wk = CD_ZERO; model%tw_ak = CD_ZERO; model%tw_ptrial = CD_ZERO; model%tw_dp = CD_ZERO
model%tw_G = CD_ZERO; model%tw_Gt = CD_ZERO; model%tw_Rk = CD_ZERO; model%tw_Rt = CD_ZERO
Expand Down Expand Up @@ -11730,12 +11770,30 @@ SUBROUTINE tw_release(model)
IF (ALLOCATED(model%tw_K7)) DEALLOCATE (model%tw_K7, model%tw_x7, model%tw_ipiv)
IF (ALLOCATED(model%tw_su)) DEALLOCATE (model%tw_su, model%tw_stn, model%tw_sbeta)
IF (ALLOCATED(model%tw_sq)) DEALLOCATE (model%tw_sq, model%tw_rq)
IF (ALLOCATED(model%tw_mk)) DEALLOCATE (model%tw_mk, model%tw_mv, model%tw_mqo, model%tw_mo)
model%tw_rq_ok = .FALSE.
IF (ALLOCATED(model%ws_recovery_tw)) DEALLOCATE (model%ws_recovery_tw)
IF (ALLOCATED(model%snap_tw)) DEALLOCATE (model%snap_tw)
IF (ALLOCATED(model%snap_tw_fcR)) DEALLOCATE (model%snap_tw_fcR)
END SUBROUTINE tw_release

PURE SUBROUTINE tw_memo_inputs(model, e, q_cfg, key)
!! The inputs twist_reference reads at an element e away from a rigid end (see tw_mk): the
!! element's 12 DOFs of q_cfg, the reference unit tangents of its nodes, tw_beta(e), l0(e)
!! and the coupling (zero when there is none, as twist_reference takes it).
TYPE(CD_HermiteCableDynType), INTENT(IN) :: model
INTEGER, INTENT(IN) :: e
REAL(wp), INTENT(IN) :: q_cfg(:)
REAL(wp), INTENT(OUT) :: key(TW_MEMO_KEY)
key(1:12) = q_cfg(6*e - 5:6*e + 6)
key(13:15) = model%tw_tn(:, e)
key(16:18) = model%tw_tn(:, e + 1)
key(19) = model%tw_beta(e)
key(20) = model%l0(e)
key(21) = CD_ZERO
IF (ALLOCATED(model%torsion%couple)) key(21) = model%torsion%couple(e)
END SUBROUTINE tw_memo_inputs

SUBROUTINE tw_advance_reference(model, q_new, ends_new, ErrStat, ErrMsg)
!! The twist reference at q_new with the frames ends_new, into the commit scratch: the
!! reference twists and end-frame references (the step's own formulas, so the committed
Expand Down
10 changes: 8 additions & 2 deletions src/CableDyn_HermiteTorsion.f90
Original file line number Diff line number Diff line change
Expand Up @@ -1641,15 +1641,21 @@ PURE REAL(wp) FUNCTION CD_HermiteTorsion_Element_Stretch(qe, L, quadrature_order
CALL element_stretch(qe, L, order, .FALSE., ls, g, h)
END FUNCTION CD_HermiteTorsion_Element_Stretch

PURE SUBROUTINE CD_HermiteTorsion_Stretch_Derivatives(qe, L, ls, grad, hess, quadrature_order)
PURE SUBROUTINE CD_HermiteTorsion_Stretch_Derivatives(qe, L, ls, grad, hess, quadrature_order, want_hess)
!! CD_HermiteTorsion_Element_Stretch with its gradient and Hessian over the 12 DOFs.
!! want_hess = .FALSE. leaves the Hessian zero (the residual needs the gradient alone); ls and
!! grad are the same either way.
REAL(wp), INTENT(IN) :: qe(12), L
REAL(wp), INTENT(OUT) :: ls, grad(12), hess(12, 12)
INTEGER, INTENT(IN), OPTIONAL :: quadrature_order
LOGICAL, INTENT(IN), OPTIONAL :: want_hess
INTEGER :: order
LOGICAL :: hs
order = NG_DEFAULT
IF (PRESENT(quadrature_order)) order = quadrature_order
CALL element_stretch(qe, L, order, .TRUE., ls, grad, hess)
hs = .TRUE.
IF (PRESENT(want_hess)) hs = want_hess
CALL element_stretch(qe, L, order, hs, ls, grad, hess)
END SUBROUTINE CD_HermiteTorsion_Stretch_Derivatives

PURE SUBROUTINE element_stretch(qe, L, order, want_hess, ls, grad, hess)
Expand Down
Loading
Loading