資源描述:
《潮流計(jì)算源程序》由會(huì)員上傳分享,免費(fèi)在線閱讀,更多相關(guān)內(nèi)容在工程資料-天天文庫(kù)。
1、vl.O/*矩陣階數(shù)*//*迭代次數(shù)勺inti,j,k,a,b,c;intt,l,g;intn,m,pq,PV,duidi;/*循環(huán)控制變量*/嚴(yán)中間變量*//*節(jié)點(diǎn)數(shù)*//*支路數(shù)*//*PQ節(jié)點(diǎn)數(shù)勺/*PV節(jié)點(diǎn)數(shù)*/嚴(yán)對(duì)地支路數(shù)*/doubleeps;doubleaa[M],bb[M],cc[M],dd[M],max,temp,rr,tt;doublemo,c1,d1,c2,d2,fushuqiujiao;doubleG[M][M],B[M][M],Y[M][M];虛部及其模方值*/doubleykb[M][M],D[M],dU[M];陣勺/*精度*//*中間變量*//*復(fù)
2、數(shù)運(yùn)算函數(shù)的返回值*/代節(jié)點(diǎn)導(dǎo)納矩陣中的實(shí)部、/咅雅克比矩陣、不平衡量矩structjd{intnum,s;類型*/doublep,q,S,e,f,U,zkj,dp,dq,du,de,df;電壓縱、橫分量,電壓模值,阻抗角,/*節(jié)點(diǎn)結(jié)構(gòu)體*//*num為節(jié)點(diǎn)號(hào),s為節(jié)點(diǎn)/*節(jié)點(diǎn)有功、無(wú)功功率,功率模值,牛頓?■拉夫遜中功率不平衡量、電壓不平衡量*/}jd[M];structzhl/*支路結(jié)構(gòu)體*/潮流計(jì)算源程序/***********************************************************文件名稱:潮流計(jì)算程序.cpp作者:版本:說(shuō)明:修
3、改記錄:?丄“?土?丄■?丄■?丄■?土?丄■?£??丄■?丄■?丄■*£??丄■?£??丄■*£??丄■?卜?丄■?£??丄■?卜?丄■?丄■?丄■?£*?丄■?丄■?丄■?£*?丄■/^7^^7w^7^^7^叫.#T%#T%#T%#T%#T%#T^#T%^T%嚇?#T%嚇?#T%嚇?#T%嚇?#T%嚇?*■#7^#T>f#include#include#include#defineM100#defineN100/*numb為支路號(hào)*//*支路的兩個(gè)
4、節(jié)點(diǎn)*//*支路的電阻與電抗*/{intnumb;intpl,p2;doubler,x;}zhlLMJ;FILE*fpl,*fp2;函數(shù)名稱:voidReadData()函數(shù)功能:讀取數(shù)據(jù)入口參數(shù):出口參數(shù):備注:voidReadData(){inth,number;fp1=fopen(,,input.txt,,,,,r");if(fp1==NULL)則跳出勺{printf(ucannotopenfile!u);exit(O);}fscanf(fp1,"%d,%d,%d,%d,%d,%lfH,&n,&m,&pq,&pv,&duidi,&eps);支路數(shù),PQ節(jié)點(diǎn)數(shù),PV
5、節(jié)點(diǎn)數(shù)對(duì)地支路數(shù)和精度*//*如果輸入為空/*輸入節(jié)點(diǎn)數(shù),j=l;k=pq+l;for(i=l;i<=n;i4-+)編號(hào)、類型、輸入功率和電壓初值勺/*輸入節(jié)點(diǎn)fscanf(fp1,“%d,%d”,&number,&h);if(h==l)/*類型h=l是PQ節(jié)點(diǎn)*/{fscanf(fpl,”,%lf,%lf,%lf,%lf”,&jd[j].p,&jd[j]?q,&jd[j].e,&jd[j].f);jd[j].num=number;jdfj].s=h;j++;if(h==2)是pv節(jié)點(diǎn)*//*類型h=2fscanf(fpl,“,%lf,%lf”,&jd[k].p,&jd
6、[k].U);jd[k].num=number;jd[k].s=h;jd[k].q=O;k++;/*類型h=3/*輸入支路if(h==3)是平衡節(jié)點(diǎn)*/{fscanf(fpl,”,%lf,%lf”,&jd[n]?e,&jd[n].f);jd[n].num=number;jd[n].s=h;}}fbr(i=l;i<=m;i++)阻抗勺fscanf(lp1;,%d,%d,%d,%lf,%lfn,&zhl[i].numb,&zhl[i].p1,&zhl[i].p2,&zhl[i],r,&zhl[i].x);fclose(fpl);if((fp2=fopen("output.t
7、xt",HwH))==NULL){printf(Hcannotopenfile!n);exit(O);fprintf(fp2/200801000705M);fprintf(fp2;*fprintf(fp2,u**********原始數(shù)據(jù)E);潮流上機(jī)實(shí)習(xí)華北電力大學(xué)電氣化0807段春姝fprintf(fp2,n節(jié)點(diǎn)數(shù):%d支路數(shù):%dPQ節(jié)點(diǎn)數(shù):%dPV節(jié)點(diǎn)數(shù):%d對(duì)地支路數(shù):%d精度:%fn,n,m,pq,pv,duidi,eps);fprintf(fp2,"n);