Skip to content

Commit

Permalink
Update DRC_Fortran
Browse files Browse the repository at this point in the history
  • Loading branch information
nikhar-abbas committed Sep 27, 2019
1 parent f6b4011 commit 83db59b
Show file tree
Hide file tree
Showing 8 changed files with 2 additions and 342 deletions.
22 changes: 2 additions & 20 deletions DRC_Fortran/Parameter_files/NREL5MW/DISCON.IN
Original file line number Diff line number Diff line change
Expand Up @@ -8,19 +8,12 @@
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}
<<<<<<< HEAD
1 ! VS_ControlMode - Generator torque control mode in above rated conditions {0: constant torque, 1: constant power}
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 ! 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.)}
1 ! PS_Mode - Peak shaving mode {0: no peak shaving, 1: implement peak shaving}
>>>>>>> tuning_dev

!------- FILTERS ----------------------------------------------------------
1.570796326 ! F_LPFCornerFreq - Corner frequency (-3dB point) in the low-pass filters, [Hz]
Expand Down Expand Up @@ -65,15 +58,10 @@
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
<<<<<<< HEAD
-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)
>>>>>>> tuning_dev

!------- Setpoint Smoother ------------------------------------------------
!------- SETPOINT SMOOTHER ------------------------------------------------
30 ! SS_VSGainBias - Variable speed torque controller gain bias, [(rad/s)/rad].
0.0001 ! SS_PCGainBias - Collective pitch controller gain bias, [(rad/s)/Nm].

Expand All @@ -85,14 +73,11 @@
97 ! WE_GearboxRatio - Gearbox ratio [>=1], [-]
4.0469564E+07 ! WE_Jtot - Total drivetrain inertia, including blades, hub and casted generator inertia to LSS, [kg m^2]
1.225 ! WE_RhoAir - Air density, [kg m^-3]
<<<<<<< HEAD
=======
"Cp_Ct_Cq.txt" ! PerfFileName - File containing rotor performance tables (Cp,Ct,Cq)
320 40 ! PerfTableSize - Size of rotor performance tables, first number refers to number of blade pitch angles, second number referse to number of tip-speed ratios
23 ! WE_FOPoles_N - Number of first-order system poles used in EKF
3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 ! WE_FOPoles_v - Wind speeds corresponding to first-order system poles [m/s]
-0.0203 -0.0270 -0.0338 -0.0405 -0.0473 -0.0540 -0.0608 -0.0675 -0.0743 -0.0671 -0.0939 -0.1257 -0.1601 -0.1973 -0.2364 -0.2783 -0.3223 -0.3678 -0.4153 -0.4632 -0.5122 -0.5629 -0.6194 ! WE_FOPoles - First order system poles
>>>>>>> tuning_dev

!------- YAW CONTROL ------------------------------------------------------
1.745329252 ! Y_ErrThresh - Yaw error threshold. Turbine begins to yaw when it passes this, [rad^2 s]
Expand All @@ -111,11 +96,8 @@
-1 ! FA_KI - Integral gain for the fore-aft tower damper controller, -1 = off / >0 = on [rad s/m] - !NJA - Make this a switch
0.1 ! FA_HPF_CornerFreq - Corner frequency (-3dB point) in the high-pass filter on the fore-aft acceleration signal, [rad/s]
0.087266 ! FA_IntSat - Integrator saturation (maximum signal amplitude contribution to pitch from FA damper), [rad]
<<<<<<< HEAD
=======

!------- PEAK SHAVING -------------------------------------------
23 ! PS_BldPitchMin_N - Number of values in minimum blade pitch lookup table (should equal number of values in PS_WindSpeeds and PS_BldPitchMin)
3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 ! PS_WindSpeeds - Wind speeds corresponding to minimum blade pitch angles [m/s]
-0.0349 -0.0349 -0.0349 -0.0349 -0.0349 -0.0349 -0.0349 -0.0114 0.0356 0.0577 0.0825 0.1058 0.1282 0.1499 0.1708 0.1913 0.2114 0.2310 0.2502 0.2690 0.2874 0.3056 0.3239 ! PS_BldPitchMin - Minimum blade pitch angles [rad]
>>>>>>> tuning_dev
-0.0349 -0.0349 -0.0349 -0.0349 -0.0349 -0.0349 -0.0349 -0.0114 0.0356 0.0577 0.0825 0.1058 0.1282 0.1499 0.1708 0.1913 0.2114 0.2310 0.2502 0.2690 0.2874 0.3056 0.3239 ! PS_BldPitchMin - Minimum blade pitch angles [rad]
3 changes: 0 additions & 3 deletions DRC_Fortran/Source/Constants.f90
Original file line number Diff line number Diff line change
@@ -1,10 +1,7 @@
MODULE Constants
REAL(4), PARAMETER :: RPS2RPM = 9.5492966 ! Factor to convert radians per second to revolutions per minute.
REAL(4), PARAMETER :: R2D = 57.295780 ! Factor to convert radians to degrees.
<<<<<<< HEAD
=======
REAL(4), PARAMETER :: D2R = 0.0175 ! Factor to convert degrees to radians.
>>>>>>> tuning_dev
REAL(4), PARAMETER :: PI = 3.14159265359 ! Mathematical constant pi
INTEGER(4), PARAMETER :: NP_1 = 1 ! First rotational harmonic
INTEGER(4), PARAMETER :: NP_2 = 2 ! Second rotational harmonic
Expand Down
80 changes: 0 additions & 80 deletions DRC_Fortran/Source/ControllerBlocks.f90
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,7 @@

MODULE ControllerBlocks

<<<<<<< HEAD
=======
USE, INTRINSIC :: ISO_C_Binding
>>>>>>> tuning_dev
USE Constants
USE Filters
USE Functions
Expand All @@ -21,12 +18,8 @@ MODULE ControllerBlocks

CONTAINS
!-------------------------------------------------------------------------------------------------------------------------------
<<<<<<< HEAD
! 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
>>>>>>> tuning_dev
! PC States:
! PC_State = 0, No pitch control active, BldPitch = PC_MinPit
! PC_State = 1, Active PI blade pitch control enabled
Expand All @@ -37,34 +30,21 @@ SUBROUTINE StateMachine(CntrPar, LocalVar)
! 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)
<<<<<<< HEAD
SUBROUTINE StateMachine(CntrPar, LocalVar)
=======
! VS_State = 6, Tip-Speed-Ratio tracking PI controller
>>>>>>> tuning_dev
USE DRC_Types, ONLY : LocalVariables, ControlParameters
IMPLICIT NONE

! Inputs
<<<<<<< HEAD
TYPE(ControlParameters), INTENT(IN) :: CntrPar
TYPE(LocalVariables), INTENT(INOUT) :: LocalVar
=======
TYPE(ControlParameters), INTENT(IN) :: CntrPar
TYPE(LocalVariables), INTENT(INOUT) :: LocalVar
>>>>>>> tuning_dev

! Initialize State machine if first call
IF (LocalVar%iStatus == 0) THEN ! .TRUE. if we're on the first call to the DLL

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
<<<<<<< HEAD
LocalVar%PC_State = 2
=======
LocalVar%PC_State = 1
>>>>>>> tuning_dev
ELSE ! Constant torque tracking
LocalVar%VS_State = 4
LocalVar%PC_State = 1
Expand All @@ -76,39 +56,13 @@ SUBROUTINE StateMachine(CntrPar, LocalVar)

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

<<<<<<< HEAD
! 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
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
LocalVar%VS_State = 2
! Error state, Debug
ELSE
=======
! --- Torque control state machine ---
IF (LocalVar%PC_PitComT >= CntrPar%VS_Rgn3Pitch) THEN ! Region 3
IF (CntrPar%VS_ControlMode == 1) THEN
Expand All @@ -126,33 +80,12 @@ SUBROUTINE StateMachine(CntrPar, LocalVar)

LocalVar%VS_State = 1
ELSE ! Error state, Debug
>>>>>>> tuning_dev
LocalVar%VS_State = 0
END IF
END IF
END IF
END SUBROUTINE StateMachine
!-------------------------------------------------------------------------------------------------------------------------------
<<<<<<< HEAD
SUBROUTINE WindSpeedEstimator(LocalVar, CntrPar)
USE DRC_Types, ONLY : LocalVariables, ControlParameters
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

END SUBROUTINE WindSpeedEstimator
!-------------------------------------------------------------------------------------------------------------------------------
SUBROUTINE SetpointSmoother(LocalVar, CntrPar, objInst)
USE DRC_Types!, ONLY : LocalVariables, ControlParameters, ObjectInstances
=======
SUBROUTINE WindSpeedEstimator(LocalVar, CntrPar, objInst, PerfData)
! 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
Expand Down Expand Up @@ -299,7 +232,6 @@ SUBROUTINE SetpointSmoother(LocalVar, CntrPar, objInst)
! SS_Mode = 0, No setpoint smoothing
! SS_Mode = 1, Implement setpoint smoothing
USE DRC_Types, ONLY : LocalVariables, ControlParameters, ObjectInstances
>>>>>>> tuning_dev
IMPLICIT NONE

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

<<<<<<< HEAD
! Setpoint Smoothing
=======
! ------ Setpoint Smoothing ------
>>>>>>> tuning_dev
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
<<<<<<< HEAD
LocalVar%SS_DelOmegaF = 0
=======
LocalVar%SS_DelOmegaF = 0 ! No setpoint smoothing
>>>>>>> tuning_dev
ENDIF

END SUBROUTINE SetpointSmoother
!-------------------------------------------------------------------------------------------------------------------------------
<<<<<<< HEAD
END MODULE ControllerBlocks
=======

END MODULE ControllerBlocks
>>>>>>> tuning_dev
Loading

0 comments on commit 83db59b

Please sign in to comment.