Professional Documents
Culture Documents
clear variables;
xmq = xq - xls;
xmd = xd - xls;
H = 0.5*J_rotor*wbasem*wbasem/Sbase;
rs = rs/Zbase;
xls = xls/Zbase;
xppd = xppd/Zbase;
xppq = xppq/Zbase;
xpd = xpd/Zbase;
xpq = xpq/Zbase;
x2 = x2/Zbase;
x0 = x0/Zbase;
xd = xd/Zbase;
xq = xq/Zbase;
xmd = xmd/Zbase;
xmq = xmq/Zbase;
rpf = rpf/Zbase;
rpkd = rpkd/Zbase;
rpkq = rpkq/Zbase;
xplf = xplf/Zbase;
xplkd = xplkd/Zbase;
xplkq = xplkq/Zbase;
end
%****************************************************
% Establish initial conditions for starting simulation
wb=wbase;
xMQ = (1/xls + 1/xmq + 1/xplkq)^(-1);
xMD = (1/xls + 1/xmd + 1/xplf + 1/xplkd)^(-1);
It = conj(St/Vt);
Eq = Vt + (rs + 1i*xq)*It
delt = angle(Eq) % angle Eq leads Vt
Eqo = abs(Eq);
I = It*(cos(delt) - sin(delt)*1i)% same as I = (conj(Eq)/Eqo)*It;
Iqo = real(I)
Ido = -imag(I); % when the d-axis lags the q-axis
Efo = Eqo + (xd-xq)*Ido;
Ifo = Efo/xmd;
switch (modo)
case '3f'
disp('P: Para falla trif�sica en el pico de la onda de la fase a')
disp('0: Para falla trif�sica en el cero de la onda de la fase a')
disp(' ');
kl='P';
kl=input(' MODO : ','S');
switch(kl)
case 'P'
Vatime=[0 tfstart tfstart (tfstart+tfault) (tfstart+tfault) tstop];
Va=[1 1 0 0 1 1];
Vbtime=[0 tfstart tfstart (tfstart+tfault) (tfstart+tfault) tstop];
Vb=[1 1 0 0 1 1];
Vctime=[0 tfstart tfstart (tfstart+tfault) (tfstart+tfault) tstop];
Vc=[1 1 0 0 1 1];
case '0'
tfstart=0.1-0.004166667;
Vatime=[0 tfstart tfstart (tfstart+tfault) (tfstart+tfault) tstop];
Va=[1 1 0 0 1 1];
Vbtime=[0 tfstart tfstart (tfstart+tfault) (tfstart+tfault) tstop];
Vb=[1 1 0 0 1 1];
Vctime=[0 tfstart tfstart (tfstart+tfault) (tfstart+tfault) tstop];
Vc=[1 1 0 0 1 1];
end
case '2f'
Vatime=[0 tfstart tfstart (tfstart+tfault) (tfstart+tfault) tstop];
Va=[1 1 1 1 1 1];
Vbtime=[0 tfstart tfstart (tfstart+tfault) (tfstart+tfault) tstop];
Vb=[1 1 0 0 1 1];
Vctime=[0 tfstart tfstart (tfstart+tfault) (tfstart+tfault) tstop];
Vc=[1 1 0 0 1 1];
case '1f'
Vatime=[0 tfstart tfstart (tfstart+tfault) (tfstart+tfault) tstop];
Va=[1 1 0 0 1 1];
Vbtime=[0 tfstart tfstart (tfstart+tfault) (tfstart+tfault) tstop];
Vb=[1 1 1 1 1 1];
Vctime=[0 tfstart tfstart (tfstart+tfault) (tfstart+tfault) tstop];
Vc=[1 1 1 1 1 1];
end
plotfile
subplot(4,1,1)
plot(y(:,1),y(:,2),'-')
ylabel('|Vt| in pu')
axis([-inf inf 0.9 1.1])
title('stator voltage magnitude')
subplot(4,1,2)
plot(y(:,1),y(:,3),'-')
ylabel('|It| in pu')
axis([-inf inf 0 inf])
title('stator current magnitude')
subplot(4,1,3)
plot(y(:,1),y(:,4),'-')
ylabel('Pgen in pu')
title('Real power generated')
subplot(4,1,4)
plot(y(:,1),y(:,5),'-')
ylabel('Qgen in pu')
xlabel('time in sec')
title('Reactive power generated')
h2=figure;
subplot(4,1,1)
plot(y(:,1),y(:,6),'-')
ylabel('Delta in rad')
title('Power angle delta')
subplot(4,1,2)
plot(y(:,1),y(:,7),'-')
ylabel('Tem in pu')
title('Instantaneous electrical torque')
subplot(4,1,3)
plot(y(:,1),y(:,8),'-')
ylabel('If in pu')
title('Field current')
subplot(4,1,4)
plot(y(:,1),y(:,9),'-')
ylabel('ia in pu')
xlabel('time in sec')
title('Instantaneous phase a current')