Skip to content

Commit

Permalink
Update DRC
Browse files Browse the repository at this point in the history
  • Loading branch information
nikhar-abbas committed Oct 19, 2019
1 parent 104392a commit c8ffde3
Show file tree
Hide file tree
Showing 4 changed files with 29 additions and 13 deletions.
5 changes: 4 additions & 1 deletion DRC_Fortran/Source/ControllerBlocks.f90
Original file line number Diff line number Diff line change
Expand Up @@ -245,7 +245,10 @@ SUBROUTINE SetpointSmoother(LocalVar, CntrPar, objInst)
! ------ 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
! DelOmega = (LocalVar%BlPitch(1) - CntrPar%PC_MinPit)*CntrPar%SS_VSGainBias - (CntrPar%VS_RtTq - LocalVar%VS_LastGenTrq)*CntrPar%SS_PCGainBias
! DelOmega = ((LocalVar%BlPitch(1) - CntrPar%PC_MinPit)/0.524) * CntrPar%SS_VSGainBias - ((CntrPar%VS_RtPwr - LocalVar%VS_GenPwr))/CntrPar%VS_RtPwr * CntrPar%SS_PCGainBias ! 30 degrees
DelOmega = ((LocalVar%BlPitch(1) - CntrPar%PC_MinPit)/0.524) * CntrPar%SS_VSGainBias - ((CntrPar%VS_RtTq - LocalVar%VS_GenPwr))/CntrPar%VS_RtTq * CntrPar%SS_PCGainBias ! 30 degrees
DelOmega = DelOmega * CntrPar%PC_RefSpd
! Filter
LocalVar%SS_DelOmegaF = LPFilter(DelOmega, LocalVar%DT, CntrPar%F_SSCornerFreq, LocalVar%iStatus, .FALSE., objInst%instLPF)
ELSE
Expand Down
10 changes: 6 additions & 4 deletions DRC_Fortran/Source/Controllers.f90
Original file line number Diff line number Diff line change
Expand Up @@ -80,11 +80,11 @@ SUBROUTINE PitchControl(avrSWAP, CntrPar, LocalVar, objInst)

! Combine and saturate all pitch commands:
DO K = 1,LocalVar%NumBl ! Loop through all blades, add IPC contribution and limit pitch rate
! PitCom(K) = ratelimit(LocalVar%PC_PitComT_IPC(K), LocalVar%BlPitch(K), PC_MinRat, PC_MaxRat, LocalVar%DT) ! Saturate the overall command of blade K using the pitch rate limit
LocalVar%PitCom(K) = saturate(LocalVar%PC_PitComT, LocalVar%PC_MinPit, CntrPar%PC_MaxPit) ! Saturate the overall command using the pitch angle limits
LocalVar%PitCom(K) = LocalVar%PitCom(K) + LocalVar%IPC_PitComF(K) + LocalVar%FA_PitCom(K) + LocalVar%PC_SineExcitation
LocalVar%PitCom(K) = ratelimit(LocalVar%PitCom(K), LocalVar%BlPitch(K), CntrPar%PC_MinRat, CntrPar%PC_MaxRat, LocalVar%DT) ! Saturate the overall command of blade K using the pitch rate limit
END DO

! Command the pitch demanded from the last
! call to the controller (See Appendix A of Bladed User's Guide):
avrSWAP(42) = LocalVar%PitCom(1) ! Use the command angles of all blades if using individual pitch
Expand Down Expand Up @@ -121,7 +121,7 @@ SUBROUTINE VariableSpeedControl(avrSWAP, CntrPar, LocalVar, objInst)
! VS_MaxTq = CntrPar%VS_MaxTq ! NJA: May want to boost max torque
VS_MaxTq = CntrPar%VS_RtTq
ENDIF
LocalVar%GenTq = PIController(LocalVar%VS_SpdErr, CntrPar%VS_KP(1), CntrPar%VS_KI(1), CntrPar%VS_MinTq, VS_MaxTq, LocalVar%DT, CntrPar%VS_MaxOMTq, .FALSE., objInst%instPI)
LocalVar%GenTq = PIController(LocalVar%VS_SpdErr, CntrPar%VS_KP(1), CntrPar%VS_KI(1), CntrPar%VS_MinTq, VS_MaxTq, LocalVar%DT, LocalVar%VS_LastGenTrq, .FALSE., objInst%instPI)

! K*Omega^2 control law with PI torque control in transition regions
ELSE
Expand Down Expand Up @@ -149,12 +149,14 @@ SUBROUTINE VariableSpeedControl(avrSWAP, CntrPar, LocalVar, objInst)
LocalVar%GenTq = MIN(LocalVar%GenTq, CntrPar%VS_MaxTq) ! Saturate the command using the maximum torque limit

! Saturate the commanded torque using the torque rate limit:
IF (LocalVar%iStatus == 0) LocalVar%VS_LastGenTrq = LocalVar%GenTq ! Initialize the value of LocalVar%VS_LastGenTrq on the first pass only
LocalVar%GenTq = ratelimit(LocalVar%GenTq, LocalVar%VS_LastGenTrq, -CntrPar%VS_MaxRat, CntrPar%VS_MaxRat, LocalVar%DT) ! Saturate the command using the torque rate limit

! Reset the value of LocalVar%VS_LastGenTrq to the current values:
LocalVar%VS_LastGenTrq = LocalVar%GenTq

! Account for first run


! Set the command generator torque (See Appendix A of Bladed User's Guide):
avrSWAP(47) = LocalVar%VS_LastGenTrq ! Demanded generator torque
END SUBROUTINE VariableSpeedControl
Expand Down
6 changes: 3 additions & 3 deletions DRC_Fortran/Source/Functions.f90
Original file line number Diff line number Diff line change
Expand Up @@ -423,8 +423,8 @@ SUBROUTINE Debug(LocalVar, CntrPar, avrSWAP, RootName, size_avcOUTNAME)
IF (CntrPar%LoggingLevel > 0) THEN
!OPEN(unit=UnDb, FILE=TRIM(RootName)//'.dbg', STATUS='NEW')
OPEN(unit=UnDb, FILE='DEBUG.dbg')
WRITE (UnDb,'(A)') ' Time ' //Tab//' WE_TowerTop ' //Tab//' WE_Vw '
WRITE (UnDb,'(A)') ' (sec) ' //Tab//'(m/s) '
WRITE (UnDb,'(A)') ' Time ' //Tab//' WE_TowerTop ' //Tab//' WE_Vw ' //Tab//' SS_DelOmega '
WRITE (UnDb,'(A)') ' (sec) ' //Tab//'(m/s) ' //Tab//'(rad) '
!WRITE (UnDb,'(A)') ' LocalVar%Time ' //Tab//'LocalVar%PC_PitComT ' //Tab//'LocalVar%PC_SpdErr ' //Tab//'LocalVar%PC_KP ' //Tab//'LocalVar%PC_KI ' //Tab//'LocalVar%Y_M ' //Tab//'LocalVar%rootMOOP(1) '//Tab//'VS_RtPwr '//Tab//'LocalVar%GenTq'
!WRITE (UnDb,'(A)') ' (sec) ' //Tab//'(rad) ' //Tab//'(rad/s) '//Tab//'(-) ' //Tab//'(-) ' //Tab//'(rad) ' //Tab//'(?) ' //Tab//'(W) '//Tab//'(Nm) '
END IF
Expand All @@ -447,7 +447,7 @@ SUBROUTINE Debug(LocalVar, CntrPar, avrSWAP, RootName, size_avcOUTNAME)

! Output debugging information if requested:
IF (CntrPar%LoggingLevel > 0) THEN
WRITE (UnDb,FmtDat) LocalVar%Time, LocalVar%TestType, LocalVar%WE_Vw
WRITE (UnDb,FmtDat) LocalVar%Time, LocalVar%TestType, LocalVar%WE_Vw, LocalVar%SS_DelOmegaF
END IF

IF (CntrPar%LoggingLevel > 1) THEN
Expand Down
21 changes: 16 additions & 5 deletions DRC_Fortran/Source/ReadSetParameters.f90
Original file line number Diff line number Diff line change
Expand Up @@ -211,9 +211,10 @@ SUBROUTINE ComputeVariablesSetpoints(CntrPar, LocalVar, objInst)
! ----- Torque controller reference errors -----
! Define VS reference generator speed [rad/s]
IF (CntrPar%VS_ControlMode == 2) THEN
WE_Vw_f = LPFilter(LocalVar%We_Vw, LocalVar%DT, 0.1, LocalVar%iStatus, .FALSE., objInst%instLPF)
WE_Vw_f = LPFilter(LocalVar%We_Vw, LocalVar%DT, 0.625, LocalVar%iStatus, .FALSE., objInst%instLPF)
! WE_Vw_f = LocalVar%We_Vw
VS_RefSpd = (CntrPar%VS_TSRopt * WE_Vw_f / CntrPar%WE_BladeRadius) * CntrPar%WE_GearboxRatio
VS_RefSpd = saturate(VS_RefSpd,CntrPar%VS_MinOMSpd, CntrPar%PC_RefSpd)
VS_RefSpd = saturate(VS_RefSpd,CntrPar%VS_MinOMSpd, CntrPar%VS_RefSpd)
ELSE
VS_RefSpd = CntrPar%VS_RefSpd
ENDIF
Expand All @@ -232,6 +233,8 @@ SUBROUTINE ComputeVariablesSetpoints(CntrPar, LocalVar, objInst)
! Define transition region setpoint errors
LocalVar%VS_SpdErrAr = VS_RefSpd - LocalVar%GenSpeedF ! Current speed error - Region 2.5 PI-control (Above Rated)
LocalVar%VS_SpdErrBr = CntrPar%VS_MinOMSpd - LocalVar%GenSpeedF ! Current speed error - Region 1.5 PI-control (Below Rated)


END SUBROUTINE ComputeVariablesSetpoints
! -----------------------------------------------------------------------------------
! Read avrSWAP array passed from ServoDyn
Expand All @@ -245,7 +248,8 @@ SUBROUTINE ReadAvrSWAP(avrSWAP, LocalVar)
LocalVar%iStatus = NINT(avrSWAP(1))
LocalVar%Time = avrSWAP(2)
LocalVar%DT = avrSWAP(3)
LocalVar%BlPitch(1) = avrSWAP(4)
! LocalVar%BlPitch(1) = avrSWAP(4)
LocalVar%BlPitch(1) = LocalVar%PitCom(1)
LocalVar%VS_MechGenPwr = avrSWAP(14)
LocalVar%VS_GenPwr = avrSWAP(15)
LocalVar%GenSpeed = avrSWAP(20)
Expand All @@ -256,8 +260,10 @@ SUBROUTINE ReadAvrSWAP(avrSWAP, LocalVar)
LocalVar%rootMOOP(1) = avrSWAP(30)
LocalVar%rootMOOP(2) = avrSWAP(31)
LocalVar%rootMOOP(3) = avrSWAP(32)
LocalVar%BlPitch(2) = avrSWAP(33)
LocalVar%BlPitch(3) = avrSWAP(34)
! LocalVar%BlPitch(2) = avrSWAP(33)
! LocalVar%BlPitch(3) = avrSWAP(34)
LocalVar%BlPitch(2) = LocalVar%PitCom(2)
LocalVar%BlPitch(3) = LocalVar%PitCom(3)
LocalVar%FA_Acc = avrSWAP(53)
LocalVar%Azimuth = avrSWAP(60)
LocalVar%NumBl = NINT(avrSWAP(61))
Expand Down Expand Up @@ -493,6 +499,11 @@ SUBROUTINE SetParameters(avrSWAP, aviFAIL, ErrMsg, size_avcMSG, CntrPar, LocalVa
! Setpoint Smoother initialization to zero
LocalVar%SS_DelOmegaF = 0

! Generator Torque at K omega^2
LocalVar%GenTq = min(CntrPar%VS_RtTq, CntrPar%VS_Rgn2K*LocalVar%GenSpeed*LocalVar%GenSpeed)
LocalVar%VS_LastGenTrq = LocalVar%GenTq
print *,'Initial GenTq = ', LocalVar%GenTq

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

Expand Down

0 comments on commit c8ffde3

Please sign in to comment.