欢迎来到天天文库
浏览记录
ID:50816522
大小:33.00 KB
页数:9页
时间:2020-03-14
《电力系统通用潮流计算C语言程序.doc》由会员上传分享,免费在线阅读,更多相关内容在行业资料-天天文库。
1、#include#include#include#includeusingnamespacestd;//节点号类型负荷有功负荷无功母线数据(类型1=PV节点,2=PQ节点,3=平衡节点)structBUS{intbusno;inttype;floatPd;floatQd;};//发电机数据节点号有功发电电压幅值structGenerator{intbusno;floatPg;floatVg;};//支路信息节点I节点JRXB/2kstructLine{in
2、tbusi;intbusj;floatR;floatX;floatB;floatk;};//deltaPdeltaQdeltaV^2//voidfun1(doubleYG[][50],doubleYB[][50],doublee[],doublef[],inttype[],intN,doubleW[],doubleP[],doubleQ[],doubleV[]){doubledP=0,dQ=0,dV=0;inti,j;for(i=0;i3、[i][j]*e[j]-YB[i][j]*f[j];B+=YG[i][j]*f[j]+YB[i][j]*e[j];}dV=V[i]*V[i]-e[i]*e[i]-f[i]*f[i];dP=P[i]-e[i]*A-f[i]*B;W[2*i]=dP;dQ=Q[i]-f[i]*A+e[i]*B;if(type[i]==1)W[2*i+1]=dQ;elseW[2*i+1]=dV;}}//Jacobi矩阵//voidJacobi(doubleYG[][50],doubleYB[][50],doublee[50],doublef[50],4、inttype[50],intN,doubleJa[100][101]){inti,j;for(i=0;i5、j]=-YG[i][j]*e[i]+YB[i][j]*f[i];Ja[2*i][2*j+1]=YB[i][j]*e[i]-YG[i][j]*f[i];Ja[2*i+1][2*j+1]=Ja[2*i+1][2*j]=0;}}else{doublea[50]={0},b[50]={0};for(intk=0;k6、-YB[i][i]*f[i];Ja[2*i][2*j+1]=-b[i]+YB[i][i]*e[i]-YG[i][i]*f[i];if(type[i]==1){Ja[2*i+1][2*j]=b[i]+YB[i][i]*e[i]-YG[i][i]*f[i];Ja[2*i+1][2*j+1]=-a[i]+YG[i][i]*e[i]+YB[i][i]*f[i];}else{Ja[2*i+1][2*j]=-2*e[i];Ja[2*i+1][2*j+1]=-2*f[i];}}}}}}//高斯消元法解方程组函数//voidgauss(dou7、blea[][101],intn){inti,j,k;doublec;for(k=0;k=0;k--)for(j=k+1;j8、n;intN=0,GS=0,LD=0,ZLs=0;//节点数发电机数负荷数支路数//BUS*B;Generator*G;Line*L;//从文本中读入原始数据到数组中//fin.open("C:\data.txt");if(!fin){cout<<"输入数据文件不存在!"<
3、[i][j]*e[j]-YB[i][j]*f[j];B+=YG[i][j]*f[j]+YB[i][j]*e[j];}dV=V[i]*V[i]-e[i]*e[i]-f[i]*f[i];dP=P[i]-e[i]*A-f[i]*B;W[2*i]=dP;dQ=Q[i]-f[i]*A+e[i]*B;if(type[i]==1)W[2*i+1]=dQ;elseW[2*i+1]=dV;}}//Jacobi矩阵//voidJacobi(doubleYG[][50],doubleYB[][50],doublee[50],doublef[50],
4、inttype[50],intN,doubleJa[100][101]){inti,j;for(i=0;i5、j]=-YG[i][j]*e[i]+YB[i][j]*f[i];Ja[2*i][2*j+1]=YB[i][j]*e[i]-YG[i][j]*f[i];Ja[2*i+1][2*j+1]=Ja[2*i+1][2*j]=0;}}else{doublea[50]={0},b[50]={0};for(intk=0;k6、-YB[i][i]*f[i];Ja[2*i][2*j+1]=-b[i]+YB[i][i]*e[i]-YG[i][i]*f[i];if(type[i]==1){Ja[2*i+1][2*j]=b[i]+YB[i][i]*e[i]-YG[i][i]*f[i];Ja[2*i+1][2*j+1]=-a[i]+YG[i][i]*e[i]+YB[i][i]*f[i];}else{Ja[2*i+1][2*j]=-2*e[i];Ja[2*i+1][2*j+1]=-2*f[i];}}}}}}//高斯消元法解方程组函数//voidgauss(dou7、blea[][101],intn){inti,j,k;doublec;for(k=0;k=0;k--)for(j=k+1;j8、n;intN=0,GS=0,LD=0,ZLs=0;//节点数发电机数负荷数支路数//BUS*B;Generator*G;Line*L;//从文本中读入原始数据到数组中//fin.open("C:\data.txt");if(!fin){cout<<"输入数据文件不存在!"<
5、j]=-YG[i][j]*e[i]+YB[i][j]*f[i];Ja[2*i][2*j+1]=YB[i][j]*e[i]-YG[i][j]*f[i];Ja[2*i+1][2*j+1]=Ja[2*i+1][2*j]=0;}}else{doublea[50]={0},b[50]={0};for(intk=0;k6、-YB[i][i]*f[i];Ja[2*i][2*j+1]=-b[i]+YB[i][i]*e[i]-YG[i][i]*f[i];if(type[i]==1){Ja[2*i+1][2*j]=b[i]+YB[i][i]*e[i]-YG[i][i]*f[i];Ja[2*i+1][2*j+1]=-a[i]+YG[i][i]*e[i]+YB[i][i]*f[i];}else{Ja[2*i+1][2*j]=-2*e[i];Ja[2*i+1][2*j+1]=-2*f[i];}}}}}}//高斯消元法解方程组函数//voidgauss(dou7、blea[][101],intn){inti,j,k;doublec;for(k=0;k=0;k--)for(j=k+1;j8、n;intN=0,GS=0,LD=0,ZLs=0;//节点数发电机数负荷数支路数//BUS*B;Generator*G;Line*L;//从文本中读入原始数据到数组中//fin.open("C:\data.txt");if(!fin){cout<<"输入数据文件不存在!"<
6、-YB[i][i]*f[i];Ja[2*i][2*j+1]=-b[i]+YB[i][i]*e[i]-YG[i][i]*f[i];if(type[i]==1){Ja[2*i+1][2*j]=b[i]+YB[i][i]*e[i]-YG[i][i]*f[i];Ja[2*i+1][2*j+1]=-a[i]+YG[i][i]*e[i]+YB[i][i]*f[i];}else{Ja[2*i+1][2*j]=-2*e[i];Ja[2*i+1][2*j+1]=-2*f[i];}}}}}}//高斯消元法解方程组函数//voidgauss(dou
7、blea[][101],intn){inti,j,k;doublec;for(k=0;k=0;k--)for(j=k+1;j8、n;intN=0,GS=0,LD=0,ZLs=0;//节点数发电机数负荷数支路数//BUS*B;Generator*G;Line*L;//从文本中读入原始数据到数组中//fin.open("C:\data.txt");if(!fin){cout<<"输入数据文件不存在!"<
8、n;intN=0,GS=0,LD=0,ZLs=0;//节点数发电机数负荷数支路数//BUS*B;Generator*G;Line*L;//从文本中读入原始数据到数组中//fin.open("C:\data.txt");if(!fin){cout<<"输入数据文件不存在!"<
此文档下载收益归作者所有