Skip to content

Commit

Permalink
Update parameters, debugging
Browse files Browse the repository at this point in the history
  • Loading branch information
nikhar-abbas committed Sep 16, 2020
1 parent f7e3296 commit 2626c6f
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 26 deletions.
13 changes: 5 additions & 8 deletions src/ControllerBlocks.f90
Original file line number Diff line number Diff line change
Expand Up @@ -159,7 +159,7 @@ SUBROUTINE WindSpeedEstimator(LocalVar, CntrPar, objInst, PerfData, DebugVar)
! Extended Kalman Filter (EKF) implementation
ELSEIF (CntrPar%WE_Mode == 2) THEN
! Define contant values
L = 6.0 * CntrPar%WE_BladeRadius
L = 2.0 * CntrPar%WE_BladeRadius
Ti = 0.18
R_m = 0.02
H = RESHAPE((/1.0 , 0.0 , 0.0/),(/1,3/))
Expand All @@ -172,6 +172,7 @@ SUBROUTINE WindSpeedEstimator(LocalVar, CntrPar, objInst, PerfData, DebugVar)
v_t = 0.0
v_m = LocalVar%HorWindV
v_h = LocalVar%HorWindV
lambda = LocalVar%RotSpeed * CntrPar%WE_BladeRadius/v_h
xh = RESHAPE((/om_r, v_t, v_m/),(/3,1/))
P = RESHAPE((/0.01, 0.0, 0.0, 0.0, 0.01, 0.0, 0.0, 0.0, 1.0/),(/3,3/))
K = RESHAPE((/0.0,0.0,0.0/),(/3,1/))
Expand Down Expand Up @@ -206,30 +207,26 @@ SUBROUTINE WindSpeedEstimator(LocalVar, CntrPar, objInst, PerfData, DebugVar)

xh = xh + LocalVar%DT * dxh ! state update
P = P + LocalVar%DT*(MATMUL(F,P) + MATMUL(P,TRANSPOSE(F)) + Q - MATMUL(K * R_m, TRANSPOSE(K)))

! Measurement update
S = MATMUL(H,MATMUL(P,TRANSPOSE(H))) + R_m ! NJA: (H*T*H') \approx 0
K = MATMUL(P,TRANSPOSE(H))/S(1,1)
xh = xh + K*(LocalVar%RotSpeedF - om_r)
P = MATMUL(identity(3) - MATMUL(K,H),P)


! Wind Speed Estimate
om_r = xh(1,1)
v_t = xh(2,1)
v_m = xh(3,1)
v_h = v_t + v_m
LocalVar%WE_Vw = v_m + v_t

ENDIF
ENDIF
! Debug Outputs
DebugVar%WE_Cp = Cp_op
DebugVar%WE_Vm = v_m
DebugVar%WE_Vt = v_t
DebugVar%WE_lambda = lambda
DebugVar%WE_F12 = F(1,2)
DebugVar%WE_F13 = F(1,3)

ELSE
! Define Variables
F_WECornerFreq = 0.20944 ! Fix to 30 second time constant for now
Expand Down
14 changes: 6 additions & 8 deletions src/Functions.f90
Original file line number Diff line number Diff line change
Expand Up @@ -473,7 +473,7 @@ SUBROUTINE Debug(LocalVar, CntrPar, DebugVar, avrSWAP, RootName, size_avcOUTNAME

! Set up Debug Strings and Data
! Note that Debug strings have 10 character limit
nDebugOuts = 20
nDebugOuts = 18
ALLOCATE(DebugOutData(nDebugOuts))
! Header Unit Variable
! Filters
Expand All @@ -495,23 +495,21 @@ SUBROUTINE Debug(LocalVar, CntrPar, DebugVar, avrSWAP, RootName, size_avcOUTNAME
DebugOutStr14 = 'WE_w'; DebugOutUni14 = '(rad/s)'; DebugOutData(14) = DebugVar%WE_w
DebugOutStr15 = 'WE_Vm'; DebugOutUni15 = '(m/s)'; DebugOutData(15) = DebugVar%WE_Vm
DebugOutStr16 = 'WE_Vt'; DebugOutUni16 = '(m/s)'; DebugOutData(16) = DebugVar%WE_Vt
DebugOutStr17 = 'WE_Cp'; DebugOutUni17 = '(-)'; DebugOutData(17) = DebugVar%WE_Cp
DebugOutStr18 = 'WE_lambda'; DebugOutUni18 = '(rad/s)'; DebugOutData(18) = DebugVar%WE_lambda
DebugOutStr19 = 'WE_F12'; DebugOutUni19 = '(-)'; DebugOutData(19) = DebugVar%WE_F12
DebugOutStr20 = 'WE_F13'; DebugOutUni20 = '(-)'; DebugOutData(20) = DebugVar%WE_F13
DebugOutStr17 = 'WE_lambda'; DebugOutUni17 = '(rad/s)'; DebugOutData(17) = DebugVar%WE_lambda
DebugOutStr18 = 'WE_Cp'; DebugOutUni18 = '(-)'; DebugOutData(18) = DebugVar%WE_Cp

Allocate(DebugOutStrings(nDebugOuts))
Allocate(DebugOutUnits(nDebugOuts))
DebugOutStrings = [CHARACTER(10) :: DebugOutStr1, DebugOutStr2, DebugOutStr3, DebugOutStr4, &
DebugOutStr5, DebugOutStr6, DebugOutStr7, DebugOutStr8, &
DebugOutStr9, DebugOutStr10, DebugOutStr11, DebugOutStr12, &
DebugOutStr13, DebugOutStr14, DebugOutStr15, DebugOutStr16, &
DebugOutStr17, DebugOutStr18, DebugOutStr19, DebugOutStr20]
DebugOutStr17, DebugOutStr18]
DebugOutUnits = [CHARACTER(10) :: DebugOutUni1, DebugOutUni2, DebugOutUni3, DebugOutUni4, &
DebugOutUni5, DebugOutUni6, DebugOutUni7, DebugOutUni8, &
DebugOutUni9, DebugOutUni10, DebugOutUni11, DebugOutUni12, &
DebugOutUni13, DebugOutUni14, DebugOutUni15, DebugOutUni1, &
DebugOutUni17, DebugOutUni18, DebugOutUni19, DebugOutUni20]
DebugOutUni17, DebugOutUni18]

! Initialize debug file
IF (LocalVar%iStatus == 0) THEN ! .TRUE. if we're on the first call to the DLL
Expand All @@ -523,7 +521,7 @@ SUBROUTINE Debug(LocalVar, CntrPar, DebugVar, avrSWAP, RootName, size_avcOUTNAME
WRITE (UnDb,'(99(a10,TR5:))') '(sec)', DebugOutUnits
END IF

IF (CntrPar%LoggingLevel > 1) THEN
IF (CntrPar%LoggingLevel > 1) THEN
OPEN(unit=UnDb2, FILE='DEBUG2.dbg')
WRITE(UnDb2,'(/////)')
WRITE(UnDb2,'(A,85("'//Tab//'AvrSWAP(",I2,")"))') 'LocalVar%Time ', (i,i=1,85)
Expand Down
19 changes: 9 additions & 10 deletions src/ROSCO_Types.f90
Original file line number Diff line number Diff line change
Expand Up @@ -216,16 +216,15 @@ MODULE ROSCO_Types
REAL(8), DIMENSION(:,:), ALLOCATABLE :: Cq_mat
END TYPE PerformanceData

TYPE, PUBLIC :: DebugVariables
REAL(8) :: WE_Cp ! Cp that WSE uses to determine aerodynamic torque, for debug purposes [-]
REAL(8) :: WE_b ! Pitch that WSE uses to determine aerodynamic torque, for debug purposes [-]
REAL(8) :: WE_w ! Rotor Speed that WSE uses to determine aerodynamic torque, for debug purposes [-]
REAL(8) :: WE_t ! Torque that WSE uses, for debug purposes [-]
REAL(8) :: WE_Vm ! Torque that WSE uses, for debug purposes [-]
REAL(8) :: WE_Vt ! Torque that WSE uses, for debug purposes [-]
REAL(8) :: WE_lambda ! Torque that WSE uses, for debug purposes [-]
REAL(8) :: WE_F12 ! Torque that WSE uses, for debug purposes [-]
REAL(8) :: WE_F13 ! Torque that WSE uses, for debug purposes [-]
TYPE, PUBLIC :: DebugVariables
! Variables used for debug purposes
REAL(8) :: WE_Cp ! Cp that WSE uses to determine aerodynamic torque[-]
REAL(8) :: WE_b ! Pitch that WSE uses to determine aerodynamic torque[-]
REAL(8) :: WE_w ! Rotor Speed that WSE uses to determine aerodynamic torque[-]
REAL(8) :: WE_t ! Torque that WSE uses[-]
REAL(8) :: WE_Vm ! Mean wind speed component in WSE [m/s]
REAL(8) :: WE_Vt ! Turbulent wind speed component in WSE [m/s]
REAL(8) :: WE_lambda ! TSR in WSE [rad]
END TYPE DebugVariables

END MODULE ROSCO_Types

0 comments on commit 2626c6f

Please sign in to comment.