for t=1:24%24小时潮流计算 mpc=case33bw; mpc.bus(13,3)=mpc.bus(13,3)-pv(1,t);%光伏 12 光伏在13节点(P-光伏) mpc.bus(18,3)=mpc.bus(18,3)-wt(1,t);%风 33 风电在18节点(P-风电) mpc.bus(33,4)=mpc.bus(33,4)-wt(1,t)*0.328;%风无功出力 33节点(Q-风Q) mpc.bus(33,3)=mpc.bus(33,3)-wt(1,t);%风有功出力 18 33节点(p-风P) mpc.bus(5,4)=mpc.bus(5,4)-Cb1(1,t); %c1在5节点 mpc.bus(24,4)=mpc.bus(24,4)-Cb2(1,t); %24节点 mpc.bus(25,4)=mpc.bus(25,4)-Cb3(1,t); %25节点 res=runopf(mpc,mpoption('out.all',0,'verbose',0));%(潮流计算) if res.success==1 disp('潮流计算成功!') ploss=ploss+res.branch(:,14);
时间: 2023-09-12 22:07:50 浏览: 218
这段代码是一个基于Matlab的配电网调度程序,它通过循环控制,实现了对24小时内电网的潮流计算和调度。具体来说,该程序包含以下几个步骤:
1. 在每个时刻t,根据光伏、风电和负荷的变化情况,更新电力系统的节点数据和支路数据,其中包括节点的有功出力、无功出力和电压等信息,以及支路的阻抗等参数。
2. 使用MATPOWER工具箱中的runopf函数对电力系统进行潮流计算,计算得到电力系统中各个节点和支路的电压、电流、功率等信息,保存在结构体变量res中。
3. 判断潮流计算是否成功,如果成功则在命令窗口中输出“潮流计算成功!”。
4. 从res结构体中提取出所有支路的有功损耗,保存在res.branch(:,14)中。
5. 将所有支路的有功损耗加入到变量ploss中,最终得到电力系统中所有支路的总损耗。
需要注意的是,该程序中的潮流计算是基于直流潮流计算模型,实际的电力系统中可能存在交流特性,因此在实际应用中需要考虑更为复杂的模型和算法。此外,该程序中的负荷和发电设备的变化情况是由外部数据源提供的,因此需要注意数据的准确性和可靠性。
相关问题
for t=1:24%24小时潮流计算 mpc=case33bw; mpc.bus(13,3)=mpc.bus(13,3)-pv(1,t);%光伏 12 光伏在13节点(P-光伏) mpc.bus(18,3)=mpc.bus(18,3)-wt(1,t);%风 33 风电在18节点(P-风电) mpc.bus(33,4)=mpc.bus(33,4)-wt(1,t)*0.328;%风无功出力 33节点(Q-风Q) mpc.bus(33,3)=mpc.bus(33,3)-wt(1,t);%风有功出力 18 33节点(p-风P) mpc.bus(5,4)=mpc.bus(5,4)-Cb1(1,t); %c1在5节点 mpc.bus(24,4)=mpc.bus(24,4)-Cb2(1,t); %24节点 mpc.bus(25,4)=mpc.bus(25,4)-Cb3(1,t); %25节点 res=runopf(mpc,mpoption('out.all',0,'verbose',0));%(潮流计算) if res.success==1 disp('潮流计算成功!') ploss=ploss+sum(res.branch(:,14));
这段代码是一个基于Matlab的24小时潮流计算程序。其中使用了Matpower工具箱中的runopf()函数进行潮流计算,通过对电网节点的有功功率和无功功率进行调整,计算电网的潮流状态,并计算电网中的损耗。具体来说,代码中的for循环遍历了24小时内的每个时间点,通过修改mpc.bus中各节点的有功功率和无功功率,来模拟风电和光伏等可再生能源的输出,并在每个时间点调用runopf()函数进行潮流计算。当计算成功时,将计算结果中的分支损耗累加到ploss变量中,最终得到整个24小时内的电网损耗。
[baseMVA,bus,gen,branch]=deal(mpc.baseMVA,mpc.bus,mpc.gen,mpc.branch);
This line of code extracts the variables 'baseMVA', 'bus', 'gen', and 'branch' from the input mpc struct and assigns them to separate variables.
- 'baseMVA' is the base MVA used for the power flow calculation.
- 'bus' contains information about the buses in the power system, such as their voltage magnitude and phase angle.
- 'gen' contains information about the generators in the power system, such as their maximum and minimum power output limits.
- 'branch' contains information about the branches connecting the buses, such as their resistance and reactance values.
By separating these variables, we can access and manipulate the power system data more easily.
相关推荐
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![pptx](https://img-home.csdnimg.cn/images/20210720083543.png)