使用WLS进行电力系统状态估计

使用WLS进行电力系统状态估计,加权最小二乘法的电力系统状态估计

应用介绍

使用WLS进行电力系统状态估计,加权最小二乘法的电力系统状态估计

% Power System State Estimation using Weighted Least Square Method..

num = 30; % IEEE - 14 or IEEE - 30 bus system..(for IEEE-14 bus system replace 30 by 14)...

ybus = ybusppg(num); % Get YBus..

zdata = zdatas(num); % Get Measurement data..

bpq = bbusppg(num); % Get B data..

nbus = max(max(zdata(:,4)),max(zdata(:,5))); % Get number of buses..

type = zdata(:,2); % Type of measurement, Vi - 1, Pi - 2, Qi - 3, Pij - 4, Qij - 5, Iij - 6..

z = zdata(:,3); % Measuement values..

fbus = zdata(:,4); % From bus..

tbus = zdata(:,5); % To bus..

Ri = diag(zdata(:,6)); % Measurement Error..

V = ones(nbus,1); % Initialize the bus voltages..

del = zeros(nbus,1); % Initialize the bus angles..

E = [del(2:end); V];   % State Vector..

G = real(ybus);

B = imag(ybus);

vi = find(type == 1); % Index of voltage magnitude measurements..

ppi = find(type == 2); % Index of real power injection measurements..

qi = find(type == 3); % Index of reactive power injection measurements..

pf = find(type == 4); % Index of real powerflow measurements..

qf = find(type == 5); % Index of reactive powerflow measurements..

nvi = length(vi); % Number of Voltage measurements..

npi = length(ppi); % Number of Real Power Injection measurements..

nqi = length(qi); % Number of Reactive Power Injection measurements..

npf = length(pf); % Number of Real Power Flow measurements..

nqf = length(qf); % Number of Reactive Power Flow measurements..

iter = 1;

tol = 5;

while(tol > 1e-4)

    

    %Measurement Function, h

    h1 = V(fbus(vi),1);

    h2 = zeros(npi,1);

    h3 = zeros(nqi,1);

    h4 = zeros(npf,1);

    h5 = zeros(nqf,1);

    

    for i = 1:npi

        m = fbus(ppi(i));

        for k = 1:nbus

            h2(i) = h2(i) + V(m)*V(k)*(G(m,k)*cos(del(m)-del(k)) + B(m,k)*sin(del(m)-del(k)));

        end

    end

    

    for i = 1:nqi

        m = fbus(qi(i));

        for k = 1:nbus

            h3(i) = h3(i) + V(m)*V(k)*(G(m,k)*sin(del(m)-del(k)) - B(m,k)*cos(del(m)-del(k)));

        end

    end

    

    for i = 1:npf

        m = fbus(pf(i));

        n = tbus(pf(i));

        h4(i) = -V(m)^2*G(m,n) - V(m)*V(n)*(-G(m,n)*cos(del(m)-del(n)) - B(m,n)*sin(del(m)-del(n)));

    end

    

    for i = 1:nqf

        m = fbus(qf(i));

        n = tbus(qf(i));

        h5(i) = -V(m)^2*(-B(m,n)+bpq(m,n)) - V(m)*V(n)*(-G(m,n)*sin(del(m)-del(n)) + B(m,n)*cos(del(m)-del(n)));

    end

    

    h = [h1; h2; h3; h4; h5];

    

    % Residue..

    r = z - h;

    

    % Jacobian..

    % H11 - Derivative of V with respect to angles.. All Zeros

    H11 = zeros(nvi,nbus-1);

    % H12 - Derivative of V with respect to V.. 

    H12 = zeros(nvi,nbus);

    for k = 1:nvi

        for n = 1:nbus

            if n == k

                H12(k,n) = 1;

            end

        end

    end

    % H21 - Derivative of Real Power Injections with Angles..

    H21 = zeros(npi,nbus-1);

    for i = 1:npi

        m = fbus(ppi(i));

        for k = 1:(nbus-1)

            if k+1 == m

                for n = 1:nbus

                    H21(i,k) = H21(i,k) + V(m)* V(n)*(-G(m,n)*sin(del(m)-del(n)) + B(m,n)*cos(del(m)-del(n)));

                end

                H21(i,k) = H21(i,k) - V(m)^2*B(m,m);

            else

                H21(i,k) = V(m)* V(k+1)*(G(m,k+1)*sin(del(m)-del(k+1)) - B(m,k+1)*cos(del(m)-del(k+1)));

            end

        end

    end

    

    % H22 - Derivative of Real Power Injections with V..

    H22 = zeros(npi,nbus);

    for i = 1:npi

        m = fbus(ppi(i));

        for k = 1:(nbus)

            if k == m

                for n = 1:nbus

                    H22(i,k) = H22(i,k) + V(n)*(G(m,n)*cos(del(m)-del(n)) + B(m,n)*sin(del(m)-del(n)));

                end

                H22(i,k) = H22(i,k) + V(m)*G(m,m);

            else

                H22(i,k) = V(m)*(G(m,k)*cos(del(m)-del(k)) + B(m,k)*sin(del(m)-del(k)));

            end

        end

    end

    

    % H31 - Derivative of Reactive Power Injections with Angles..

    H31 = zeros(nqi,nbus-1);

    for i = 1:nqi

        m = fbus(qi(i));

        for k = 1:(nbus-1)

            if k+1 == m

                for n = 1:nbus

                    H31(i,k) = H31(i,k) + V(m)* V(n)*(G(m,n)*cos(del(m)-del(n)) + B(m,n)*sin(del(m)-del(n)));

                end

                H31(i,k) = H31(i,k) - V(m)^2*G(m,m);

            else

                H31(i,k) = V(m)* V(k+1)*(-G(m,k+1)*cos(del(m)-del(k+1)) - B(m,k+1)*sin(del(m)-del(k+1)));

            end

        end

    end

    

    % H32 - Derivative of Reactive Power Injections with V..

    H32 = zeros(nqi,nbus);

    for i = 1:nqi

        m = fbus(qi(i));

        for k = 1:(nbus)

            if k == m

                for n = 1:nbus

                    H32(i,k) = H32(i,k) + V(n)*(G(m,n)*sin(del(m)-del(n)) - B(m,n)*cos(del(m)-del(n)));

                end

                H32(i,k) = H32(i,k) - V(m)*B(m,m);

            else

                H32(i,k) = V(m)*(G(m,k)*sin(del(m)-del(k)) - B(m,k)*cos(del(m)-del(k)));

            end

        end

    end

    

    % H41 - Derivative of Real Power Flows with Angles..

    H41 = zeros(npf,nbus-1);

    for i = 1:npf

        m = fbus(pf(i));

        n = tbus(pf(i));

        for k = 1:(nbus-1)

            if k+1 == m

                H41(i,k) = V(m)* V(n)*(-G(m,n)*sin(del(m)-del(n)) + B(m,n)*cos(del(m)-del(n)));

            else if k+1 == n

                H41(i,k) = -V(m)* V(n)*(-G(m,n)*sin(del(m)-del(n)) + B(m,n)*cos(del(m)-del(n)));

                else

                    H41(i,k) = 0;

                end

            end

        end

    end

    

    % H42 - Derivative of Real Power Flows with V..

    H42 = zeros(npf,nbus);

    for i = 1:npf

        m = fbus(pf(i));

        n = tbus(pf(i));

        for k = 1:nbus

            if k == m

                H42(i,k) = -V(n)*(-G(m,n)*cos(del(m)-del(n)) - B(m,n)*sin(del(m)-del(n))) - 2*G(m,n)*V(m);

            else if k == n

                H42(i,k) = -V(m)*(-G(m,n)*cos(del(m)-del(n)) - B(m,n)*sin(del(m)-del(n)));

                else

                    H42(i,k) = 0;

                end

            end

        end

    end

    

    % H51 - Derivative of Reactive Power Flows with Angles..

    H51 = zeros(nqf,nbus-1);

    for i = 1:nqf

        m = fbus(qf(i));

        n = tbus(qf(i));

        for k = 1:(nbus-1)

            if k+1 == m

                H51(i,k) = -V(m)* V(n)*(-G(m,n)*cos(del(m)-del(n)) - B(m,n)*sin(del(m)-del(n)));

            else if k+1 == n

                H51(i,k) = V(m)* V(n)*(-G(m,n)*cos(del(m)-del(n)) - B(m,n)*sin(del(m)-del(n)));

                else

                    H51(i,k) = 0;

                end

            end

        end

    end

    

    % H52 - Derivative of Reactive Power Flows with V..

    H52 = zeros(nqf,nbus);

    for i = 1:nqf

        m = fbus(qf(i));

        n = tbus(qf(i));

        for k = 1:nbus

            if k == m

                H52(i,k) = -V(n)*(-G(m,n)*sin(del(m)-del(n)) + B(m,n)*cos(del(m)-del(n))) - 2*V(m)*(-B(m,n)+ bpq(m,n));

            else if k == n

                H52(i,k) = -V(m)*(-G(m,n)*sin(del(m)-del(n)) + B(m,n)*cos(del(m)-del(n)));

                else

                    H52(i,k) = 0;

                end

            end

        end

    end

    

    % Measurement Jacobian, H..

    H = [H11 H12; H21 H22; H31 H32; H41 H42; H51 H52];

    

    % Gain Matrix, Gm..

    Gm = H'*inv(Ri)*H;

    

    %Objective Function..

    J = sum(inv(Ri)*r.^2);  

    

    % State Vector..

    dE = inv(Gm)*(H'*inv(Ri)*r);

    E = E + dE;

    del(2:end) = E(1:nbus-1);

    V = E(nbus:end);

    iter = iter + 1;

    tol = max(abs(dE));

end

CvE = diag(inv(H'*inv(Ri)*H)); % Covariance matrix..

Del = 180/pi*del;

E2 = [V Del]; % Bus Voltages and angles..

disp('-------- State Estimation ------------------');

disp('--------------------------');

disp('| Bus |    V   |  Angle  | ');

disp('| No  |   pu   |  Degree | ');

disp('--------------------------');

for m = 1:n

    fprintf('%4g', m); fprintf('  %8.4f', V(m)); fprintf('   %8.4f', Del(m)); fprintf('\n');

end

disp('---------------------------------------------');

文件列表(部分)

名称 大小 修改日期
bbusppg.m0.24 KB2008-11-25
busdatas.m0.56 KB2008-12-07
linedatas.m0.83 KB2008-11-25
pol2rect.m0.27 KB2008-10-16
rect2pol.m0.21 KB2017-10-29
wls.m1.67 KB2009-02-21
ybusppg.m0.58 KB2008-11-25
zdatas.m1.26 KB2008-12-03
estimation0.00 KB2013-11-11
Power System State Estimation using WLS_powermatlab0.00 KB2017-10-29

立即下载

相关下载

[基于逆变器的微电网在SIMULINK中] 此仿真模型表示 SIMULINK 环境中基于逆变器的微电网示例。
[opendss进行不平衡三相配电网的WLS状态估计] 在配备智能电表和相量测量单元的配电网络中进行WLS状态估计,opendss进行不平衡三相配电网的WLS状态估计,这是在matlab里调用opendss完成得,使用33节点算例进行计算得。
[电力系统稳定与控制-Kundur(中文版)] 电力系统稳定与控制-Kundur(中文版)
[使用WLS的电力系统状态估计程序] 这是使用加权最小二乘法的电力系统状态估计程序,使用加权最小二乘法的电力系统状态估计。 测量的是电压幅值,注入功率和功率潮流。 非常不错的代码,有参考意义。
[电力系统暂态稳定计算的例程] 此代码考虑了同步发电机的凸极模型来进行暂态稳定性分析。考虑到越来越多地使用仿真来评估电力系统性能,特别是由于微电网和智能电网技术的影响,希望这个代码对学生和专业人士有所帮助。
[暂态稳定代码] 这是使用电力系统暂态稳定的简单代码,使用的是二阶模型。 该方法基于Paul M. Anderson,A. A. Fouad所著的《电力系统控制与稳定性》第二版。 主文件:example_ANDERSON.m

评论列表 共有 0 条评论

暂无评论

微信捐赠

微信扫一扫体验

立即
上传
发表
评论
返回
顶部