Skip to content

Commit

Permalink
ADsk: fix vs-build for driver
Browse files Browse the repository at this point in the history
  • Loading branch information
andrew-platt committed Aug 12, 2024
1 parent 6af5bb8 commit 29ad020
Show file tree
Hide file tree
Showing 4 changed files with 19 additions and 350 deletions.
2 changes: 1 addition & 1 deletion modules/aerodisk/src/AeroDisk_Registry.txt
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
###################################################################################################################################
# ...... Include files (definitions from NWTC Library) ............................................................................
include Registry_NWTC_Library.txt
usefrom InflowWind.txt
usefrom IfW_FlowField.txt

# ..... Static Param ..............................................................................................................
param AeroDisk/ADsk - IntKi ADsk_NumPtsDiskAvg - 144 - "Number of points averaged for rotor-average wind speed" -
Expand Down
340 changes: 1 addition & 339 deletions modules/aerodisk/src/AeroDisk_Types.f90
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@
!! unpack routines associated with each defined data type. This code is automatically generated by the FAST Registry.
MODULE AeroDisk_Types
!---------------------------------------------------------------------------------------------------------------------------------
USE InflowWind_Types
USE IfW_FlowField_Types
USE NWTC_Library
IMPLICIT NONE
INTEGER(IntKi), PUBLIC, PARAMETER :: ADsk_NumPtsDiskAvg = 144 ! Number of points averaged for rotor-average wind speed [-]
Expand Down Expand Up @@ -1268,343 +1268,5 @@ subroutine ADsk_UnPackMisc(RF, OutData)
call RegUnpackAlloc(RF, OutData%DiskWindVel); if (RegCheckErr(RF, RoutineName)) return
call RegUnpack(RF, OutData%DiskAvgVel); if (RegCheckErr(RF, RoutineName)) return
end subroutine

subroutine ADsk_Input_ExtrapInterp(u, t, u_out, t_out, ErrStat, ErrMsg)
!
! This subroutine calculates a extrapolated (or interpolated) Input u_out at time t_out, from previous/future time
! values of u (which has values associated with times in t). Order of the interpolation is given by the size of u
!
! expressions below based on either
!
! f(t) = a
! f(t) = a + b * t, or
! f(t) = a + b * t + c * t**2
!
! where a, b and c are determined as the solution to
! f(t1) = u1, f(t2) = u2, f(t3) = u3 (as appropriate)
!
!----------------------------------------------------------------------------------------------------------------------------------

type(ADsk_InputType), intent(inout) :: u(:) ! Input at t1 > t2 > t3
real(DbKi), intent(in ) :: t(:) ! Times associated with the Inputs
type(ADsk_InputType), intent(inout) :: u_out ! Input at tin_out
real(DbKi), intent(in ) :: t_out ! time to be extrap/interp'd to
integer(IntKi), intent( out) :: ErrStat ! Error status of the operation
character(*), intent( out) :: ErrMsg ! Error message if ErrStat /= ErrID_None
! local variables
integer(IntKi) :: order ! order of polynomial fit (max 2)
integer(IntKi) :: ErrStat2 ! local errors
character(ErrMsgLen) :: ErrMsg2 ! local errors
character(*), PARAMETER :: RoutineName = 'ADsk_Input_ExtrapInterp'

! Initialize ErrStat
ErrStat = ErrID_None
ErrMsg = ''
if (size(t) /= size(u)) then
call SetErrStat(ErrID_Fatal, 'size(t) must equal size(u)', ErrStat, ErrMsg, RoutineName)
return
endif
order = size(u) - 1
select case (order)
case (0)
call ADsk_CopyInput(u(1), u_out, MESH_UPDATECOPY, ErrStat2, ErrMsg2)
call SetErrStat(ErrStat2, ErrMsg2, ErrStat, ErrMsg, RoutineName)
case (1)
call ADsk_Input_ExtrapInterp1(u(1), u(2), t, u_out, t_out, ErrStat2, ErrMsg2)
call SetErrStat(ErrStat2, ErrMsg2, ErrStat, ErrMsg, RoutineName)
case (2)
call ADsk_Input_ExtrapInterp2(u(1), u(2), u(3), t, u_out, t_out, ErrStat2, ErrMsg2)
call SetErrStat(ErrStat2, ErrMsg2, ErrStat, ErrMsg, RoutineName)
case default
call SetErrStat(ErrID_Fatal, 'size(u) must be less than 4 (order must be less than 3).', ErrStat, ErrMsg, RoutineName)
return
end select
end subroutine

SUBROUTINE ADsk_Input_ExtrapInterp1(u1, u2, tin, u_out, tin_out, ErrStat, ErrMsg )
!
! This subroutine calculates a extrapolated (or interpolated) Input u_out at time t_out, from previous/future time
! values of u (which has values associated with times in t). Order of the interpolation is 1.
!
! f(t) = a + b * t, or
!
! where a and b are determined as the solution to
! f(t1) = u1, f(t2) = u2
!
!..................................................................................................................................

TYPE(ADsk_InputType), INTENT(INOUT) :: u1 ! Input at t1 > t2
TYPE(ADsk_InputType), INTENT(INOUT) :: u2 ! Input at t2
REAL(DbKi), INTENT(IN ) :: tin(2) ! Times associated with the Inputs
TYPE(ADsk_InputType), INTENT(INOUT) :: u_out ! Input at tin_out
REAL(DbKi), INTENT(IN ) :: tin_out ! time to be extrap/interp'd to
INTEGER(IntKi), INTENT( OUT) :: ErrStat ! Error status of the operation
CHARACTER(*), INTENT( OUT) :: ErrMsg ! Error message if ErrStat /= ErrID_None
! local variables
REAL(DbKi) :: t(2) ! Times associated with the Inputs
REAL(DbKi) :: t_out ! Time to which to be extrap/interpd
CHARACTER(*), PARAMETER :: RoutineName = 'ADsk_Input_ExtrapInterp1'
REAL(DbKi) :: a1, a2 ! temporary for extrapolation/interpolation
INTEGER(IntKi) :: ErrStat2 ! local errors
CHARACTER(ErrMsgLen) :: ErrMsg2 ! local errors
! Initialize ErrStat
ErrStat = ErrID_None
ErrMsg = ''
! we'll subtract a constant from the times to resolve some
! numerical issues when t gets large (and to simplify the equations)
t = tin - tin(1)
t_out = tin_out - tin(1)

IF (EqualRealNos(t(1), t(2))) THEN
CALL SetErrStat(ErrID_Fatal, 't(1) must not equal t(2) to avoid a division-by-zero error.', ErrStat, ErrMsg, RoutineName)
RETURN
END IF

! Calculate weighting factors from Lagrange polynomial
a1 = -(t_out - t(2))/t(2)
a2 = t_out/t(2)

CALL MeshExtrapInterp1(u1%HubMotion, u2%HubMotion, tin, u_out%HubMotion, tin_out, ErrStat2, ErrMsg2)
CALL SetErrStat(ErrStat2, ErrMsg2, ErrStat, ErrMsg,RoutineName)
u_out%RotSpeed = a1*u1%RotSpeed + a2*u2%RotSpeed
CALL Angles_ExtrapInterp( u1%BlPitch, u2%BlPitch, tin, u_out%BlPitch, tin_out )
END SUBROUTINE

SUBROUTINE ADsk_Input_ExtrapInterp2(u1, u2, u3, tin, u_out, tin_out, ErrStat, ErrMsg )
!
! This subroutine calculates a extrapolated (or interpolated) Input u_out at time t_out, from previous/future time
! values of u (which has values associated with times in t). Order of the interpolation is 2.
!
! expressions below based on either
!
! f(t) = a + b * t + c * t**2
!
! where a, b and c are determined as the solution to
! f(t1) = u1, f(t2) = u2, f(t3) = u3
!
!..................................................................................................................................

TYPE(ADsk_InputType), INTENT(INOUT) :: u1 ! Input at t1 > t2 > t3
TYPE(ADsk_InputType), INTENT(INOUT) :: u2 ! Input at t2 > t3
TYPE(ADsk_InputType), INTENT(INOUT) :: u3 ! Input at t3
REAL(DbKi), INTENT(IN ) :: tin(3) ! Times associated with the Inputs
TYPE(ADsk_InputType), INTENT(INOUT) :: u_out ! Input at tin_out
REAL(DbKi), INTENT(IN ) :: tin_out ! time to be extrap/interp'd to
INTEGER(IntKi), INTENT( OUT) :: ErrStat ! Error status of the operation
CHARACTER(*), INTENT( OUT) :: ErrMsg ! Error message if ErrStat /= ErrID_None
! local variables
REAL(DbKi) :: t(3) ! Times associated with the Inputs
REAL(DbKi) :: t_out ! Time to which to be extrap/interpd
INTEGER(IntKi) :: order ! order of polynomial fit (max 2)
REAL(DbKi) :: a1,a2,a3 ! temporary for extrapolation/interpolation
INTEGER(IntKi) :: ErrStat2 ! local errors
CHARACTER(ErrMsgLen) :: ErrMsg2 ! local errors
CHARACTER(*), PARAMETER :: RoutineName = 'ADsk_Input_ExtrapInterp2'
! Initialize ErrStat
ErrStat = ErrID_None
ErrMsg = ''
! we'll subtract a constant from the times to resolve some
! numerical issues when t gets large (and to simplify the equations)
t = tin - tin(1)
t_out = tin_out - tin(1)

IF ( EqualRealNos( t(1), t(2) ) ) THEN
CALL SetErrStat(ErrID_Fatal, 't(1) must not equal t(2) to avoid a division-by-zero error.', ErrStat, ErrMsg,RoutineName)
RETURN
ELSE IF ( EqualRealNos( t(2), t(3) ) ) THEN
CALL SetErrStat(ErrID_Fatal, 't(2) must not equal t(3) to avoid a division-by-zero error.', ErrStat, ErrMsg,RoutineName)
RETURN
ELSE IF ( EqualRealNos( t(1), t(3) ) ) THEN
CALL SetErrStat(ErrID_Fatal, 't(1) must not equal t(3) to avoid a division-by-zero error.', ErrStat, ErrMsg,RoutineName)
RETURN
END IF

! Calculate Lagrange polynomial coefficients
a1 = (t_out - t(2))*(t_out - t(3))/((t(1) - t(2))*(t(1) - t(3)))
a2 = (t_out - t(1))*(t_out - t(3))/((t(2) - t(1))*(t(2) - t(3)))
a3 = (t_out - t(1))*(t_out - t(2))/((t(3) - t(1))*(t(3) - t(2)))
CALL MeshExtrapInterp2(u1%HubMotion, u2%HubMotion, u3%HubMotion, tin, u_out%HubMotion, tin_out, ErrStat2, ErrMsg2)
CALL SetErrStat(ErrStat2, ErrMsg2, ErrStat, ErrMsg,RoutineName)
u_out%RotSpeed = a1*u1%RotSpeed + a2*u2%RotSpeed + a3*u3%RotSpeed
CALL Angles_ExtrapInterp( u1%BlPitch, u2%BlPitch, u3%BlPitch, tin, u_out%BlPitch, tin_out )
END SUBROUTINE

subroutine ADsk_Output_ExtrapInterp(y, t, y_out, t_out, ErrStat, ErrMsg)
!
! This subroutine calculates a extrapolated (or interpolated) Output y_out at time t_out, from previous/future time
! values of y (which has values associated with times in t). Order of the interpolation is given by the size of y
!
! expressions below based on either
!
! f(t) = a
! f(t) = a + b * t, or
! f(t) = a + b * t + c * t**2
!
! where a, b and c are determined as the solution to
! f(t1) = y1, f(t2) = y2, f(t3) = y3 (as appropriate)
!
!----------------------------------------------------------------------------------------------------------------------------------

type(ADsk_OutputType), intent(inout) :: y(:) ! Output at t1 > t2 > t3
real(DbKi), intent(in ) :: t(:) ! Times associated with the Outputs
type(ADsk_OutputType), intent(inout) :: y_out ! Output at tin_out
real(DbKi), intent(in ) :: t_out ! time to be extrap/interp'd to
integer(IntKi), intent( out) :: ErrStat ! Error status of the operation
character(*), intent( out) :: ErrMsg ! Error message if ErrStat /= ErrID_None
! local variables
integer(IntKi) :: order ! order of polynomial fit (max 2)
integer(IntKi) :: ErrStat2 ! local errors
character(ErrMsgLen) :: ErrMsg2 ! local errors
character(*), PARAMETER :: RoutineName = 'ADsk_Output_ExtrapInterp'

! Initialize ErrStat
ErrStat = ErrID_None
ErrMsg = ''
if (size(t) /= size(y)) then
call SetErrStat(ErrID_Fatal, 'size(t) must equal size(y)', ErrStat, ErrMsg, RoutineName)
return
endif
order = size(y) - 1
select case (order)
case (0)
call ADsk_CopyOutput(y(1), y_out, MESH_UPDATECOPY, ErrStat2, ErrMsg2)
call SetErrStat(ErrStat2, ErrMsg2, ErrStat, ErrMsg, RoutineName)
case (1)
call ADsk_Output_ExtrapInterp1(y(1), y(2), t, y_out, t_out, ErrStat2, ErrMsg2)
call SetErrStat(ErrStat2, ErrMsg2, ErrStat, ErrMsg, RoutineName)
case (2)
call ADsk_Output_ExtrapInterp2(y(1), y(2), y(3), t, y_out, t_out, ErrStat2, ErrMsg2)
call SetErrStat(ErrStat2, ErrMsg2, ErrStat, ErrMsg, RoutineName)
case default
call SetErrStat(ErrID_Fatal, 'size(y) must be less than 4 (order must be less than 3).', ErrStat, ErrMsg, RoutineName)
return
end select
end subroutine

SUBROUTINE ADsk_Output_ExtrapInterp1(y1, y2, tin, y_out, tin_out, ErrStat, ErrMsg )
!
! This subroutine calculates a extrapolated (or interpolated) Output y_out at time t_out, from previous/future time
! values of y (which has values associated with times in t). Order of the interpolation is 1.
!
! f(t) = a + b * t, or
!
! where a and b are determined as the solution to
! f(t1) = y1, f(t2) = y2
!
!..................................................................................................................................

TYPE(ADsk_OutputType), INTENT(INOUT) :: y1 ! Output at t1 > t2
TYPE(ADsk_OutputType), INTENT(INOUT) :: y2 ! Output at t2
REAL(DbKi), INTENT(IN ) :: tin(2) ! Times associated with the Outputs
TYPE(ADsk_OutputType), INTENT(INOUT) :: y_out ! Output at tin_out
REAL(DbKi), INTENT(IN ) :: tin_out ! time to be extrap/interp'd to
INTEGER(IntKi), INTENT( OUT) :: ErrStat ! Error status of the operation
CHARACTER(*), INTENT( OUT) :: ErrMsg ! Error message if ErrStat /= ErrID_None
! local variables
REAL(DbKi) :: t(2) ! Times associated with the Outputs
REAL(DbKi) :: t_out ! Time to which to be extrap/interpd
CHARACTER(*), PARAMETER :: RoutineName = 'ADsk_Output_ExtrapInterp1'
REAL(DbKi) :: a1, a2 ! temporary for extrapolation/interpolation
INTEGER(IntKi) :: ErrStat2 ! local errors
CHARACTER(ErrMsgLen) :: ErrMsg2 ! local errors
INTEGER :: i01 ! dim1 level 0 counter variable for arrays of ddts
INTEGER :: i1 ! dim1 counter variable for arrays
! Initialize ErrStat
ErrStat = ErrID_None
ErrMsg = ''
! we'll subtract a constant from the times to resolve some
! numerical issues when t gets large (and to simplify the equations)
t = tin - tin(1)
t_out = tin_out - tin(1)

IF (EqualRealNos(t(1), t(2))) THEN
CALL SetErrStat(ErrID_Fatal, 't(1) must not equal t(2) to avoid a division-by-zero error.', ErrStat, ErrMsg, RoutineName)
RETURN
END IF

! Calculate weighting factors from Lagrange polynomial
a1 = -(t_out - t(2))/t(2)
a2 = t_out/t(2)

CALL MeshExtrapInterp1(y1%AeroLoads, y2%AeroLoads, tin, y_out%AeroLoads, tin_out, ErrStat2, ErrMsg2)
CALL SetErrStat(ErrStat2, ErrMsg2, ErrStat, ErrMsg,RoutineName)
y_out%YawErr = a1*y1%YawErr + a2*y2%YawErr
y_out%PsiSkew = a1*y1%PsiSkew + a2*y2%PsiSkew
y_out%ChiSkew = a1*y1%ChiSkew + a2*y2%ChiSkew
y_out%VRel = a1*y1%VRel + a2*y2%VRel
y_out%Ct = a1*y1%Ct + a2*y2%Ct
y_out%Cq = a1*y1%Cq + a2*y2%Cq
IF (ALLOCATED(y_out%WriteOutput) .AND. ALLOCATED(y1%WriteOutput)) THEN
y_out%WriteOutput = a1*y1%WriteOutput + a2*y2%WriteOutput
END IF ! check if allocated
END SUBROUTINE

SUBROUTINE ADsk_Output_ExtrapInterp2(y1, y2, y3, tin, y_out, tin_out, ErrStat, ErrMsg )
!
! This subroutine calculates a extrapolated (or interpolated) Output y_out at time t_out, from previous/future time
! values of y (which has values associated with times in t). Order of the interpolation is 2.
!
! expressions below based on either
!
! f(t) = a + b * t + c * t**2
!
! where a, b and c are determined as the solution to
! f(t1) = y1, f(t2) = y2, f(t3) = y3
!
!..................................................................................................................................

TYPE(ADsk_OutputType), INTENT(INOUT) :: y1 ! Output at t1 > t2 > t3
TYPE(ADsk_OutputType), INTENT(INOUT) :: y2 ! Output at t2 > t3
TYPE(ADsk_OutputType), INTENT(INOUT) :: y3 ! Output at t3
REAL(DbKi), INTENT(IN ) :: tin(3) ! Times associated with the Outputs
TYPE(ADsk_OutputType), INTENT(INOUT) :: y_out ! Output at tin_out
REAL(DbKi), INTENT(IN ) :: tin_out ! time to be extrap/interp'd to
INTEGER(IntKi), INTENT( OUT) :: ErrStat ! Error status of the operation
CHARACTER(*), INTENT( OUT) :: ErrMsg ! Error message if ErrStat /= ErrID_None
! local variables
REAL(DbKi) :: t(3) ! Times associated with the Outputs
REAL(DbKi) :: t_out ! Time to which to be extrap/interpd
INTEGER(IntKi) :: order ! order of polynomial fit (max 2)
REAL(DbKi) :: a1,a2,a3 ! temporary for extrapolation/interpolation
INTEGER(IntKi) :: ErrStat2 ! local errors
CHARACTER(ErrMsgLen) :: ErrMsg2 ! local errors
CHARACTER(*), PARAMETER :: RoutineName = 'ADsk_Output_ExtrapInterp2'
INTEGER :: i01 ! dim1 level 0 counter variable for arrays of ddts
INTEGER :: i1 ! dim1 counter variable for arrays
! Initialize ErrStat
ErrStat = ErrID_None
ErrMsg = ''
! we'll subtract a constant from the times to resolve some
! numerical issues when t gets large (and to simplify the equations)
t = tin - tin(1)
t_out = tin_out - tin(1)

IF ( EqualRealNos( t(1), t(2) ) ) THEN
CALL SetErrStat(ErrID_Fatal, 't(1) must not equal t(2) to avoid a division-by-zero error.', ErrStat, ErrMsg,RoutineName)
RETURN
ELSE IF ( EqualRealNos( t(2), t(3) ) ) THEN
CALL SetErrStat(ErrID_Fatal, 't(2) must not equal t(3) to avoid a division-by-zero error.', ErrStat, ErrMsg,RoutineName)
RETURN
ELSE IF ( EqualRealNos( t(1), t(3) ) ) THEN
CALL SetErrStat(ErrID_Fatal, 't(1) must not equal t(3) to avoid a division-by-zero error.', ErrStat, ErrMsg,RoutineName)
RETURN
END IF

! Calculate Lagrange polynomial coefficients
a1 = (t_out - t(2))*(t_out - t(3))/((t(1) - t(2))*(t(1) - t(3)))
a2 = (t_out - t(1))*(t_out - t(3))/((t(2) - t(1))*(t(2) - t(3)))
a3 = (t_out - t(1))*(t_out - t(2))/((t(3) - t(1))*(t(3) - t(2)))
CALL MeshExtrapInterp2(y1%AeroLoads, y2%AeroLoads, y3%AeroLoads, tin, y_out%AeroLoads, tin_out, ErrStat2, ErrMsg2)
CALL SetErrStat(ErrStat2, ErrMsg2, ErrStat, ErrMsg,RoutineName)
y_out%YawErr = a1*y1%YawErr + a2*y2%YawErr + a3*y3%YawErr
y_out%PsiSkew = a1*y1%PsiSkew + a2*y2%PsiSkew + a3*y3%PsiSkew
y_out%ChiSkew = a1*y1%ChiSkew + a2*y2%ChiSkew + a3*y3%ChiSkew
y_out%VRel = a1*y1%VRel + a2*y2%VRel + a3*y3%VRel
y_out%Ct = a1*y1%Ct + a2*y2%Ct + a3*y3%Ct
y_out%Cq = a1*y1%Cq + a2*y2%Cq + a3*y3%Cq
IF (ALLOCATED(y_out%WriteOutput) .AND. ALLOCATED(y1%WriteOutput)) THEN
y_out%WriteOutput = a1*y1%WriteOutput + a2*y2%WriteOutput + a3*y3%WriteOutput
END IF ! check if allocated
END SUBROUTINE
END MODULE AeroDisk_Types
!ENDOFREGISTRYGENERATEDFILE
Loading

0 comments on commit 29ad020

Please sign in to comment.