Skip to content

Commit dc553f2

Browse files
authored
Merge pull request #3278 from luwang00/b/AD_MHK
Various bug fixes for AeroDyn when modeling MHK turbines
2 parents 5d5b2b8 + e5803db commit dc553f2

6 files changed

Lines changed: 55 additions & 17 deletions

File tree

modules/aerodyn/src/AeroDyn.f90

Lines changed: 35 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1976,18 +1976,27 @@ subroutine AD_CalcWind(t, u, FLowField, p, m, o, Inflow, ErrStat, ErrMsg)
19761976
! OLAF points
19771977
if (allocated(o%WakeLocationPoints) .and. allocated(Inflow%InflowWakeVel)) then
19781978
! If rotor is MHK, add water depth to z coordinate
1979-
if (p%FVW%MHK > 0) then
1979+
if (p%FVW%MHK /= MHK_None) then
19801980
PosOffset = [0.0_ReKi, 0.0_ReKi, p%FVW%WtrDpth]
19811981
else
19821982
PosOffset = 0.0_ReKi
19831983
end if
19841984

1985-
call IfW_FlowField_GetVelAcc(FlowField, StartNode, t, &
1986-
o%WakeLocationPoints, &
1987-
Inflow%InflowWakeVel, &
1988-
NoAcc, ErrStat2, ErrMsg2, &
1989-
BoxExceedAllow=.true., PosOffset=PosOffset)
1990-
if(Failed()) return
1985+
if (p%FVW%MHK /= MHK_None .and. p%CompSeaSt) then ! MHK turbines with waves
1986+
call WaveField_GetWaveVelAcc_AD(p%WaveField, m%WaveField_m, &
1987+
StartNode, t, &
1988+
o%WakeLocationPoints, &
1989+
Inflow%InflowWakeVel, &
1990+
NoAcc, ErrStat2, ErrMsg2)
1991+
if(Failed()) return
1992+
else
1993+
call IfW_FlowField_GetVelAcc(FlowField, StartNode, t, &
1994+
o%WakeLocationPoints, &
1995+
Inflow%InflowWakeVel, &
1996+
NoAcc, ErrStat2, ErrMsg2, &
1997+
BoxExceedAllow=.true., PosOffset=PosOffset)
1998+
if(Failed()) return
1999+
end if
19912000
StartNode = StartNode + size(o%WakeLocationPoints)
19922001
end if
19932002

@@ -2034,7 +2043,7 @@ subroutine AD_CalcWind_Rotor(t, u, FlowField, p, p_AD, m, RotInflow, StartNode,
20342043
call WaveField_GetWaveVelAcc_AD(p_AD%WaveField, m%WaveField_m, StartNode, t, &
20352044
real(u%HubMotion%TranslationDisp + u%HubMotion%Position, ReKi), &
20362045
RotInflow%InflowOnHub, NoAcc, ErrStat2, ErrMsg2)
2037-
if(Failed()) return
2046+
if(Failed()) return
20382047
else
20392048
RotInflow%InflowOnHub = 0.0_ReKi
20402049
end if
@@ -2085,7 +2094,7 @@ subroutine AD_CalcWind_Rotor(t, u, FlowField, p, p_AD, m, RotInflow, StartNode,
20852094
call IfW_FlowField_GetVelAcc(FlowField, StartNode, t, &
20862095
real(u%HubMotion%TranslationDisp + u%HubMotion%Position, ReKi), &
20872096
RotInflow%InflowOnHub, NoAcc, ErrStat2, ErrMsg2, PosOffset=PosOffset)
2088-
if(Failed()) return
2097+
if(Failed()) return
20892098
else
20902099
RotInflow%InflowOnHub = 0.0_ReKi
20912100
end if
@@ -3208,7 +3217,7 @@ end subroutine SetDisturbedInflow
32083217
!! Loop on blade nodes and computed a weighted sector average inflow at each node
32093218
subroutine SetSectAvgInflow(t, p, p_AD, u, RotInflow, m, errStat, errMsg)
32103219
real(DbKi), intent(in ) :: t !< Current simulation time in seconds
3211-
type(RotParameterType), intent(in ) :: p !< AD parameters
3220+
type(RotParameterType), intent(in ) :: p !< Rotor parameters
32123221
type(AD_ParameterType), intent(in ) :: p_AD !< AD parameters
32133222
type(RotInputType), intent(in ) :: u !< AD Inputs at Time
32143223
type(RotInflowType), intent(in ) :: RotInflow !< Rotor inflow at Time
@@ -3227,6 +3236,7 @@ subroutine SetSectAvgInflow(t, p, p_AD, u, RotInflow, m, errStat, errMsg)
32273236
real(ReKi) :: e_t(3) !< Polar unit vector perpendicular to rHA_perp ("e_theta")
32283237
real(ReKi) :: psi !< Azimuthal offset in the current sector, runs from -psi_bwd to psi_fwd
32293238
real(ReKi) :: dpsi !< Azimuthal increment
3239+
real(ReKi) :: PosOffset(3)!< IfW position offset for MHK turbines
32303240
real(ReKi), allocatable :: SectPos(:,:)!< Points used to define a given sector (for a given blade node A)
32313241
real(ReKi), allocatable :: SectVel(:,:)!< Inflow velocity at a given sector (Undisturbed and then disturbed)
32323242
real(ReKi), allocatable :: SectAcc(:,:)!< Inflow velocity at a given sector (Undisturbed and then disturbed)
@@ -3293,7 +3303,21 @@ subroutine SetSectAvgInflow(t, p, p_AD, u, RotInflow, m, errStat, errMsg)
32933303

32943304
! --- Inflow on sector points
32953305
! Undisturbed
3296-
call IfW_FlowField_GetVelAcc(p_AD%FlowField, 1, t, SectPos, SectVel, SectAcc, errStat=errStat2, errMsg=errMsg2); if(Failed()) return
3306+
if (p%MHK /= MHK_None .and. p_AD%CompSeaSt) then ! MHK turbines with waves
3307+
call WaveField_GetWaveVelAcc_AD(p_AD%WaveField, m%WaveField_m, 1_IntKi, t, &
3308+
SectPos, SectVel, SectAcc, ErrStat2, ErrMsg2)
3309+
if(Failed()) return
3310+
else
3311+
if (p%MHK /= MHK_None) then
3312+
PosOffset = [0.0_ReKi, 0.0_ReKi, p%WtrDpth]
3313+
else
3314+
PosOffset = 0.0_ReKi
3315+
end if
3316+
call IfW_FlowField_GetVelAcc(p_AD%FlowField, 1_IntKi, t, &
3317+
SectPos, SectVel, SectAcc, errStat=errStat2, errMsg=errMsg2, &
3318+
PosOffset=PosOffset); if(Failed()) return
3319+
end if
3320+
32973321
! --- Option 1 Disturbed inflow Before averaging - SectVel is modified in place
32983322
!if (p%TwrPotent /= TwrPotent_none .or. p%TwrShadow /= TwrShadow_none) then
32993323
! call TwrInflArray(p, u, RotInflow, m, SectPos, SectVel, errStat2, errMsg2); if(Failed()) return

modules/aerodyn/src/AeroDyn_Registry.txt

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -517,6 +517,7 @@ typedef ^ RotMiscVarType ReKi TFinVrel_i 3 - - "Relative velocity at the refere
517517
typedef ^ RotMiscVarType ReKi TFinSTV_i 3 - - "Structural velocity at the reference point of the fin in the inertial system"
518518
typedef ^ RotMiscVarType ReKi TFinF_i 3 - - "Forces at the reference point of the fin in the inertial system"
519519
typedef ^ RotMiscVarType ReKi TFinM_i 3 - - "Moments at the reference point of the fin in the inertial system"
520+
typedef ^ RotMiscVarType GridInterp_MiscVarType WaveField_m - - - "misc var information from the GridInterp module"
520521

521522
typedef ^ MiscVarType RotMiscVarType rotors {:} - - "MiscVars for each rotor" -
522523
typedef ^ MiscVarType FVW_InputType FVW_u : - - "Inputs to the FVW module" -
@@ -525,7 +526,7 @@ typedef ^ MiscVarType FVW_MiscVarType FVW - - - "MiscVars from the FVW module" -
525526
typedef ^ MiscVarType ReKi WindPos {:}{:} - - "XYZ coordinates to query for wind velocity/acceleration" -
526527
typedef ^ MiscVarType ReKi WindVel {:}{:} - - "XYZ components of wind velocity" -
527528
typedef ^ MiscVarType ReKi WindAcc {:}{:} - - "XYZ components of wind acceleration" -
528-
typedef ^ MiscVarType GridInterp_MiscVarType WaveField_m - - - "misc var information from the SeaState WaveField module" -
529+
typedef ^ MiscVarType GridInterp_MiscVarType WaveField_m - - - "misc var information from the GridInterp module" -
529530
typedef ^ MiscVarType AD_InflowType Inflow {:} - - "Inflow storage (size of u for history of inputs)" -
530531
typedef ^ MiscVarType AD_InputType u_perturb - - - "input perturbation for linearization" -
531532
typedef ^ MiscVarType AD_OutputType y_lin - - - "output perturbation for linearization" -

modules/aerodyn/src/AeroDyn_Types.f90

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -557,6 +557,7 @@ MODULE AeroDyn_Types
557557
REAL(ReKi) , DIMENSION(1:3) :: TFinSTV_i = 0.0_ReKi !< Structural velocity at the reference point of the fin in the inertial system [-]
558558
REAL(ReKi) , DIMENSION(1:3) :: TFinF_i = 0.0_ReKi !< Forces at the reference point of the fin in the inertial system [-]
559559
REAL(ReKi) , DIMENSION(1:3) :: TFinM_i = 0.0_ReKi !< Moments at the reference point of the fin in the inertial system [-]
560+
TYPE(GridInterp_MiscVarType) :: WaveField_m !< misc var information from the GridInterp module [-]
560561
END TYPE RotMiscVarType
561562
! =======================
562563
! ========= AD_MiscVarType =======
@@ -568,7 +569,7 @@ MODULE AeroDyn_Types
568569
REAL(ReKi) , DIMENSION(:,:), ALLOCATABLE :: WindPos !< XYZ coordinates to query for wind velocity/acceleration [-]
569570
REAL(ReKi) , DIMENSION(:,:), ALLOCATABLE :: WindVel !< XYZ components of wind velocity [-]
570571
REAL(ReKi) , DIMENSION(:,:), ALLOCATABLE :: WindAcc !< XYZ components of wind acceleration [-]
571-
TYPE(GridInterp_MiscVarType) :: WaveField_m !< misc var information from the SeaState WaveField module [-]
572+
TYPE(GridInterp_MiscVarType) :: WaveField_m !< misc var information from the GridInterp module [-]
572573
TYPE(AD_InflowType) , DIMENSION(:), ALLOCATABLE :: Inflow !< Inflow storage (size of u for history of inputs) [-]
573574
TYPE(AD_InputType) :: u_perturb !< input perturbation for linearization [-]
574575
TYPE(AD_OutputType) :: y_lin !< output perturbation for linearization [-]
@@ -5553,6 +5554,9 @@ subroutine AD_CopyRotMiscVarType(SrcRotMiscVarTypeData, DstRotMiscVarTypeData, C
55535554
DstRotMiscVarTypeData%TFinSTV_i = SrcRotMiscVarTypeData%TFinSTV_i
55545555
DstRotMiscVarTypeData%TFinF_i = SrcRotMiscVarTypeData%TFinF_i
55555556
DstRotMiscVarTypeData%TFinM_i = SrcRotMiscVarTypeData%TFinM_i
5557+
call GridInterp_CopyMisc(SrcRotMiscVarTypeData%WaveField_m, DstRotMiscVarTypeData%WaveField_m, CtrlCode, ErrStat2, ErrMsg2)
5558+
call SetErrStat(ErrStat2, ErrMsg2, ErrStat, ErrMsg, RoutineName)
5559+
if (ErrStat >= AbortErrLev) return
55565560
end subroutine
55575561

55585562
subroutine AD_DestroyRotMiscVarType(RotMiscVarTypeData, ErrStat, ErrMsg)
@@ -5776,6 +5780,8 @@ subroutine AD_DestroyRotMiscVarType(RotMiscVarTypeData, ErrStat, ErrMsg)
57765780
call SetErrStat(ErrStat2, ErrMsg2, ErrStat, ErrMsg, RoutineName)
57775781
call NWTC_Library_DestroyMeshMapType(RotMiscVarTypeData%T_P_2_T_L, ErrStat2, ErrMsg2)
57785782
call SetErrStat(ErrStat2, ErrMsg2, ErrStat, ErrMsg, RoutineName)
5783+
call GridInterp_DestroyMisc(RotMiscVarTypeData%WaveField_m, ErrStat2, ErrMsg2)
5784+
call SetErrStat(ErrStat2, ErrMsg2, ErrStat, ErrMsg, RoutineName)
57795785
end subroutine
57805786

57815787
subroutine AD_PackRotMiscVarType(RF, Indata)
@@ -5916,6 +5922,7 @@ subroutine AD_PackRotMiscVarType(RF, Indata)
59165922
call RegPack(RF, InData%TFinSTV_i)
59175923
call RegPack(RF, InData%TFinF_i)
59185924
call RegPack(RF, InData%TFinM_i)
5925+
call GridInterp_PackMisc(RF, InData%WaveField_m)
59195926
if (RegCheckErr(RF, RoutineName)) return
59205927
end subroutine
59215928

@@ -6083,6 +6090,7 @@ subroutine AD_UnPackRotMiscVarType(RF, OutData)
60836090
call RegUnpack(RF, OutData%TFinSTV_i); if (RegCheckErr(RF, RoutineName)) return
60846091
call RegUnpack(RF, OutData%TFinF_i); if (RegCheckErr(RF, RoutineName)) return
60856092
call RegUnpack(RF, OutData%TFinM_i); if (RegCheckErr(RF, RoutineName)) return
6093+
call GridInterp_UnpackMisc(RF, OutData%WaveField_m) ! WaveField_m
60866094
end subroutine
60876095

60886096
subroutine AD_CopyMisc(SrcMiscData, DstMiscData, CtrlCode, ErrStat, ErrMsg)

modules/seastate/src/SeaSt_WaveField.f90

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -684,7 +684,7 @@ end subroutine WaveField_GetWaveKin
684684

685685

686686
! This subroutine is intended for AeroDyn when modeling MHK turbines
687-
SUBROUTINE WaveField_GetWaveVelAcc_AD( WaveField, WaveField_m, StartNode, Time, pos, FV, FA, ErrStat, ErrMsg )
687+
SUBROUTINE WaveField_GetWaveVelAcc_AD( WaveField, WaveField_m, StartNode, Time, pos, FV, FA, ErrStat, ErrMsg, BoxExceedAllow )
688688
type(SeaSt_WaveFieldType), intent(in ) :: WaveField
689689
type(GridInterp_MiscVarType), intent(inout) :: WaveField_m
690690
integer(IntKi), intent(in ) :: StartNode
@@ -694,6 +694,7 @@ SUBROUTINE WaveField_GetWaveVelAcc_AD( WaveField, WaveField_m, StartNode, Time,
694694
real(ReKi), allocatable, intent(inout) :: FA(:,:)
695695
integer(IntKi), intent( out) :: ErrStat ! Error status of the operation
696696
character(*), intent( out) :: ErrMsg ! Error message if errStat /= ErrID_None
697+
logical, optional, intent(in ) :: BoxExceedAllow
697698
integer(IntKi), allocatable :: nodeInWater(:)
698699
integer(IntKi) :: NumPoints, i
699700
real(SiKi) :: FV_node(3), FA_node(3)
@@ -734,7 +735,12 @@ SUBROUTINE WaveField_GetWaveVelAcc_AD( WaveField, WaveField_m, StartNode, Time,
734735
IF (getAcc) THEN
735736
ALLOCATE(FA_DC( 3, NumPoints ), STAT=ErrStat2); if (FailedMsg('Error allocating FA_DC')) return;
736737
END IF
737-
CALL IfW_FlowField_GetVelAcc(WaveField%CurrField, StartNode, Time, pos, FV_DC, FA_DC, ErrStat2, ErrMsg2, PosOffset=PosOffset); if (Failed()) return;
738+
739+
IF (PRESENT(BoxExceedAllow)) THEN
740+
CALL IfW_FlowField_GetVelAcc(WaveField%CurrField, StartNode, Time, pos, FV_DC, FA_DC, ErrStat2, ErrMsg2, BoxExceedAllow=BoxExceedAllow, PosOffset=PosOffset); if (Failed()) return
741+
ELSE
742+
CALL IfW_FlowField_GetVelAcc(WaveField%CurrField, StartNode, Time, pos, FV_DC, FA_DC, ErrStat2, ErrMsg2, PosOffset=PosOffset); if (Failed()) return
743+
END IF
738744

739745
! Add contributions from IfW current field if node is in water
740746
DO i = 1, NumPoints

reg_tests/CTestList.cmake

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -455,7 +455,6 @@ ad_regression("ad_MultipleHAWT" "aerodyn;bem")
455455
ad_regression("ad_QuadRotor_OLAF" "aerodyn;bem")
456456
ad_regression("ad_VerticalAxis_OLAF" "aerodyn;bem")
457457
ad_regression("ad_MHK_RM1_Fixed" "aerodyn;bem;mhk")
458-
ad_regression("ad_MHK_RM1_Fixed_IfW" "aerodyn;bem;mhk")
459458
ad_regression("ad_MHK_RM1_Floating" "aerodyn;bem;mhk")
460459
ad_regression("ad_BAR_CombinedCases" "aerodyn;bem") # NOTE: doing BAR at the end to avoid copy errors
461460
ad_regression("ad_BAR_OLAF" "aerodyn;bem")

reg_tests/r-test

Submodule r-test updated 25 files

0 commit comments

Comments
 (0)