0


Matlab|含风电-光伏-光热电站电力系统N-k安全优化调度模型

**1 **主要内容

该程序参考《光热电站促进风电消纳的电力系统优化调度》光热电站模型,主要做的是考虑N-k安全约束的含义风电-光伏-光热电站的电力系统优化调度模型,从而体现光热电站在调度灵活性以及经济性方面的优势。同时代码还考虑了光热电站对风光消纳的作用,对比了含义光热电站和不含光热电站下的弃风弃光问题,同时还对比了考虑N-k约束下的调度策略区别。以14节点和118节点算例为例,对模型进行了系统性的测试,复现效果良好,是学习N-k约束以及光热电站调度的必备程序!程序采用matlab+cplex(mosek/gurobi)进行求解,可以选择已经安装的求解器进行求解。

  • 程序算例

程序对于118节点系统采用了四个算例进行对比,14节点系统有3种算例对比,并增加了弃风量的对比程序。

  • 程序模型

  • 程序亮点

  1. 采用光热电站模型,也是最近研究比较热的一个方向。
  2. 采用转移分布因子矩阵处理潮流问题,这也是很多文献中都采用的方法。​

**2 **部分程序

  1. clc; clear; close all; % 关闭所有已打开的绘图窗口
  2. %% 参数设定
  3. NT = 24; % 时间范围
  4. CoeffReseve_load = 0.03;
  5. CoeffReserve_VRE = 0.05;
  6. yita_TES = 0.98;
  7. yita_PB = 0.415;
  8. % 文章里Table 2的数据
  9. Capacity_TES_CSP = 0;
  10. initial_TES_t0 = 0.5;
  11. initial_TES_t1 = 0.78;
  12. TES_initial = 0.5;
  13. beta_Load = 3*10e3;
  14. mpc = case14_1; % 载入数据 matpower 数据格式
  15. %% 有功负荷 24h所有节点总的
  16. % mpc.load = [
  17. % 2842.42 3020.2 3296.96 3444.44 3607.07 3891.91 4070.7 4295.95 4476.76 4661.61 4859.59 5077.77 ...
  18. % 4717.17 4519.19 4301.01 3995.95 3703.03 3806.06 4037.37 4063.63 3721.21 3245.45 3097.97 2827.27
  19. % ]/6.3;
  20. mpc.load = [
  21. 683.42 792.2 896.96 1044.44 1087.07 1121.91 1200.7 1235.95 1326.76 1461.61 1489.59 1577.77 ...
  22. 1417.17 1219.19 1101.01 1075.95 903.03 1186.06 1237.37 1463.63 1221.21 1005.45 827.97 807.27
  23. ]/2;
  24. mpc.P_RE = [0.00 0.00 0.00 0.00 0.00 0.00 15.76 43.17 82.35 109.44 122.55 146.10 ...% PV
  25. 126.66 86.05 60.05 52.82 25.78 4.28 0.00 0.00 0.00 0.00 0.00 0.00
  26. 100.26 133.95 147.28 134.11 170.52 159.44 138.55 72.83 58.83 73.37 79.90 80.54 ... % Wind
  27. 91.96 101.68 121.49 122.93 133.11 162.44 130.95 133.25 151.26 139.33 120.60 90.33
  28. ]*1; % 可再生能源 24小时数据(实际发电量)
  29. %% 电网相关名称
  30. baseMVA = mpc.baseMVA;
  31. bus = mpc.bus;
  32. gen = mpc.gen;
  33. branch = mpc.branch;
  34. gencost = mpc.gencost;
  35. RE = mpc.RE;
  36. CSP = mpc.CSP;
  37. P_RE = mpc.P_RE;
  38. N = length(bus(:,1)); % 网络中所有节点数
  39. N_Br = length(branch(:,1));% 线路数
  40. N_Gen = length(gen(:,1)); % 火电发电机组数
  41. N_RE = length(RE(:,1)); % 可再生能源节点机组数
  42. N_CSP = length(CSP(:,1)); % CSP发电站数
  43. % 常规机组相关数据提取, 取数据矩阵中的列向量 和功率有功的项,均需标幺值化,以便运算和求解
  44. P_Gen_max = gen(:,9)/baseMVA;
  45. P_Gen_min = gen(:,10)/baseMVA;
  46. type_Gen = gen(:,22);
  47. P_Gen_up = gen(:,23) /baseMVA;
  48. P_Gen_down = gen(:,24) /baseMVA;
  49. T_Gen_min_on = gen(:,25);
  50. T_Gen_min_off = gen(:,26);
  51. c_ST_g = gen(:,28);
  52. c_G_g = gen(:,30);
  53. % CSP机组相关数据提取
  54. P_CSP_max = CSP(:,9)/baseMVA;
  55. P_CSP_min = CSP(:,10)/baseMVA;
  56. P_CSP_up = CSP(:,23)/baseMVA;
  57. P_CSP_down = CSP(:,24)/baseMVA;
  58. T_CSP_min_on = CSP(:,25);
  59. T_CSP_min_off = CSP(:,26);
  60. c_CSP_g = CSP(:,30);
  61. PtCSP_fore = [ % 可用的太阳能热功率向量
  62. 0.00 0.00 0.00 0.00 0.00 0.00 190.57 390.57 790.57 990.57 1390.57 1891.03 ...
  63. 2111.64 2200.92 2202.36 2118.26 1895.37 1408.35 0.00 0.00 0.00 0.00 0.00 0.00 ]/20;
  64. PtCSP_fore = PtCSP_fore/baseMVA;
  65. P_RE = P_RE/baseMVA; % 可再生能源PV WT机组出力
  66. beta_Load = beta_Load*baseMVA^2; % $/MWh -> $/p.u.
  67. M_bus_G = zeros(N,N_Gen); % 发电机机组-索引矩阵
  68. for row = 1:N
  69. if abs(find(mpc.gen(:,1) == row)) > 0 % 发电机节点号 行号对应
  70. M_bus_G(row,find(mpc.gen(:,1) == row)) = 1; % M_bus_G相应处置1
  71. end
  72. end
  73. M_bus_RE = zeros(N,N_RE); % 可再生能源机组-索引矩阵
  74. for row = 1:N
  75. if abs(find(mpc.RE(:,1) == row))>0
  76. M_bus_RE(row,find(mpc.RE(:,1) == row)) = 1;
  77. end
  78. end
  79. M_bus_CSP = zeros(N,N_CSP); % CSP机组-索引矩阵
  80. for row = 1:N
  81. if abs(find(mpc.CSP(:,1) == row))>0
  82. M_bus_CSP(row,find(mpc.CSP(:,1) == row)) = 1;
  83. end
  84. end
  85. GSDF = makePTDF(mpc); % 发电转移分布因子矩阵,表征节点注入功率在全网络的分布
  86. %% 负荷矩阵数据,按照 算例数据mpc.bus(:,3) 中各节点负荷的比例分配
  87. PD = bus(:,3)/baseMVA;
  88. P_factor = PD/sum(PD);
  89. P_sum = mpc.load/baseMVA;
  90. PD = P_factor*P_sum;
  91. %% 决策变量命名
  92. PG_G = sdpvar(N_Gen,NT,'full');
  93. PG_RE = sdpvar(N_RE,NT,'full'); % (风光并网量)
  94. PG_CSP = sdpvar(N_CSP,NT,'full');
  95. PC_Load = sdpvar(N,NT,'full');
  96. onoff_gen = binvar(N_Gen,NT,'full');
  97. onoff_CSP = binvar(N_CSP,NT,'full');
  98. Branch = sdpvar(N_Br,NT,'full');
  99. Cost_StartUp = sdpvar(N_Gen,NT-1,'full');
  100. Pt_TES_charge = sdpvar(N_CSP,NT,'full');
  101. Pt_TES_discharge= sdpvar(N_CSP,NT,'full');
  102. Et_TES = sdpvar(N_CSP,NT,'full');
  103. %% 约束条件列写
  104. Cons = [];
  105. for t = 1:NT
  106. if t >= 2 % type(1-水电, 2-火电机组)
  107. for i = 1:N_Gen % 火电机组-最小启/停时间约束 式(8-9)
  108. if (type_Gen(i,1)==2) || (type_Gen(i,1)==5)
  109. for tao = t + 1:min(t+T_Gen_min_on(i,1)-1,NT)
  110. Cons = [Cons, onoff_gen(i,t)-onoff_gen(i,t-1) <= onoff_gen(i,tao)];
  111. end
  112. for tao = t + 1:min(t+T_Gen_min_off(i,1)-1,NT)
  113. Cons = [Cons, onoff_gen(i,t-1)-onoff_gen(i,t) <= 1-onoff_gen(i,tao)];
  114. end
  115. end
  116. end
  117. for i = 1:N_CSP
  118. for tao = t+1:min(t+T_CSP_min_on(i,1)-1,NT)
  119. Cons = [Cons, onoff_CSP(i,t)-onoff_CSP(i,t-1) <= onoff_CSP(i,tao)]; % CSP机组最小启/停时间约束
  120. end
  121. for tao = t+1:min(t+T_CSP_min_off(i,1)-1,NT)
  122. Cons = [Cons, onoff_CSP(i,t-1)-onoff_CSP(i,t) <= 1-onoff_CSP(i,tao)];
  123. end
  124. end
  125. end
  126. if t >= 2 % 火电机组 爬坡约束 式(6-7)
  127. Cons = [Cons, PG_G(:,t) - PG_G(:,t-1) <= ...
  128. onoff_gen(:,t-1).* P_Gen_up*60 + ...
  129. (onoff_gen(:,t)-onoff_gen(:,t-1)) .* P_Gen_min + ...
  130. (1-onoff_gen(:,t)) .* P_Gen_max];
  131. Cons = [Cons, -PG_G(:,t) + PG_G(:,t-1) <= ...
  132. onoff_gen(:,t) .* P_Gen_down*60 + ...
  133. (onoff_gen(:,t-1)-onoff_gen(:,t)) .* P_Gen_min + ...
  134. (1-onoff_gen(:,t-1)) .* P_Gen_max];
  135. % CSP 机组 爬坡约束 式(6-7)
  136. Cons = [Cons, PG_CSP(:,t) - PG_CSP(:,t-1) <= ...
  137. onoff_CSP(:,t-1).* P_CSP_up*60 + ... %
  138. (onoff_CSP(:,t)-onoff_CSP(:,t-1)) .* P_CSP_min + ...
  139. (1-onoff_CSP(:,t)) .* P_CSP_max];
  140. Cons = [Cons, -PG_CSP(:,t) + PG_CSP(:,t-1) <= onoff_CSP(:,t) .* P_CSP_down*60 + ...
  141. (onoff_CSP(:,t-1)-onoff_CSP(:,t)) .* P_CSP_min + ...
  142. (1-onoff_CSP(:,t-1)) .* P_CSP_max];
  143. end
  144. end
  145. % 机组出力的上下边界约束-式(3) % t(1-水电,2-火电, 5-燃气发电机组 6-CSP)
  146. Ind_2_5 = union(find(type_Gen(:,1) == 2),find(type_Gen(:,1) == 5));
  147. Cons = [Cons, onoff_gen(Ind_2_5,:) .* (P_Gen_min(Ind_2_5,1) * ones(1,NT)) ...
  148. <= PG_G(Ind_2_5,:) <= ...
  149. onoff_gen(Ind_2_5,:) .* (P_Gen_max(Ind_2_5,1) * ones(1,NT))];
  150. Cons = [Cons, onoff_CSP.*(P_CSP_min*ones(1,NT)) <= PG_CSP <= onoff_CSP.*(P_CSP_max*ones(1,NT))]; % CSP机组出力-边界约束
  151. % Cons = [Cons, onoff_CSP == ones(1,24)]; % CSP机组
  152. Cons = [Cons, sum(PG_G,1) + sum(PG_RE,1) + sum(PG_CSP,1) == sum(PD - PC_Load,1)]; % 式(2)
  153. Cons = [Cons, Branch == GSDF*(M_bus_G*PG_G + M_bus_RE*PG_RE + M_bus_CSP*PG_CSP - (PD-PC_Load))]; %
  154. % Cons = [Cons, -branch(:,6)*ones(1,NT) <= GSDF*(M_bus_G*PG_G+M_bus_RE*PG_RE+M_bus_CSP*PG_CSP-(PD- PC_Load)) <= branch(:,6)*ones(1,NT)]; %
  155. Cons = [Cons, -999*ones(N_Br,NT) <= GSDF*(M_bus_G*PG_G+M_bus_RE*PG_RE+M_bus_CSP*PG_CSP-(PD-PC_Load)) <= 999*ones(N_Br,NT)]; % 118系统有186条线路
  156. Cons = [Cons, 0 <= PG_RE <= P_RE]; % 可再生出力
  157. Cons = [Cons, [60;50;100;80;40]/baseMVA * ones(1,24) <= PG_G ];
  158. Cons = [Cons, 0 <= PC_Load <= PD]; % 式(22)
  159. Cons = [Cons, sum(onoff_gen .* (P_Gen_max*ones(1,NT)) - PG_G,1) + ...
  160. sum(onoff_CSP .* (P_CSP_max*ones(1,NT)) - PG_CSP,1) >= ...
  161. sum(CoeffReseve_load*PD,1) + sum(CoeffReserve_VRE*PG_RE,1) ];
  162. Cons = [Cons, Cost_StartUp >= (onoff_gen(:,2:NT) - onoff_gen(:,1:NT-1)) .* (c_ST_g*ones(1,NT-1))]; % 传统机组启动成本
  163. Cons = [Cons, Cost_StartUp >= 0];
  164. %%%%%% CSP电站运转内部约束 %%%%%%
  165. E_TES_max = Capacity_TES_CSP * P_CSP_max;
  166. Cons = [Cons, PG_CSP/yita_PB + Pt_TES_charge - Pt_TES_discharge <= PtCSP_fore]; % CSP输出电功率与TES充/放热功率,预测光热功率关系
  167. Cons = [Cons, Et_TES(:,2:NT) == Et_TES(:,1:NT-1) + Pt_TES_charge(:,1:NT-1)*yita_TES - Pt_TES_discharge(:,1:NT-1)/yita_TES];
  168. Cons = [Cons, Et_TES(:,1) == TES_initial * E_TES_max];
  169. Cons = [Cons, Et_TES(:,1) == Et_TES(:,NT)];
  170. Cons = [Cons, 0 <= Pt_TES_charge <= Capacity_TES_CSP*ones(N_CSP,NT)];
  171. Cons = [Cons, 0 <= Pt_TES_discharge <= Capacity_TES_CSP*ones(N_CSP,NT)];
  172. Cons = [Cons, 0 <= Et_TES <= E_TES_max * ones(1,NT)];
  173. %% 目标函数
  174. obj = sum(c_G_g'*PG_G) + sum(c_CSP_g'*PG_CSP) + sum(sum(Cost_StartUp) + beta_Load*sum(sum(PC_Load)) );
  175. % 机组的边际发电成本 + 启动成本 + 负荷削减成本
  176. % 运行调度
  177. ops = sdpsettings('solver','cplex'); % gurobi
  178. ans = optimize(Cons,obj,ops)
  179. %% 求解成功后取值
  180. PG_G = value(PG_G) ;
  181. PG_RE = value(PG_RE) ;
  182. PG_CSP = value(PG_CSP) ;
  183. PC_Load = value(PC_Load) ;
  184. onoff_gen = value(onoff_gen) ;
  185. onoff_CSP = value(onoff_CSP) ;
  186. Branch = value(Branch) ;
  187. Cost_StartUp = value(Cost_StartUp);
  188. obj = value(obj); % 总成本
  189. Pt_TES_charge = value(Pt_TES_charge);
  190. Pt_TES_discharge = value(Pt_TES_discharge);
  191. Et_TES = value(Et_TES);
  192. disp(['IEEE14 不考虑N-k的和无CSP的经济调度情况,运行成本为 ', num2str(obj)])
  193. %% 绘图
  194. % 已知的相关输入数据
  195. figure
  196. subplot(3,1,1)
  197. plot(PtCSP_fore * baseMVA,'m-o');
  198. title('CSP预测功率值')
  199. xlabel('时间(h)');
  200. ylabel('功率(MW)');
  201. subplot(3,1,2)
  202. plot(P_RE(1,:) * baseMVA,'m-o'); hold on
  203. plot(P_RE(2,:) * baseMVA,'b-s');
  204. title('可再生能源预测出力值')
  205. xlabel('时间(h)');
  206. ylabel('功率(MW)');
  207. legend('光伏','风电')
  208. subplot(3,1,3)
  209. plot(sum(PD) * baseMVA,'r-v');
  210. title('24h负荷值')
  211. xlabel('时间(h)');
  212. ylabel('功率(MW)');
  213. % subplot(2,1,2)
  214. % bar(baseMVA*PG_RE',0.75,'stack'); hold on; % 各PV、Wind机组出力
  215. % legend('PV','Wind')
  216. % title('电网中可再生能源机组出力')
  217. % xlabel('时间(h)');
  218. % ylabel('功率(MW)');
  219. % figure
  220. % surf(baseMVA*PC_Load);
  221. % title('负荷削减量')
  222. % xlabel('时间(h)');
  223. % ylabel('功率(MW)');

**3 **部分结果

4 下载链接


本文转载自: https://blog.csdn.net/superone89/article/details/135855432
版权归原作者 科研工作站 所有, 如有侵权,请联系我们删除。

“Matlab|含风电-光伏-光热电站电力系统N-k安全优化调度模型”的评论:

还没有评论