Skip to content

Commit

Permalink
Merge branch 'dev_TorquePI'
Browse files Browse the repository at this point in the history
  • Loading branch information
nikhar-abbas committed Sep 23, 2019
2 parents 34b09f3 + 9c3acfe commit 26d91e8
Show file tree
Hide file tree
Showing 8 changed files with 165 additions and 108 deletions.
Binary file modified DISCON/DISCON_glin64.so
Binary file not shown.
7 changes: 4 additions & 3 deletions Parameter_files/NREL5MW/DISCON.IN
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,11 @@
1 ! F_LPFType - {1: first-order low-pass filter, 2: second-order low-pass filter}, [rad/s] (currently filters generator speed and pitch control signals)
0 ! F_NotchType - Notch on the measured generator speed {0: disable, 1: enable}
0 ! IPC_ControlMode - Turn Individual Pitch Control (IPC) for fatigue load reductions (pitch contribution) {0: off, 1: 1P reductions, 2: 1P+2P reductions}
1 ! VS_ControlMode - Generator torque control mode in above rated conditions {0: constant torque, 1: constant power}
0 ! VS_ControlMode - Generator torque control mode in above rated conditions {0: constant torque, 1: constant power, 2: TSR tracking PI control}
1 ! PC_ControlMode - Blade pitch control mode {0: No pitch, fix to fine pitch, 1: active PI blade pitch control}
0 ! Y_ControlMode - Yaw control mode {0: no yaw control, 1: yaw rate control, 2: yaw-by-IPC}
1 ! SS_Mode - Setpoint Smoother mode {0: no setpoint smoothing, 1: introduce setpoint smoothing}
0 ! WE_Mode - Wind speed estimator mode {0: One-second low pass filtered hub height wind speed, 1: Imersion and Invariance Estimator (Ortega et al.)}

!------- FILTERS ----------------------------------------------------------
1.570796326 ! F_LPFCornerFreq - Corner frequency (-3dB point) in the low-pass filters, [Hz]
Expand Down Expand Up @@ -56,8 +57,8 @@
43093.55 ! VS_RtTq - Rated torque, [Nm].
120.113 ! VS_RefSpd - Rated generator speed [rad/s]
1 ! VS_n - Number of generator PI torque controller gains
-4200 ! VS_KP - Proportional gain for generator PI torque controller, used in the transitional 2.5 region, [1/(rad/s) Nm]
-2100 ! VS_KI - Integral gain for generator PI torque controller, used in the transitional 2.5 region, [1/rad Nm]
-4200 ! VS_KP - Proportional gain for generator PI torque controller [1/(rad/s) Nm]. (Only used in the transitional 2.5 region if VS_ControlMode =/ 2)
-2100 ! VS_KI - Integral gain for generator PI torque controller [1/rad Nm]. (Only used in the transitional 2.5 region if VS_ControlMode =/ 2)

!------- Setpoint Smoother ------------------------------------------------
30 ! SS_VSGainBias - Variable speed torque controller gain bias, [(rad/s)/rad].
Expand Down
84 changes: 49 additions & 35 deletions Source/ControllerBlocks.f90
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,8 @@ MODULE ControllerBlocks

CONTAINS
!-------------------------------------------------------------------------------------------------------------------------------
! State machines, determines the state of the wind turbine to specify the corresponding control actions
SUBROUTINE StateMachine(CntrPar, LocalVar)
! State machine, determines the state of the wind turbine to specify the corresponding control actions
! PC States:
! PC_State = 0, No pitch control active, BldPitch = PC_MinPit
! PC_State = 1, Active PI blade pitch control enabled
Expand All @@ -28,7 +29,7 @@ MODULE ControllerBlocks
! VS_State = 3, Region 2.5, transition between below and above-rated operating conditions (near-rated region) using PI torque control
! VS_State = 4, above-rated operation using pitch control (constant torque mode)
! VS_State = 5, above-rated operation using pitch and torque control (constant power mode)
SUBROUTINE StateMachine(CntrPar, LocalVar)
! VS_State = 6, Tip-Speed-Ratio tracking PI controller
USE DRC_Types, ONLY : LocalVariables, ControlParameters
IMPLICIT NONE

Expand All @@ -42,7 +43,7 @@ SUBROUTINE StateMachine(CntrPar, LocalVar)
IF (LocalVar%PitCom(1) >= CntrPar%VS_Rgn3Pitch) THEN ! We are in region 3
IF (CntrPar%VS_ControlMode == 1) THEN ! Constant power tracking
LocalVar%VS_State = 5
LocalVar%PC_State = 2
LocalVar%PC_State = 1
ELSE ! Constant torque tracking
LocalVar%VS_State = 4
LocalVar%PC_State = 1
Expand All @@ -54,57 +55,70 @@ SUBROUTINE StateMachine(CntrPar, LocalVar)

! Operational States
ELSE
! Pitch controller state machine
! --- Pitch controller state machine ---
IF (CntrPar%PC_ControlMode == 1) THEN
LocalVar%PC_State = 1
ELSE
LocalVar%PC_State = 0
END IF

! Torque control state machine
IF (LocalVar%PC_PitComT >= CntrPar%VS_Rgn3Pitch) THEN
! Region 3
IF (CntrPar%VS_ControlMode == 1) THEN ! Constant power tracking
LocalVar%VS_State = 5
ELSE ! Constant torque tracking
LocalVar%VS_State = 4
! --- Torque control state machine ---
IF (LocalVar%PC_PitComT >= CntrPar%VS_Rgn3Pitch) THEN ! Region 3
IF (CntrPar%VS_ControlMode == 1) THEN
LocalVar%VS_State = 5 ! Constant power tracking
ELSE
LocalVar%VS_State = 4 ! Constant torque tracking
END IF
ELSE
! Region 2 1/2 - active PI torque control
IF (LocalVar%GenArTq >= CntrPar%VS_MaxOMTq*1.01) THEN
LocalVar%VS_State = 3
! Region 1 1/2
ELSEIF (LocalVar%GenBrTq <= CntrPar%VS_MinOMTq*0.99) THEN
LocalVar%VS_State = 1
! Region 2 - optimal torque is proportional to the square of the generator speed
ELSEIF (LocalVar%GenSpeedF < CntrPar%VS_RefSpd) THEN
IF (LocalVar%GenArTq >= CntrPar%VS_MaxOMTq*1.01) THEN ! Region 2 1/2 - active PI torque control
LocalVar%VS_State = 3
ELSEIF (LocalVar%GenSpeedF < CntrPar%VS_RefSpd) THEN ! Region 2 - optimal torque is proportional to the square of the generator speed

LocalVar%VS_State = 2
! Error state, Debug
ELSE
ELSEIF (LocalVar%GenBrTq <= CntrPar%VS_MinOMTq*0.99) THEN ! Region 1 1/2

LocalVar%VS_State = 1
ELSE ! Error state, Debug
LocalVar%VS_State = 0
END IF
END IF
END IF
END SUBROUTINE StateMachine
!-------------------------------------------------------------------------------------------------------------------------------
SUBROUTINE WindSpeedEstimator(LocalVar, CntrPar)
USE DRC_Types, ONLY : LocalVariables, ControlParameters
SUBROUTINE WindSpeedEstimator(LocalVar, CntrPar, objInst)
! Wind Speed Estimator estimates wind speed at hub height. Currently implements two types of estimators
! WE_Mode = 0, Filter hub height wind speed as passed from servodyn using first order low pass filter with 1Hz cornering frequency
! WE_Mode = 1, Use Inversion and Inveriance filter as defined by Ortege et. al.
USE DRC_Types, ONLY : LocalVariables, ControlParameters, ObjectInstances
IMPLICIT NONE

! Inputs
TYPE(ControlParameters), INTENT(IN) :: CntrPar
TYPE(LocalVariables), INTENT(INOUT) :: LocalVar

! Body
LocalVar%WE_VwIdot = CntrPar%WE_Gamma/CntrPar%WE_Jtot*(LocalVar%VS_LastGenTrq*CntrPar%WE_GearboxRatio - AeroDynTorque(LocalVar, CntrPar))

LocalVar%WE_VwI = LocalVar%WE_VwI + LocalVar%WE_VwIdot*LocalVar%DT
LocalVar%WE_Vw = LocalVar%WE_VwI + CntrPar%WE_Gamma*LocalVar%RotSpeed
TYPE(ControlParameters), INTENT(IN) :: CntrPar
TYPE(LocalVariables), INTENT(INOUT) :: LocalVar
TYPE(ObjectInstances), INTENT(INOUT) :: objInst
! Allocate Variables
REAL(4) :: F_WECornerFreq ! Corner frequency (-3dB point) for first order low pass filter for measured hub height wind speed [Hz]
! Define Variables
F_WECornerFreq = 0.0333 ! Fix to 30 second time constant for now

! Define wind speed estimate
IF (CntrPar%WE_Mode == 1) THEN
! Inversion and Invariance Filter implementation
LocalVar%WE_VwIdot = CntrPar%WE_Gamma/CntrPar%WE_Jtot*(LocalVar%VS_LastGenTrq*CntrPar%WE_GearboxRatio - AeroDynTorque(LocalVar, CntrPar))
LocalVar%WE_VwI = LocalVar%WE_VwI + LocalVar%WE_VwIdot*LocalVar%DT
LocalVar%WE_Vw = LocalVar%WE_VwI + CntrPar%WE_Gamma*LocalVar%RotSpeed
ELSE
! Filter wind speed at hub height as directly passed from OpenFAST
LocalVar%WE_Vw = LPFilter(LocalVar%HorWindV, LocalVar%DT, F_WECornerFreq, LocalVar%iStatus, .FALSE., objInst%instLPF)
END IF

END SUBROUTINE WindSpeedEstimator
!-------------------------------------------------------------------------------------------------------------------------------
SUBROUTINE SetpointSmoother(LocalVar, CntrPar, objInst)
USE DRC_Types!, ONLY : LocalVariables, ControlParameters, ObjectInstances
! Setpoint smoother modifies controller reference in order to separate generator torque and blade pitch control actions
! SS_Mode = 0, No setpoint smoothing
! SS_Mode = 1, Implement setpoint smoothing
USE DRC_Types, ONLY : LocalVariables, ControlParameters, ObjectInstances
IMPLICIT NONE

! Inputs
Expand All @@ -114,16 +128,16 @@ SUBROUTINE SetpointSmoother(LocalVar, CntrPar, objInst)
! Allocate Variables
Real(4) :: DelOmega ! Reference generator speed shift, rad/s.

! Setpoint Smoothing
! ------ Setpoint Smoothing ------
IF ( CntrPar%SS_Mode == 1) THEN
! Find setpoint shift amount
DelOmega = (LocalVar%BlPitch(1) - CntrPar%PC_MinPit)*CntrPar%SS_VSGainBias - (CntrPar%VS_RtTq - LocalVar%VS_LastGenTrq)*CntrPar%SS_PCGainBias
! Filter
LocalVar%SS_DelOmegaF = LPFilter(DelOmega, LocalVar%DT, CntrPar%F_SSCornerFreq, LocalVar%iStatus, .FALSE., objInst%instLPF)
ELSE
LocalVar%SS_DelOmegaF = 0
LocalVar%SS_DelOmegaF = 0 ! No setpoint smoothing
ENDIF

END SUBROUTINE SetpointSmoother
!-------------------------------------------------------------------------------------------------------------------------------
END MODULE ControllerBlocks
END MODULE ControllerBlocks
Loading

0 comments on commit 26d91e8

Please sign in to comment.