Hello,
I did this work one year ago. So I may forget some modifications I did.
Currently, since no one describe this process, I plan to detail it in the appendix of my PhD thesis. You can read it and cite it, but it will be published in this August.
I also did some microtab control in my research projects and the paper is currently under review.
Here are some hints:
1)Fast_library.f90
IF ( NINT(InitInpAry(2)) == 1 ) THEN
ExternInitData%LidRadialVel = .true.
ELSE
ExternInitData%LidRadialVel = .false.
END IF
!Xiao Sun: add flap input
do i = 1, 3
ExternInitData%FlapPos(i) = InitInpAry(i+2)
end do
!-------------
CALL FAST_InitializeAll_T( t_initial, 1_IntKi, Turbine, ErrStat, ErrMsg, InputFileName, ExternInitData )
IF ( NumInputs_c > NumFixedInputs ) THEN ! NumFixedInputs is the fixed number of inputs
IF ( NumInputs_c == NumFixedInputs + 3 ) &
!Xiao Sun: Set NumAdditionalInput to 3
! Pass three flap angle input to AeroDyn
m_FAST%ExternInput%FlapCtrl = InputAry(9:11)
m_FAST%ExternInput%LidarFocus = InputAry(9:11)
END IF
2)FAST_subs.f90
!Xiao Sun: add m_FAST
!,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,
! Passed variables
! Xiao Sun: add m_FAST
TYPE(FAST_MiscVarType), INTENT(IN ) :: m_FAST ! Misc variables (including external inputs) for the glue code
TYPE(FAST_ParameterType), INTENT(IN ) :: p_FAST ! parameter FAST data
TYPE(AD14_InputType), INTENT(INOUT) :: u_AD14 ! The inputs to AeroDyn14
TYPE(ED_OutputType), INTENT(IN) :: y_ED ! The outputs from the structural dynamics module
TYPE(FAST_ModuleMapType), INTENT(INOUT) :: MeshMapData ! Data for mapping between modules
INTEGER(IntKi) :: ErrStat ! Error status of the operation
CHARACTER(*) :: ErrMsg ! Error message if ErrStat /= ErrID_None
! Local variables:
!Xiao Sun: add I
INTEGER(IntKi) :: I ! Loops through blades
INTEGER(IntKi) :: J ! Loops through nodes / elements.
INTEGER(IntKi) :: K ! Loops through blades.
INTEGER(IntKi) :: NodeNum ! Node number for blade/node on mesh
INTEGER(IntKi) :: NumBl
INTEGER(IntKi) :: BldNodes
! Xiao Sun: Set MulTabLoc based on FlapCtrl
DO I=1,3
u_AD14%MulTabLoc(16,i) = m_FAST%ExternInput%FlapCtrl(i)
END Do
IF ( p_FAST%CompAero == Module_AD14 ) THEN
!Xiao Sun: add m_FAST
CALL AD14_InputSolve_NoIfW( p_FAST, m_FAST, AD14%Input(1), ED%Output(1), MeshMapData, ErrStat2, ErrMsg2 )
CALL SetErrStat( ErrStat2, ErrMsg2, ErrStat, ErrMsg, RoutineName )
IF ( p_FAST%CompAero == Module_AD14 ) THEN
!Xiao Sun: add m_FAST
CALL AD14_InputSolve_NoIfW( p_FAST, m_FAST, AD14%Input(1), ED%Output(1), MeshMapData, ErrStat2, ErrMsg2 )
CALL SetErrStat( ErrStat2, ErrMsg2, ErrStat, ErrMsg, RoutineName )
! Xiao Sun: add initialization for flap
IF (PRESENT(ExternInitData)) THEN
do i=1,3
m_FAST%ExternInput%FlapCtrl(i) = ExternInitData%FlapPos(i)
end do
END IF
3)FAST_Type.f90
! ========= FAST_ExternInputType =======
TYPE, PUBLIC :: FAST_ExternInputType
REAL(ReKi) :: GenTrq ! generator torque input from Simulink/Labview [-]
REAL(ReKi) :: ElecPwr ! electric poser input from Simulink/Labview [-]
REAL(ReKi) :: YawPosCom ! yaw position command from Simulink/Labview [-]
REAL(ReKi) :: YawRateCom ! yaw rate command from Simulink/Labview [-]
REAL(ReKi) , DIMENSION(1:3) :: BlPitchCom ! blade pitch commands from Simulink/Labview [rad/s]
REAL(ReKi) :: HSSBrFrac ! Fraction of full braking torque: 0 (off) <= HSSBrFrac <= 1 (full) from Simulink or LabVIEW [-]
!Xiao Sun: flapCtrl
REAL(ReKi) , DIMENSION(1:3) :: FlapCtrl ! Flap Angle Control Signal [deg]
REAL(ReKi) , DIMENSION(1:3) :: LidarFocus ! lidar focus (relative to lidar location) [m]
END TYPE FAST_ExternInputType
========= FAST_ExternInitType =======
! Xiao Sun: Add initial viarable for flap?
TYPE, PUBLIC :: FAST_ExternInitType
REAL(DbKi) :: Tmax = -1 ! External code specified Tmax [s]
INTEGER(IntKi) :: SensorType = SensorType_None ! lidar sensor type, which should not be pulsed at the moment; this input should be replaced with a section in the InflowWind input file [-]
LOGICAL :: LidRadialVel ! TRUE => return radial component, FALSE => return 'x' direction estimate [-]
INTEGER(IntKi) :: TurbineID ! ID number for turbine (used to create output file naming convention) [-]
REAL(ReKi) , DIMENSION(1:3) :: TurbinePos ! Initial position of turbine base (origin used in future for graphics) [m]
INTEGER(IntKi) :: NumSCin ! number of controller inputs [from supercontroller] [-]
INTEGER(IntKi) :: NumSCout ! number of controller outputs [to supercontroller] [-]
! Xiao Sun: add flap
REAL(ReKi) , DIMENSION(1:3) :: FlapPos ! Initial position of flap [deg]
END TYPE FAST_ExternInitType
DstExternInputTypeData%GenTrq = SrcExternInputTypeData%GenTrq
DstExternInputTypeData%ElecPwr = SrcExternInputTypeData%ElecPwr
DstExternInputTypeData%YawPosCom = SrcExternInputTypeData%YawPosCom
DstExternInputTypeData%YawRateCom = SrcExternInputTypeData%YawRateCom
DstExternInputTypeData%BlPitchCom = SrcExternInputTypeData%BlPitchCom
DstExternInputTypeData%HSSBrFrac = SrcExternInputTypeData%HSSBrFrac
! Xiao Sun: add FlapCtrl
DstExternInputTypeData%FlapCtrl = SrcExternInputTypeData%FlapCtrl
Int_BufSz = 0
Re_BufSz = Re_BufSz + 1 ! GenTrq
Re_BufSz = Re_BufSz + 1 ! ElecPwr
Re_BufSz = Re_BufSz + 1 ! YawPosCom
Re_BufSz = Re_BufSz + 1 ! YawRateCom
Re_BufSz = Re_BufSz + SIZE(InData%BlPitchCom) ! BlPitchCom
Re_BufSz = Re_BufSz + 1 ! HSSBrFrac
Re_BufSz = Re_BufSz + SIZE(InData%FlapCtrl) !Xiao Sun: add FlapCtrl
Re_BufSz = Re_BufSz + SIZE(InData%LidarFocus)
ReKiBuf ( Re_Xferred:Re_Xferred+(1)-1 ) = InData%GenTrq
Re_Xferred = Re_Xferred + 1
ReKiBuf ( Re_Xferred:Re_Xferred+(1)-1 ) = InData%ElecPwr
Re_Xferred = Re_Xferred + 1
ReKiBuf ( Re_Xferred:Re_Xferred+(1)-1 ) = InData%YawPosCom
Re_Xferred = Re_Xferred + 1
ReKiBuf ( Re_Xferred:Re_Xferred+(1)-1 ) = InData%YawRateCom
Re_Xferred = Re_Xferred + 1
ReKiBuf ( Re_Xferred:Re_Xferred+(SIZE(InData%BlPitchCom))-1 ) = PACK(InData%BlPitchCom,.TRUE.)
Re_Xferred = Re_Xferred + SIZE(InData%BlPitchCom)
ReKiBuf ( Re_Xferred:Re_Xferred+(1)-1 ) = InData%HSSBrFrac
Re_Xferred = Re_Xferred + 1
! Xiao Sun: add FlapCtrl
ReKiBuf ( Re_Xferred:Re_Xferred+(SIZE(InData%FlapCtrl))-1 ) = PACK(InData%FlapCtrl,.TRUE.)
Re_Xferred = Re_Xferred + SIZE(InData%FlapCtrl)
ReKiBuf ( Re_Xferred:Re_Xferred+(SIZE(InData%LidarFocus))-1 ) = PACK(InData%LidarFocus,.TRUE.)
Re_Xferred = Re_Xferred + SIZE(InData%LidarFocus)
OutData%HSSBrFrac = ReKiBuf( Re_Xferred )
Re_Xferred = Re_Xferred + 1
! xiao Sun: add FlapCtrl
i1_l = LBOUND(OutData%FlapCtrl,1)
i1_u = UBOUND(OutData%FlapCtrl,1)
ALLOCATE(mask1(i1_l:i1_u),STAT=ErrStat2)
This should be enough. And you need recomply FAST library.