Skip to content

Commit

Permalink
AD: AeroProjMod based on BEM_Mod by default
Browse files Browse the repository at this point in the history
  • Loading branch information
Emmanuel Branlard committed Mar 12, 2024
1 parent e8d45d2 commit 6a04310
Show file tree
Hide file tree
Showing 4 changed files with 79 additions and 24 deletions.
70 changes: 56 additions & 14 deletions modules/aerodyn/src/AeroDyn.f90
Original file line number Diff line number Diff line change
Expand Up @@ -319,19 +319,48 @@ subroutine AD_Init( InitInp, u, p, x, xd, z, OtherState, y, m, Interval, InitOut

! Temporary HACK, for WakeMod=10, 11 or 12 use AeroProjMod 2 (will trigger PolarBEM)
if (InputFileData%Wake_Mod==10) then
call WrScr(' WARNING: Wake_Mod=10 is a temporary hack. Using new projection method with Wake_Mod=0.')
call WrScr('[WARN] Wake_Mod=10 is a temporary hack. Using new projection method with Wake_Mod=0 and DBEMT_Mod=0')
if (InputFileData%DBEMT_Mod/=0) then
call Fatal('DBEMT_Mod should be =0 when using the temporary hack Wake_Mod=10.'); return
endif
InputFileData%Wake_Mod = 0
AeroProjMod(:) = 2
AeroProjMod(:) = APM_BEM_Polar

elseif (InputFileData%Wake_Mod==11) then
call WrScr(' WARNING: Wake_Mod=11 is a temporary hack. Using new projection method with Wake_Mod=1.')
call WrScr('[WARN] Wake_Mod=11 is a temporary hack. Using new projection method with Wake_Mod=1 (BEM) and DBEMT_Mod=0.')
if (InputFileData%DBEMT_Mod/=0) then
call Fatal('DBEMT_Mod should be 0 when using the temporary hack Wake_Mod=11.'); return
endif
InputFileData%Wake_Mod = 1
AeroProjMod(:) = 2
AeroProjMod(:) = APM_BEM_Polar

elseif (InputFileData%Wake_Mod==12) then
call WrScr(' WARNING: Wake_Mod=12 is a temporary hack. Using new projection method with Wake_Mod=2.')
InputFileData%Wake_Mod = 2
AeroProjMod(:) = 2
call WrScr('[WARN] Wake_Mod=12 is a temporary hack. Using new projection method with Wake_Mod=1 (BEM) and DBEMT_Mod>=1.')
if (InputFileData%DBEMT_Mod<1) then
call Fatal('DBEMT_Mod should be >=1 when using the temporary hack Wake_Mod=12.'); return
endif
InputFileData%Wake_Mod = 1
AeroProjMod(:) = APM_BEM_Polar
endif

! --- "Automatic handling of AeroProjMod
do iR = 1, nRotors
if (AeroProjMod(iR) == -1) then
if (InputFileData%Wake_Mod /= WakeMod_BEMT) then
! For BEMT, we don't throw a warning
call WrScr('[INFO] Using the input file input `BEMT_Mod` to match BEM coordinate system outputs')
endif
select case (InputFileData%BEM_Mod)
case (BEMMod_2D); AeroProjMod(ir) = APM_BEM_NoSweepPitchTwist
case (BEMMod_3D); AeroProjMod(ir) = APM_BEM_Polar
case default; call Fatal('Input `BEMT_Mod` not supported'); return
end select

endif
enddo

print*,'AD_Init: AeroProjMod B:',AeroProjMod

! -----------------------------------------------------------------
! Read the AeroDyn blade files, or copy from passed input
!FIXME: add handling for passing of blade files and other types of files.
Expand Down Expand Up @@ -367,13 +396,8 @@ subroutine AD_Init( InitInp, u, p, x, xd, z, OtherState, y, m, Interval, InitOut
! set the rest of the parameters
p%Skew_Mod = InputFileData%Skew_Mod
do iR = 1, nRotors
p%rotors(iR)%AeroProjMod = InitInp%rotors(iR)%AeroProjMod
!p%rotors(iR)%AeroProjMod = AeroProjMod(iR)
p%rotors(iR)%AeroProjMod = AeroProjMod(iR)
call WrScr(' AeroDyn: projMod: '//trim(num2lstr(p%rotors(iR)%AeroProjMod)))
if (AeroProjMod(iR) == APM_BEM_Polar .and. InputFileData%Wake_Mod==WakeMod_FVW) then
call WrScr('AeroProj cannot be 2 (somehow) when using OLAF - Aborting')
STOP
endif
call SetParameters( InitInp, InputFileData, InputFileData%rotors(iR), p%rotors(iR), p, ErrStat2, ErrMsg2 )
if (Failed()) return;
enddo
Expand Down Expand Up @@ -528,6 +552,12 @@ subroutine AD_Init( InitInp, u, p, x, xd, z, OtherState, y, m, Interval, InitOut
call Cleanup()

contains
subroutine Fatal(errMsg_in)
character(*), intent(in) :: errMsg_in
call SetErrStat(ErrID_Fatal, errMsg_in, ErrStat, ErrMsg, RoutineName )
call Cleanup()
end subroutine Fatal

logical function Failed()
CALL SetErrStat( ErrStat2, ErrMsg2, ErrStat, ErrMsg, RoutineName )
Failed = ErrStat >= AbortErrLev
Expand Down Expand Up @@ -3426,10 +3456,22 @@ subroutine SetInputsForFVW(p, u, m, errStat, errMsg)
! Get disk average values and orientations
! NOTE: needed because it sets m%V_diskAvg and m%V_dot_x, needed by CalcOutput..
call DiskAvgValues(p%rotors(iR), u(tIndx)%rotors(iR), m%rotors(iR), x_hat_disk) ! also sets m%V_diskAvg and m%V_dot_x

! Compute Orientation similar to BEM, only to have consistent outputs...
! TODO TODO TODO All this below is mostly a calcOutput thing, we should move it somewhere else!
! orientation annulus is only used for Outputs with OLAF, same for pitch and azimuth
if (p%rotors(iR)%AeroProjMod==APM_BEM_NoSweepPitchTwist) then
call Calculate_MeshOrientation_NoSweepPitchTwist(p%rotors(iR),u(tIndx)%rotors(iR), m%rotors(iR), thetaBladeNds,ErrStat=ErrStat2,ErrMsg=ErrMsg2) ! sets m%orientationAnnulus, m%Curve
call Calculate_MeshOrientation_NoSweepPitchTwist(p%rotors(iR), u(tIndx)%rotors(iR), m%rotors(iR), thetaBladeNds,ErrStat=ErrStat2,ErrMsg=ErrMsg2) ! sets m%orientationAnnulus, m%Curve

elseif (p%rotors(iR)%AeroProjMod==APM_BEM_Polar) then
do k=1,p%rotors(iR)%numBlades
call Calculate_MeshOrientation_Rel2Hub(u(tIndx)%rotors(iR)%BladeMotion(k), u(tIndx)%rotors(iR)%HubMotion, x_hat_disk, m%rotors(iR)%orientationAnnulus(:,:,:,k))
enddo

else if (p%rotors(iR)%AeroProjMod==APM_LiftingLine) then
call Calculate_MeshOrientation_LiftingLine (p%rotors(iR),u(tIndx)%rotors(iR), m%rotors(iR), thetaBladeNds,ErrStat=ErrStat2,ErrMsg=ErrMsg2) ! sets m%orientationAnnulus, m%Curve
else
call SetErrStat(ErrID_Fatal, 'Aero Projection Method not implemented' ,ErrStat, ErrMsg, RoutineName)
endif
call StorePitchAndAzimuth(p%rotors(iR), u(tIndx)%rotors(iR), m%rotors(iR), ErrStat2, ErrMsg2)
call SetErrStat(ErrStat2,ErrMsg2,ErrStat,ErrMsg,RoutineName)
Expand Down
3 changes: 2 additions & 1 deletion modules/aerodyn/src/AeroDyn_Driver_Subs.f90
Original file line number Diff line number Diff line change
Expand Up @@ -496,7 +496,8 @@ subroutine Init_ADI_ForDriver(iCase, ADI, dvr, FED, dt, errStat, errMsg)
if (wt%projMod==-1)then
!call WrScr('>>> Using HAWTprojection to determine projMod')
if (wt%HAWTprojection) then
InitInp%AD%rotors(iWT)%AeroProjMod = APM_BEM_NoSweepPitchTwist ! default, with WithoutSweepPitchTwist
!InitInp%AD%rotors(iWT)%AeroProjMod = APM_BEM_NoSweepPitchTwist ! default, with WithoutSweepPitchTwist
InitInp%AD%rotors(iWT)%AeroProjMod = -1 ! We let the code decide based on BEM_Mod
else
InitInp%AD%rotors(iWT)%AeroProjMod = APM_LiftingLine
endif
Expand Down
28 changes: 20 additions & 8 deletions modules/aerodyn/src/AeroDyn_IO.f90
Original file line number Diff line number Diff line change
Expand Up @@ -706,7 +706,7 @@ SUBROUTINE ParsePrimaryFileInfo( PriPath, InitInp, InputFile, RootName, NumBlade
call ParseVarWDefault ( FileInfo_In, CurLine, "DTAero", InputFileData%DTAero, interval, ErrStat2, ErrMsg2, UnEc )
if (Failed()) return
! WakeMod - LEGACY
call ParseVar( FileInfo_In, CurLine, "WakeMod", InputFileData%WakeMod, ErrStat2, ErrMsg2, UnEc ); if (Failed()) return
call ParseVar( FileInfo_In, CurLine, "WakeMod", InputFileData%WakeMod, ErrStat2, ErrMsg2, UnEc)
wakeModProvided = legacyInputPresent('WakeMod', CurLine, ErrStat2, ErrMsg2, 'Wake_Mod=0 (WakeMod=0), Wake_Mod=1 (WakeMod=1), DBEMT_Mod>0 (WakeMod=2, Wake_Mod=3 (WakeMod=3)')
! Wake_Mod- Type of wake/induction model (switch) {0=none, 1=BEMT, 2=TBD, 3=OLAF}
call ParseVar( FileInfo_In, CurLine, "Wake_Mod", InputFileData%Wake_Mod, ErrStat2, ErrMsg2, UnEc )
Expand All @@ -722,7 +722,7 @@ SUBROUTINE ParsePrimaryFileInfo( PriPath, InitInp, InputFile, RootName, NumBlade

! AFAeroMod - Type of blade airfoil aerodynamics model (switch) {1=steady model, 2=Beddoes-Leishman unsteady model} [AFAeroMod must be 1 when linearizing]
call ParseVar( FileInfo_In, CurLine, "AFAeroMod", InputFileData%AFAeroMod, ErrStat2, ErrMsg2, UnEc )
AFAeroModProvided = legacyInputPresent('AFAeroMod', CurLine, ErrStat2, ErrMsg2, 'UAMod=0 (AFAeroMod=1), UAMod>1 (AFAeroMod=2)')
AFAeroModProvided = legacyInputPresent('AFAeroMod', CurLine, ErrStat2, ErrMsg2, 'UAMod=0 (AFAeroMod=1) or UAMod>1 (AFAeroMod=2)')
! TwrPotent - Type of tower influence on wind based on potential flow around the tower (switch) {0=none, 1=baseline potential flow, 2=potential flow with Bak correction}
call ParseVar( FileInfo_In, CurLine, "TwrPotent", InputFileData%TwrPotent, ErrStat2, ErrMsg2, UnEc )
if (Failed()) return
Expand All @@ -734,7 +734,7 @@ SUBROUTINE ParsePrimaryFileInfo( PriPath, InitInp, InputFile, RootName, NumBlade
if (Failed()) return
! FrozenWake - Assume frozen wake during linearization? (flag) [used only when WakeMod=1 and when linearizing]
call ParseVar( FileInfo_In, CurLine, "FrozenWake", InputFileData%FrozenWake, ErrStat2, ErrMsg2, UnEc )
frozenWakeProvided = legacyInputPresent('FrozenWake', Curline, ErrStat2, ErrMsg2, 'DBEMTMod=-1 (FrozenWake=True), DBEMTMod>-1 (FrozenWake=False)')
frozenWakeProvided = legacyInputPresent('FrozenWake', Curline, ErrStat2, ErrMsg2, 'DBEMTMod=-1 (FrozenWake=True) or DBEMTMod>-1 (FrozenWake=False)')
! CavitCheck - Perform cavitation check? (flag) [AFAeroMod must be 1 when CavitCheck=true]
call ParseVar( FileInfo_In, CurLine, "CavitCheck", InputFileData%CavitCheck, ErrStat2, ErrMsg2, UnEc )
if (Failed()) return
Expand Down Expand Up @@ -1130,10 +1130,23 @@ SUBROUTINE ParsePrimaryFileInfo( PriPath, InitInp, InputFile, RootName, NumBlade
! Prevent segfault when no blades specified. All logic tests on BldNd_NumOuts at present.
if (InputFileData%BldNd_BladesOut <= 0) InputFileData%BldNd_NumOuts = 0

! Temporary HACK, for WakeMod=10, 11 or 12 use AeroProjMod 2 (will trigger PolarBEM)
if (InputFileData%Wake_Mod==10) then
call WrScr(' WARNING: Wake_Mod=10 is a temporary hack. Setting BEM_Mod to 0')
InputFileData%BEM_Mod = 0
elseif (InputFileData%Wake_Mod==11) then
call WrScr(' WARNING: Wake_Mod=11 is a temporary hack. Setting BEM_Mod to 2')
InputFileData%BEM_Mod = 2
elseif (InputFileData%Wake_Mod==12) then
call WrScr(' WARNING: Wake_Mod=12 is a temporary hack. Setting BEM_Mod to 2')
InputFileData%BEM_Mod = 2
endif


!====== Summary of new AeroDyn options ===============================================================
! NOTE: remove me in future release
call WrScr('-------------- New AeroDyn inputs (with new meaning):')
write (*,'(A20,I0)') 'WakeMod: ' , InputFileData%WakeMod
write (*,'(A20,I0)') 'Wake_Mod: ' , InputFileData%Wake_Mod
write (*,'(A20,I0)') 'BEM_Mod: ' , InputFileData%BEM_Mod
write (*,'(A20,L0)') 'SectAvg: ' , InputFileData%SectAvg
write (*,'(A20,I0)') 'SectAvgWeighting: ', InputFileData%SA_Weighting
Expand All @@ -1145,6 +1158,7 @@ SUBROUTINE ParsePrimaryFileInfo( PriPath, InitInp, InputFile, RootName, NumBlade
write (*,'(A20,L0)') 'AoA34: ' , InputFileData%AoA34
write (*,'(A20,I0)') 'UAMod: ' , InputFileData%UAMod
call WrScr('-------------- Old AeroDyn inputs:')
write (*,'(A20,I0)') 'WakeMod: ', InputFileData%WakeMod
write (*,'(A20,I0)') 'SkewMod: ', InputFileData%SkewMod
write (*,'(A20,I0)') 'AFAeroMod:', InputFileData%AFAeroMod
write (*,'(A20,L0)') 'FrozenWake:', InputFileData%FrozenWake
Expand Down Expand Up @@ -1200,12 +1214,10 @@ subroutine LegacyWarning(Message)
character(len=*), intent(in) :: Message
if (.not.FirstWarn) then
call WrScr('!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!')
call WrScr('!!!!!!! Warning: the AeroDyn input file is not at the latest format!' )
call WrScr(' Visit: https://openfast.readthedocs.io/en/dev/source/user/api_change.html')
call WrScr('[WARN] The AeroDyn input file is not at the latest format!' )
call WrScr(' Visit: https://openfast.readthedocs.io/en/dev/source/user/api_change.html')
call WrScr('!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!')
FirstWarn=.true.
else
call WrScr('!!!!!!! Warning: the AeroDyn input file is not at the latest format!' )
endif
call WrScr('> Issue: '//trim(Message))
end subroutine LegacyWarning
Expand Down
2 changes: 1 addition & 1 deletion modules/aerodyn/src/FVW.f90
Original file line number Diff line number Diff line change
Expand Up @@ -481,7 +481,7 @@ subroutine FVW_FinalWrite(u, p, x, z, m, ErrStat, ErrMsg)
ErrMsg = ""
! Place any last minute operations or calculations here:
if (p%WrVTK>0 .and. m%VTKstep<FINAL_STEP) then
print*,'>>> FINAL WRITE'
call WrScr('OLAF: writting final VTK outputs')
t=-1.0_ReKi
if (p%WrVTK==1) then
if (m%VTKstep<m%iStep+1) then
Expand Down

0 comments on commit 6a04310

Please sign in to comment.