r1 = 0.100; % Stator resistance
x1 = 0.210; % Stator reactance
r2 = 0.07; % Rotor resistance
x2 = 0.210; % Rotor reactance
xm = 10.0; % Magnetization branch reactance
vphase = (208) / sqrt(3); % Phase voltage
nsy = 1800; % Synchronous speed (r/min)
wsy = 188.5; % Synchronous speed (rad/s)
%/////////////////Voltage Conditions////////////////////%
Vth1=0.85*vth;
Vth2=0.60*vth;
Vth3=0.35*vth;
Vth4=0.5*vth;
%//////////////////Resistance Varying////////////////////%
 r2_1=0.1;
 r2_2=0.4;
 r2_3=0.7;
 r2_4=1;
 r2_5=3.5;
 r2_6=5;
 r2_7=10;
 r2_8=30; 
%////////////////////////////////////////////////////////%

vth = vphase * ( xm / sqrt(r1^2 + (x1 + xm)^2) );
zth = ((j*xm) * (r1 + j*x1)) / (r1 + j*(x1 + xm));
rth = real(zth);
xth = imag(zth);
s = (-5000:1:10100)/ 5000;
s(1)=-1.0005;
s(15101)=2.0005
nm = (1 - s)*nsy; 
wm = (1 - s)*wsy;

for x = 1:15101
tind(x) = (3 * vth^2 * r2 / s(x)) /(wsy * ((rth + r2/s(x))^2 + (xth + x2)^2) );
pout(x) = tind(x) * wm(x);
end

figure(1);
plot(nm,tind,'r','linewidth',2.5);
xlabel('\bf n_{m} (rpm)');
ylabel(' \bf \tau_{ind}');
title ('\bf Torque-Speed Characteristic    \bf[\tau_{ind} Vs n_{m}]');
grid on;

figure(2);
plot(s,tind,'k','linewidth',2.5);
xlabel(' \bf s(slip)');
ylabel('\bf \tau_{ind}');
title ('\bf Torque-Slip Characteristic     \bf[\tau_{ind} Vs s] ');
grid on;

figure(3);

plot(nm,pout,'b','linewidth',2.5);
xlabel('\bf s');
ylabel(' \bf P_{OUT} \bf(W)');
title ('Output Power Vs. Speed     \bf[P_{out} Vs n_{m}] ');
grid on;

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%%%%%%%%%%%%%%%%%%% LINE VOLTAGE VARYING%%%%%%%%%%%%%%%%%%%%%%%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% %%%%%%%%%%%%%%%%%%%%%%%%%%%%
 
for x = 1:15101 %Vl reduced to 85%
tind1(x) = (3 * Vth1^2 * r2 / s(x)) /(wsy * ((rth + r2/s(x))^2 + (xth + x2)^2) );
pout1(x) = tind1(x) * wm(x);
end
 
for x = 1:15101 %Vl reduced to 60%
tind2(x) = (3 * Vth2^2 * r2 / s(x)) /(wsy * ((rth + r2/s(x))^2 + (xth + x2)^2) );
pout2(x) = tind2(x) * wm(x);
end
 
for x = 1:15101 %vl reduced to 35%
tind3(x) = (3 * Vth3^2 * r2 / s(x)) /(wsy * ((rth + r2/s(x))^2 + (xth + x2)^2) );
pout3(x) = tind3(x) * wm(x);
end


for x = 1:15101 %to 5%
tind4(x) = (3 * Vth4^2 * r2 / s(x)) /(wsy * ((rth + r2/s(x))^2 + (xth + x2)^2) );
pout4(x) = tind4(x) * wm(x);
end
 
% ///////////////////// Plot the torque - speed curve////////////////////
figure(4);
plot(nm,tind1,'color','k','linewidth',2.2);
hold on;
plot(nm,tind2,'color','g','linewidth',2.2);
plot(nm,tind3,'color','r','linewidth',2.2);
plot(nm,tind4,'color','b','linewidth',2.2);
xlabel('\bf\itn_{m} \rm\bfrpm');
ylabel('\bf\tau_{ind} \rm\bf(N.m)');
title('Torque Induced Vs. Mechanical Speed');
legend('when VLL=85% of VLL rated  ','when VLL=60% of VLL rated  ','when VLL=35% of VLL rated ','when VLL=5% of VLL rated');
grid on;
hold off;
%////////////////////////////////////////////////////////////////////////

% ///////////////////// Plot the torque - slip curve/////////////////////

figure(5);
plot(s,tind1,'color','k','linewidth',2.2);
hold on;
plot(s,tind2,'color','g','linewidth',2.2);
plot(s,tind3,'color','r','linewidth',2.2);
plot(s,tind4,'color','b','linewidth',2.2);
xlabel('\bf\itn_{m} \rm\bfrpm');
ylabel('\bf\tau_{ind} \rm\bf(N.m)');
title('Torque Induced Vs Slip');
legend('when VLL=85% of VLL rated  ','when VLL=60% of VLL rated  ','when VLL=35% of VLL rated ','when VLL=5% of VLL rated');
grid on;
hold off;

%////////////////////////////////////////////////////////////////////////
% ///////////////////// Plots of OUTPUT POWER VS - SLIP//////////////////

figure(6);
plot(s,pout1/1000,'color','k','linewidth',2.2);
hold on;
plot(s,pout2/1000,'color','g','linewidth',2.2);
plot(s,pout3/1000,'color','r','linewidth',2.2);
plot(s,pout4/1000,'color','b','linewidth',2.2);
xlabel('\bf s');
ylabel(' \bf P_{OUT} \bf(kW)');
title('Output Power Vs. Slip');
legend('when VLL=85% of VLL rated  ','when VLL=60% of VLL rated  ','when VLL=35% of VLL rated ','when VLL=5% of VLL rated');
grid on;
hold off;

%////////////////////////////////////////////////////////////////////////

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%%%%%%%%%%%%%%%%%%%( RESISTANCE VARYING )%%%%%%%%%%%%%%%%%%%%%%%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%

for x = 1:15101
tind5(x) = (3 * vth^2 * r1/ s(x)) /(wsy * ((rth + r2_1/s(x))^2 + (xth + x2)^2) );
pout5(x) = tind5(x) * wm(x);
end
for x = 1:15101
tind6(x) = (3 * vth^2 * r1/ s(x)) /(wsy * ((rth + r2_2/s(x))^2 + (xth + x2)^2) );
pout6(x) = tind6(x) * wm(x);
end
for x = 1:15101
tind7(x) = (3 * vth^2 * r1/ s(x)) /(wsy * ((rth + r2_3/s(x))^2 + (xth + x2)^2) );
pout7(x) = tind7(x) * wm(x);
end
for x = 1:15101
tind8(x) = (3 * vth^2 * r1/ s(x)) /(wsy * ((rth + r2_4/s(x))^2 + (xth + x2)^2) );
pout8(x) = tind8(x) * wm(x);
end
for x = 1:15101
tind9(x) = (3 * vth^2 * r1/ s(x)) /(wsy * ((rth + r2_5/s(x))^2 + (xth + x2)^2) );
pout9(x) = tind9(x) * wm(x);
end
for x = 1:15101
tind10(x) = (3 * vth^2 * r1/ s(x)) /(wsy * ((rth + r2_6/s(x))^2 + (xth + x2)^2) );
pout10(x) = tind10(x) * wm(x);
end
for x = 1:15101
tind11(x) = (3 * vth^2 * r1/ s(x)) /(wsy * ((rth + r2_7/s(x))^2 + (xth + x2)^2) );
pout11(x) = tind11(x) * wm(x);
end
for x = 1:15101
tind12(x) = (3 * vth^2 * r1/ s(x)) /(wsy * ((rth + r2_8/s(x))^2 + (xth + x2)^2) );
pout12(x) = tind12(x) * wm(x);
end



%%%%%%%%%%%%%% PLOT OF Torque induced Vs Mechaical Speed %%%%%%%%%%
figure(7);
plot(nm,tind5,'k','linewidth',2.2);
hold on;
plot(nm,tind6,'g','linewidth',2.2);
plot(nm,tind7,'r','linewidth',2.2);
plot(nm,tind8,'b','linewidth',2.2);
plot(nm,tind9,'k','linewidth',2.2);
plot(nm,tind10,'c','linewidth',2.2);
plot(nm,tind11,'y','linewidth',2.2);
plot(nm,tind12,'m','linewidth',2.2);
xlabel('\bf n_{m} (rpm)');
ylabel(' \bf \tau_{ind}');
title ('Torque-Speed Characteristic    \bf[\tau_{ind} Vs n_{m}]');
legend('When R1=0.1ohm','When R1=0.4ohm','When R1=0.7ohm','When R1=1ohm','When R1=3.5ohm','When R1=5ohm','When R1=10ohm','When R1=30ohm')
grid on;
hold off;

%%%%%%%%%%%%%% PLOT OF Torque induced Vs Slip  %%%%%%%%%%%%%%%%%%%


figure(8);
plot(s,tind5,'k','linewidth',2.2);
hold on;
plot(s,tind6,'g','linewidth',2.2);
plot(s,tind7,'r','linewidth',2.2);
plot(s,tind8,'b','linewidth',2.2);
plot(s,tind9,'k','linewidth',2.2);
plot(s,tind10,'c','linewidth',2.2);
plot(s,tind11,'y','linewidth',2.2);
plot(s,tind12,'m','linewidth',2.2);
xlabel('\bf s (slip)');
ylabel(' \bf \tau_{ind}');
title ('Torque-Slip Characteristic    \bf[\tau_{ind} Vs slip]');
legend('When R1=0.1ohm','When R1=0.4ohm','When R1=0.7ohm','When R1=1ohm','When R1=3.5ohm','When R1=5ohm','When R1=10ohm','When R1=30ohm')
grid on;
hold off;


%%%%%%%%%%%%%% PLOT Power Out Vs Slip  %%%%%%%%%%%%%%%%%%%

figure(9);
plot(s,pout5/1000,'k','linewidth',2.2);
hold on;
plot(s,pout6/1000,'g','linewidth',2.2);
plot(s,pout7/1000,'r','linewidth',2.2);
plot(s,pout8/1000,'b','linewidth',2.2);
plot(s,pout9/1000,'k','linewidth',2.2);
plot(s,pout10/1000,'c','linewidth',2.2);
plot(s,pout11/1000,'y','linewidth',2.2);
plot(s,pout12/1000,'m','linewidth',2.2);
xlabel('\bf s (slip)');
ylabel('\bfP_{out}(kW)');
title ('Power Converted Characteristics   \bf[P_{out} Vs slip]');
legend('When R1=0.1ohm','When R1=0.4ohm','When R1=0.7ohm','When R1=1ohm','When R1=3.5ohm','When R1=5ohm','When R1=10ohm','When R1=30ohm')
grid on;
hold off;




