Skip to content

Commit

Permalink
Merge pull request #2609 from andrew-platt/b/ADdvr_WindSpeed
Browse files Browse the repository at this point in the history
AD bugfix: aerodyn driver non-OLAF combined cases don't update wind
  • Loading branch information
andrew-platt authored Jan 21, 2025
2 parents f0a5d30 + 66fa41f commit 3a46cc4
Showing 1 changed file with 13 additions and 2 deletions.
15 changes: 13 additions & 2 deletions modules/aerodyn/src/AeroDyn_Driver_Subs.f90
Original file line number Diff line number Diff line change
Expand Up @@ -150,8 +150,10 @@ subroutine Dvr_InitCase(iCase, dvr, ADI, FED, errStat, errMsg )
integer(IntKi) :: errStat2 ! local status of error message
character(ErrMsgLen) :: errMsg2 ! local error message if errStat /= ErrID_None
integer(IntKi) :: iWT, j !<
logical :: needInitIW ! Need to initialize IfW if any changes to wind in combined cases
errStat = ErrID_None
errMsg = ""
needInitIW = .false.

dvr%out%root = dvr%root
dvr%iCase = iCase ! for output only..
Expand Down Expand Up @@ -181,6 +183,11 @@ subroutine Dvr_InitCase(iCase, dvr, ADI, FED, errStat, errMsg )
dvr%IW_InitInp%PLexp = dvr%Cases(iCase)%PLExp
ADI%m%IW%HWindSpeed = dvr%Cases(iCase)%HWindSpeed ! We need to do it again since InFlow Wind is initialized only for iCase==1
ADI%m%IW%PLexp = dvr%Cases(iCase)%PLExp
! if wind profile changes between cases, we need to re-init
if (iCase > 1) then
if (dvr%Cases(iCase)%HWindSpeed /= dvr%Cases(iCase-1)%HWindSpeed) needInitIW = .true.
if (dvr%Cases(iCase)%PLExp /= dvr%Cases(iCase-1)%PLExp ) needInitIW = .true.
endif
! Set motion for this case
call setSimpleMotion(dvr%WT(1), dvr%Cases(iCase)%rotSpeed, dvr%Cases(iCase)%bldPitch, dvr%Cases(iCase)%nacYaw, dvr%Cases(iCase)%DOF, dvr%Cases(iCase)%amplitude, dvr%Cases(iCase)%frequency)

Expand Down Expand Up @@ -218,7 +225,7 @@ subroutine Dvr_InitCase(iCase, dvr, ADI, FED, errStat, errMsg )
dvr%out%unOutFile = -1

! --- Initialize ADI
call Init_ADI_ForDriver(iCase, ADI, dvr, FED, dvr%dt, errStat2, errMsg2); if(Failed()) return
call Init_ADI_ForDriver(iCase, ADI, dvr, FED, dvr%dt, needInitIW, errStat2, errMsg2); if(Failed()) return

! --- Initialize meshes
if (iCase==1) then
Expand Down Expand Up @@ -399,12 +406,13 @@ subroutine Dvr_CleanUp(dvr, ADI, FED, initialized, errStat, errMsg)
end subroutine Dvr_CleanUp

!----------------------------------------------------------------------------------------------------------------------------------
subroutine Init_ADI_ForDriver(iCase, ADI, dvr, FED, dt, errStat, errMsg)
subroutine Init_ADI_ForDriver(iCase, ADI, dvr, FED, dt, needInitIW, errStat, errMsg)
integer(IntKi) , intent(in ) :: iCase
type(ADI_Data), intent(inout) :: ADI ! Input data for initialization (intent out for getting AD WriteOutput names/units)
type(Dvr_SimData), target, intent(inout) :: dvr ! Input data for initialization (intent out for getting AD WriteOutput names/units)
type(FED_Data), target, intent(inout) :: FED ! Elastic wind turbine data (Fake ElastoDyn)
real(DbKi), intent(inout) :: dt ! interval
logical, intent(in ) :: needInitIW ! Need to initialize IfW if any changes to wind in combined cases
integer(IntKi) , intent(out) :: errStat ! Status of error message
character(*) , intent(out) :: errMsg ! Error message if errStat /= ErrID_None
! locals
Expand Down Expand Up @@ -454,6 +462,9 @@ subroutine Init_ADI_ForDriver(iCase, ADI, dvr, FED, dt, errStat, errMsg)
endif
endif

! if wind profile changed in a combined case, need to re-init
if (needInitIW) needInit = .true.

if (needInit) then
! ADI
InitInp%storeHHVel = .true.
Expand Down

0 comments on commit 3a46cc4

Please sign in to comment.