资源描述:
《牛顿-拉夫逊迭代法极坐标潮流计算C语言程序.doc》由会员上传分享,免费在线阅读,更多相关内容在行业资料-天天文库。
1、/*利用牛顿-拉夫逊迭代法(极坐标形式),计算复杂电力系统潮流,具有收敛性好,收敛速度快等优点。所有参数应归算至标幺值下。/*可计算最大节点数为100,可计算PQ,PV,平衡节点*//*可计算非标准变比和平行支路*/#include#include#include#defineM100/*最大矩阵阶数*/#defineNl100/*迭代次数*/inti,j,k,a,b,c;/*循环控制变量*/intt,l;doubleP,Q,H,J;/*中间变量*/intn,/*节点数*/m,/*支路数*/pq,/*PQ节点数*
2、/pv;/*PV节点数*/doubleeps;/*迭代精度*/doubleaa[M],bb[M],cc[M],dd[M],max,rr,tt;/*中间变量*/doublemo,c1,d1,c2,d2;/*复数运算函数的返回值*/doubleG[M][M],B[M][M],Y[M][M];/*节点导纳矩阵中的实部、虚部及其模方值*/doubleykb[M][M],D[M],d[M],dU[M];/*雅克比矩阵、不平衡量矩阵*/structjd/*节点结构体*/{intnum,ty;/*num为节点号,ty为节点类型*/doublep,q,S,U,zkj,dp,dq,d
3、u,dj;/*节点有功、无功功率,功率模值,电压模值,阻抗角牛顿--拉夫逊中功率不平衡量、电压修正量*/}jd[M];structzl/*支路结构体*/{intnumb;/*numb为支路号*/intp1,p2;/*支路的两个节点*/doublekx;/*非标准变比*/doubler,x;/*支路的电阻与电抗*/}zl[M];FILE*fp1,*fp2;voiddata()/*读取数据*/{inth,number;fp1=fopen("input.txt","r");fscanf(fp1,"%d,%d,%d,%d,%lf",&n,&m,&pq,&pv,&eps)
4、;/*输入节点数,支路数,PQ节点数,PV节点数和迭代精度*/for(i=1;i<=n;i++)/*输入节点编号、类型、输入功率和电压初值*/{fscanf(fp1,"%d,%d",&number,&h);if(h==1)/*类型h=1是PQ节点*/{fscanf(fp1,"%lf,%lf,%lf,%lf",&jd[i].p,&jd[i].q,&jd[i].U,&jd[i].zkj);jd[i].num=number;jd[i].ty=h;}if(h==2)/*类型h=2是pv节点*/{fscanf(fp1,",%lf,%lf,%lf",&jd[i].p,&
5、jd[i].U,&jd[i].zkj);jd[i].num=number;jd[i].ty=h;jd[i].q=-1.567;}if(h==3)/*类型h=3是平衡节点*/{fscanf(fp1,",%lf,%lf",&jd[i].U,&jd[i].zkj);jd[i].num=number;jd[i].ty=h;}}for(i=1;i<=m;i++)/*输入支路阻抗*/fscanf(fp1,"%d,%lf,%d,%d,%lf,%lf",&zl[i].numb,&zl[i].kx,&zl[i].p1,&zl[i].p2,&zl[i].r,&zl[i].x);
6、fclose(fp1);if((fp2=fopen("output.txt","w"))==NULL){printf("cannotopenfile!");exit(0);}fprintf(fp2,"电力系统潮流计算");fprintf(fp2,"**********原始数据*********");fprintf(fp2,"================================================================================");fprintf(fp2,"节点数:%d支路数:%dPQ节点数:%
7、dPV节点数:%d精度:%f",n,m,pq,pv,eps);fprintf(fp2,"------------------------------------------------------------------------------");for(i=1;i<=pq;i++)fprintf(fp2,"PQ节点:节点%dP[%d]=%fQ[%d]=%f",jd[i].num,jd[i].num,jd[i].p,jd[i].num,jd[i].q);for(i=pq+1;i<=pq+pv;i++)fprintf(fp2,"PV节点:节点%dP[