直流微电网潮流计算matlab程序
时间: 2023-07-28 10:10:15 浏览: 144
微电网基于Matlab实现微电网直流和交流系统潮流计算
5星 · 资源好评率100%
以下是一个简单的直流微电网潮流计算的MATLAB程序:
```
% 定义微电网拓扑
branches = [1 2; 1 3; 2 4; 2 5; 3 6; 3 7; 4 8; 5 8; 6 8; 7 8];
% 定义节点功率注入和负载
P_inj = [-1.8; -1.6; -1.2; -2.5; 1.2; 1.6; 0.9; 0.7];
P_load = [1.8; 1.6; 1.2; 2.5; -1.2; -1.6; -0.9; -0.7];
% 定义节点电压
V = [1.05; 1.05; 1.05; 1.05; 1.05; 1.05; 1.05; 1.05];
% 定义节点电阻和导纳
R = [0.1; 0.1; 0.2; 0.2; 0.15; 0.15; 0.1; 0.1];
Y = 1./R;
% 构造导纳矩阵
G = zeros(length(V), length(V));
B = zeros(length(V), length(V));
for i = 1:length(branches)
G(branches(i, 1), branches(i, 2)) = -Y(i);
G(branches(i, 2), branches(i, 1)) = -Y(i);
G(branches(i, 1), branches(i, 1)) = G(branches(i, 1), branches(i, 1)) + Y(i);
G(branches(i, 2), branches(i, 2)) = G(branches(i, 2), branches(i, 2)) + Y(i);
B(branches(i, 1), branches(i, 2)) = -imag(Y(i));
B(branches(i, 2), branches(i, 1)) = -imag(Y(i));
B(branches(i, 1), branches(i, 1)) = B(branches(i, 1), branches(i, 1)) + imag(Y(i));
B(branches(i, 2), branches(i, 2)) = B(branches(i, 2), branches(i, 2)) + imag(Y(i));
end
% 定义节点注入功率和负载功率矩阵
P = P_inj - P_load;
% 定义节点电流矩阵
I = (G + 1j*B)*V;
% 定义节点电压矩阵
V_new = zeros(length(V), 1);
% 迭代计算节点电压
while norm(V_new - V) > 1e-6
V = V_new;
P_net = P + I.*conj(V);
V_new = (G + 1j*B)\P_net;
end
% 输出结果
disp(V_new);
```
这个程序使用节点注入功率和负载功率计算潮流,并通过迭代计算节点电压。
阅读全文