实验三:发电系统裕度表生成及可靠性指标计算
clear;
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% %形成第一台发电机组停运表%%%%%%%%%%%%%%%%%%%%%%%%%% C1=input('请输入第一台发电机的容量:C1=');
q1=input('请输入第一台发电机的强迫停运率:q1='); t=input('请输入发电机的平均修复时间:t='); DX=input('请输入所设置的计算步长:DX='); Na=C1/DX;AF=zeros(Na+1,6);ui=1/t; for i=0:Na j=i+1; AF(j,1)=i; end
for i=0:Na j=i+1;
AF(j,2)= AF(j,1)*DX; end
for i=0:Na j=i+1;
if AF(j,2)<=0 AF(j,5)=1-q1; AF(j,4)=0;
else if AF(j,2)>=C1 AF(j,5)=q1; AF(j,4)=q1*ui; else
AF(j,5)=0; AF(j,4)=q1*ui; end end end
for i=0:Na sum=0; for j=i:Na j=j+1;
sum=sum+AF(j,5); end
AF(i+1,3)=sum; end
for i=0:Na if i~=Na
AF(i+1,6)=AF(i+1,4)-AF(i+2,4); else
AF(i+1,6)=AF(i+1,4); end end
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% %形成第二台发电机组停运表%%%%%%%%%%%%%%%%%%%%%%%%%% C2=input('请输入第二台发电机的容量:C2=');
q2=input('请输入第二台发电机的强迫停运率:q2='); Nb=C2/DX;
BF=zeros(Nb+1,5); for i=0:Nb BF(i+1,1)=i; end
for i=0:Nb
BF(i+1,2)= BF(i+1,1)*DX; end
for i=0:Nb
if BF(i+1,2)<=0 BF(i+1,5)=1-q2; BF(i+1,4)=0;
elseif BF(i+1,2)>=C2 BF(i+1,5)=q2; BF(i+1,4)=q2*ui; else
BF(i+1,5)=0; BF(i+1,4)=q2*ui; end end
for i=0:Nb sum=0; for j=i:Nb
sum=sum+BF(j+1,5); end
BF(i+1,3)=sum; end
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% %%第一台和第二台发电机并联后的停运表%%%%%%%%%%%%%%%%%%% Nd=Na+Nb;
DF=zeros(Nd+1,5); for i=0:Nd DF(i+1,1)=i;
DF(i+1,2)=DF(i+1,1)*DX; end
for k=0:Nd for i=0:k if k<=Na
DF(k+1,5)=AF(i+1,5)*BF(k+1-i,5)+DF(k+1,5); else sum=0;
for i=k-Nb:Na
sum=AF(i+1,5)*BF(k+1-i,5)+sum; end
DF(k+1,5)=sum; end end end
for k=0:Nd for i=0:Na if k<=Na if k+1-i>0
DF(k+1,4)=AF(i+1,5)*BF(k+1-i,4)+AF(i+1,6)*BF(k+1-i,3)+DF(k+1,4); else
DF(k+1,4)=AF(i+1,6)+DF(k+1,4); end else sum2=0;
for i=k-Nb:Na
sum2=AF(i+1,5)*BF(k+1-i,4)+AF(i+1,6)*BF(k+1-i,3)+sum2; end
DF(k+1,4)=sum2; end end end
for k=0:Nd sum1=0; for j=k:Nd
sum1=DF(j+1,5)+sum1; end
DF(k+1,3)=sum1; end
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% %形成第三台发电机组停运表%%%%%%%%%%%%%%%%%%%%%%%%%% C3=input('请输入第三台发电机的容量:C3=');
q3=input('请输入第三台发电机的强迫停运率:q3='); Nc=C3/DX;
CF=zeros(Nc+1,6); for i=0:Nc