資源描述:
《牛頓-拉夫遜迭代法極坐標潮流計算C語言程序》由會員上傳分享,免費在線閱讀,更多相關內容在工程資料-天天文庫。
1、實用文檔/*利用牛頓-拉夫遜迭代法(極坐標形式),計算復雜電力系統潮流,具有收斂性好,收斂速度快等優(yōu)點。所有參數應歸算至標幺值下。/*可計算最大節(jié)點數為100,可計算PQ,PV,平衡節(jié)點*//*可計算非標準變比和平行支路*/#include#include#include#defineM100/*最大矩陣階數*/#defineNl100/*迭代次數*/inti,j,k,a,b,c;/*循環(huán)控制變量*/intt,l;doubleP,Q,H,J;/*中間變量*/int
2、n,/*節(jié)點數*/m,/*支路數*/pq,/*PQ節(jié)點數*/pv;/*PV節(jié)點數*/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];/*節(jié)點導納矩陣中的實部、虛部及其模方值*/doubleykb[M][M],D[M],d[M],dU[M];/*雅克比矩陣、不平衡量矩陣*/structjd/*節(jié)點結構體*/{
3、intnum,ty;/*num為節(jié)點號,ty為節(jié)點類型*/doublep,q,S,U,zkj,dp,dq,du,dj;/*節(jié)點有功、無功功率,功率模值,電壓模值,阻抗角牛頓--拉夫遜中功率不平衡量、電壓修正量*/}jd[M];structzl/*支路結構體*/{intnumb;/*numb為支路號*/intp1,p2;/*支路的兩個節(jié)點*/doublekx;/*非標準變比*/doubler,x;/*支路的電阻與電抗*/}zl[M];FILE*fp1,*fp2;voiddata()/*讀取數據*/{inth,numbe
4、r;fp1=fopen("input.txt","r");fscanf(fp1,"%d,%d,%d,%d,%lf",&n,&m,&pq,&pv,&eps);文案大全實用文檔/*輸入節(jié)點數,支路數,PQ節(jié)點數,PV節(jié)點數和迭代精度*/for(i=1;i<=n;i++)/*輸入節(jié)點編號、類型、輸入功率和電壓初值*/{fscanf(fp1,"%d,%d",&number,&h);if(h==1)/*類型h=1是PQ節(jié)點*/{fscanf(fp1,"%lf,%lf,%lf,%lf",&jd[i].p,&jd[i].q
5、,&jd[i].U,&jd[i].zkj);jd[i].num=number;jd[i].ty=h;}if(h==2)/*類型h=2是pv節(jié)點*/{fscanf(fp1,",%lf,%lf,%lf",&jd[i].p,&jd[i].U,&jd[i].zkj);jd[i].num=number;jd[i].ty=h;jd[i].q=-1.567;}if(h==3)/*類型h=3是平衡節(jié)點*/{fscanf(fp1,",%lf,%lf",&jd[i].U,&jd[i].zkj);jd[i].num=number;
6、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);fclose(fp1);if((fp2=fopen("output.txt","w"))==NULL){printf("cannotopenfile!");exit(0);}fprintf(fp2,"電力系統潮流計算");fprintf(f
7、p2,"**********原始數據*********");文案大全實用文檔fprintf(fp2,"================================================================================");fprintf(fp2,"節(jié)點數:%d支路數:%dPQ節(jié)點數:%dPV節(jié)點數:%d精度:%f",n,m,pq,pv,eps);fprintf(fp2,"---------------------------------------------
8、---------------------------------");for(i=1;i<=pq;i++)fprintf(fp2,"PQ節(jié)點:節(jié)點%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++)fpri