Skip to content

Commit

Permalink
Pull ROSCO mhk
Browse files Browse the repository at this point in the history
  • Loading branch information
dzalkind committed Aug 23, 2023
2 parents 5dc6c21 + a06cce7 commit d450f7d
Show file tree
Hide file tree
Showing 17 changed files with 252 additions and 178 deletions.
67 changes: 54 additions & 13 deletions ROSCO/Matlab_Toolbox/rosco_filters.m
Original file line number Diff line number Diff line change
Expand Up @@ -2,23 +2,64 @@

clear;

%% Notch Filter
dbg = ROSCOout2Matlab('/Users/dzalkind/Tools/ROSCO1/Examples/examples_out/26_MHK/5_low_ws_debug/RM1_MHK/power_curve/base/RM1_MHK_0.RO.dbg2');


%%

DT = 0.01;

omega = 2.4;
BetaNum = 0.1;
BetaDen = 0.65;

K = 2.0/DT;
b2 = (K^2.0 + 2.0*omega*BetaNum*K + omega^2.0)/(K^2.0 + 2.0*omega*BetaDen*K + omega^2.0);
b1 = (2.0*omega^2.0 - 2.0*K^2.0) / (K^2.0 + 2.0*omega*BetaDen*K + omega^2.0);
b0 = (K^2.0 - 2.0*omega*BetaNum*K + omega^2.0) / (K^2.0 + 2.0*omega*BetaDen*K + omega^2.0);
a1 = (2.0*omega^2.0 - 2.0*K^2.0) / (K^2.0 + 2.0*omega*BetaDen*K + omega^2.0);
a0 = (K^2.0 - 2.0*omega*BetaDen*K + omega^2.0)/ (K^2.0 + 2.0*omega*BetaDen*K + omega^2.0);
%%

notch_filt = tf([b2,b1,b0],[1,a1,a0],DT)
num2 = 0.001;
den2 = 0.1;

num1 = 0.001;
den1 = 0.1;

NF1 = notch(1,num1,den1,0.01);
NF2 = notch(2.42,num2,den2,0.01);

figure(1);
bode(notch_filt)
bode(NF1)
bode(NF2)
bode(NF1*NF2)

% BS = fdesign.bandstop(




y = lsim(NF1*NF2,dbg.GenSpeed,dbg.Time);
% %
% %
figure(2);
plot(dbg.Time,dbg.GenSpeed)
hold on;
plot(dbg.Time,dbg.GenSpeedF)
plot(dbg.Time,y)
% %
% %
hold off

%% Notch Filter

function notch_filt = notch(omega,BetaNum,BetaDen,DT)

% DT = 0.01;
%
% omega = 1;
% BetaNum = 0.01;
% BetaDen = 0.25;

K = 2.0/DT;
b2 = (K^2.0 + 2.0*omega*BetaNum*K + omega^2.0)/(K^2.0 + 2.0*omega*BetaDen*K + omega^2.0);
b1 = (2.0*omega^2.0 - 2.0*K^2.0) / (K^2.0 + 2.0*omega*BetaDen*K + omega^2.0);
b0 = (K^2.0 - 2.0*omega*BetaNum*K + omega^2.0) / (K^2.0 + 2.0*omega*BetaDen*K + omega^2.0);
a1 = (2.0*omega^2.0 - 2.0*K^2.0) / (K^2.0 + 2.0*omega*BetaDen*K + omega^2.0);
a0 = (K^2.0 - 2.0*omega*BetaDen*K + omega^2.0)/ (K^2.0 + 2.0*omega*BetaDen*K + omega^2.0);

notch_filt = tf([b2,b1,b0],[1,a1,a0],DT);

end

9 changes: 9 additions & 0 deletions ROSCO/ROSCO/rosco_registry/rosco_types.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -293,6 +293,9 @@ ControlParameters:
VS_TSRopt:
<<: *real
description: Power-maximizing region 2 tip-speed ratio [rad]
VS_PwrFiltF:
<<: *real
description: Cut-off frequency of filter on generator power for power-based tsr tracking control

# Setpoint Smoother
SS_Mode:
Expand Down Expand Up @@ -898,6 +901,9 @@ LocalVariables:
VS_GenPwr:
<<: *real
description: Generator power [W]
VS_GenPwrF:
<<: *real
description: Generator power [W]
GenSpeed:
<<: *real
description: Generator speed (HSS) [rad/s]
Expand Down Expand Up @@ -966,6 +972,9 @@ LocalVariables:
<<: *real
description: Tower fore-aft vibration damping pitch contribution [rad]
size: 3
VS_RefSpd:
<<: *real
description: Torque control generator speed set point [rad/s]
RotSpeedF:
<<: *real
description: Filtered LSS (generator) speed [rad/s].
Expand Down
21 changes: 11 additions & 10 deletions ROSCO/ROSCO/src/ControllerBlocks.f90
Original file line number Diff line number Diff line change
Expand Up @@ -46,39 +46,40 @@ SUBROUTINE ComputeVariablesSetpoints(CntrPar, LocalVar, objInst)

LocalVar%PC_SpdErr = PC_RefSpd - LocalVar%GenSpeedF ! Speed error
LocalVar%PC_PwrErr = CntrPar%VS_RtPwr - LocalVar%VS_GenPwr ! Power error

! ----- Torque controller reference errors -----
! Define VS reference generator speed [rad/s]
IF (CntrPar%VS_ControlMode == 2) THEN
VS_RefSpd = (CntrPar%VS_TSRopt * LocalVar%We_Vw_F / CntrPar%WE_BladeRadius) * CntrPar%WE_GearboxRatio
LocalVar%VS_RefSpd = (CntrPar%VS_TSRopt * LocalVar%We_Vw_F / CntrPar%WE_BladeRadius) * CntrPar%WE_GearboxRatio
ELSEIF (CntrPar%VS_ControlMode == 3) THEN
VS_RefSpd = (LocalVar%VS_GenPwr/CntrPar%VS_Rgn2K)**(1./3.) ! Genspeed reference that doesnt depend on wind speed estimate (https://doi.org/10.2172/1259805)
LocalVar%VS_GenPwrF = LPFilter(LocalVar%VS_GenPwr, LocalVar%DT,CntrPar%VS_PwrFiltF, LocalVar%FP, LocalVar%iStatus, LocalVar%restart, objInst%instLPF) ! 30 second time constant
LocalVar%VS_RefSpd = (LocalVar%VS_GenPwrF/CntrPar%VS_Rgn2K)**(1./3.) ! Genspeed reference that doesnt depend on wind speed estimate (https://doi.org/10.2172/1259805)
ELSE
VS_RefSpd = CntrPar%VS_RefSpd
LocalVar%VS_RefSpd = CntrPar%VS_RefSpd
ENDIF

VS_RefSpd = saturate(VS_RefSpd,CntrPar%VS_MinOMSpd, CntrPar%VS_RefSpd)
LocalVar%VS_RefSpd = saturate(LocalVar%VS_RefSpd,CntrPar%VS_MinOMSpd, CntrPar%VS_RefSpd)

! Implement setpoint smoothing
IF (LocalVar%SS_DelOmegaF > 0) THEN
VS_RefSpd = VS_RefSpd - LocalVar%SS_DelOmegaF
LocalVar%VS_RefSpd = LocalVar%VS_RefSpd - LocalVar%SS_DelOmegaF
ENDIF

! Force zero torque in shutdown mode
IF (LocalVar%SD) THEN
VS_RefSpd = CntrPar%VS_MinOMSpd
LocalVar%VS_RefSpd = CntrPar%VS_MinOMSpd
ENDIF

! Force minimum rotor speed
VS_RefSpd = max(VS_RefSpd, CntrPar%VS_MinOmSpd)
LocalVar%VS_RefSpd = max(LocalVar%VS_RefSpd, CntrPar%VS_MinOmSpd)

! TSR-tracking reference error
IF ((CntrPar%VS_ControlMode == 2) .OR. (CntrPar%VS_ControlMode == 3)) THEN
LocalVar%VS_SpdErr = VS_RefSpd - LocalVar%GenSpeedF
LocalVar%VS_SpdErr = LocalVar%VS_RefSpd - LocalVar%GenSpeedF
ENDIF

! Define transition region setpoint errors
LocalVar%VS_SpdErrAr = VS_RefSpd - LocalVar%GenSpeedF ! Current speed error - Region 2.5 PI-control (Above Rated)
LocalVar%VS_SpdErrAr = LocalVar%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)

! Region 3 minimum pitch angle for state machine
Expand Down
Loading

0 comments on commit d450f7d

Please sign in to comment.