Академический Документы
Профессиональный Документы
Культура Документы
if M(ib)==1000
if M(jb)==1000
k=k+1;
end
if M(jb)~=1000
if status(k)~=0
M(ib)=M(jb);
k=k+1;
end
temp=find(hvbuses==ib);
if k<=(length(ele_num))& k==flag
if status(k)==0
if (length(temp)==0)
M(ib)=M(jb)-1;
k=k+1;
else
M(ib)=M(jb)+1;
k=k+1;
end
end
end
end
kk=find(M==1000);
if length(kk)==0
%M
break;
end
if length(kk)~=0
if k<=length(ele_num)
%k=k+1;
%M
continue;
end
if k>length(ele_num)
k=1;
%M
continue;
end
end
end
if M(ib)~=1000
if M(jb)~=1000
k=k+1;
end
if M(jb)==1000
if status(k)~=0
M(jb)=M(ib);
k=k+1;
end
temp=find(hvbuses==jb);
if k<=(length(ele_num)) & k==flag
if status(k)==0
if (length(temp)==0)
M(jb)=M(ib)-1;
k=k+1;
else
M(jb)=M(ib)+1;
k=k+1;
end
end
end
end
kk=find(M==1000);
if length(kk)==0
%M
break;
end
if length(kk)~=0
if k<=length(ele_num)
%k=k+1;
%M
continue;
end
if k>length(ele_num)
k=1;
%M
continue;
end
end
end
end
fid=fopen('faultdata.txt','r');
b=textread('faultdata.txt');
fclose(fid);
FB=b(1);
flag=M(FB);
for i=1:(nb+1)
M(i)=M(i)-flag;
end
M
%correction of voltage and flows
value=input('Enter the phase shift that you desire in degrees. The choice that you
have are 30 and 90 degrees.');
for i=1:nb
vf_phase(i)=vf_phase(i)+M(i)*(value*pi/180);
end
for i=1:length(posflow_phase)
posflow_phase(i)=posflow_phase(i)+M(start_bus(i))*(value*pi/180);
negflow_phase(i)=negflow_phase(i)+M(end_bus(i))*(value*pi/180);
end
%negflow_mag
%negflow_phase
%data entry into output file
fid=fopen('output.txt','w');
fprintf(fid,'The Ybus\n\n');
for i=1:nb
for k=1:nb
fprintf(fid,'%-10.3f\t',Yp(i,k));
end
fprintf(fid,'\n\n');
end
fprintf(fid,'The Zbus\n\n');
for i=1:nb
for k=1:nb
fprintf(fid,'%-10.3f\t',Zbus(i,k));
end
fprintf(fid,'\n\n');
end
fprintf(fid,'Fault current\n\n');
fprintf(fid,'Magnitude Angle(radians)\n');
fprintf(fid,'%-10.3f %-10.3f\n\n',abs(fault_current),angle(fault_current));
fprintf(fid,'Post Fault Voltages\n\n');
fprintf(fid,'Bus-number Magnitude Angle(radians)\n');
for i=1:length(vf)
fprintf(fid,'%-10.3f %-10.3f %-10.3f\n',i,vf_mag(i),vf_phase(i));
end
fprintf(fid,'\n\n');
fprintf(fid,'Post fault flows\n\n');
fprintf(fid,'The extra bus represents the reference bus\n');
fprintf(fid,'Start-bus End-bus Magnitude Phase\n');
fprintf(fid,'This represents the I to J flows\n\n');
for i=1:length(posflow_mag)
fprintf(fid,'%-10.3f %-10.3f %-10.3f %-
10.3f\n',start_bus(i),end_bus(i),posflow_mag(i),posflow_phase(i));
end
fprintf(fid,'\n\n');
fprintf(fid,'This represents the J to I flows\n\n');
fprintf(fid,'Start-bus End-bus Magnitude Phase\n');
kk=find(end_bus==(nb+1));
for i=1:length(negflow_mag)
test=find(kk==i);
if length(test)==0
fprintf(fid,'%-10.3f %-10.3f %-10.3f %-
10.3f\n',end_bus(i),start_bus(i),negflow_mag(i),negflow_phase(i));
end
end
fprintf(fid,'\n\n');
fclose(fid);
done=1;