Skip to content

Commit

Permalink
Add MaxTq to LocalVar
Browse files Browse the repository at this point in the history
  • Loading branch information
nikhar-abbas committed Dec 1, 2020
1 parent 1030f5c commit 4cc00bc
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 7 deletions.
13 changes: 6 additions & 7 deletions src/Controllers.f90
Original file line number Diff line number Diff line change
Expand Up @@ -142,27 +142,26 @@ SUBROUTINE VariableSpeedControl(avrSWAP, CntrPar, LocalVar, objInst)
TYPE(ObjectInstances), INTENT(INOUT) :: objInst
! Allocate Variables
REAL(C_FLOAT), INTENT(INOUT) :: avrSWAP(*) ! The swap array, used to pass data to, and receive data from, the DLL controller.
REAL(8) :: VS_MaxTq ! Locally allocated maximum torque saturation limits

! -------- Variable-Speed Torque Controller --------
! Define max torque
IF (LocalVar%VS_State == 4) THEN
VS_MaxTq = CntrPar%VS_RtTq
LocalVar%VS_MaxTq = CntrPar%VS_RtTq
ELSE
! VS_MaxTq = CntrPar%VS_MaxTq ! NJA: May want to boost max torque
VS_MaxTq = CntrPar%VS_RtTq
LocalVar%VS_MaxTq = CntrPar%VS_RtTq
ENDIF

! Optimal Tip-Speed-Ratio tracking controller
IF ((CntrPar%VS_ControlMode == 2) .OR. (CntrPar%VS_ControlMode == 3)) THEN
! Constant Power, update VS_MaxTq
IF (CntrPar%VS_ControlMode == 3) THEN
VS_MaxTq = min((CntrPar%VS_RtPwr/(CntrPar%VS_GenEff/100.0))/LocalVar%GenSpeedF, CntrPar%VS_MaxTq)
LocalVar%VS_MaxTq = min((CntrPar%VS_RtPwr/(CntrPar%VS_GenEff/100.0))/LocalVar%GenSpeedF, CntrPar%VS_MaxTq)
END IF

! PI controller
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)
LocalVar%GenTq = saturate(LocalVar%GenTq, CntrPar%VS_MinTq, VS_MaxTq)
LocalVar%GenTq = PIController(LocalVar%VS_SpdErr, CntrPar%VS_KP(1), CntrPar%VS_KI(1), CntrPar%VS_MinTq, LocalVar%VS_MaxTq, LocalVar%DT, LocalVar%VS_LastGenTrq, .FALSE., objInst%instPI)
LocalVar%GenTq = saturate(LocalVar%GenTq, CntrPar%VS_MinTq, LocalVar%VS_MaxTq)

! K*Omega^2 control law with PI torque control in transition regions
ELSE
Expand All @@ -184,7 +183,7 @@ SUBROUTINE VariableSpeedControl(avrSWAP, CntrPar, LocalVar, objInst)
END IF

! Saturate
LocalVar%GenTq = saturate(LocalVar%GenTq, CntrPar%VS_MinTq, VS_MaxTq)
LocalVar%GenTq = saturate(LocalVar%GenTq, CntrPar%VS_MinTq, CntrPar%VS_MaxTq)
ENDIF


Expand Down
1 change: 1 addition & 0 deletions src/ROSCO_Types.f90
Original file line number Diff line number Diff line change
Expand Up @@ -176,6 +176,7 @@ MODULE ROSCO_Types
REAL(8) :: PitCom(3) ! Commanded pitch of each blade the last time the controller was called [rad].
REAL(8) :: SS_DelOmegaF ! Filtered setpoint shifting term defined in setpoint smoother [rad/s].
REAL(8) :: TestType ! Test variable, no use
REAL(8) :: VS_MaxTq ! Maximum allowable generator torque [Nm].
REAL(8) :: VS_LastGenTrq ! Commanded electrical generator torque the last time the controller was called [Nm].
REAL(8) :: VS_MechGenPwr ! Mechanical power on the generator axis [W]
REAL(8) :: VS_SpdErrAr ! Current speed error for region 2.5 PI controller (generator torque control) [rad/s].
Expand Down

0 comments on commit 4cc00bc

Please sign in to comment.