
%%%%%%%%%%%%%%%%%%%% Exciter settings %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%


AVR_dash=~(AVR);
AVR_sm=AVR_dash(gen(:,1));
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
static_sm=zeros(1,nb);
static_sm(exc_static(:,1))=-1./TA_static;
static_sm=static_sm(gen(:,1));

SL_static_dash=~(SL_static);
SL_static_sm=SL_static_dash(gen(:,1));
static_dEfd=SL_static_sm.*static_sm.*AVR_sm;
%~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
static_bm=zeros(1,nb);
static_bm(exc_static(:,1))=kA_static./TA_static;
static_bm=static_bm(gen(:,1));

static_bdEfd=SL_static_sm.*static_bm.*AVR_sm;

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

%%%%%%%%%%%%%%%%%%%%%%DC1A_EXCITER%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%%%%%%%%%%%%%%%Ag77%%%%%%%%%%%%%%%%5555
DC1A_Ag77=zeros(1,nb);
DC1A_Ag77(exc_DC1A(:,1))=(-(KE_DC1A+A_DC1A.*exp(B_DC1A.*Efd0_DC1A).*(B_DC1A.*Efd0_DC1A+1)))./TE_DC1A;
DC1A_Ag77=DC1A_Ag77(gen(:,1));

SL_DC1A_dash=~(SL_DC1A);
SL_DC1A_sm=SL_DC1A_dash(gen(:,1));

DC1A_dAg77=SL_DC1A_sm.*DC1A_Ag77.*AVR_sm;
%~~~~~~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