Code of An Estimation-based Approach of Fault Detection and Isolation of the Wind TurbineBenchmark

by

 

The matlab code of the solution of “FDI Design Competition for Wind Turbines" (winning 2nd place)

FDI_DriveTrain_c(t,x,u,flag,A,B,C,L)
%faults 4, 5, 8, 9

function [sys,x0,str,ts] = FDI_DriveTrain_c(t,x,u,flag,A,B,C,L)



switch flag,

  %%%%%%%%%%%%%%%%%%
  % Initialization %
  %%%%%%%%%%%%%%%%%%
  case 0,
    [sys,x0,str,ts]=mdlInitializeSizes();

  %%%%%%%%%%%%%%%
  % Derivatives %
  %%%%%%%%%%%%%%%
  case 1,
    sys=mdlDerivatives(t,x,u,A,B,C,L);

  %%%%%%%%%%%
  % Outputs %
  %%%%%%%%%%%
  case 3,
    sys=mdlOutputs(t,x,u,C);

  %%%%%%%%%%%%%%%%%%%
  % Unhandled flags %
  %%%%%%%%%%%%%%%%%%%
  case { 2, 4, 9 },
    sys = [];

  %%%%%%%%%%%%%%%%%%%%
  % Unexpected flags %
  %%%%%%%%%%%%%%%%%%%%
  otherwise
    error(['Unhandled flag = ',num2str(flag)]);

end
% end csfunc

%
%=============================================================================
% mdlInitializeSizes
% Return the sizes, initial conditions, and sample times for the S-function.
%=============================================================================
%
function [sys,x0,str,ts]=mdlInitializeSizes()

sizes = simsizes;
sizes.NumContStates  = 2;
sizes.NumDiscStates  = 0;
sizes.NumOutputs     = 1;
sizes.NumInputs      = 3;
sizes.DirFeedthrough = 1;
sizes.NumSampleTimes = 1;

sys = simsizes(sizes);
x0  = [100  0 ]' ;
str = [];
ts  = [0 0];

% end mdlInitializeSizes
%
%=============================================================================
% mdlDerivatives
% Return the derivatives for the continuous states.
%=============================================================================
%
function sys=mdlDerivatives(t,x,u,A,B,C,L)

omega_r = u(1);
Tau_g = u(2);
Omega_g = u(3);

x_est = x(1:2);
Omega_g_est = C*x_est;

sys = [ A*x_est + B*[Tau_g omega_r]' + L*(Omega_g-Omega_g_est) 
      ];
    

% end mdlDerivatives
%
%=============================================================================
% mdlOutputs
% Return the block outputs.
%=============================================================================
%
function sys=mdlOutputs(t,x,u,C)

x_est = x(1:2);
Omega_g_est = C*x_est;

sys = [ Omega_g_est ]; 

%end mdlOutputs

Contact us