diff --git a/0PD0.mat b/0PD0.mat index c78db61..00bfc6c 100644 Binary files a/0PD0.mat and b/0PD0.mat differ diff --git a/0QD0.mat b/0QD0.mat index 19bc650..733cc73 100644 Binary files a/0QD0.mat and b/0QD0.mat differ diff --git a/12PD0.mat b/12PD0.mat index 85525f4..65f1f29 100644 Binary files a/12PD0.mat and b/12PD0.mat differ diff --git a/12QD0.mat b/12QD0.mat index fe326ed..371b4f2 100644 Binary files a/12QD0.mat and b/12QD0.mat differ diff --git a/16PD0.mat b/16PD0.mat index 37a7220..e4e2f65 100644 Binary files a/16PD0.mat and b/16PD0.mat differ diff --git a/16QD0.mat b/16QD0.mat index d03a88e..fe41c6b 100644 Binary files a/16QD0.mat and b/16QD0.mat differ diff --git a/4PD0.mat b/4PD0.mat index 7181fd5..3c6017a 100644 Binary files a/4PD0.mat and b/4PD0.mat differ diff --git a/4QD0.mat b/4QD0.mat index 9edccdc..5d5ef3a 100644 Binary files a/4QD0.mat and b/4QD0.mat differ diff --git a/8PD0.mat b/8PD0.mat index 486594f..5d83ebe 100644 Binary files a/8PD0.mat and b/8PD0.mat differ diff --git a/8QD0.mat b/8QD0.mat index f8fc076..c73bbab 100644 Binary files a/8QD0.mat and b/8QD0.mat differ diff --git a/@ForThesis/MaxBranchDeviation.asv b/@ForThesis/MaxBranchDeviation.asv index aeaa522..ac15e4c 100644 --- a/@ForThesis/MaxBranchDeviation.asv +++ b/@ForThesis/MaxBranchDeviation.asv @@ -1,10 +1,41 @@ -function [ output_args ] = MaxBranchDeviation( this, Linei,Linej,Liner,Linex,Lineb,Transfori,Transforj,Transforr,Transforx,Branchg,Branchb,Transfork0,Volt0,UAngel0,Volt,UAngel) +function [ output_args ] = MaxBranchDeviation( ~, Linei,Linej,Liner,Linex,Lineb,Transfori,Transforj,Transforr,Transforx,Branchi,Branchg,Branchb,Transfork0,Volt0,UAngel0,Volt,UAngel,FileName,PD0,QD0) %% 最大支路功率偏差 % 支路功率包括线路和变压器 -%% -[dispLineloss0 dispTransloss0]=Lineloss(Linei,Linej,Liner,Linex,Lineb2,Transi,Transj,Transr,Transx,Branchg,Branchb,k0,Volt0,Angle0); -[dispLineloss dispTransloss]=Lineloss(Linei,Linej,Liner,Linex,Lineb2,Transi,Transj,Transr,Transx,Branchg,Branchb,k0,Volt,Angle); -real(dispLineloss0 - dispLineloss)./real(dispLineloss0) - +%% 先用加了误差的负荷功率计算潮流值 +[Busnum,Balance,PQstandard,Precision,~,~,~,~,~,kmax,~ ,... + ~,~,~,~,~,~,~,Pointpoweri,PG,QG,PD,QD,PVi,PVu,~,~,~,~,~,~,~]= openfile2(FileName); +PD=PD0; +QD=QD0; +%% 形成节点导纳矩阵 +[~,Y,r,c,Angle] = admmatrix(Busnum,Linei,Linej,Liner,Linex,Lineb,Transfori,Transforj,Transforr,... + Transforx,Transfork0,Branchi,Branchg,Branchb); +[P0,Q0,U,Uangle] = Initial(PG,PD,PQstandard,Pointpoweri,QG,QD,Busnum); %求功率不平衡量 +%disp('迭代次数i 最大不平衡量'); +%% 循环体计算 +for i = 0:kmax + [Jacob,PQ,U,Uangle] = jacobian(Busnum,Balance,PVi,PVu,U,Uangle,Y,Angle,P0,Q0,r,c); %形成雅克比矩阵 + % disp('第一次雅克比'); + m = max(abs(PQ)); + m=full(m); + %fprintf(' %u %.8f \n',i,m); + if m > Precision %判断不平衡量是否满足精度要求 + [Uangle,U] = solvefun(Busnum,Jacob,PQ,Uangle,U); %求解修正方程,更新电压变量 + else + disp(['收敛,迭代次数为',num2str(i),'次']); + break %若满足精度要求,则计算收敛 + end +end + +Volt0=U; +UAngel0=Uangle; + +[dispLineloss0 dispTransloss0]=Lineloss(Linei,Linej,Liner,Linex,Lineb,Transfori,Transforj,Transforr,Transforx,Branchi,Branchg,Branchb,Transfork0,Volt0,UAngel0); +[dispLineloss dispTransloss]=Lineloss(Linei,Linej,Liner,Linex,Lineb,Transfori,Transforj,Transforr,Transforx,Branchi,Branchg,Branchb,Transfork0,Volt,UAngel); +t1=(dispLineloss0(:,3) - dispLineloss(:,3))./dispLineloss0(:,3); +t2=(dispTransloss0(:,3) - dispTransloss(:,3))./dispTransloss0(:,3); +t11=dispLineloss0(:,3)>1e-5;% 太小的值不计算 +t22=dispTransloss0(:,3)>1e-5;% 太小的值不计算 +t3=abs([t1(t11);t2(t22)]); +output_args=max(t3(t3~=Inf)); end diff --git a/@ForThesis/MaxBranchDeviation.m b/@ForThesis/MaxBranchDeviation.m index fadccac..ac15e4c 100644 --- a/@ForThesis/MaxBranchDeviation.m +++ b/@ForThesis/MaxBranchDeviation.m @@ -3,7 +3,7 @@ function [ output_args ] = MaxBranchDeviation( ~, Linei,Linej,Liner,Linex,Lineb, % 支路功率包括线路和变压器 %% 先用加了误差的负荷功率计算潮流值 [Busnum,Balance,PQstandard,Precision,~,~,~,~,~,kmax,~ ,... - ~,~,~,~,~,~,~,Pointpoweri,PG,QG,~,~,PVi,PVu,~,~,~,~,~,~,~]= openfile2(FileName); + ~,~,~,~,~,~,~,Pointpoweri,PG,QG,PD,QD,PVi,PVu,~,~,~,~,~,~,~]= openfile2(FileName); PD=PD0; QD=QD0; %% 形成节点导纳矩阵 diff --git a/OPF.m b/OPF.m index b59f5ce..df3f0d6 100644 --- a/OPF.m +++ b/OPF.m @@ -7,7 +7,7 @@ clear thesis=ForThesis(1,45); for II=1:1 [kmax,Precision,UAngel,Volt,Busnum,PVi,PVu,Balance,Y,Angle,P0,Q0,r,c,GB,Linei,Linej,Transfori,Transforj,GenU,GenL,GenC,PG,QG,PD,QD,CenterA,PGi,PVQU,PVQL,Liner,Linex,Lineb,Transforr,Transforx,Branchi,Branchg,Branchb,Transfork0]= ... - pf('E:\算例\柳金Ⅰ926_21671693_2012-09-06\newFIle20.txt'); + pf('E:\算例\柳金Ⅰ926_21671693_2012-09-06\newFIle4 - 计算用.txt'); %pf('D:\Project\青秀降损项目\最小化潮流\最小潮流算例\原始\津头站津视922(3-1)_0.5_120%.txt'); %pf('D:\Project\最小化潮流\最小潮流算例\仙海919.txt'); %pf('c:/file31.txt'); @@ -55,8 +55,8 @@ for II=1:1 %% 加误差 PD0(Loadi)=PD0(Loadi).*(1+normrnd(0,0.05,length(Loadi),1)); QD0(Loadi)=QD0(Loadi).*(1+normrnd(0,0.05,length(Loadi),1)); - load('200PD0.mat'); - load('200QD0.mat'); + load('20PD0.mat'); + load('20QD0.mat'); % PG0(PGi)=PG0(PGi).*(1+normrnd(0,0.01,length(PGi),1)); % QG0(PVi)=QG0(PVi).*(1+normrnd(0,0.01,length(PVi),1)); %% 读变压器容量