Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Improvements to the InflowWind disk averaged velocity calculations #1240

Merged
merged 14 commits into from
Oct 26, 2022
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
Binary file modified docs/OtherSupporting/OutListParameters.xlsx
Binary file not shown.
25 changes: 25 additions & 0 deletions docs/source/user/inflowwind/driver.rst
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ Command-line syntax for InflowWind driver:
/vv -- very verbose output
/hawc -- convert wind file specified in InflowWind to HAWC format
/bladed -- convert wind file specified in InflowWind to Bladed format
/uniform -- convert wind file specified in InflowWind to Uniform-wind format
/vtk -- convert wind file specified in InflowWind to VTK format
/help -- print this help menu and exit

Expand Down Expand Up @@ -89,6 +90,15 @@ vtk file for each time in the full-field data structure, and the entire
Y-Z grid is printed in each file. This format can be used to visualize
the wind field using a viewer such as ParaView.

Uniform Wind
~~~~~~~~~~~~

This format generates a text file in the uniform wind format. Converting to this format will
generally lose information in the file because it specifies the wind speed and direction
at only one point and approximates the shear as a power-law exponent.



Converting uniform wind to full-field wind format
-------------------------------------------------

Expand All @@ -113,3 +123,18 @@ full-field wind files, equal to the time it takes to travel the distance
of half the grid width. When using the resulting full-field files, care
must be taken that the aeroelastic code does not treat it as periodic.


Converting from a full-field wind format to uniform wind format
---------------------------------------------------------------

When converting from a full-field wind format to a uniform wind file, the following assumptions are used:

- The gust speed, horizontal shear, and vertical linear shear are all 0.
- The Uniform Wind reference height is on a full-field grid point.
- The upflow is calculated using the mean upflow value at the reference point.
- The mean wind direction and upflow are removed from the reference grid point before writing the velocities to the Uniform Wind file.
- The wind direction in the file is the sum of the mean wind direction and the instantaneous direction calculated between instantaneous U and V wind components.
- The power law exponent is either

1. The power-law exponent specified in InflowWind (if a power law wind profile is used to add to the turbulence with native-Bladed or HAWC2 files), or
2. Calculated by using the mean wind speeds at two points: the reference (hub) height and the uppermost height on the grid.
9 changes: 9 additions & 0 deletions modules/aerodyn14/src/AeroDyn14.f90
Original file line number Diff line number Diff line change
Expand Up @@ -121,6 +121,15 @@ SUBROUTINE AD14_Init( InitInp, u, p, x, xd, z, O, y, m, Interval, InitOut, ErrSt
p%DtAero = Interval ! set the default DT here; may be overwritten later, when we read the input file in AD14_GetInput()
p%UseDWM = InitInp%UseDWM

! 2022.09.06 -- ADP
! Recent changes to how the disk average velocity is calculated in InflowWind will likely cause seg-faults in DWM. Therefore
! changes will need to be made to DWM for this to work properly. Since AD14 and DWM will be removed in the very near future,
! it is not a good use of time to fix this. Instead I'll leave this comment here for anyone who really wants to use DWM.
if (p%UseDWM) then
call SetErrStat(ErrID_Fatal, ' DWM is no longer supported and will be deprecated in the near future. We recommend using FAST.Farm instead.', ErrStat,ErrMess,RoutineName )
return
endif

! Define parameters here:

p%WrOptFile = InitInp%WrSumFile
Expand Down
51 changes: 40 additions & 11 deletions modules/inflowwind/src/IfW_BladedFFWind.f90
Original file line number Diff line number Diff line change
Expand Up @@ -93,13 +93,17 @@ SUBROUTINE IfW_BladedFFWind_Init(InitInp, ParamData, MiscVars, InitOutData, ErrS
! If the wind file has zero-mean and unit standard deviation (native Bladed format), scale the data:
!-------------------------------------------------------------------------------------------------
ParamData%FF%AddMeanAfterInterp = .false.
ParamData%FF%WindProfileType = FF_InitInp%WindProfileType
ParamData%FF%Z0 = FF_InitInp%Z0
ParamData%FF%PLExp = FF_InitInp%PLExp
ParamData%FF%VLinShr = FF_InitInp%VLinShr
ParamData%FF%HLinShr = FF_InitInp%HLinShr
ParamData%FF%RefLength = FF_InitInp%RefLength

if (InitInp%NativeBladedFmt) then
ParamData%FF%InterpTower = .true.
ParamData%FF%AddMeanAfterInterp = .true.
ParamData%FF%WindProfileType = FF_InitInp%WindProfileType


! Validate scaling data if we've got native-Bladed format
CALL FFWind_ValidateInput(FF_InitInp, ParamData%FF%NFFComp, TmpErrStat, TmpErrMsg)
Expand All @@ -112,9 +116,10 @@ SUBROUTINE IfW_BladedFFWind_Init(InitInp, ParamData, MiscVars, InitOutData, ErrS
IF (ErrStat >= AbortErrLev) RETURN

! Add the mean wind speed to the u component.
if (.not. ParamData%FF%AddMeanAfterInterp) call AddMeanVelocity(FF_InitInp, ParamData%FF%GridBase, 1.0_ReKi/ParamData%FF%InvFFZD, ParamData%FF%FFData)
if (.not. ParamData%FF%AddMeanAfterInterp) call AddMeanVelocity(FF_InitInp, ParamData%FF%GridBase, 1.0_ReKi/ParamData%FF%InvFFZD, 1.0_ReKi/ParamData%FF%InvFFYD, ParamData%FF%FFData)
else
ParamData%FF%InterpTower = .false.
ParamData%FF%WindProfileType = WindProfileType_None
end if


Expand Down Expand Up @@ -244,7 +249,9 @@ SUBROUTINE ReadFiles(InitInp, FF_InitInp, InitOut, ParamData, TI, ErrStat, ErrMs


if (InitInp%NativeBladedFmt) then
call Read_NativeBladedSummary(InitInp%WindFileName, FF_InitInp%PLExp, NatTI, ParamData%FF%MeanFFWS, ParamData%FF%RefHt, InitOut%PropagationDir, InitOut%VFlowAngle, BinFileName, FF_InitInp%XOffset, TmpErrStat, TmpErrMsg)
call Read_NativeBladedSummary(InitInp%WindFileName, FF_InitInp%PLExp, FF_InitInp%VLinShr, FF_InitInp%HLinShr, FF_InitInp%RefLength, &
NatTI, ParamData%FF%MeanFFWS, ParamData%FF%RefHt, InitOut%PropagationDir, InitOut%VFlowAngle, &
BinFileName, FF_InitInp%XOffset, TmpErrStat, TmpErrMsg)
CALL SetErrStat(TmpErrStat,TmpErrMsg,ErrStat,ErrMsg,RoutineName)
IF ( ErrStat >= AbortErrLev ) RETURN

Expand Down Expand Up @@ -283,6 +290,10 @@ SUBROUTINE ReadFiles(InitInp, FF_InitInp, InitOut, ParamData, TI, ErrStat, ErrMs
else
InitOut%PropagationDir = 0.0_ReKi
InitOut%VFlowAngle = 0.0_ReKi
FF_InitInp%VLinShr = 0.0_ReKi
FF_InitInp%HLinShr = 0.0_ReKi
FF_InitInp%RefLength = 1.0_ReKi

BinFileName = InitInp%WindFileName
end if

Expand Down Expand Up @@ -1700,7 +1711,7 @@ END SUBROUTINE Read_FF_Tower
!====================================================================================================
!> This subroutine reads the text summary file to get normalizing parameters, the location of the
!! grid, and the direction the grid was written to the binary file
SUBROUTINE Read_NativeBladedSummary ( FileName, PLExp, TI, UBar, RefHt, PropagationDir, VFlowAngle, BinFileName, XOffset, ErrStat, ErrMsg )
SUBROUTINE Read_NativeBladedSummary ( FileName, PLExp, VLinShr, HLinShr, RefLength, TI, UBar, RefHt, PropagationDir, VFlowAngle, BinFileName, XOffset, ErrStat, ErrMsg )

IMPLICIT NONE

Expand All @@ -1710,6 +1721,9 @@ SUBROUTINE Read_NativeBladedSummary ( FileName, PLExp, TI, UBar, RefHt, Propagat
! Passed variables
CHARACTER(*), INTENT(IN ) :: FileName !< name of the summary file
REAL(ReKi), INTENT( OUT) :: PLExp !< the power-law exponent for vertical wind shear
REAL(ReKi), INTENT( OUT) :: VLinShr !< the linear shape for vertical wind shear
REAL(ReKi), INTENT( OUT) :: HLinShr !< the linear shape for horizontal wind shear
REAL(ReKi), INTENT( OUT) :: RefLength !< Reference (rotor) diameter
REAL(ReKi), INTENT( OUT) :: TI (3) !< turbulence intensities of the wind components as defined in the FF file, not necessarially the actual TI
REAL(ReKi), INTENT( OUT) :: UBar !< mean (advection) wind speed
REAL(ReKi), INTENT( OUT) :: RefHt !< Reference height
Expand Down Expand Up @@ -1786,12 +1800,28 @@ SUBROUTINE Read_NativeBladedSummary ( FileName, PLExp, TI, UBar, RefHt, Propagat
CALL Cleanup()
RETURN
END IF


CALL ParseVar ( FileInfo, CurLine, 'VLINSHEAR', VLinShr, ErrStat2, ErrMsg2, UnEc )
if (ErrStat2/=ErrID_None) then
VLinShr = 0.0_ReKi ! this will be the default if VLINSHEAR is not in the file
end if

CALL ParseVar ( FileInfo, CurLine, 'HLINSHEAR', HLinShr, ErrStat2, ErrMsg2, UnEc )
if (ErrStat2/=ErrID_None) then
HLinShr = 0.0_ReKi ! this will be the default if HLINSHEAR is not in the file
end if

CALL ParseVar ( FileInfo, CurLine, 'REFLENGTH', RefLength, ErrStat2, ErrMsg2, UnEc )
if (ErrStat2/=ErrID_None) then
RefLength = 0.0_ReKi ! this will be the default if RefLength is not in the file; it will cause an error if either of the linear shears are non-zero
end if

CALL ParseVar ( FileInfo, CurLine, 'XOffset', XOffset, ErrStat2, ErrMsg2, UnEc )
if (ErrStat2/=ErrID_None) then
XOffset = 0.0_ReKi ! this will be the default if offset is not in the file
end if
if (ErrStat2/=ErrID_None) then
XOffset = 0.0_ReKi ! this will be the default if offset is not in the file
end if


!-------------------------------------------------------------------------------------------------
! Get rid of the FileInfo data structure (including pointers and allocatable array):
Expand All @@ -1818,7 +1848,7 @@ END SUBROUTINE Read_NativeBladedSummary
!! day. For now, it merely needs to be functional. It can be fixed up and made all pretty later.
!!
!! 16-Apr-2013 - A. Platt, NREL. Converted to modular framework. Modified for NWTC_Library 2.0
SUBROUTINE IfW_BladedFFWind_CalcOutput(Time, PositionXYZ, ParamData, Velocity, DiskVel, MiscVars, ErrStat, ErrMsg)
SUBROUTINE IfW_BladedFFWind_CalcOutput(Time, PositionXYZ, ParamData, Velocity, MiscVars, ErrStat, ErrMsg)

IMPLICIT NONE

Expand All @@ -1829,7 +1859,6 @@ SUBROUTINE IfW_BladedFFWind_CalcOutput(Time, PositionXYZ, ParamData, Velocity, D
REAL(ReKi), INTENT(IN ) :: PositionXYZ(:,:) !< Array of XYZ coordinates, 3xN
TYPE(IfW_BladedFFWind_ParameterType), INTENT(IN ) :: ParamData !< Parameters
REAL(ReKi), INTENT(INOUT) :: Velocity(:,:) !< Velocity output at Time (Set to INOUT so that array does not get deallocated)
REAL(ReKi), INTENT( OUT) :: DiskVel(3) !< HACK for AD14: disk velocity output at Time
TYPE(IfW_BladedFFWind_MiscVarType), INTENT(INOUT) :: MiscVars !< misc/optimization data (storage for the main data)

! Error handling
Expand All @@ -1838,7 +1867,7 @@ SUBROUTINE IfW_BladedFFWind_CalcOutput(Time, PositionXYZ, ParamData, Velocity, D



CALL IfW_FFWind_CalcOutput(Time, PositionXYZ, ParamData%FF, Velocity, DiskVel, ErrStat, ErrMsg)
CALL IfW_FFWind_CalcOutput(Time, PositionXYZ, ParamData%FF, Velocity, ErrStat, ErrMsg)


RETURN
Expand Down
20 changes: 10 additions & 10 deletions modules/inflowwind/src/IfW_C_Binding.f90
Original file line number Diff line number Diff line change
Expand Up @@ -32,16 +32,16 @@ MODULE InflowWind_C_BINDING
PUBLIC :: IfW_C_End

! Accessible to all routines inside module
TYPE(InflowWind_InputType) :: InputData !< Inputs to InflowWind
TYPE(InflowWind_InitInputType) :: InitInp
TYPE(InflowWind_InitOutputType) :: InitOutData !< Initial output data -- Names, units, and version info.
TYPE(InflowWind_ParameterType) :: p !< Parameters
TYPE(InflowWind_ContinuousStateType) :: ContStates !< Initial continuous states
TYPE(InflowWind_DiscreteStateType) :: DiscStates !< Initial discrete states
TYPE(InflowWind_ConstraintStateType) :: ConstrStates !< Constraint states at Time
TYPE(InflowWind_OtherStateType) :: OtherStates !< Initial other/optimization states
TYPE(InflowWind_OutputType) :: y !< Initial output (outputs are not calculated; only the output mesh is initialized)
TYPE(InflowWind_MiscVarType) :: m !< Misc variables for optimization (not copied in glue code)
TYPE(InflowWind_InputType) , SAVE :: InputData !< Inputs to InflowWind
TYPE(InflowWind_InitInputType) , SAVE :: InitInp
TYPE(InflowWind_InitOutputType) , SAVE :: InitOutData !< Initial output data -- Names, units, and version info.
TYPE(InflowWind_ParameterType) , SAVE :: p !< Parameters
TYPE(InflowWind_ContinuousStateType) , SAVE :: ContStates !< Initial continuous states
TYPE(InflowWind_DiscreteStateType) , SAVE :: DiscStates !< Initial discrete states
TYPE(InflowWind_ConstraintStateType) , SAVE :: ConstrStates !< Constraint states at Time
TYPE(InflowWind_OtherStateType) , SAVE :: OtherStates !< Initial other/optimization states
TYPE(InflowWind_OutputType) , SAVE :: y !< Initial output (outputs are not calculated; only the output mesh is initialized)
TYPE(InflowWind_MiscVarType) , SAVE :: m !< Misc variables for optimization (not copied in glue code)

! This must exactly match the value in the Python interface. We are not using the variable 'ErrMsgLen'
! so that we avoid issues if ErrMsgLen changes in the NWTC Library. If the value of ErrMsgLen does change
Expand Down
Loading