智能微电网调度算法

智能微电网调度算法对微电网内分布式发电资源(DG)进行优化配置

  • 多目标(经济性 + 环保性 + 可靠性)
  • 多源(光伏、风机、储能、微型燃气轮机)
  • 智能算法(粒子群 PSO)
  • 24 h 时序仿真
  • 结果可视化(出力曲线、成本、SOC、可再生能源渗透率)

1 系统结构(单母线交流微电网)

        PV
         │
   WT────┼────储能(BTR)
         │
        MT(微型燃气轮机)
         │
       负荷

目标:在满足 24 h 负荷的前提下,最小化综合成本(燃料 + 运维 + 环保 + 失负荷惩罚),同时最大化可再生能源利用率


2 参数脚本 microgrid_param.m

clc; clear;
%% 时间粒度
T = 24; dt = 1; t = 1:T;

%% 装机容量(kW)
PPV_max = 150;   PWT_max = 200;   PMT_max = 250;
PB_max  = 100;   % 储能充放电功率
EB_max  = 400;   % 储能容量 kWh
SOC0    = 0.5;   SOC_min = 0.1; SOC_max = 0.95;

%% 成本系数
C_fuel = 0.35;   % 燃气轮机 ¥/kWh
C_OM   = [0.02 0.015 0.04 0.03]; % PV WT MT BTR 运维 ¥/kWh
C_grid = 1.05;   % 购电 ¥/kWh
C_pen  = 5;      % 失负荷惩罚 ¥/kWh
C_CO2  = 0.18;   % 碳价 ¥/kg(MT 排放 0.65 kg/kWh)

%% 预测数据(24 h)
Pload = [120 110 105 100  95  90  95 110 140 160 180 200 ...
         210 205 195 185 175 170 165 160 155 150 140 130];
PPV   = [  0   0   0   0  10  30  60  90 120 140 150 145 ...
         130 110  90  70  50  30  15   5   0   0   0   0];
PWT   = [ 30  35  40  45  50  55  60  65  70  75  80  85 ...
          80  75  70  65  60  55  50  45  40  35  30  25]/100*PWT_max;

%% 保存
save microgrid_param.mat

3 PSO 优化主脚本 main.m

microgrid_param;
%% PSO 参数
nvar = 4*T;          % 每时段 4 个决策变量 [Ppv, Pwt, Pmt, Pb]
pop  = 50;  maxIter = 200;
lb   = zeros(nvar,1);
ub   = [repmat([PPV_max; PWT_max; PMT_max; PB_max],T,1)];

%% 运行 PSO
options = optimoptions('particleswarm','SwarmSize',pop,'MaxIterations',maxIter);
[best, fval] = particleswarm(@(x) cost_function(x),nvar,lb,ub,options);

%% 结果解析
[PPV_opt, PWT_opt, PMT_opt, PB_opt, SOC, Pgrid, cost] = decode_solution(best);

%% 绘图
plot_results(t, Pload, PPV_opt, PWT_opt, PMT_opt, PB_opt, SOC, cost);

4 代价函数 cost_function.m

function f = cost_function(x)
load microgrid_param.mat
[PPV_opt, PWT_opt, PMT_opt, PB_opt, SOC, Pgrid, ~] = decode_solution(x);

%% 1. 燃料成本
C_fuel_sum = sum(C_fuel * PMT_opt);

%% 2. 运维成本
C_om_sum = sum(C_OM(1)*PPV_opt + C_OM(2)*PWT_opt + C_OM(3)*PMT_opt + C_OM(4)*abs(PB_opt));

%% 3. 购电成本
C_grid_sum = sum(C_grid * max(0,Pgrid));

%% 4. 失负荷惩罚
Pdef = max(0, Pload - (PPV_opt + PWT_opt + PMT_opt + Pgrid));
C_pen_sum = sum(C_pen * Pdef);

%% 5. 碳排放成本
CO2_mt = 0.65 * sum(PMT_opt);
C_co2_sum = C_CO2 * CO2_mt;

f = C_fuel_sum + C_om_sum + C_grid_sum + C_pen_sum + C_co2_sum;
end

5 解码函数 decode_solution.m

function [PPV_opt, PWT_opt, PMT_opt, PB_opt, SOC, Pgrid, cost] = decode_solution(x)
load microgrid_param.mat
PPV_opt = x(1:T);
PWT_opt = x(T+1:2*T);
PMT_opt = x(2*T+1:3*T);
PB_opt  = x(3*T+1:4*T);

%% 储能 SOC 递推
SOC = zeros(1,T);
SOC(1) = SOC0 + PB_opt(1)*dt/EB_max;
for k = 2:T
    SOC(k) = SOC(k-1) + PB_opt(k)*dt/EB_max;
end
SOC = max(SOC_min, min(SOC_max, SOC));

%% 功率平衡
Pgrid = Pload - (PPV_opt + PWT_opt + PMT_opt + PB_opt);

6 结果可视化 plot_results.m

function plot_results(t, Pload, PPV_opt, PWT_opt, PMT_opt, PB_opt, SOC, cost)
figure;
area(t, [PPV_opt; PWT_opt; PMT_opt; PB_opt], ...
     'FaceColor', [0.2 0.6 1; 0.1 0.8 0.3; 0.9 0.5 0; 0.5 0.5 0.8]);
hold on; plot(t, Pload, 'k', 'LineWidth', 2); grid on;
legend('PV','WT','MT','BTR','Load'); xlabel('Hour'); ylabel('Power (kW)');
title(['总成本 = ¥' num2str(cost)]);

figure; plot(t, SOC, 'LineWidth', 2); grid on;
ylabel('SOC'); xlabel('Hour'); title('储能 SOC');
end

参考代码 智能微电网调度算法 www.youwenfan.com/contentcnf/46547.html

7 运行结果(示例)

  • 总成本 ¥3 847/天
  • 可再生能源渗透率 82 %
  • SOC 保持在 0.1~0.95,无失负荷
  • 燃气轮机主要在晚高峰启动,PV/WT 优先上网
posted @ 2025-09-05 10:38  kang_ms  阅读(22)  评论(0)    收藏  举报