Skip to content

Commit

Permalink
Merge pull request #1 from Russell9798/Lidar-IfW-Updates
Browse files Browse the repository at this point in the history
Lidar-IfW-updates
  • Loading branch information
Russell9798 authored Mar 9, 2023
2 parents f8636c8 + 3876a20 commit 3b114ad
Show file tree
Hide file tree
Showing 7 changed files with 232 additions and 201 deletions.
28 changes: 14 additions & 14 deletions modules/inflowwind/src/InflowWind.txt
Original file line number Diff line number Diff line change
Expand Up @@ -91,20 +91,20 @@ typedef ^ ^ ReKi HAWC_dy
typedef ^ ^ ReKi HAWC_dz - - - "HAWC -- distance between points in z direction" meters
typedef ^ ^ LOGICAL SumPrint - - - "Write summary info to a file <ROOTNAME>.IfW.Sum" -
typedef ^ ^ IntKi NumOuts - - - "Number of parameters in the output list (number of outputs requested)" -
typedef ^ ^ CHARACTER(ChanLen) OutList : - - "List of user-requested output channels" -
typedef ^ ^ IntKi SensorType - - - "Sensor type (for lidar/sensor module)" -
typedef ^ ^ IntKi NumBeam - - - "Number of lidar beams"
typedef ^ ^ IntKi NumPulseGate - - - "The number of range gates to return wind speeds at" -
typedef ^ ^ ReKi RotorApexOffsetPos 3 - - "position of the lidar unit relative to the rotor apex of rotation" m
typedef ^ ^ LOGICAL LidRadialVel - - - "TRUE => return radial component, FALSE => return 'x' direction estimate" -
typedef ^ ^ CHARACTER(ChanLen) OutList : - - "List of user-requested output channels" -
typedef ^ ^ IntKi SensorType - - - "Sensor type (for lidar/sensor module)" -
typedef ^ ^ IntKi NumBeam - - - "Number of lidar beams" -
typedef ^ ^ IntKi NumPulseGate - - - "The number of range gates to return wind speeds at" -
typedef ^ ^ ReKi RotorApexOffsetPos {3} - - "Position of the lidar unit relative to the rotor apex of rotation" m
typedef ^ ^ ReKi FocalDistanceX : - - "LIDAR LOS focal distance co-ordinates in the x direction" m
typedef ^ ^ ReKi FocalDistanceY : - - "LIDAR LOS focal distance co-ordinates in the y direction" m
typedef ^ ^ ReKi FocalDistanceZ : - - "LIDAR LOS focal distance co-ordinates in the z direction" m
typedef ^ ^ ReKi PulseSpacing - - - "Distance between range gates" m
typedef ^ ^ ReKi MeasurementInterval - - - "Time between each measurement" s
typedef ^ ^ ReKi URefLid - - - "Reference average wind speed for the lidar" m/s
typedef ^ ^ IntKi ConsiderHubMotion - - - "Flag whether the hub motion's impact on the Lidar measurement will be considered" -
typedef ^ ^ IfW_FFWind_InitInputType FF - - - "scaling data" -
typedef ^ ^ ReKi PulseSpacing - - - "Distance between range gates" m
typedef ^ ^ ReKi MeasurementInterval - - - "Time between each measurement" s
typedef ^ ^ ReKi URefLid - - - "Reference average wind speed for the lidar" m/s
typedef ^ ^ LOGICAL LidRadialVel - - - "TRUE => return radial component, FALSE => return 'x' direction estimate" -
typedef ^ ^ IntKi ConsiderHubMotion - - - "Flag whether or not the hub motion's impact on the Lidar measurement will be considered" -
typedef ^ ^ IfW_FFWind_InitInputType FF - - - "scaling data" -



Expand All @@ -117,11 +117,11 @@ typedef ^ ^ LOGICAL FixedWindFi
typedef ^ ^ LOGICAL UseInputFile - .TRUE. - "Should we read everthing from an input file, or do we get it some other way" -
typedef ^ ^ CHARACTER(1024) RootName - - - "RootName for writing output files"
typedef ^ ^ FileInfoType PassedFileData - - - "If we don't use the input file, pass everything through this" -
typedef ^ ^ LOGICAL WindType2UseInputFile - .TRUE. - "Flag for toggling file based IO in wind type 2." -
typedef ^ ^ FileInfoType WindType2Data - - - "Optional slot for wind type 2 data if file IO is not used." -
typedef ^ ^ LOGICAL WindType2UseInputFile - .TRUE. - "Flag for toggling file based IO in wind type 2." -
typedef ^ ^ FileInfoType WindType2Data - - - "Optional slot for wind type 2 data if file IO is not used." -
typedef ^ ^ Lidar_InitInputType lidar - - - "InitInput for lidar data" -
typedef ^ ^ IfW_4Dext_InitInputType FDext - - - "InitInput for 4D external wind data" -
typedef ^ ^ ReKi RadAvg - - - "Radius (from hub) used for averaging wind speed" -
typedef ^ ^ ReKi RadAvg - - - "Radius (from hub) used for averaging wind speed" -


# Init Output
Expand Down
182 changes: 83 additions & 99 deletions modules/inflowwind/src/InflowWind_Subs.f90
Original file line number Diff line number Diff line change
Expand Up @@ -269,105 +269,6 @@ SUBROUTINE InflowWind_ParseInputFileInfo( InputFileData, InFileInfo, PriPath, In

CALL ParseAry( InFileInfo, CurLine, 'WindVziList', InputFileData%WindVziList, InputFileData%NWindVel, TmpErrStat, TmpErrMsg, UnEc )
if (Failed()) return


!-------------------------------------------------------------------------------------------------
!> Read the _Parameters for LIDAR section
!-------------------------------------------------------------------------------------------------

CurLine = CurLine + 1 ! Skip section break

! LIDAR Sensor Type
CALL ParseVar( InFileInfo, CurLine, "SensorType", InputFileData%SensorType, TmpErrStat, TmpErrMsg, UnEc )
CALL SetErrStat( TmpErrStat, TmpErrMsg, ErrStat, ErrMsg, RoutineName )
IF (Failed()) RETURN

! Number of Range Gates
CALL ParseVar( InFileInfo, CurLine, "NumPulseGate", InputFileData%NumPulseGate, TmpErrStat, TmpErrMsg, UnEc )
CALL SetErrStat( TmpErrStat, TmpErrMsg, ErrStat, ErrMsg, RoutineName )
IF (Failed()) RETURN

! Before proceeding, make sure that NumPulseGate makes sense
IF ( InputFileData%NumPulseGate < 0 .OR. InputFileData%NumPulseGate > 5 ) THEN
CALL SetErrStat( ErrID_Fatal, 'NumPulseGate must be greater than or equal to zero and less than 5.', &
ErrStat, ErrMsg, RoutineName )
RETURN
ENDIF

! Pulse Gate Spacing
CALL ParseVar( InFileInfo, CurLine, "PulseSpacing", InputFileData%PulseSpacing, TmpErrStat, TmpErrMsg, UnEc )
CALL SetErrStat( TmpErrStat, TmpErrMsg, ErrStat, ErrMsg, RoutineName )
IF (Failed()) RETURN

! NumBeam: Number of points to output the lidar measured wind velocity (1 to 5)
CALL ParseVar( InFileInfo, CurLine, "NumBeam", InputFileData%NumBeam, TmpErrStat, TmpErrMsg, UnEc )
CALL SetErrStat( TmpErrStat, TmpErrMsg, ErrStat, ErrMsg, RoutineName )
if (Failed()) return

! Before proceeding, make sure that NumBeam makes sense
IF ( InputFileData%NumBeam < 1 .OR. InputFileData%NumBeam > 5 ) THEN
CALL SetErrStat( ErrID_Fatal, 'NumBeam must be greater than or equal to one and less than 6.', &
ErrStat, ErrMsg, RoutineName )
RETURN
ENDIF

! Before proceeding, make sure that NumBeam makes sense
IF ( InputFileData%NumBeam > 1 .AND. InputFileData%SensorType > 1) THEN
CALL SetErrStat( ErrID_Fatal, 'Multiple beams can only be used with single point lidar', &
ErrStat, ErrMsg, RoutineName )
RETURN

ELSE
! Allocate space for the output location arrays:
CALL AllocAry( InputFileData%FocalDistanceX, InputFileData%NumBeam, 'NumBeam', TmpErrStat, TmpErrMsg )
CALL SetErrStat( TmpErrStat, TmpErrMsg, ErrStat, ErrMsg, RoutineName )
CALL AllocAry( InputFileData%FocalDistanceY, InputFileData%NumBeam, 'NumBeam', TmpErrStat, TmpErrMsg )
CALL SetErrStat( TmpErrStat, TmpErrMsg, ErrStat, ErrMsg, RoutineName )
CALL AllocAry( InputFileData%FocalDistanceZ, InputFileData%NumBeam, 'NumBeam', TmpErrStat, TmpErrMsg )
CALL SetErrStat( TmpErrStat, TmpErrMsg, ErrStat, ErrMsg, RoutineName )
if (Failed()) return
ENDIF

! Focal Distance X
CALL ParseAry( InFileInfo, CurLine, 'FocalDistanceX', InputFileData%FocalDistanceX, InputFileData%NumBeam, TmpErrStat, TmpErrMsg, UnEc )
CALL SetErrStat( TmpErrStat, TmpErrMsg, ErrStat, ErrMsg, RoutineName )
if (Failed()) return

! Focal Distance Y
CALL ParseAry( InFileInfo, CurLine, 'FocalDistanceY', InputFileData%FocalDistanceY, InputFileData%NumBeam, TmpErrStat, TmpErrMsg, UnEc )
CALL SetErrStat( TmpErrStat, TmpErrMsg, ErrStat, ErrMsg, RoutineName )
if (Failed()) return

! Focal Distance Z
CALL ParseAry( InFileInfo, CurLine, 'FocalDistanceZ', InputFileData%FocalDistanceZ, InputFileData%NumBeam, TmpErrStat, TmpErrMsg, UnEc )
CALL SetErrStat( TmpErrStat, TmpErrMsg, ErrStat, ErrMsg, RoutineName )
if (Failed()) return

! Rotor Apex Offset Position
CALL ParseAry( InFileInfo, CurLine, "RotorApexOffsetPos", InputFileData%RotorApexOffsetPos, 1, TmpErrStat, TmpErrMsg, UnEc )
CALL SetErrStat( TmpErrStat, TmpErrMsg, ErrStat, ErrMsg, RoutineName )
IF (Failed()) RETURN

! URefIni
CALL ParseVar( InFileInfo, CurLine, "URefLid", InputFileData%URefLid, TmpErrStat, TmpErrMsg, UnEc )
CALL SetErrStat( TmpErrStat, TmpErrMsg, ErrStat, ErrMsg, RoutineName )
IF (Failed()) RETURN

! Measurement Interval
CALL ParseVar( InFileInfo, CurLine, "MeasurementInterval", InputFileData%MeasurementInterval, TmpErrStat, TmpErrMsg, UnEc )
CALL SetErrStat( TmpErrStat, TmpErrMsg, ErrStat, ErrMsg, RoutineName )
IF (Failed()) RETURN

! Lidar Radial Vel
CALL ParseLoVar( InFileInfo, CurLine, "LidRadialVel", InputFileData%LidRadialVel, TmpErrStat, TmpErrMsg, UnEc )
CALL SetErrStat( TmpErrStat, TmpErrMsg, ErrStat, ErrMsg, RoutineName )
IF (Failed()) RETURN

! Consider Hub Motion
CALL ParseVar( InFileInfo, CurLine, "ConsiderHubMotion", InputFileData%ConsiderHubMotion, TmpErrStat, TmpErrMsg, UnEc )
CALL SetErrStat( TmpErrStat, TmpErrMsg, ErrStat, ErrMsg, RoutineName )
IF (Failed()) RETURN


!-------------------------------------------------------------------------------------------------
!> Read the _Parameters for Steady Wind Conditions [used only for WindType = 1]_ section
Expand Down Expand Up @@ -552,6 +453,89 @@ SUBROUTINE InflowWind_ParseInputFileInfo( InputFileData, InFileInfo, PriPath, In

CALL ParseVarWDefault( InFileInfo, CurLine, "XOffset", InputFileData%FF%XOffset, 0.0_ReKi, TmpErrStat, TmpErrMsg, UnEc )
if (Failed()) return

!-------------------------------------------------------------------------------------------------
!> Read the _Parameters for LIDAR section
!-------------------------------------------------------------------------------------------------

CurLine = CurLine + 1 ! Skip section break

! LIDAR Sensor Type
CALL ParseVar( InFileInfo, CurLine, "SensorType", InputFileData%SensorType, TmpErrStat, TmpErrMsg, UnEc )
CALL SetErrStat( TmpErrStat, TmpErrMsg, ErrStat, ErrMsg, RoutineName )
IF (Failed()) RETURN

! Number of Range Gates
CALL ParseVar( InFileInfo, CurLine, "NumPulseGate", InputFileData%NumPulseGate, TmpErrStat, TmpErrMsg, UnEc )
CALL SetErrStat( TmpErrStat, TmpErrMsg, ErrStat, ErrMsg, RoutineName )
IF (Failed()) RETURN

! Pulse Gate Spacing
CALL ParseVar( InFileInfo, CurLine, "PulseSpacing", InputFileData%PulseSpacing, TmpErrStat, TmpErrMsg, UnEc )
CALL SetErrStat( TmpErrStat, TmpErrMsg, ErrStat, ErrMsg, RoutineName )
IF (Failed()) RETURN

! NumBeam: Number of points to output the lidar measured wind velocity (1 to 5)
CALL ParseVar( InFileInfo, CurLine, "NumBeam", InputFileData%NumBeam, TmpErrStat, TmpErrMsg, UnEc )
CALL SetErrStat( TmpErrStat, TmpErrMsg, ErrStat, ErrMsg, RoutineName )
if (Failed()) return

! Before proceeding, make sure that NumBeam makes sense
IF ((InputFileData%SensorType == 1) .and. (InputFileData%NumBeam < 1 .OR. InputFileData%NumBeam > 5)) THEN
CALL SetErrStat( ErrID_Fatal, 'NumBeam must be greater than or equal to one and less than 6.', &
ErrStat, ErrMsg, RoutineName )
RETURN
ELSE
! Allocate space for the output location arrays:
CALL AllocAry( InputFileData%FocalDistanceX, InputFileData%NumBeam, 'NumBeam', TmpErrStat, TmpErrMsg )
CALL SetErrStat( TmpErrStat, TmpErrMsg, ErrStat, ErrMsg, RoutineName )
CALL AllocAry( InputFileData%FocalDistanceY, InputFileData%NumBeam, 'NumBeam', TmpErrStat, TmpErrMsg )
CALL SetErrStat( TmpErrStat, TmpErrMsg, ErrStat, ErrMsg, RoutineName )
CALL AllocAry( InputFileData%FocalDistanceZ, InputFileData%NumBeam, 'NumBeam', TmpErrStat, TmpErrMsg )
CALL SetErrStat( TmpErrStat, TmpErrMsg, ErrStat, ErrMsg, RoutineName )
if (Failed()) return
ENDIF

! Focal Distance X
CALL ParseAry( InFileInfo, CurLine, 'FocalDistanceX', InputFileData%FocalDistanceX, InputFileData%NumBeam, TmpErrStat, TmpErrMsg, UnEc )
CALL SetErrStat( TmpErrStat, TmpErrMsg, ErrStat, ErrMsg, RoutineName )
if (Failed()) return

! Focal Distance Y
CALL ParseAry( InFileInfo, CurLine, 'FocalDistanceY', InputFileData%FocalDistanceY, InputFileData%NumBeam, TmpErrStat, TmpErrMsg, UnEc )
CALL SetErrStat( TmpErrStat, TmpErrMsg, ErrStat, ErrMsg, RoutineName )
if (Failed()) return

! Focal Distance Z
CALL ParseAry( InFileInfo, CurLine, 'FocalDistanceZ', InputFileData%FocalDistanceZ, InputFileData%NumBeam, TmpErrStat, TmpErrMsg, UnEc )
CALL SetErrStat( TmpErrStat, TmpErrMsg, ErrStat, ErrMsg, RoutineName )
if (Failed()) return

! Rotor Apex Offset Position
CALL ParseAry( InFileInfo, CurLine, "RotorApexOffsetPos", InputFileData%RotorApexOffsetPos, 1, TmpErrStat, TmpErrMsg, UnEc )
CALL SetErrStat( TmpErrStat, TmpErrMsg, ErrStat, ErrMsg, RoutineName )
IF (Failed()) RETURN

! URefIni
CALL ParseVar( InFileInfo, CurLine, "URefLid", InputFileData%URefLid, TmpErrStat, TmpErrMsg, UnEc )
CALL SetErrStat( TmpErrStat, TmpErrMsg, ErrStat, ErrMsg, RoutineName )
IF (Failed()) RETURN

! Measurement Interval
CALL ParseVar( InFileInfo, CurLine, "MeasurementInterval", InputFileData%MeasurementInterval, TmpErrStat, TmpErrMsg, UnEc )
CALL SetErrStat( TmpErrStat, TmpErrMsg, ErrStat, ErrMsg, RoutineName )
IF (Failed()) RETURN

! Lidar Radial Vel
CALL ParseLoVar( InFileInfo, CurLine, "LidRadialVel", InputFileData%LidRadialVel, TmpErrStat, TmpErrMsg, UnEc )
CALL SetErrStat( TmpErrStat, TmpErrMsg, ErrStat, ErrMsg, RoutineName )
IF (Failed()) RETURN

! Consider Hub Motion
CALL ParseVar( InFileInfo, CurLine, "ConsiderHubMotion", InputFileData%ConsiderHubMotion, TmpErrStat, TmpErrMsg, UnEc )
CALL SetErrStat( TmpErrStat, TmpErrMsg, ErrStat, ErrMsg, RoutineName )
IF (Failed()) RETURN


!----------------------------------------------------------------------------------------------
!> Read the _OUTPUT_ subsection
Expand Down
32 changes: 22 additions & 10 deletions modules/inflowwind/src/Lidar.f90
Original file line number Diff line number Diff line change
Expand Up @@ -102,10 +102,22 @@ SUBROUTINE Lidar_Init( InitInp, u, p, x, xd, z, OtherState, y, m, Interval, Init
ErrStat = ErrID_None
ErrMsg = ""

!............................................................................................
! Define parameters here:
!............................................................................................

! Check for errors in the InflowWind Input File

! Make sure that NumPulseGate makes sense
IF ( (p%lidar%SensorType == 3) .and. (p%lidar%NumPulseGate < 0 .OR. p%lidar%NumPulseGate > 5) ) THEN
CALL SetErrStat( ErrID_Fatal, 'NumPulseGate must be greater than or equal to zero and less than 5.', &
ErrStat, ErrMsg, RoutineName )
RETURN
ENDIF

! Make sure that multiple beams are only used when using single point beams
IF ( p%lidar%NumBeam > 1 .AND. p%lidar%SensorType > 1) THEN
CALL SetErrStat( ErrID_Fatal, 'Multiple beams can only be used with single point lidar', &
ErrStat, ErrMsg, RoutineName )
RETURN
ENDIF

CALL AllocAry(p%lidar%MsrPosition , 3, p%lidar%NumBeam, 'Array for measurement coordinates', TmpErrStat, TmpErrMsg )
CALL SetErrStat( TmpErrStat, TmpErrMsg, ErrStat, ErrMsg, RoutineName)
IF ( ErrStat>= AbortErrLev ) RETURN
Expand Down Expand Up @@ -351,18 +363,19 @@ SUBROUTINE Lidar_CalcOutput( t, u, p, x, xd, z, OtherState, y, m, ErrStat, ErrMs

IF ( (p%lidar%MeasurementInterval * MeasurementCurrentStep) /= t ) THEN
Output%VelocityUVW(:,1) = 0
RETURN
ENDIF

ELSE
IF (p%lidar%ConsiderHubMotion == 1) THEN
LidPosition_N = (/ u%lidar%HubDisplacementX, u%lidar%HubDisplacementY, u%lidar%HubDisplacementZ /) & ! rotor apex position (absolute)
+ p%lidar%RotorApexOffsetPos ! lidar offset-from-rotor-apex position
LidPosition = p%lidar%LidPosition + LidPosition_N
LidPosition = p%lidar%LidPosition + LidPosition_N
ELSE
LidPosition_N = p%lidar%RotorApexOffsetPos
LidPosition = p%lidar%LidPosition + LidPosition_N
LidPosition_N = p%lidar%RotorApexOffsetPos
LidPosition = p%lidar%LidPosition + LidPosition_N
END IF

IF (p%lidar%SensorType == SensorType_None) RETURN
IF (p%lidar%SensorType == SensorType_None) RETURN

! allocate arrays to compute outputs
CALL AllocAry(Input%PositionXYZ, 3,1, 'Input%PositionXYZ',ErrStat2, ErrMsg2)
Expand Down Expand Up @@ -641,7 +654,6 @@ SUBROUTINE Lidar_CalcOutput( t, u, p, x, xd, z, OtherState, y, m, ErrStat, ErrMs
END DO

END IF
END IF !type of lidar measurementd

CALL Cleanup()

Expand Down
Loading

0 comments on commit 3b114ad

Please sign in to comment.