From 2626c6f40054ef5a81719511cb81e06f8d90bbb1 Mon Sep 17 00:00:00 2001 From: Nikhar Abbas Date: Wed, 16 Sep 2020 14:59:07 -0600 Subject: [PATCH] Update parameters, debugging --- src/ControllerBlocks.f90 | 13 +++++-------- src/Functions.f90 | 14 ++++++-------- src/ROSCO_Types.f90 | 19 +++++++++---------- 3 files changed, 20 insertions(+), 26 deletions(-) diff --git a/src/ControllerBlocks.f90 b/src/ControllerBlocks.f90 index 76be308e..21affa70 100644 --- a/src/ControllerBlocks.f90 +++ b/src/ControllerBlocks.f90 @@ -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/)) @@ -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/)) @@ -206,13 +207,13 @@ 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) @@ -220,16 +221,12 @@ SUBROUTINE WindSpeedEstimator(LocalVar, CntrPar, objInst, PerfData, DebugVar) 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 diff --git a/src/Functions.f90 b/src/Functions.f90 index e87c6551..f2dc5036 100644 --- a/src/Functions.f90 +++ b/src/Functions.f90 @@ -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 @@ -495,10 +495,8 @@ 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)) @@ -506,12 +504,12 @@ SUBROUTINE Debug(LocalVar, CntrPar, DebugVar, avrSWAP, RootName, size_avcOUTNAME 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 @@ -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) diff --git a/src/ROSCO_Types.f90 b/src/ROSCO_Types.f90 index 69e629a1..67bb2091 100644 --- a/src/ROSCO_Types.f90 +++ b/src/ROSCO_Types.f90 @@ -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