Skip to content

Commit

Permalink
Include SS_DelOmegaF in LocalVar
Browse files Browse the repository at this point in the history
  • Loading branch information
nikhar-abbas committed Sep 18, 2019
1 parent 677790f commit a4eb203
Show file tree
Hide file tree
Showing 3 changed files with 28 additions and 28 deletions.
21 changes: 11 additions & 10 deletions Source/DRC_Types.f90
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ MODULE DRC_Types
END TYPE ControlParameters

TYPE, PUBLIC :: LocalVariables
! From avrSWAP
! ---------- From avrSWAP ----------
INTEGER(4) :: iStatus
REAL(4) :: Time
REAL(4) :: DT
Expand All @@ -97,7 +97,7 @@ MODULE DRC_Types
REAL(4) :: Azimuth
INTEGER(4) :: NumBl

! Internal controller variables
! ---------- -Internal controller variables ----------
REAL(4) :: FA_Acc ! Tower fore-aft acceleration [m/s^2]
REAL(4) :: FA_AccHPF ! High-pass filtered fore-aft acceleration [m/s^2]
REAL(4) :: FA_AccHPFI ! Tower velocity, high-pass filtered and integrated fore-aft acceleration [m/s]
Expand All @@ -108,21 +108,22 @@ MODULE DRC_Types
REAL(4) :: GenArTq ! Electrical generator torque, for above-rated PI-control [Nm].
REAL(4) :: GenBrTq ! Electrical generator torque, for below-rated PI-control [Nm].
INTEGER(4) :: GlobalState ! Current global state to determine the behavior of the different controllers [-].
REAL(4) :: IPC_PitComF(3) ! Commanded pitch of each blade as calculated by the individual pitch controller, F stands for low-pass filtered, [rad].
REAL(4) :: PC_KP ! Proportional gain for pitch controller at rated pitch (zero), [s].
REAL(4) :: PC_KI ! Integral gain for pitch controller at rated pitch (zero), [-].
REAL(4) :: PC_KD ! Differential gain for pitch controller at rated pitch (zero), [-].
REAL(4) :: IPC_PitComF(3) ! Commanded pitch of each blade as calculated by the individual pitch controller, F stands for low-pass filtered [rad].
REAL(4) :: PC_KP ! Proportional gain for pitch controller at rated pitch (zero) [s].
REAL(4) :: PC_KI ! Integral gain for pitch controller at rated pitch (zero) [-].
REAL(4) :: PC_KD ! Differential gain for pitch controller at rated pitch (zero) [-].
REAL(4) :: PC_TF ! First-order filter parameter for derivative action
REAL(4) :: PC_MaxPitVar ! Maximum pitch setting in pitch controller (variable) [rad].
REAL(4) :: PC_PitComT ! Total command pitch based on the sum of the proportional and integral terms, [rad].
REAL(4) :: PC_PitComT ! Total command pitch based on the sum of the proportional and integral terms [rad].
REAL(4) :: PC_PitComT_IPC(3) ! Total command pitch based on the sum of the proportional and integral terms, including IPC term [rad].
REAL(4) :: PC_PwrErr ! Power error with respect to rated power [W]
REAL(4) :: PC_SineExcitation ! Sine contribution to pitch signal
REAL(4) :: PC_SpdErr ! Current speed error (pitch control) [rad/s].
INTEGER(4) :: PC_State ! State of the pitch control system
REAL(4) :: PitCom(3) ! Commanded pitch of each blade the last time the controller was called, [rad].
REAL(4) :: PitCom(3) ! Commanded pitch of each blade the last time the controller was called [rad].
REAL(4) :: SS_DelOmegaF ! Filtered setpoint shifting term defined in setpoint smoother [rad/s].
INTEGER(4) :: TestType ! Test variable, no use
REAL(4) :: VS_LastGenTrq ! Commanded electrical generator torque the last time the controller was called, [Nm].
REAL(4) :: VS_LastGenTrq ! Commanded electrical generator torque the last time the controller was called [Nm].
REAL(4) :: VS_MechGenPwr ! Mechanical power on the generator axis [W]
REAL(4) :: VS_SpdErrAr ! Current speed error (generator torque control) [rad/s].
REAL(4) :: VS_SpdErrBr ! Current speed error (generator torque control) [rad/s].
Expand All @@ -134,7 +135,7 @@ MODULE DRC_Types
REAL(4) :: Y_ErrLPFFast ! Filtered yaw error by fast low pass filter [rad].
REAL(4) :: Y_ErrLPFSlow ! Filtered yaw error by slow low pass filter [rad].
REAL(4) :: Y_MErr ! Measured yaw error, measured + setpoint [rad].
REAL(4) :: Y_YawEndT ! Yaw end time, [s]. Indicates the time up until which yaw is active with a fixed rate
REAL(4) :: Y_YawEndT ! Yaw end time [s]. Indicates the time up until which yaw is active with a fixed rate
END TYPE LocalVariables

TYPE, PUBLIC :: ObjectInstances
Expand Down
32 changes: 14 additions & 18 deletions Source/Functions.f90
Original file line number Diff line number Diff line change
Expand Up @@ -325,27 +325,23 @@ SUBROUTINE SetpointSmoother(LocalVar, CntrPar, objInst)
TYPE(LocalVariables), INTENT(INOUT) :: LocalVar
TYPE(ObjectInstances), INTENT(INOUT) :: objInst

Real(4), PARAMETER :: SetpointSmoother_Mode = 1 ! Gain Bias Mode, 0 = no gain bais, 1 = gain bias-.
Real(4), PARAMETER :: VS_GainBias = 30 ! Variable speed torque controller gain bias, (rad/s)/(rad).
Real(4), PARAMETER :: PC_GainBias = 0.0001 ! Collective pitch controller gain bias, (rad/s)/(Nm).
Real(4), PARAMETER :: CornerFreq_GB = 0.1 ! Cornering frequency of first order low pass filter for the gain bias signal, Hz.
Real(4) :: DelOmega ! Reference generator speed shift, rad/s.
Real(4), SAVE :: DelOmegaF ! Filtered reference generator speed shift, rad/s.
Real(4) :: Alpha_GB ! Current coefficient in the recursive, single-pole, low-pass filter for DelOmega, (-).
Real(4) :: GainBias_Mode = 1
! Setpoint Smoothing.
! Note: This method is adapted from methods developed by David Schlipf
! with Sowento energy. Any publications about this controller
! should give him credit, where credit is due.
print *, 'GenTq = ', LocalVar%VS_LastGenTrq
IF ( GainBias_Mode == 1) THEN
DelOmega = (LocalVar%BlPitch(1) - CntrPar%PC_MinPit)*VS_GainBias - (CntrPar%VS_RtTq - LocalVar%VS_LastGenTrq)*PC_GainBias
Real(4), PARAMETER :: SS_Mode = 1 ! Gain Bias Mode, 0 = no gain bais, 1 = gain bias-.
Real(4), PARAMETER :: SS_VSGainBias = 30 ! Variable speed torque controller gain bias, (rad/s)/(rad).
Real(4), PARAMETER :: SS_PCGainBias = 0.0001 ! Collective pitch controller gain bias, (rad/s)/(Nm).
Real(4), PARAMETER :: F_SSCornerFreq = 0.1 ! Cornering frequency of first order low pass filter for the gain bias signal, Hz.
Real(4) :: DelOmega ! Reference generator speed shift, rad/s.
! Real(4) :: SS_DelOmegaF ! Filtered reference generator speed shift, rad/s.

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

print *, LocalVar%SS_DelOmegaF

END SUBROUTINE SetpointSmoother
!-------------------------------------------------------------------------------------------------------------------------------
SUBROUTINE Debug(LocalVar, CntrPar, avrSWAP, RootName, size_avcOUTNAME)
Expand Down
3 changes: 3 additions & 0 deletions Source/ReadSetParameters.f90
Original file line number Diff line number Diff line change
Expand Up @@ -410,6 +410,9 @@ SUBROUTINE SetParameters(avrSWAP, aviFAIL, ErrMsg, size_avcMSG, CntrPar, LocalVa
LocalVar%WE_Vw = 10
LocalVar%WE_VwI = LocalVar%WE_Vw - CntrPar%WE_Gamma*LocalVar%RotSpeed

! Setpoint Smoother initialization to zero
LocalVar%SS_DelOmegaF = 0

! Check validity of input parameters:
CALL Assert(LocalVar, CntrPar, avrSWAP, aviFAIL, ErrMsg, size_avcMSG)

Expand Down

0 comments on commit a4eb203

Please sign in to comment.