潮流上機(jī)課程設(shè)計(jì)報(bào)告1.華電_第1頁
潮流上機(jī)課程設(shè)計(jì)報(bào)告1.華電_第2頁
潮流上機(jī)課程設(shè)計(jì)報(bào)告1.華電_第3頁
潮流上機(jī)課程設(shè)計(jì)報(bào)告1.華電_第4頁
潮流上機(jī)課程設(shè)計(jì)報(bào)告1.華電_第5頁
已閱讀5頁,還剩14頁未讀, 繼續(xù)免費(fèi)閱讀

下載本文檔

版權(quán)說明:本文檔由用戶提供并上傳,收益歸屬內(nèi)容提供方,若內(nèi)容存在侵權(quán),請(qǐng)進(jìn)行舉報(bào)或認(rèn)領(lǐng)

文檔簡介

《電力系統(tǒng)潮流上機(jī)》課程設(shè)計(jì)報(bào)告院系:電氣與電子工程學(xué)院班級(jí):電氣1108班學(xué)號(hào):1111180806學(xué)生姓名:陳子君指導(dǎo)教師:劉寶柱設(shè)計(jì)周數(shù):兩周成績:日期:2014年1月10日課程課程設(shè)計(jì)報(bào)告一、課程設(shè)計(jì)的目的與要求培養(yǎng)學(xué)生的電力系統(tǒng)潮流計(jì)算機(jī)編程能力,掌握計(jì)算機(jī)潮流計(jì)算的相關(guān)知識(shí)二、設(shè)計(jì)正文(詳細(xì)內(nèi)容見附錄)1.手算:要求應(yīng)用牛頓-拉夫遜法或P-Q分解法手算求解,要求精度為0.001MW。節(jié)點(diǎn)1為平衡節(jié)點(diǎn),電壓,節(jié)點(diǎn)2為PQ節(jié)點(diǎn),負(fù)荷功率,節(jié)點(diǎn)3是PV節(jié)點(diǎn),,兩條支路分別為,,對(duì)地支路2.計(jì)算機(jī)計(jì)算:編寫潮流計(jì)算程序,要求如下:2.1據(jù)給定的潮流計(jì)算任務(wù)書整理潮流計(jì)算的基礎(chǔ)數(shù)據(jù):節(jié)點(diǎn)的分類,線路模型,等值變壓器模型,電壓等級(jí)的歸算,標(biāo)幺值的計(jì)算;2.2基礎(chǔ)數(shù)據(jù)的計(jì)算機(jī)存儲(chǔ):節(jié)點(diǎn)數(shù)據(jù),支路數(shù)據(jù)(包括變壓器);2.3用牛頓-拉夫遜法計(jì)算;2.4根據(jù)所選潮流計(jì)算方法畫流程圖,劃分出功能模塊,有數(shù)據(jù)輸入模塊,導(dǎo)納陣形成模塊,解線性方程組模塊,計(jì)算不平衡功率模塊,形成雅可比矩陣模塊,解修正方程模塊,計(jì)算線路潮流,網(wǎng)損,PV節(jié)點(diǎn)無功功率和平衡節(jié)點(diǎn)功率,數(shù)據(jù)輸出模塊;2.5據(jù)上述模塊編制程序并上機(jī)調(diào)試程序,得出潮流計(jì)算結(jié)果;2.6源程序及其程序中的符號(hào)說明集、程序流圖簡單系統(tǒng)如下圖所示,支路數(shù)據(jù)如下:,,,,,節(jié)點(diǎn)數(shù)據(jù)如下:,,,,//2014.cpp:定義控制臺(tái)應(yīng)用程序的入口點(diǎn)。//#include"stdafx.h"structLine//線路結(jié)構(gòu)體{intNum,NumI,NumJ;//線路號(hào)左節(jié)點(diǎn)名右節(jié)點(diǎn)名floatR,X,B,K;//電阻電抗電納變比(K等于1為普通支路,不等于1為變壓器支路的變比)};structBus//節(jié)點(diǎn)結(jié)構(gòu)體{intNum;floatVolt,Phase,GenP,GenQ,LoadP,LoadQ;intType;};#include"stdio.h"#include"string.h"#include"math.h"#include"stdlib.h"#defineNBUS4//#defineNLINE4/*Globalvariables*/intnL,nB,nVA,nSH;floatX[NBUS];intL;doubledef[2*NBUS];doubleawe[100];int_tmain(intargc,_TCHAR*argv[]){FILE*fp;FILE*fpout;inti,j,l,h,n,k;inti1=0,i2=0,i3=0,kp,kq;doublea,b,k1;doubleH=0,N=0,J=0,L=0,R=0,S=0;floatd1=0,d2=0,d3=0,d4=0,d5=0,d6=0,r,x,g,b1,b2,g1,g2,tt,LL,e,ps=0,qs=0,shsh,m;structLinesL[NLINE];structBussB[NBUS];floatYG[NBUS+1][NBUS+1],YB[NBUS+1][NBUS+1];doubleu[50][2],p[50],da,db,pp[50],ppl[50],Q[10][10],gJaccobi[50][50],sP[10][10],sQ[10][10],WP=0.0,WQ=0.0;for(i=0;i<NBUS;i++){if((fp=fopen("H:\\2014\\2014\\in.txt","r"))==NULL){printf("Cannotopenthefilenamed'in.txt'\n");exit(0);}fscanf(fp,"%d,%d,%d",&nB,&nL,&nSH);}for(i=0;i<nB;i++){sB[i].Num=sB[i].Type=0;sB[i].Volt=1.0;sB[i].Phase=sB[i].GenP=sB[i].GenQ=sB[i].LoadP=sB[i].LoadQ=0.0;fscanf(fp,"%d,%f,%f,%f,%f,%f,%f,%d",&i1,&d1,&d2,&d3,&d4,&d5,&d6,&i2);sB[i].Num=i1;sB[i].Volt=d1;sB[i].Phase=d2;sB[i].GenP=d3;sB[i].GenQ=d4;sB[i].LoadP=d5,sB[i].LoadQ=d6;sB[i].Type=i2;};for(i=0;i<nL;i++){sL[i].Num=sL[i].NumI=sL[i].NumJ=0;sL[i].R=sL[i].X=sL[i].B=0.0;sL[i].K=1.0;fscanf(fp,"%2d%3d%3d%f%f%f%f",&i1,&i2,&i3,&d1,&d2,&d3,&d4);sL[i].Num=i1;sL[i].NumI=i2;sL[i].NumJ=i3;sL[i].R=d1;sL[i].X=d2;sL[i].B=d3;sL[i].K=d4;}if(fp!=NULL)fclose(fp);/*MakeYMatrix*/for(i=1;i<nB+1;i++)for(j=1;j<nB+1;j++){YG[i][j]=0.0;YB[i][j]=0.0;};for(l=0;l<nL;l++){i=sL[l].NumI;j=sL[l].NumJ;r=sL[l].R;x=sL[l].X;d1=r*r+x*x;g=r/d1;b=-x/d1;m=sL[l].K;if(fabs(sL[l].K-1.0)<0.000001)//普通支路{YG[i][i]=YG[i][i]+g;YG[j][j]=YG[j][j]+g;YB[i][i]=YB[i][i]+b+sL[l].B;YB[j][j]=YB[j][j]+b+sL[l].B;YG[i][j]=YG[i][j]-g;YG[j][i]=YG[j][i]-g;YB[i][j]=YB[i][j]-b;YB[j][i]=YB[j][i]-b;}else//變壓器支路{YG[i][i]=YG[i][i]+g;YB[i][i]=YB[i][i]+b;YG[j][j]=YG[j][j]+g/(m*m);YB[j][j]=YB[j][j]+b/(m*m);YG[i][j]=YG[i][j]-g/m;YG[j][i]=YG[j][i]-g/m;YB[i][j]=YB[i][j]-b/m;YB[j][i]=YB[j][i]-b/m;}}/*ChecktheYmatrix*/if((fp=fopen("GGBB.txt","w"))==NULL){printf("Cannotopenthefilenamed'GGBB.txt'\n");exit(0);}fprintf(fp,"---YMatrix---\n");for(i=1;i<nB+1;i++)for(j=1;j<nB+1;j++)if(fabs(YB[i][j]-0.0)>0.000001)fprintf(fp,"Y(%3d,%-3d)=(%10.5f,%10.5f)\n",i,j,YG[i][j],YB[i][j]);if(fp!=NULL)fclose(fp); for(i=1;i<nB+1;i++) { if(sB[i-1].Type==2) { u[i][0]=sB[i-1].Volt*cos(sB[i-1].Phase); u[i][1]=sB[i-1].Volt*sin(sB[i-1].Phase); } elseif(sB[i-1].Type==1) {u[i][0]=sB[i-1].Volt*cos(sB[i-1].Phase);u[i][1]=0.0; } elseif(sB[i-1].Type==0) { u[i][0]=1.0; u[i][1]=0.0; } }fp=fopen("電壓初值.txt","w"); if(fp==NULL) { printf("Cannotopenthefilenamed'電壓初值.txt'\n"); exit(0); } fprintf(fp,"---電壓初值---\n"); for(i=1;i<nB+1;i++) fprintf(fp,"e(%d)=%10.5f;f(%d)=%10.5f\n",i,u[i][0],i,u[i][1]); if(fp!=NULL)fclose(fp); printf("賦予的電壓初值為(e+if):\n");for(i=1;i<nB+1;i++)printf("%lf+i%lf\n",u[i][0],u[i][1]);printf("\n");printf("\n");/*循環(huán)迭代*/ /*求偏移量*/ doubleP_P[5]; doubleP_Q[5]; doubleP_UU[5]; intv;for(v=1;;v++){ for(i=1;i<nB+1;i++) {if(sB[i-1].Type==2) {P_P[i]=0.0; P_Q[i]=0.0; P_UU[i]=0.0; } if(sB[i-1].Type==0)//0為PQ節(jié)點(diǎn),1為PV節(jié)點(diǎn) { doubletempP=0.0; doubletempQ=0.0; for(j=1;j<nB+1;j++) { tempP+=YG[i][j]*u[j][1]+YB[i][j]*u[j][0]; tempQ+=YG[i][j]*u[j][0]-YB[i][j]*u[j][1]; } P_P[i]=(sB[i-1].GenP-sB[i-1].LoadP)-tempP*u[i][1]-tempQ*u[i][0];P_Q[i]=(sB[i-1].GenQ-sB[i-1].LoadQ)+tempP*u[i][0]-tempQ*u[i][1]; } if(sB[i-1].Type==1) {doubletempP=0.0; doubletempQ=0.0; for(j=1;j<nB+1;j++) {tempP+=YG[i][j]*u[j][1]+YB[i][j]*u[j][0]; tempQ+=YG[i][j]*u[j][0]-YB[i][j]*u[j][1]; }P_P[i]=(sB[i-1].GenP-sB[i-1].LoadP)-tempP*u[i][1]-tempQ*u[i][0]; P_UU[i]=sB[i-1].Volt*sB[i-1].Volt-(u[i][0]*u[i][0]+u[i][1]*u[i][1]);}}/*偏移量陣*/ doubleP_PQ[6];// intc=0; for(i=2;i<nB+1;i++) { if(sB[i-1].Type==0) { P_PQ[c]=P_P[i]; c=c+2; } } for(i=2;i<nB+1;i++) { if(sB[i-1].Type==1) { P_PQ[c]=P_P[i]; c=c+2; } } c=1; for(i=2;i<nB+1;i++) { if(sB[i-1].Type==0) { P_PQ[c]=P_Q[i]; c=c+2;} } for(i=2;i<nB+1;i++) { if(sB[i-1].Type==1) { P_PQ[c]=P_UU[i]; c=c+2; } }/*輸出偏移量*/ printf("輸出偏移量\n");if((fp=fopen("偏移量.txt","w"))==NULL){printf("Cannotopenthefilenamed'偏移量.txt'\n");exit(0);}fprintf(fp,"---偏移量---\n");for(i=0;i<c-1;i++)fprintf(fp,"P_PQ(%2d)=(%10.5f)\n",i,P_PQ[i]);if(fp!=NULL)fclose(fp);for(i=0;i<2*(nB-1);i++)printf("P_PQ[%2d]=(%10.5f)\n",i,P_PQ[i]);//形成雅克比矩陣for(i=2;i<nB+1;i++){ for(j=2;j<nB+1;j++) { if(sB[i-1].Type==0)//PQ節(jié)點(diǎn) { if(i!=j)//非對(duì)角元素 { H=-YB[i][j]*u[i][0]+YG[i][j]*u[i][1]; N=YG[i][j]*u[i][0]+YB[i][j]*u[i][1]; J=-N; L=H; } else//對(duì)角元素 { a=0;b=0; for(k=1;k<nB+1;k++)//u[i][]從i=1開始 { a=a+(YG[i][k]*u[k][0]-YB[i][k]*u[k][1]); b=b+(YG[i][k]*u[k][1]+YB[i][k]*u[k][0]); } H=+YG[i][i]*u[i][1]-YB[i][i]*u[i][0]+b; N=+YG[i][i]*u[i][0]+YB[i][i]*u[i][1]+a; J=-YG[i][i]*u[i][0]-YB[i][i]*u[i][1]+a; L=YG[i][i]*u[i][1]-YB[i][i]*u[i][0]-b; } gJaccobi[2*(i-2)][2*(j-2)]=H; gJaccobi[2*(i-2)][2*(j-2)+1]=N; gJaccobi[2*(i-2)+1][2*(j-2)]=J; gJaccobi[2*(i-2)+1][2*(j-2)+1]=L; } else //PV節(jié)點(diǎn) { if(i!=j)//非對(duì)角元素 { H=-YB[i][j]*u[i][0]+YG[i][j]*u[i][1]; N=YG[i][j]*u[i][0]+YB[i][j]*u[i][1]; R=0; S=0; } else//對(duì)角元素 { a=b=0; for(k=1;k<nB+1;k++) { a=a+(YG[i][k]*u[k][0]-YB[i][k]*u[k][1]); b=b+(YG[i][k]*u[k][1]+YB[i][k]*u[k][0]); } H=YG[i][i]*u[i][1]-YB[i][i]*u[i][0]+b; N=YG[i][i]*u[i][0]+YB[i][i]*u[i][1]+a; R=2*u[i][1]; S=2*u[i][0]; } gJaccobi[2*(i-2)][2*(j-2)]=H; gJaccobi[2*(i-2)][2*(j-2)+1]=N; gJaccobi[2*(i-2)+1][2*(j-2)]=R; gJaccobi[2*(i-2)+1][2*(j-2)+1]=S; } }}//outputtheJaccobi fp=fopen("雅克比.txt","w"); if(fp==NULL) { printf("Cannotopenthefilenamed'雅克比.txt'\n"); exit(0); } fprintf(fp,"---雅克比矩陣---\n"); for(i=0;i<2*(nB-1);i++)// { for(j=0;j<2*(nB-1);j++) { fprintf(fp,"Jaccobi(%d,%d)=(%10.5lf)\b",i+1,j+1,gJaccobi[i][j]);//雅克比矩陣從i=0開始 } fprintf(fp,"\n"); } if(fp!=NULL)fclose(fp);voidGauss(doublea[50][50],doubleb[6],intn);// intNN=6;//Gauss(gJaccobi,P_PQ,NN);//調(diào)用高斯函數(shù) for(i=0;i<6;i++)// printf("awe[%d]=%lf\n",i,awe[i]); printf("\n開始計(jì)算電壓新值\n"); for(i=2,j=0;i<=nB,j<2*(nB-1);i++,j=j+2)//i=1是平衡節(jié)點(diǎn)不放入 { u[i][1]+=awe[j]; u[i][0]+=awe[j+1]; printf("u[%d][0]=%10.5lf,u[%d][1]=%10.5lf\n",i,u[i][0],i,u[i][1]); } fp=fopen("電壓新值.txt","w");/*路徑*/ if(fp==NULL) { printf("Cannotopenthefilenamed'電壓新值.txt'\n"); exit(0); } fprintf(fp,"---電壓新值---\n"); for(i=1;i<=3;i++)// { fprintf(fp,"ge[%d]=%10.5f,gf[%d]=%10.5f\n",i,u[i][0],i,u[i][1]); } if(fp!=NULL)fclose(fp); doublemax; max=0.0; for(i=0;i<6;i++) if(fabs(awe[i])>max) max=fabs(awe[i]); if(max<=0.00001) break; printf("循環(huán)次數(shù)v=%d\n",v);}//計(jì)算平衡節(jié)點(diǎn)功率doubletempP=0.0;doubletempQ=0.0;ps=0;qs=0;for(i=1;i<NBUS+1;i++){if(sB[i-1].Type==2){ for(j=1;j<nB+1;j++) { tempP+=YG[i][j]*u[j][1]+YB[i][j]*u[j][0]; tempQ+=YG[i][j]*u[j][0]-YB[i][j]*u[j][1]; } ps=tempP*u[i][1]+tempQ*u[i][0];qs=-tempP*u[i][0]+tempQ*u[i][1];}}//計(jì)算線路流動(dòng)功率for(i=1;i<NBUS+1;i++){for(j=1;j<NBUS+1;j++){ sP[i][j]=0;sQ[i][j]=0; }}for(l=0;l<nL;l++){i=sL[l].NumI;j=sL[l].NumJ;r=sL[l].R;x=sL[l].X;d1=r*r+x*x;g=r/d1;b=-x/d1; b1=sL[l].B;if(fabs(sL[l].K-1.0)<0.000001){//普通支路 sP[i][j]=u[i][0]*((u[i][0]-u[j][0])*g-(u[i][1]-u[j][1])*b)+u[i][1]*((u[i][1]-u[j][1])*g+(u[i][0]-u[j][0])*b); sQ[i][j]=-u[i][0]*((u[i][0]-u[j][0])*b+(u[i][1]-u[j][1])*g)+u[i][1]*((u[i][0]-u[j][0])*g-(u[i][1]-u[j][1])*b)-(u[i][0]*u[i][0]+u[i][1]*u[i][1])*b1; sP[j][i]=u[j][0]*((u[j][0]-u[i][0])*g-(u[j][1]-u[i][1])*b)+u[j][1]*((u[j][1]-u[i][1])*g+(u[j][0]-u[i][0])*b); sQ[j][i]=-u[j][0]*((u[j][0]-u[i][0])*b+(u[j][1]-u[i][1])*g)+u[j][1]*((u[j][0]-u[i][0])*g-(u[j][1]-u[i][1])*b)-(u[j][0]*u[j][0]+u[j][1]*u[j][1])*b1;}else{//abnormaltransformerratio k1=sL[l].K; r=sL[l].R;x=sL[l].X;d1=r*r+x*x;g=r/d1; g1=(k1-1)/k1*g; g2=(1-k1)/(k1*k1)*g;b=-x/d1; b1=(k1-1)/k1*b; b2=(1-k1)/(k1*k1)*b; //sP[i][j]=u[i][0]*((u[i][0]-u[j][0])*g-(u[i][1]-u[j][1])*b-u[i][1]*b1)+u[i][1]*((u[i][0]-u[j][0])*b+(u[i][1]-u[j][1])*g+u[i][0]*b1); //sP[j][i]=u[j][0]*((u[j][0]-u[i][0])*g-(u[j][1]-u[i][1])*b-u[j][1]*b2)+u[j][1]*((u[j][0]-u[i][0])*b+(u[j][1]-u[i][1])*g+u[j][0]*b2); //sQ[i][j]=u[i][1]*((u[i][0]-u[j][0])*g-(u[i][1]-u[j][1])*b-u[i][1]*b1)-u[i][0]*((u[i][0]-u[j][0])*b+(u[i][1]-u[j][1])*g+u[i][0]*b1); //sQ[i][j]=u[j][1]*((u[j][0]-u[i][0])*g-(u[j][1]-u[i][1])*b-u[j][1]*b2)-u[j][0]*((u[j][0]-u[i][0])*b+(u[j][1]-u[i][1])*g+u[i][0]*b2);sP[i][j]=u[i][0]*((u[i][0]-u[j][0])*g/k1-(u[i][1]-u[j][1])*b/k1)+u[i][1]*((u[i][1]-u[j][1])*g/k1+(u[i][0]-u[j][0])*b/k1)+(u[i][0]*u[i][0]+u[i][1]*u[i][1])*g1;sQ[i][j]=-u[i][0]*((u[i][0]-u[j][0])*b/k1+(u[i][1]-u[j][1])*g/k1)+u[i][1]*((u[i][0]-u[j][0])*g/k1-(u[i][1]-u[j][1])*b/k1)-(u[i][0]*u[i][0]+u[i][1]*u[i][1])*b1;sP[j][i]=u[j][0]*((u[j][0]-u[i][0])*g/k1-(u[j][1]-u[i][1])*b/k1)+u[j][1]*((u[j][1]-u[i][1])*g/k1+(u[j][0]-u[i][0])*b/k1)+(u[j][0]*u[j][0]+u[j][1]*u[j][1])*g2;sQ[j][i]=-u[j][0]*((u[j][0]-u[i][0])*b/k1+(u[j][1]-u[i][1])*g/k1)+u[j][1]*((u[j][0]-u[i][0])*g/k1-(u[j][1]-u[i][1])*b/k1)-(u[j][0]*u[j][0]+u[j][1]*u[j][1])*b2;}}doubledsp,dsq,sumgen,dp;dsp=ps;dsq=qs;sumgen=ps;for(i=0;i<NBUS;i++){dsp+=sB[i].GenP-sB[i].LoadP;dsq+=sB[i].GenQ-sB[i].LoadQ;sumgen+=sB[i].GenP;}dp=dsp/sumgen*100;//輸出功率情況if((fp=fopen("功率情況.txt","w"))==NULL){printf("Cannotopenthefilenamed'功率情況.txt'\n");exit(0);}fprintf(fp,"---各支路功率情況---\n");fprintf(fp,"平衡節(jié)點(diǎn)功率S=%10.5f+i%10.5f\n",ps,qs);for(i=1;i<NBUS+1;i++)for(j=1;j<NBUS+1;j++)if(fabs(sP[i][j]-0.0)>0.000001) fprintf(fp,"S(%3d,%-3d)=(%10.5f,j%10.5f)\n",i,j,sP[i][j],sQ[i][j]);fprintf(fp,"網(wǎng)損為%10.5f+j%10.5f,輸電效率為%10.3f\n",dsp,dsq,100-dp);if(fp!=NULL)fclose(fp);//PV節(jié)點(diǎn)無功功率doublepP=0.0;doublepQ=0.0;doubletq[50]={0};for(i=1;i<nB+1;i++){ if(sB[i-1].Type==1) { for(j=1;j<nB+1;j++) { pP+=YG[i][j]*u[j][1]+YB[i][j]*u[j][0]; pQ+=YG[i][j]*u[j][0]-YB[i][j]*u[j][1]; } tq[i-1]=-pP*u[i][0]+pQ*u[i][1]; }}//輸出PV無功if((fp=fopen("PV無功.txt","w"))==NULL){printf("Cannotopenthefilenamed'PV無功.txt'\n");exit(0);}fprintf(fp,"---PV無功---\n");for(i=1;i<nB+1;i++){ if(sB[i-1].Type==1) fprintf(fp,"Q(%3d)=%10.5f\n",i,tq[i-1]);}if(fp!=NULL)fclose(fp);//輸出最終結(jié)果if((fp=fopen("最終結(jié)果.txt","w"))==NULL){ printf("Cannotopenthefilenamed'最終結(jié)果.txt'\n");exit(0);}fprintf(fp,"---最終結(jié)果---\n");fprintf(fp,"\n\n\n");fprintf(fp,"一共循環(huán)迭代計(jì)算%d次\n",v);fprintf(fp,"\n\n\n");fprintf(fp,"---電壓終值---\n");for(i=1;i<NBUS+1;i++)for(j=1;j<2;j++)fprintf(fp,"U(%2d)=(%8.5lf+i%8.5lf)\n",i,u[i][0],u[i][1]);fprintf(fp,"\n\n\n");fprintf(fp,"平衡節(jié)點(diǎn)功率S=%8.5f+j%7.5f\n",ps,qs); for(i=1;i<NBUS+1;i++){ if(sB[i-1].Type==1) fprintf(fp,"PV節(jié)點(diǎn)無功功率Q(%3d)=%10.5f\n",i,tq[i-1]);}fprintf(fp,"\n\n\n");fprintf(fp,"---各節(jié)點(diǎn)間功率---\n");for(i=1;i<NBUS+1;i++) for(j=1;j<NBUS+1;j++) if(fabs(sP[i][j]-0.0)>0.000001) fprintf(fp,"S(%2d,%-2d)=(%8.5f,j%8.5f)\n",i,j,sP[i][j],sQ[i][j]);fprintf(fp,"\n\n\n");fprintf(fp,"網(wǎng)損為:%7.5f+j%7.5f。\n\n網(wǎng)損率為:百分之%7.5f\n",dsp,dsq,dp);if(fp!=NULL)fclose(fp); return0;}voidGauss(doublea[50][50],doubleb[6],intn)/*定義高斯法*///{intJS[50];inti,j,k;doubled,t,x[50];FILE*fp;intL=1;for(i=0;i<NBUS;i++)JS[i]=0;for(k=0;k<n;k++){d=0.0;for(j=k;j<n;j++) if(fabs(a[k][j])>d) {/*在一行中找到一個(gè)最大值賦值d,并用JS[K]記住這個(gè)最大值所在的列號(hào)*/d=fabs(a[k][j]);JS[k]=j;}if(fabs(d)<0.000001)/*如果d的數(shù)值太小,做為被除數(shù)將帶來很大的誤差*/L=0;else {if(JS[k]!=k) for(i=0;i<n;i++) {t=a[i][k];a[i][k]=a[i][JS[k]];/*進(jìn)行列交換,讓最大值始終在對(duì)角元上*/a[i][JS[k]]=t; }}if(L==0)break;for(j=k+1;j<n;j++) a[k][j]=a[k][j]/a[k][k];/*對(duì)角元上的元素消為1*/b[k]=b[k]/a[k][k];for(i=k+1;i<n;i++) {for(j=k+1;j<n;j++) a[i][j]=a[i][j]-a[i][k]*a[k][j];/*使下三角陣的元素為0*/b[i]=b[i]-a[i][k]*b[k];}}if(fabs(a[n-1][n-1])>0.00001){/*用追趕法,解方程組,求未知數(shù)x*/x[n-1]=b[n-1];for(i=n-2;i>=0;i--) {t=0.0;for(j=i+1;j<n;j++) t=t+a[i][j]*x[j];x[i]=(b[i]-t);}}if((fp=fopen("高斯.txt","w"))==NULL)/*將結(jié)果寫到TXT文件中*/{ printf("Cannotopenthefilenamed'高斯.txt'\n");exit(0);}for(i=0;i<n;i++){fprintf(fp,"%lf",x[i]);awe[i]=x[i];fprintf(fp,"\n");}if(fp!=NULL)fclose(fp);}5)程序流圖請(qǐng)看附錄6)得到的數(shù)據(jù)(out.txt)---YMatrix---Y(1,1)=(0.93463,-4.26159)Y(1,2)=(-0.48077,2.40385)Y(1,3)=(-0.45386,1.89107)Y(2,1)=(-0.48077,2.40385)Y(2,2)=(1.04225,-4.67651)Y(2,3)=(-0.56148,2.30208)Y(3,1)=(-0.45386,1.89107)Y(3,2)=(-0.56148,2.30208)Y(3,3)=(1.01534,-9.03909)Y(3,4)=(0.00000,4.43674)Y(4,3)=(0.00000,4.43674)Y(4,4)=(0.00000,-4.03340)---雅克比矩陣1---Jaccobi(1,1)=(4.82612)_Jaccobi(1,2)=(1.01821)_Jaccobi(1,3)=(-2.30208)_Jaccobi(1,4)=(-0.56148)_Jaccobi(1,5)=(0.00000)_Jaccobi(1,6)=(0.00000)_Jaccobi(2,1)=(-1.06629)_Jaccobi(2,2)=(4.52691)_Jaccobi(2,3)=(0.56148)_Jaccobi(2,4)=(-2.30208)_Jaccobi(2,5)=(0.00000)_Jaccobi(2,6)=(0.00000)_Jaccobi(3,1)=(-2.30208)_Jaccobi(3,2)=(-0.56148)_Jaccobi(3,3)=(9.16812)_Jaccobi(3,4)=(0.99265)_Jaccobi(3,5)=(-4.43674)_Jaccobi(3,6)=(0.00000)_Jaccobi(4,1)=(0.56148)_Jaccobi(4,2)=(-2.30208)_Jaccobi(4,3)=(-1.03803)_Jaccobi(4,4)=(8.91006)_Jaccobi(4,5)=(0.00000)_Jaccobi(4,6)=(-4.43674)_Jaccobi(5,1)=(0.00000)_Jaccobi(5,2)=(0.00000)_Jaccobi(5,3)=(-4.88042)_Jaccobi(5,4)=(0.00000)_Jaccobi(5,5)=(4.43674)_Jaccobi(5,6)=(0.00000)_Jaccobi(6,1)=(0.00000)_Jaccobi(6,2)=(0.00000)_Jaccobi(6,3)=(0.00000)_Jaccobi(6,4)=(0.00000)_Jaccobi(6,5)=(0.00000)_Jaccobi(6,6)=(2.20000)_---雅克比矩陣2---Jaccobi(1,1)=(4.59086)_Jaccobi(1,2)=(0.99168)_Jaccobi(1,3)=(-2.18767)_Jaccobi(1,4)=(-0.79848)_Jaccobi(1,5)=(0.00000)_Jaccobi(1,6)=(0.00000)_Jaccobi(2,1)=(-2.06030)_Jaccobi(2,2)=(4.31870)_Jaccobi(2,3)=(0.79848)_Jaccobi(2,4)=(-2.18767)_Jaccobi(2,5)=(0.00000)_Jaccobi(2,6)=(0.00000)_Jaccobi(3,1)=(-2.28417)_Jaccobi(3,2)=(-0.57680)_Jaccobi(3,3)=(9.15929)_Jaccobi(3,4)=(0.78329)_Jaccobi(3,5)=(-4.41095)_Jaccobi(3,6)=(-0.03580)_Jaccobi(4,1)=(0.57680)_Jaccobi(4,2)=(-2.28417)_Jaccobi(4,3)=(-1.38147)_Jaccobi(4,4)=(8.79742)_Jaccobi(4,5)=(0.03580)_Jaccobi(4,6)=(-4.41095)_Jaccobi(5,1)=(0.00000)_Jaccobi(5,2)=(0.00000)_Jaccobi(5,3)=(-4.88042)_Jaccobi(5,4)=(0.46062)_Jaccobi(5,5)=(4.41095)_Jaccobi(5,6)=(0.03580)_Jaccobi(6,1)=(0.00000)_Jaccobi(6,2)=(0.00000)_Jaccobi(6,3)=(0.00000)_Jaccobi(6,4)=(0.00000)_Jaccobi(6,5)=(0.20764)_Jaccobi(6,6)=(2.20000)_---雅克比矩陣3---Jaccobi(1,1)=(4.57330)_Jaccobi(1,2)=(0.96137)_Jaccobi(1,3)=(-2.14904)_Jaccobi(1,4)=(-0.79057)_Jaccobi(1,5)=(0.00000)_Jaccobi(1,6)=(0.00000)_Jaccobi(2,1)=(-2.06173)_Jaccobi(2,2)=(4.17946)_Jaccobi(2,3)=(0.79057)_Jaccobi(2,4)=(-2.14904)_Jaccobi(2,5)=(0.00000)_Jaccobi(2,6)=(0.00000)_Jaccobi(3,1)=(-2.26771)_Jaccobi(3,2)=(-0.57317)_Jaccobi(3,3)=(9.09880)_Jaccobi(3,4)=(0.77422)_Jaccobi(3,5)=(-4.37942)_Jaccobi(3,6)=(-0.03650)_Jaccobi(4,1)=(0.57317)_Jaccobi(4,2)=(-2.26771)_Jaccobi(4,3)=(-1.37895)_Jaccobi(4,4)=(8.72910)_Jaccobi(4,5)=(0.03650)_Jaccobi(4,6)=(-4.37942)_Jaccobi(5,1)=(0.00000)_Jaccobi(5,2)=(0.00000)_Jaccobi(5,3)=(-4.85817)_Jaccobi(5,4)=(0.46601)_Jaccobi(5,5)=(4.37942)_Jaccobi(5,6)=(0.03650)_Jaccobi(6,1)=(0.00000)_Jaccobi(6,2)=(0.00000)_Jaccobi(6,3)=(0.00000)_Jaccobi(6,4)=(0.00000)_Jaccobi(6,5)=(0.21007)_Jaccobi(6,6)=(2.18997)_---雅克比矩陣4---Jaccobi(1,1)=(4.57309)_Jaccobi(1,2)=(0.96085)_Jaccobi(1,3)=(-2.14837)_Jaccobi(1,4)=(-0.79043)_Jaccobi(1,5)=(0.00000)_Jaccobi(1,6)=(0.00000)_Jaccobi(2,1)=(-2.06175)_Jaccobi(2,2)=(4.17693)_Jaccobi(2,3)=(0.79043)_Jaccobi(2,4)=(-2.14837)_Jaccobi(2,5)=(0.00000)_Jaccobi(2,6)=(0.00000)_Jaccobi(3,1)=(-2.26751)_Jaccobi(3,2)=(-0.57315)_Jaccobi(3,3)=(9.09805)_Jaccobi(3,4)=(0.77422)_Jaccobi(3,5)=(-4.37903)_Jaccobi(3,6)=(-0.03657)_Jaccobi(4,1)=(0.57315)_Jaccobi(4,2)=(-2.26751)_Jaccobi(4,3)=(-1.37904)_Jaccobi(4,4)=(8.72825)_Jaccobi(4,5)=(0.03657)_Jaccobi(4,6)=(-4.37903)_Jaccobi(5,1)=(0.00000)_Jaccobi(5,2)=(0.00000)_Jaccobi(5,3)=(-4.85811)_Jaccobi(5,4)=(0.46602)_Jaccobi(5,5)=(4.37903)_Jaccobi(5,6)=(0.03657)_Jaccobi(6,1)=(0.00000)_Jaccobi(6,2)=(0.00000)_Jaccobi(6,3)=(0.00000)_Jaccobi(6,4)=(0.00000)_Jaccobi(6,5)=(0.21007)_Jaccobi(6,6)=(2.18995)_---電壓新值1---ge[1]=1.05000,gf[1]=0.00000ge[2]=0.97679,gf[2]=-0.10861ge[3]=0.99419,gf[3]=-0.00807---電壓新值2---ge[1]=1.05000,gf[1]=0.00000ge[2]=0.96017,gf[2]=-0.10923ge[3]=0.98708,gf[3]=-0.00823---電壓新值3---ge[1]=1.05000,gf[1]=0.00000ge[2]=0.95987,gf[2]=-0.10924ge[3]=0.98699,gf[3]=-0.00824---電壓新值4---ge[1]=1.05000,gf[1]=0.00000ge[2]=0.95987,gf[2]=-0.10924ge[3]=0.98699,gf[3]=-0.00824---偏移量1---P_PQ(0)=(-0.52596)P_PQ(1)=(0.01960)P_PQ(2)=(-0.27731)P_PQ(3)=(-0.05097)P_PQ(4)=(0.50000)P_PQ(5)=(0.00000)---偏移量2---P_PQ(0)=(-0.01331)P_PQ(1)=(-0.05511)P_PQ(2)=(-0.00119)P_PQ(3)=(-0.00253)P_PQ(4)=(0.00268)P_PQ(5)=(-0.0

溫馨提示

  • 1. 本站所有資源如無特殊說明,都需要本地電腦安裝OFFICE2007和PDF閱讀器。圖紙軟件為CAD,CAXA,PROE,UG,SolidWorks等.壓縮文件請(qǐng)下載最新的WinRAR軟件解壓。
  • 2. 本站的文檔不包含任何第三方提供的附件圖紙等,如果需要附件,請(qǐng)聯(lián)系上傳者。文件的所有權(quán)益歸上傳用戶所有。
  • 3. 本站RAR壓縮包中若帶圖紙,網(wǎng)頁內(nèi)容里面會(huì)有圖紙預(yù)覽,若沒有圖紙預(yù)覽就沒有圖紙。
  • 4. 未經(jīng)權(quán)益所有人同意不得將文件中的內(nèi)容挪作商業(yè)或盈利用途。
  • 5. 人人文庫網(wǎng)僅提供信息存儲(chǔ)空間,僅對(duì)用戶上傳內(nèi)容的表現(xiàn)方式做保護(hù)處理,對(duì)用戶上傳分享的文檔內(nèi)容本身不做任何修改或編輯,并不能對(duì)任何下載內(nèi)容負(fù)責(zé)。
  • 6. 下載文件中如有侵權(quán)或不適當(dāng)內(nèi)容,請(qǐng)與我們聯(lián)系,我們立即糾正。
  • 7. 本站不保證下載資源的準(zhǔn)確性、安全性和完整性, 同時(shí)也不承擔(dān)用戶因使用這些下載資源對(duì)自己和他人造成任何形式的傷害或損失。

評(píng)論

0/150

提交評(píng)論