Skip to content

Commit

Permalink
[bugfix] SrvD: fix inconsistency in initial pos/orient for StC
Browse files Browse the repository at this point in the history
The reference position, reference orientation, translational displacement, and orientation at init are now passed to SrvD for all the StC instances.  It is possible to do this with less info since some orientations could be assumed at init, but for throroughness we pass all of it to ServoDyn to use in initializing the StC instances.  This in some ways future-proofs for when arbitrary initial orientations are added to the code (if ever)
  • Loading branch information
andrew-platt committed Nov 4, 2021
1 parent d956e39 commit 03e8dd6
Show file tree
Hide file tree
Showing 12 changed files with 754 additions and 264 deletions.
8 changes: 5 additions & 3 deletions modules/elastodyn/src/ElastoDyn.f90
Original file line number Diff line number Diff line change
Expand Up @@ -250,9 +250,11 @@ SUBROUTINE ED_Init( InitInp, u, p, x, xd, z, OtherState, y, m, Interval, InitOut
InitOut%PlatformPos(2) = InitOut%PlatformPos(2) - TransMat(3,2)*p%PtfmRefzt
InitOut%PlatformPos(3) = InitOut%PlatformPos(3) - TransMat(3,3)*p%PtfmRefzt + p%PtfmRefzt

InitOut%HubHt = p%HubHt
InitOut%TwrBasePos = y%TowerLn2Mesh%Position(:,p%TwrNodes + 2)
InitOut%TwrBaseOrient = y%TowerLn2Mesh%Orientation(:,:,p%TwrNodes + 2)
InitOut%HubHt = p%HubHt
InitOut%TwrBaseRefPos = y%TowerLn2Mesh%Position(:,p%TwrNodes + 2)
InitOut%TwrBaseTransDisp = y%TowerLn2Mesh%TranslationDisp(:,p%TwrNodes + 2)
InitOut%TwrBaseRefOrient = y%TowerLn2Mesh%RefOrientation(:,:,p%TwrNodes + 2)
InitOut%TwrBaseOrient = y%TowerLn2Mesh%Orientation(:,:,p%TwrNodes + 2)
InitOut%HubRad = p%HubRad
InitOut%RotSpeed = p%RotSpeed
InitOut%isFixed_GenDOF = .not. InputFileData%GenDOF
Expand Down
4 changes: 3 additions & 1 deletion modules/elastodyn/src/ElastoDyn_Registry.txt
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,9 @@ typedef ^ InitOutputType ReKi HubHt - - - "Height of the hub" meters
typedef ^ InitOutputType ReKi BldRNodes {:} - - "Radius to analysis nodes relative to hub ( 0 < RNodes(:) < BldFlexL )"
typedef ^ InitOutputType ReKi TwrHNodes {:} - - "Location of variable-spaced tower nodes (relative to the tower rigid base height"
typedef ^ InitOutputType ReKi PlatformPos {6} - - "Initial platform position (6 DOFs)"
typedef ^ InitOutputType ReKi TwrBasePos {3} - - "initial position of the tower base (for SrvD)" m
typedef ^ InitOutputType ReKi TwrBaseRefPos {3} - - "initial position of the tower base (for SrvD)" m
typedef ^ InitOutputType R8Ki TwrBaseTransDisp {3} - - "initial displacement of the tower base (for SrvD)" m
typedef ^ InitOutputType R8Ki TwrBaseRefOrient {3}{3} - - "reference orientation of the tower base (for SrvD)"
typedef ^ InitOutputType R8Ki TwrBaseOrient {3}{3} - - "initial orientation of the tower base (for SrvD)"
typedef ^ InitOutputType ReKi HubRad - - - "Preconed hub radius (distance from the rotor apex to the blade root)" m
typedef ^ InitOutputType ReKi RotSpeed - - - "Initial or fixed rotor speed" rad/s
Expand Down
50 changes: 41 additions & 9 deletions modules/elastodyn/src/ElastoDyn_Types.f90
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,9 @@ MODULE ElastoDyn_Types
REAL(ReKi) , DIMENSION(:), ALLOCATABLE :: BldRNodes !< Radius to analysis nodes relative to hub ( 0 < RNodes(:) < BldFlexL ) [-]
REAL(ReKi) , DIMENSION(:), ALLOCATABLE :: TwrHNodes !< Location of variable-spaced tower nodes (relative to the tower rigid base height [-]
REAL(ReKi) , DIMENSION(1:6) :: PlatformPos !< Initial platform position (6 DOFs) [-]
REAL(ReKi) , DIMENSION(1:3) :: TwrBasePos !< initial position of the tower base (for SrvD) [m]
REAL(ReKi) , DIMENSION(1:3) :: TwrBaseRefPos !< initial position of the tower base (for SrvD) [m]
REAL(R8Ki) , DIMENSION(1:3) :: TwrBaseTransDisp !< initial displacement of the tower base (for SrvD) [m]
REAL(R8Ki) , DIMENSION(1:3,1:3) :: TwrBaseRefOrient !< reference orientation of the tower base (for SrvD) [-]
REAL(R8Ki) , DIMENSION(1:3,1:3) :: TwrBaseOrient !< initial orientation of the tower base (for SrvD) [-]
REAL(ReKi) :: HubRad !< Preconed hub radius (distance from the rotor apex to the blade root) [m]
REAL(ReKi) :: RotSpeed !< Initial or fixed rotor speed [rad/s]
Expand Down Expand Up @@ -1136,7 +1138,9 @@ SUBROUTINE ED_CopyInitOutput( SrcInitOutputData, DstInitOutputData, CtrlCode, Er
DstInitOutputData%TwrHNodes = SrcInitOutputData%TwrHNodes
ENDIF
DstInitOutputData%PlatformPos = SrcInitOutputData%PlatformPos
DstInitOutputData%TwrBasePos = SrcInitOutputData%TwrBasePos
DstInitOutputData%TwrBaseRefPos = SrcInitOutputData%TwrBaseRefPos
DstInitOutputData%TwrBaseTransDisp = SrcInitOutputData%TwrBaseTransDisp
DstInitOutputData%TwrBaseRefOrient = SrcInitOutputData%TwrBaseRefOrient
DstInitOutputData%TwrBaseOrient = SrcInitOutputData%TwrBaseOrient
DstInitOutputData%HubRad = SrcInitOutputData%HubRad
DstInitOutputData%RotSpeed = SrcInitOutputData%RotSpeed
Expand Down Expand Up @@ -1374,7 +1378,9 @@ SUBROUTINE ED_PackInitOutput( ReKiBuf, DbKiBuf, IntKiBuf, Indata, ErrStat, ErrMs
Re_BufSz = Re_BufSz + SIZE(InData%TwrHNodes) ! TwrHNodes
END IF
Re_BufSz = Re_BufSz + SIZE(InData%PlatformPos) ! PlatformPos
Re_BufSz = Re_BufSz + SIZE(InData%TwrBasePos) ! TwrBasePos
Re_BufSz = Re_BufSz + SIZE(InData%TwrBaseRefPos) ! TwrBaseRefPos
Db_BufSz = Db_BufSz + SIZE(InData%TwrBaseTransDisp) ! TwrBaseTransDisp
Db_BufSz = Db_BufSz + SIZE(InData%TwrBaseRefOrient) ! TwrBaseRefOrient
Db_BufSz = Db_BufSz + SIZE(InData%TwrBaseOrient) ! TwrBaseOrient
Re_BufSz = Re_BufSz + 1 ! HubRad
Re_BufSz = Re_BufSz + 1 ! RotSpeed
Expand Down Expand Up @@ -1567,10 +1573,20 @@ SUBROUTINE ED_PackInitOutput( ReKiBuf, DbKiBuf, IntKiBuf, Indata, ErrStat, ErrMs
ReKiBuf(Re_Xferred) = InData%PlatformPos(i1)
Re_Xferred = Re_Xferred + 1
END DO
DO i1 = LBOUND(InData%TwrBasePos,1), UBOUND(InData%TwrBasePos,1)
ReKiBuf(Re_Xferred) = InData%TwrBasePos(i1)
DO i1 = LBOUND(InData%TwrBaseRefPos,1), UBOUND(InData%TwrBaseRefPos,1)
ReKiBuf(Re_Xferred) = InData%TwrBaseRefPos(i1)
Re_Xferred = Re_Xferred + 1
END DO
DO i1 = LBOUND(InData%TwrBaseTransDisp,1), UBOUND(InData%TwrBaseTransDisp,1)
DbKiBuf(Db_Xferred) = InData%TwrBaseTransDisp(i1)
Db_Xferred = Db_Xferred + 1
END DO
DO i2 = LBOUND(InData%TwrBaseRefOrient,2), UBOUND(InData%TwrBaseRefOrient,2)
DO i1 = LBOUND(InData%TwrBaseRefOrient,1), UBOUND(InData%TwrBaseRefOrient,1)
DbKiBuf(Db_Xferred) = InData%TwrBaseRefOrient(i1,i2)
Db_Xferred = Db_Xferred + 1
END DO
END DO
DO i2 = LBOUND(InData%TwrBaseOrient,2), UBOUND(InData%TwrBaseOrient,2)
DO i1 = LBOUND(InData%TwrBaseOrient,1), UBOUND(InData%TwrBaseOrient,1)
DbKiBuf(Db_Xferred) = InData%TwrBaseOrient(i1,i2)
Expand Down Expand Up @@ -1889,12 +1905,28 @@ SUBROUTINE ED_UnPackInitOutput( ReKiBuf, DbKiBuf, IntKiBuf, Outdata, ErrStat, Er
OutData%PlatformPos(i1) = ReKiBuf(Re_Xferred)
Re_Xferred = Re_Xferred + 1
END DO
i1_l = LBOUND(OutData%TwrBasePos,1)
i1_u = UBOUND(OutData%TwrBasePos,1)
DO i1 = LBOUND(OutData%TwrBasePos,1), UBOUND(OutData%TwrBasePos,1)
OutData%TwrBasePos(i1) = ReKiBuf(Re_Xferred)
i1_l = LBOUND(OutData%TwrBaseRefPos,1)
i1_u = UBOUND(OutData%TwrBaseRefPos,1)
DO i1 = LBOUND(OutData%TwrBaseRefPos,1), UBOUND(OutData%TwrBaseRefPos,1)
OutData%TwrBaseRefPos(i1) = ReKiBuf(Re_Xferred)
Re_Xferred = Re_Xferred + 1
END DO
i1_l = LBOUND(OutData%TwrBaseTransDisp,1)
i1_u = UBOUND(OutData%TwrBaseTransDisp,1)
DO i1 = LBOUND(OutData%TwrBaseTransDisp,1), UBOUND(OutData%TwrBaseTransDisp,1)
OutData%TwrBaseTransDisp(i1) = REAL(DbKiBuf(Db_Xferred), R8Ki)
Db_Xferred = Db_Xferred + 1
END DO
i1_l = LBOUND(OutData%TwrBaseRefOrient,1)
i1_u = UBOUND(OutData%TwrBaseRefOrient,1)
i2_l = LBOUND(OutData%TwrBaseRefOrient,2)
i2_u = UBOUND(OutData%TwrBaseRefOrient,2)
DO i2 = LBOUND(OutData%TwrBaseRefOrient,2), UBOUND(OutData%TwrBaseRefOrient,2)
DO i1 = LBOUND(OutData%TwrBaseRefOrient,1), UBOUND(OutData%TwrBaseRefOrient,1)
OutData%TwrBaseRefOrient(i1,i2) = REAL(DbKiBuf(Db_Xferred), R8Ki)
Db_Xferred = Db_Xferred + 1
END DO
END DO
i1_l = LBOUND(OutData%TwrBaseOrient,1)
i1_u = UBOUND(OutData%TwrBaseOrient,1)
i2_l = LBOUND(OutData%TwrBaseOrient,2)
Expand Down
32 changes: 22 additions & 10 deletions modules/openfast-library/src/FAST_Subs.f90
Original file line number Diff line number Diff line change
Expand Up @@ -1148,12 +1148,18 @@ SUBROUTINE FAST_InitializeAll( t_initial, p_FAST, y_FAST, m_FAST, ED, BD, SrvD,
Init%InData_SrvD%RootName = TRIM(p_FAST%OutFileRoot)//'.'//TRIM(y_FAST%Module_Abrev(Module_SrvD))
Init%InData_SrvD%NumBl = Init%OutData_ED%NumBl
Init%InData_SrvD%Gravity = (/ 0.0_ReKi, 0.0_ReKi, -p_FAST%Gravity /) ! "Gravitational acceleration vector" m/s^2
Init%InData_SrvD%NacPosition(1:3) = ED%Input(1)%NacelleLoads%Position(1:3,1)
Init%InData_SrvD%NacOrientation(1:3,1:3) = ED%Input(1)%NacelleLoads%RefOrientation(1:3,1:3,1) ! R8Ki
Init%InData_SrvD%TwrBasePos = Init%OutData_ED%TwrBasePos
Init%InData_SrvD%TwrBaseOrient = Init%OutData_ED%TwrBaseOrient ! R8Ki
Init%InData_SrvD%PlatformPos(1:3) = ED%y%PlatformPtMesh%Position(1:3,1)
Init%InData_SrvD%PlatformOrient(1:3,1:3) = ED%y%PlatformPtMesh%Orientation(1:3,1:3,1) ! R8Ki
Init%InData_SrvD%NacRefPos(1:3) = ED%y%NacelleMotion%Position(1:3,1)
Init%InData_SrvD%NacTransDisp(1:3) = ED%y%NacelleMotion%TranslationDisp(1:3,1) ! R8Ki
Init%InData_SrvD%NacRefOrient(1:3,1:3) = ED%y%NacelleMotion%RefOrientation(1:3,1:3,1) ! R8Ki
Init%InData_SrvD%NacOrient(1:3,1:3) = ED%y%NacelleMotion%Orientation(1:3,1:3,1) ! R8Ki
Init%InData_SrvD%TwrBaseRefPos = Init%OutData_ED%TwrBaseRefPos
Init%InData_SrvD%TwrBaseTransDisp = Init%OutData_ED%TwrBaseTransDisp
Init%InData_SrvD%TwrBaseRefOrient = Init%OutData_ED%TwrBaseRefOrient ! R8Ki
Init%InData_SrvD%TwrBaseOrient = Init%OutData_ED%TwrBaseOrient ! R8Ki
Init%InData_SrvD%PtfmRefPos(1:3) = ED%y%PlatformPtMesh%Position(1:3,1)
Init%InData_SrvD%PtfmTransDisp(1:3) = ED%y%PlatformPtMesh%TranslationDisp(1:3,1)
Init%InData_SrvD%PtfmRefOrient(1:3,1:3)= ED%y%PlatformPtMesh%RefOrientation(1:3,1:3,1) ! R8Ki
Init%InData_SrvD%PtfmOrient(1:3,1:3) = ED%y%PlatformPtMesh%Orientation(1:3,1:3,1) ! R8Ki
Init%InData_SrvD%TMax = p_FAST%TMax
Init%InData_SrvD%AirDens = AirDens
Init%InData_SrvD%AvgWindSpeed = Init%OutData_IfW%WindFileInfo%MWS
Expand All @@ -1163,17 +1169,23 @@ SUBROUTINE FAST_InitializeAll( t_initial, p_FAST, y_FAST, m_FAST, ED, BD, SrvD,
Init%InData_SrvD%RotSpeedRef = Init%OutData_ED%RotSpeed
Init%InData_SrvD%InterpOrder = p_FAST%InterpOrder

CALL AllocAry( Init%InData_SrvD%BladeRootPosition, 3, Init%OutData_ED%NumBl, 'Init%InData_SrvD%BladeRootPosition', errStat2, ErrMsg2)
CALL AllocAry( Init%InData_SrvD%BladeRootRefPos, 3, Init%OutData_ED%NumBl, 'Init%InData_SrvD%BladeRootRefPos', errStat2, ErrMsg2)
CALL SetErrStat(ErrStat2,ErrMsg2,ErrStat,ErrMsg,RoutineName)
CALL AllocAry( Init%InData_SrvD%BladeRootOrientation,3, 3, Init%OutData_ED%NumBl, 'Init%InData_SrvD%BladeRootOrientation', errStat2, ErrMsg2)
CALL AllocAry( Init%InData_SrvD%BladeRootTransDisp, 3, Init%OutData_ED%NumBl, 'Init%InData_SrvD%BladeRootTransDisp', errStat2, ErrMsg2)
CALL SetErrStat(ErrStat2,ErrMsg2,ErrStat,ErrMsg,RoutineName)
CALL AllocAry( Init%InData_SrvD%BladeRootRefOrient, 3, 3, Init%OutData_ED%NumBl, 'Init%InData_SrvD%BladeRootRefOrient', errStat2, ErrMsg2)
CALL SetErrStat(ErrStat2,ErrMsg2,ErrStat,ErrMsg,RoutineName)
CALL AllocAry( Init%InData_SrvD%BladeRootOrient, 3, 3, Init%OutData_ED%NumBl, 'Init%InData_SrvD%BladeRootOrient', errStat2, ErrMsg2)
CALL SetErrStat(ErrStat2,ErrMsg2,ErrStat,ErrMsg,RoutineName)
IF (ErrStat >= AbortErrLev) THEN
CALL Cleanup()
RETURN
END IF
do k=1,Init%OutData_ED%NumBl
Init%InData_SrvD%BladeRootPosition(:,k) = ED%y%BladeRootMotion(k)%Position(:,1)
Init%InData_SrvD%BladeRootOrientation(:,:,k) = ED%y%BladeRootMotion(k)%RefOrientation(:,:,1)
Init%InData_SrvD%BladeRootRefPos(:,k) = ED%y%BladeRootMotion(k)%Position(:,1)
Init%InData_SrvD%BladeRootTransDisp(:,k) = ED%y%BladeRootMotion(k)%TranslationDisp(:,1)
Init%InData_SrvD%BladeRootRefOrient(:,:,k)= ED%y%BladeRootMotion(k)%RefOrientation(:,:,1)
Init%InData_SrvD%BladeRootOrient(:,:,k) = ED%y%BladeRootMotion(k)%Orientation(:,:,1)
enddo


Expand Down
5 changes: 4 additions & 1 deletion modules/servodyn/src/BladedInterface_EX.f90
Original file line number Diff line number Diff line change
Expand Up @@ -172,13 +172,16 @@ subroutine InitPtfmMotionSensors() ! Channels 1001:1018
TranslationAcc =.TRUE., RotationAcc=.TRUE.)
if (Failed()) return;
! Create the node on the mesh
CALL MeshPositionNode ( u%PtfmMotionMesh,1, InitInp%PlatformPos(1:3), ErrStat2, ErrMsg2, InitInp%PlatformOrient )
CALL MeshPositionNode ( u%PtfmMotionMesh,1, InitInp%PtfmRefPos(1:3), ErrStat2, ErrMsg2, InitInp%PtfmRefOrient )
if (Failed()) return;
! Create the mesh element
CALL MeshConstructElement ( u%PtfmMotionMesh, ELEMENT_POINT, ErrStat2, ErrMsg2, 1 )
if (Failed()) return;
CALL MeshCommit ( u%PtfmMotionMesh, ErrStat2, ErrMsg2 )
if (Failed()) return;
! Set any initial offsets
u%PtfmMotionMesh%TranslationDisp(1:3,1) = InitInp%PtfmRefPos(1:3)
u%PtfmMotionMesh%Orientation(1:3,1:3,1) = InitInp%PtfmOrient(1:3,1:3)
! Writing out info on channels
if (UnSum > 0) then
call WrSumInfoSend(1001, 'General channel group -- Platform motion -- Displacement TDX (m)')
Expand Down
Loading

0 comments on commit 03e8dd6

Please sign in to comment.