文档介绍://PQ分解法解潮流程序
#include<>
#include<>
#define N 5 //节点数
#define n_PQ 3 //PQ节点数
#define n_PV 1 //PV节点数
#define PI
float G[N][N] ={{,-,-,0,0},{-,,-,0,0},{-,-,,0,0},{0,0,0,0,0},{0,0,0,0,0}};//导纳矩阵的实部
float B[N,N] ={{-,1,,0,0},{1,-,,,0},{,,-,0,},{0,-,0,,0},{0,0,,0,-}};//导纳矩阵的虚部
float U_amp[N]={,,,, ,}; //电压初值
float U_ang[N]=[0,0,0,0,0] //电压相角初值
float Ps[N-1]={,2,,5}; //有功初值
float Qs[N-2]={,1,}; //无功初值
float dU_amp[n_PQ],dU_ang[N-1]; //电压幅值和相角修正值
float P1[N],Q1[N],dP[N],dQ[n_PQ],H[N-1, N-1],L[n_PQ-1, n_PQ-1];
float J[N+ n_PQ-1, N+ n_PQ-1],M[N+ n_PQ -1,1],N[N+ n_PQ-1, N+ n_PQ-1];
// J[N+ n_PQ -1 -1, N+ n_PQ -1]雅可比矩阵, N[N+ n_PQ -1 -1, N+ n_PQ -1] 雅可比矩阵逆矩阵
float dS[N+ n_PQ -1,1],T,U[N],SS;
float precision =; // precision计算精度
int kk=0; //迭代次数
int i,j,k;
//主程序===================================================================
while(precision>)
{ for(i=1;i<N;i++)
{U[i]= U_amp[i]*cos(U_ang[i])+ U_amp[i]*sin(U_amp[i]*);}
for(i=0;i<N;i++)
{P1[i]=0;
Q1[i]=0;
for(j=0;j<N;j++)
{
P1[i]=P1[i]+ U_amp[i]*(G[i][j]*U_amp[j]*cos(U_ang[j])+B[i][j]*U_amp[j]*sin(U_ang[j]));
Q1[i]=Q1[i]+ U_amp[i]*(G[i][j]*U_amp[j]*sin(U_ang[j])-B[i][j]*U_amp[j]*cos(U_ang[j]));
}
dP[i]=Ps[i]- P1[i];
if