% Mohamad Emad Bornat
% Mohamad Emad Bornat

F=60;                                           % Frequency in Hertz 
L=700;                                          % length of the line in km
ind = 1*10^-3 ;                                 % Inductance per km per phase in H
cap = 1*10^-8 ;                                 % Capacitance per km per phase in F
Power=800*10^6;                                 % Receivng end power in watt
PF=0.95;                                        % Power facotr 
Vr=500000;                                      % Receving end rated line voltage 

x=0:5/1000:L;



beta=2*pi*F*sqrt(ind*cap);                      
Zc=sqrt(ind/cap);                              
Vr_phase=Vr/sqrt(3);
Ir=(Power)*(PF+1i*sin(acosd(PF)))/(3*Vr_phase*PF);

Vs=cos(beta*L)*Vr_phase+1i*Zc*sin(beta*L)*Ir;  

% 1)Open circuit load 
Vr_noload=Vs/cos(beta*L);
V1=Vr_noload*cos(beta.*x);
plot(x,abs(V1),'r');
grid on;
set(gca,'XDir','Reverse');
xlabel('Distance(Km)');
ylabel('voltage(V)');
title('Voltage Profile');

% 2)Short circuit load 
Ir_short=Vs/(sin(beta*L)*Zc);
V2=Zc.*sin(beta.*x).*Ir_short;
hold on ;
plot(x,abs(V2),'k');

% 3)SIL 
Vr=Vs;
Ir_SIL=Vr/Zc;
V3=cos(beta.*x)*Vr+1i*Zc.*sin(beta.*x).*Ir_SIL;
hold on ;
plot(x,abs(V3),'g');

% 4)Full load  
V4=cos(beta.*x)*Vr_phase+1i*Zc.*sin(beta.*x).*Ir;
hold on ;
plot(x,abs(V4),'b');
legend('No load volatge ','Short Circuit load','SIL','Full load');
% Mohamad Emad Bornat
% Mohamad Emad Bornat
