Skip to content

Commit 6dc4fd8

Browse files
authored
Merge pull request #3323 from andrew-platt/b/FF_wake_plane_passing
FAST.Farm: fix indexing on dropping wake planes that get dropped
2 parents 57ad6f9 + b0e0ad5 commit 6dc4fd8

5 files changed

Lines changed: 58 additions & 38 deletions

File tree

glue-codes/fast-farm/src/FAST_Farm_IO.f90

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -775,11 +775,11 @@ SUBROUTINE Farm_ReadPrimaryFile( InputFile, p, WD_InitInp, AWAE_InitInp, OutList
775775

776776
CALL ReadVarWDefault( UnIn, InputFile, WD_InitInp%NumDFull, "NumDFull", &
777777
"Distance of full wake propagation, expressed as a multiple of RotorDiamRef [>0.0] or DEFAULT [DEFAULT=15]", &
778-
15_IntKi, ErrStat2, ErrMsg2, UnEc); if (Failed()) return
778+
15.0_ReKi, ErrStat2, ErrMsg2, UnEc); if (Failed()) return
779779

780780
CALL ReadVarWDefault( UnIn, InputFile, WD_InitInp%NumDBuff, "NumDBuff", &
781781
"Length of wake propagation buffer region, expressed as a multiple of RotorDiamRef [>=0.0] or DEFAULT [DEFAULT=5]", &
782-
5_IntKi, ErrStat2, ErrMsg2, UnEc); if (Failed()) return
782+
5.0_ReKi, ErrStat2, ErrMsg2, UnEc); if (Failed()) return
783783

784784
WD_InitInp%RotorDiamRef = p%RotorDiamRef
785785

glue-codes/fast-farm/src/FAST_Farm_Subs.f90

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -211,7 +211,7 @@ SUBROUTINE Farm_Initialize( farm, InputFile, ErrStat, ErrMsg )
211211
call AllocAry( farm%p%MaxNumPlanes, farm%p%NumTurbines, 'farm%p%MaxNumPlanes', ErrStat2, ErrMsg2); CALL SetErrStat( ErrStat2, ErrMsg2, ErrStat, ErrMsg, RoutineName); if (Failed()) return
212212
do i=1,farm%p%NumTurbines
213213
! Eventually, we will have different settings for different rotors
214-
farm%p%MaxNumPlanes(i) = ceiling( 15.0 * Real( WD_InitInput%InputFileData%NumDFull + WD_InitInput%InputFileData%NumDBuff , ReKi ) / AWAE_InitInput%InputFileData%C_Meander )
214+
farm%p%MaxNumPlanes(i) = ceiling( 15.0 * ( WD_InitInput%InputFileData%NumDFull + WD_InitInput%InputFileData%NumDBuff ) / AWAE_InitInput%InputFileData%C_Meander )
215215
farm%p%MaxNumPlanes(i) = max( 2, min( farm%p%MaxNumPlanes(i) , farm%p%n_TMax + 2 ) )
216216
end do
217217

modules/wakedynamics/src/WakeDynamics.f90

Lines changed: 51 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -970,42 +970,62 @@ subroutine WD_UpdateStates( t, n, u, p, x, xd, z, OtherState, m, errStat, errMsg
970970

971971
do i=maxPln,0,-1
972972

973+
! if a plane is beyond the buffer, simply drop it and all following planes (it should only be the last plane that gets dropped)
973974
if ( xd%x_plane(i) > p%x_Buff ) then
975+
xd%NumPlanes = max( xd%NumPlanes - 1.0, 2.0 ) ! Plane indexing includes 0, hence the -1.0
976+
cycle
977+
endif
974978

975-
xd%NumPlanes = max( xd%NumPlanes - 1.0, 2.0 )
976-
977-
else if ( i+1 < NINT(xd%NumPlanes) .and. xd%x_plane(i) >= xd%x_plane(i+1) ) then
978-
979-
call SetErrStat(ErrID_Warn, ' Turbine '//trim(num2lstr(p%TurbNum))//' wake plane '//trim(num2lstr(i))//' (x_plane='//trim(num2lstr(xd%x_plane(i)))//') has overtaken wake plane '//trim(num2lstr(i+1))//' (x_plane='//trim(num2lstr(xd%x_plane(i+1)))//'). Offending wake plane removed. Reduce f_c to prevent planes from passing each other. ', errStat, errMsg, RoutineName)
980-
if (errStat >= AbortErrLev) then
981-
call Cleanup()
982-
return
983-
end if
984-
985-
! Remove offending plane and shift everything behind up
986-
987-
xd%NumPlanes = xd%NumPlanes - 1.0
988-
989-
! Didn't check xd%NumPlanes >= 2 here. The first wake plane is unlikely to move upwind of the rotor.
990-
991-
do j = i+1,NINT(xd%NumPlanes)-1
979+
! If a plane overtakes another plane, merge the planes by averaging, then shift all remaining planes forward.
980+
if ( i+1 < NINT(xd%NumPlanes)) then ! don't overstep bounds with i+1 indexing
981+
if (xd%x_plane(i) >= xd%x_plane(i+1) ) then
992982

993-
xd%Vx_wind_disk_filt(j-1) = xd%Vx_wind_disk_filt(j)
994-
xd%x_plane ( j-1) = xd%x_plane ( j)
995-
xd%TI_amb_filt ( j-1) = xd%TI_amb_filt ( j)
996-
xd%D_rotor_filt ( j-1) = xd%D_rotor_filt ( j)
997-
xd%YawErr_filt ( j-1) = xd%YawErr_filt ( j)
998-
xd%p_plane ( :,j-1) = xd%p_plane ( :,j)
999-
xd%xhat_plane ( :,j-1) = xd%xhat_plane ( :,j)
1000-
xd%V_plane_filt ( :,j-1) = xd%V_plane_filt ( :,j)
1001-
xd%Vx_wake ( :,j-1) = xd%Vx_wake ( :,j)
1002-
xd%Vr_wake ( :,j-1) = xd%Vr_wake ( :,j)
1003-
xd%Vx_wake2 (:,:,j-1) = xd%Vx_wake2 (:,:,j)
1004-
xd%Vy_wake2 (:,:,j-1) = xd%Vy_wake2 (:,:,j)
1005-
xd%Vz_wake2 (:,:,j-1) = xd%Vz_wake2 (:,:,j)
983+
call SetErrStat(ErrID_Warn, ' Turbine '//trim(num2lstr(p%TurbNum))//' wake plane '//trim(num2lstr(i))// &
984+
' (x_plane='//trim(num2lstr(xd%x_plane(i)))//') has overtaken wake plane '//trim(num2lstr(i+1))// &
985+
' (x_plane='//trim(num2lstr(xd%x_plane(i+1)))// &
986+
'). Merging planes by averaging. Reduce f_c to prevent planes from passing each other. ', errStat, errMsg, RoutineName)
987+
if (errStat >= AbortErrLev) then
988+
call Cleanup()
989+
return
990+
end if
1006991

1007-
end do
992+
! Merge the i and i+1 plane by averaging them together
993+
xd%Vx_wind_disk_filt(i) = (xd%Vx_wind_disk_filt(i) + xd%Vx_wind_disk_filt(i+1)) / 2.0_ReKi
994+
xd%x_plane ( i) = (xd%x_plane ( i) + xd%x_plane ( i+1)) / 2.0_ReKi
995+
xd%TI_amb_filt ( i) = (xd%TI_amb_filt ( i) + xd%TI_amb_filt ( i+1)) / 2.0_ReKi
996+
xd%D_rotor_filt ( i) = (xd%D_rotor_filt ( i) + xd%D_rotor_filt ( i+1)) / 2.0_ReKi
997+
xd%YawErr_filt ( i) = (xd%YawErr_filt ( i) + xd%YawErr_filt ( i+1)) / 2.0_ReKi
998+
xd%p_plane ( :,i) = (xd%p_plane ( :,i) + xd%p_plane ( :,i+1)) / 2.0_ReKi
999+
xd%xhat_plane ( :,i) = (xd%xhat_plane ( :,i) + xd%xhat_plane ( :,i+1)) / 2.0_ReKi
1000+
xd%xhat_plane ( :,i) = xd%xhat_plane ( :,i) / TwoNorm(xd%xhat_plane( :,i)) ! renormalize
1001+
xd%V_plane_filt ( :,i) = (xd%V_plane_filt ( :,i) + xd%V_plane_filt ( :,i+1)) / 2.0_ReKi
1002+
xd%Vx_wake ( :,i) = (xd%Vx_wake ( :,i) + xd%Vx_wake ( :,i+1)) / 2.0_ReKi
1003+
xd%Vr_wake ( :,i) = (xd%Vr_wake ( :,i) + xd%Vr_wake ( :,i+1)) / 2.0_ReKi
1004+
xd%Vx_wake2 (:,:,i) = (xd%Vx_wake2 (:,:,i) + xd%Vx_wake2 (:,:,i+1)) / 2.0_ReKi
1005+
xd%Vy_wake2 (:,:,i) = (xd%Vy_wake2 (:,:,i) + xd%Vy_wake2 (:,:,i+1)) / 2.0_ReKi
1006+
xd%Vz_wake2 (:,:,i) = (xd%Vz_wake2 (:,:,i) + xd%Vz_wake2 (:,:,i+1)) / 2.0_ReKi
1007+
1008+
! Since i and i+1 planes are now merged effectively dropping a plane, shift all planes that follow forward
1009+
do j = i+1,NINT(xd%NumPlanes)-2 ! NumPlanes includes 0 index plane, so last valid index is NumPlanes-1.
1010+
xd%Vx_wind_disk_filt(j) = xd%Vx_wind_disk_filt(j+1)
1011+
xd%x_plane ( j) = xd%x_plane ( j+1)
1012+
xd%TI_amb_filt ( j) = xd%TI_amb_filt ( j+1)
1013+
xd%D_rotor_filt ( j) = xd%D_rotor_filt ( j+1)
1014+
xd%YawErr_filt ( j) = xd%YawErr_filt ( j+1)
1015+
xd%p_plane ( :,j) = xd%p_plane ( :,j+1)
1016+
xd%xhat_plane ( :,j) = xd%xhat_plane ( :,j+1)
1017+
xd%V_plane_filt ( :,j) = xd%V_plane_filt ( :,j+1)
1018+
xd%Vx_wake ( :,j) = xd%Vx_wake ( :,j+1)
1019+
xd%Vr_wake ( :,j) = xd%Vr_wake ( :,j+1)
1020+
xd%Vx_wake2 (:,:,j) = xd%Vx_wake2 (:,:,j+1)
1021+
xd%Vy_wake2 (:,:,j) = xd%Vy_wake2 (:,:,j+1)
1022+
xd%Vz_wake2 (:,:,j) = xd%Vz_wake2 (:,:,j+1)
1023+
end do
1024+
1025+
! Now that we shifted the planes up, remove the last one
1026+
xd%NumPlanes = xd%NumPlanes - 1.0
10081027

1028+
end if
10091029
end if
10101030

10111031
end do

modules/wakedynamics/src/WakeDynamics_Registry.txt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,8 +25,8 @@ param ^ - INTEGER Mod_Wake_Cartesian
2525
# ..... InputFile Data .......................................................................................................
2626
typedef ^ WD_InputFileType ReKi dr - - - "Radial increment of radial finite-difference grid [>0.0]" m
2727
typedef ^ WD_InputFileType IntKi NumRadii - - - "Number of radii in the radial finite-difference grid [>=2]" -
28-
typedef ^ WD_InputFileType IntKi NumDFull - - - "Distance of full wake propagation as a multiple of RotorDiamRef" -
29-
typedef ^ WD_InputFileType IntKi NumDBuff - - - "Length of wake propagation buffer region as a multiple of RotorDiamRef" -
28+
typedef ^ WD_InputFileType ReKi NumDFull - - - "Distance of full wake propagation as a multiple of RotorDiamRef" -
29+
typedef ^ WD_InputFileType ReKi NumDBuff - - - "Length of wake propagation buffer region as a multiple of RotorDiamRef" -
3030
typedef ^ WD_InputFileType IntKi Mod_Wake - - - "Switch between wake formulations 1=Polar, 2=Cartesian, 3=Curl" -
3131
typedef ^ WD_InputFileType ReKi f_c - - - "Cut-off frequency of the low-pass time-filter for the wake advection, deflection, and meandering model [>0.0]" Hz
3232
typedef ^ WD_InputFileType ReKi C_HWkDfl_O - - - "Calibrated parameter in the correction for wake deflection defining the horizontal offset at the rotor" m

modules/wakedynamics/src/WakeDynamics_Types.f90

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -44,8 +44,8 @@ MODULE WakeDynamics_Types
4444
TYPE, PUBLIC :: WD_InputFileType
4545
REAL(ReKi) :: dr = 0.0_ReKi !< Radial increment of radial finite-difference grid [>0.0] [m]
4646
INTEGER(IntKi) :: NumRadii = 0_IntKi !< Number of radii in the radial finite-difference grid [>=2] [-]
47-
INTEGER(IntKi) :: NumDFull = 0_IntKi !< Distance of full wake propagation as a multiple of RotorDiamRef [-]
48-
INTEGER(IntKi) :: NumDBuff = 0_IntKi !< Length of wake propagation buffer region as a multiple of RotorDiamRef [-]
47+
REAL(ReKi) :: NumDFull = 0.0_ReKi !< Distance of full wake propagation as a multiple of RotorDiamRef [-]
48+
REAL(ReKi) :: NumDBuff = 0.0_ReKi !< Length of wake propagation buffer region as a multiple of RotorDiamRef [-]
4949
INTEGER(IntKi) :: Mod_Wake = 0_IntKi !< Switch between wake formulations 1=Polar, 2=Cartesian, 3=Curl [-]
5050
REAL(ReKi) :: f_c = 0.0_ReKi !< Cut-off frequency of the low-pass time-filter for the wake advection, deflection, and meandering model [>0.0] [Hz]
5151
REAL(ReKi) :: C_HWkDfl_O = 0.0_ReKi !< Calibrated parameter in the correction for wake deflection defining the horizontal offset at the rotor [m]

0 commit comments

Comments
 (0)