版權(quán)說明:本文檔由用戶提供并上傳,收益歸屬內(nèi)容提供方,若內(nèi)容存在侵權(quán),請進行舉報或認(rèn)領(lǐng)
文檔簡介
課程設(shè)計報告《電力系統(tǒng)潮流上機》課程設(shè)計報告院系:電氣與電子工程學(xué)院班級:電氣1405學(xué)號:1141180505學(xué)生姓名:指導(dǎo)教師:孫英云設(shè)計周數(shù):兩周成績:日期:2021年7月5日一、課程設(shè)計的目的與要求培養(yǎng)學(xué)生的電力系統(tǒng)潮流計算機編程能力,掌握計算機潮流計算的相關(guān)知識二、設(shè)計正文掌握計算機潮流計算的原理:復(fù)習(xí)電力系統(tǒng)分析基礎(chǔ)中潮流的計算機算法一章,重點掌握節(jié)點分類、潮流算法介紹詳細閱讀牛拉法部分,掌握潮流方程(極坐標(biāo)、直角坐標(biāo))的寫法,掌握雅可比矩陣的公式及排列順序和潮流方程、變量順序的關(guān)系,掌握迭代法收斂條件及迭代法的基本原理設(shè)計程序框圖,劃分功能模塊、并對每個模塊的輸入輸出量進行細化。編寫計算機潮流計算程序?qū)W習(xí)了解IEEE標(biāo)準(zhǔn)格式數(shù)據(jù),學(xué)習(xí)掌握C/C++讀取數(shù)據(jù)的方法設(shè)計計算機數(shù)據(jù)存儲母線、支路數(shù)據(jù)的結(jié)構(gòu),并將所讀取的數(shù)據(jù)存放于所設(shè)計的結(jié)構(gòu)當(dāng)中學(xué)習(xí)節(jié)點排序、節(jié)點導(dǎo)納陣計算方法,編寫節(jié)點導(dǎo)納陣生成模塊編寫潮流方程不平衡量計算模塊編寫雅可比矩陣生成子模塊利用給定的pfMatrix類,編寫修正量計算模塊實現(xiàn)潮流計算主程序,并利用IEEE標(biāo)準(zhǔn)節(jié)點數(shù)據(jù)進行校驗,要求能夠輸出計算結(jié)果、支路潮流等必要信息思考題1.潮流計算的方法有哪些?各有何特點?答:潮流計算分為簡單電力網(wǎng)絡(luò)的手算和復(fù)雜電力網(wǎng)絡(luò)的機算兩大類,其中機算又有高斯-賽德爾法、牛頓-拉夫遜法和P-Q分解法。各方法特點如下所示:手算求解潮流一般只用于簡單的網(wǎng)絡(luò)中,計算量大,對于多節(jié)點的網(wǎng)絡(luò)用手算一般難以解決問題。但是通過手算可以對物理概念的理解,還可以在運用計算機計算前由手算的形式求取某些原始數(shù)據(jù)。方法高斯-賽德爾法牛頓-拉夫遜法P-Q分解法初值要求不高高高迭代次數(shù)多少多收斂速度慢較快最快精度三者一樣應(yīng)用早期應(yīng)用多,現(xiàn)在較少廣泛應(yīng)用應(yīng)用較多2.如果交給你一個任務(wù),請你用已有的潮流計算軟件計算北京城市電網(wǎng)的潮流,你應(yīng)該做哪些工作?(收集哪些數(shù)據(jù),如何整理,計算結(jié)果如何分析)答:①.所需要收集的數(shù)據(jù):A.電網(wǎng)中所有節(jié)點的數(shù)據(jù):a.各節(jié)點的類型,包括平衡節(jié)點、PV節(jié)點、PQ節(jié)點b.對于平衡節(jié)點要了解節(jié)點的電壓大小相位、及節(jié)點所能提供的最大最小有功無功功率c.PV節(jié)點要知道節(jié)點電壓大小注入有功功率及節(jié)點所能提供的最大和最小無功功.率d.PQ節(jié)點要知道節(jié)點的注入有功和無功功率B.電網(wǎng)中所有支路的數(shù)據(jù):a.各支路類型,即是否含有變壓器b.各支路的電阻、電感、電納c.各變壓器的變比。②.?dāng)?shù)據(jù)整理:將上述數(shù)據(jù)資料進行分類整理,并為每個節(jié)點及支路編上編號。將整理的結(jié)果寫本錢實驗中所要求的格式(原始數(shù)據(jù)的txt文檔),再用本實驗所編制的程序進行求解,得到各節(jié)點電壓、相位,各線路傳輸功率、損耗,平衡節(jié)點注入功率等數(shù)值。③.計算結(jié)果分析:考慮PQ節(jié)點的電壓是否過高或過低;分析PV節(jié)點的電壓幅值是否正常及無功功率是否超出范圍;分析平衡節(jié)點有功、無功功率是否在節(jié)點所能提供的范圍之內(nèi);分析給定之路的功率,看是否超出線路的最大傳輸容量;分析整個系統(tǒng)的網(wǎng)損是否達到標(biāo)準(zhǔn)。3.設(shè)計中遇到的問題和解決的方法。c++好久沒用,有些生疏。經(jīng)過復(fù)習(xí)與百度,漸漸回憶起來。潮流計算機解法已經(jīng)遺忘,經(jīng)過復(fù)習(xí)查書,很快熟悉起來。對老師的思路不是很理解,經(jīng)過與同學(xué)一起探討,得到了正確答案。課程設(shè)計總結(jié)或結(jié)論2021下半年學(xué)歷電力系統(tǒng)潮流計算,當(dāng)時并沒有編程實踐,就背了背矩陣公式?,F(xiàn)在真讓我們上手實踐,感覺還是略有難度,很有挑戰(zhàn)性,畢竟平時沒多少時機接觸程序。通過這兩周的摸索與交流,最終完成了潮流的編程計算。由于是在老師的工作基礎(chǔ)上進行補充與改造,所以要讀懂老師的代碼。我覺得老師的注釋還是太少,而且還是英文(雖然英語也能看懂,但還是覺得中文環(huán)境用中文好)。在對節(jié)點數(shù)據(jù)的處理上,我們對老師的思路并不能感到理解,因此在后面雅克比矩陣生成與不平衡量計算模塊繞了些許彎路,我最后還是沒采用老師的方法。除了算法的設(shè)計外,最惱人的當(dāng)屬開發(fā)工具了,機房是vs2021,而我電腦上是vc++6.0與vs2021,一開始用vc寫,然后出了一個迷之bug,換到了vs2021才解決。但我電腦裝上vs2021卻因為2021的存在無法運行,vs2021也無法運行我在2021下寫好的程序。不想卸掉花老長時間才裝上的巨大2021,為此浪費了許多時間,很令人生氣。能夠親手實踐電力系統(tǒng)潮流的計算機計算,還是學(xué)到了很多知識,對潮流計算那一部分知識又有了更深的印象。四、參考文獻《電力系統(tǒng)穩(wěn)態(tài)分析》,陳珩,中國電力出版社,2021年,第三版;《高等電力網(wǎng)絡(luò)分析》,張伯明,陳壽孫,嚴(yán)正,清華大學(xué)出版社,2021年,第二版《電力系統(tǒng)計算:電子數(shù)字計算機的應(yīng)用》,西安交通大學(xué)等合編。北京:水利電力出版社;《現(xiàn)代電力系統(tǒng)分析》,王錫凡主編,科學(xué)出版社;程序#include<string>#include<iostream>#include<fstream>#include"pf.h"usingnamespacestd;voidmain(){ pfA;A.readDataFromFile("009ieee.dat");A.initPFData();A.makeYMatrix();A.makeJacobi();A.solveLF();A.outputResult(); system("pause");}#include"pf.h"usingnamespacestd;pf::pf(void){ m_Line=NULL; m_Bus=NULL; m_Bus_newIdx=NULL; m_pv_Num=0; m_sw_Num=0; m_pq_Num=0;}pf::~pf(void){ if(m_Line!=NULL)delete[]m_Line; if(m_Bus!=NULL)delete[]m_Bus; if(m_Bus_newIdx!=NULL)delete[]m_Bus_newIdx;}intpf::readDataFromFile(stringfileName){ inti; stringstrLine,strTemp; ifstreamfin; //openfiletoread; fin.open(fileName.c_str()); if(!fin.fail()) { //1.readSBase; getline(fin,strLine); strTemp.assign(strLine,31,6); m_SBase=atof(strTemp.c_str()); //2.readBusDatahere;//2.1readBusnum; getline(fin,strLine); size_tpos_begin,pos_end; pos_begin=strLine.find("FOLLOWS"); pos_begin=pos_begin+size_t(10); pos_end=strLine.find("ITEM"); strTemp=strLine.substr(pos_begin,pos_end-pos_begin); m_Bus_Num=atoi(strTemp.c_str()); //2.2readeachbusdatahere //allocatememoryform_Bus m_Bus=newBus[m_Bus_Num]; m_Bus_newIdx=newint[m_Bus_Num]; for(inti=0;i<m_Bus_Num;i++) { getline(fin,strLine); strTemp=strLine.substr(0,4); //readbusnum m_Bus[i].Num=atoi(strTemp.c_str()); //readbusName; strTemp=strLine.substr(5,7); m_Bus[i].Name=strTemp; //readbustypePQ:Type=1;PV:Type=2;swing:Type=3; //判斷條件YY strTemp=strLine.substr(24,2); if(atoi(strTemp.c_str())<=1) { m_Bus[i].Type=1;m_pq_Num++; } elseif(atoi(strTemp.c_str())==2) { m_Bus[i].Type=2; m_pv_Num++; } elseif(atoi(strTemp.c_str())==3) { m_Bus[i].Type=3; m_sw_Num++; } //readbusVoltage strTemp=strLine.substr(27,6); m_Bus[i].V=atof(strTemp.c_str()); //readbusangle strTemp=strLine.substr(33,7); m_Bus[i].theta=atof(strTemp.c_str())/180*3.1415926; //readbusLoadP strTemp=strLine.substr(40,9); m_Bus[i].LoadP=atof(strTemp.c_str())/m_SBase; //readbusLoadQ strTemp=strLine.substr(49,10); m_Bus[i].LoadQ=atof(strTemp.c_str())/m_SBase; //readbusGenP strTemp=strLine.substr(59,8); m_Bus[i].GenP=atof(strTemp.c_str())/m_SBase; //readbusGenQstrTemp=strLine.substr(67,8); m_Bus[i].GenQ=atof(strTemp.c_str())/m_SBase; //readbusShuntconductanceG strTemp=strLine.substr(106,8); //readbusShuntsusceptanceBstrTemp=strLine.substr(114,8);} //3.readLineDatahere; //3.1readLinenum; getline(fin,strLine); getline(fin,strLine); pos_begin=strLine.find("FOLLOWS"); pos_begin=pos_begin+size_t(10); pos_end=strLine.find("ITEM"); strTemp=strLine.substr(pos_begin,pos_end-pos_begin); m_Line_Num=atoi(strTemp.c_str()); //3.2readeachlinedata; m_Line=newLine[m_Line_Num]; for(i=0;i<m_Line_Num;i++) { getline(fin,strLine); //readTapbusnumber strTemp=strLine.substr(0,4); m_Line[i].NumI=atoi(strTemp.c_str()); //readZbusnumber strTemp=strLine.substr(5,4); m_Line[i].NumJ=atoi(strTemp.c_str()); //readlinetype strTemp=strLine.substr(18,1); m_Line[i].Type=atoi(strTemp.c_str()); //readlineresistanceR strTemp=strLine.substr(19,10); m_Line[i].R=atof(strTemp.c_str()); //readlinereactanceX strTemp=strLine.substr(29,11); m_Line[i].X=atof(strTemp.c_str()); //readlinechargingB strTemp=strLine.substr(40,10); m_Line[i].B=atof(strTemp.c_str()); //readtransformerratio strTemp=strLine.substr(76,6); m_Line[i].K=atof(strTemp.c_str()); }//4.closethefile; fin.close(); } else cout<<"fileopenfail!"<<endl; return0;}intpf::initPFData(){ //accordingtoPage132ofrefbook3, //reindexthebusnumasethesequence[PQPVSW]; intiPQ,iPV,iSW; iPQ=0; iPV=0; iSW=0; inti; for(i=0;i<m_Bus_Num;i++)//按PQPVSW排序 { switch(m_Bus[i].Type) { case1: m_Bus_newIdx[i]=iPQ; iPQ++; break; case2: m_Bus_newIdx[i]=iPV+m_pq_Num; iPV++; break; case3: m_Bus_newIdx[i]=iSW+m_pq_Num+m_pv_Num; iSW++; break; } } for(i=0;i<m_Bus_Num;i++) cout<<m_Bus_newIdx[i]<<endl; //herewegivethesizeofJacobimatrix; m_Jacobi.setSize(2*m_pq_Num+m_pv_Num,2*m_pq_Num+m_pv_Num); m_Matrix_G.setSize(m_Bus_Num,m_Bus_Num); m_Matrix_B.setSize(m_Bus_Num,m_Bus_Num); return0;}intpf::getBusIdx(intbusNum){ //returntheindexofbusfrombusNum inti,idx=-1; for(i=0;i<m_Bus_Num;i++) { if(m_Bus[i].Num==busNum) idx=i; } returnidx;}intpf::makeYMatrix(){ //TODO inti; floatLine_G; floatLine_B; for(i=0;i<m_Line_Num;i++) { Line_G=m_Line[i].R/(m_Line[i].R*m_Line[i].R+m_Line[i].X*m_Line[i].X);Line_B=-m_Line[i].X/(m_Line[i].R*m_Line[i].R+m_Line[i].X*m_Line[i].X); if(m_Line[i].Type!=2) { //m_Matrix_G.DumpInfo("here");m_Matrix_G(getBusIdx(m_Line[i].NumI),getBusIdx(m_Line[i].NumI))=m_Matrix_G(getBusIdx(m_Line[i].NumI),getBusIdx(m_Line[i].NumI))+Line_G; m_Matrix_G(getBusIdx(m_Line[i].NumI),getBusIdx(m_Line[i].NumJ))+=-Line_G;m_Matrix_G(getBusIdx(m_Line[i].NumJ),getBusIdx(m_Line[i].NumI))+=-Line_G; m_Matrix_G(getBusIdx(m_Line[i].NumJ),getBusIdx(m_Line[i].NumJ))=m_Matrix_G(getBusIdx(m_Line[i].NumJ),getBusIdx(m_Line[i].NumJ))+Line_G; m_Matrix_B(getBusIdx(m_Line[i].NumI),getBusIdx(m_Line[i].NumI))=m_Matrix_B(getBusIdx(m_Line[i].NumI),getBusIdx(m_Line[i].NumI))+Line_B+m_Line[i].B/2; m_Matrix_B(getBusIdx(m_Line[i].NumI),getBusIdx(m_Line[i].NumJ))+=-Line_B; m_Matrix_B(getBusIdx(m_Line[i].NumJ),getBusIdx(m_Line[i].NumI))+=-Line_B; m_Matrix_B(getBusIdx(m_Line[i].NumJ),getBusIdx(m_Line[i].NumJ))=m_Matrix_B(getBusIdx(m_Line[i].NumJ),getBusIdx(m_Line[i].NumJ))+Line_B+m_Line[i].B/2; } else { m_Matrix_G(getBusIdx(m_Line[i].NumI),getBusIdx(m_Line[i].NumI))=m_Matrix_G(getBusIdx(m_Line[i].NumI),getBusIdx(m_Line[i].NumI))+Line_G/(m_Line[i].K*m_Line[i].K); m_Matrix_G(getBusIdx(m_Line[i].NumI),getBusIdx(m_Line[i].NumJ))+=-Line_G/m_Line[i].K;m_Matrix_G(getBusIdx(m_Line[i].NumJ),getBusIdx(m_Line[i].NumI))+=-Line_G/m_Line[i].K; m_Matrix_G(getBusIdx(m_Line[i].NumJ),getBusIdx(m_Line[i].NumJ))=m_Matrix_G(getBusIdx(m_Line[i].NumJ),getBusIdx(m_Line[i].NumJ))+Line_G; m_Matrix_B(getBusIdx(m_Line[i].NumI),getBusIdx(m_Line[i].NumI))=m_Matrix_B(getBusIdx(m_Line[i].NumI),getBusIdx(m_Line[i].NumI))+Line_B/(m_Line[i].K*m_Line[i].K); m_Matrix_B(getBusIdx(m_Line[i].NumI),getBusIdx(m_Line[i].NumJ))+=-Line_B/m_Line[i].K; m_Matrix_B(getBusIdx(m_Line[i].NumJ),getBusIdx(m_Line[i].NumI))+=-Line_B/m_Line[i].K; m_Matrix_B(getBusIdx(m_Line[i].NumJ),getBusIdx(m_Line[i].NumJ))=m_Matrix_B(getBusIdx(m_Line[i].NumJ),getBusIdx(m_Line[i].NumJ))+Line_B; } } m_Matrix_G.outputMatrixtoFile("G.txt");//實部 m_Matrix_B.outputMatrixtoFile("B.txt");//虛部 return0;}intpf::makeJacobi(){ intequNum=2*m_pq_Num+m_pv_Num; inti,j,k; doubleH,J,N,L; //initJacobimatrix; for(i=0;i<equNum;i++) { for(j=0;j<equNum;j++) { m_Jacobi(i,j)=0.0; } } for(i=0;i<m_Bus_Num;i++) { for(j=0;j<m_Bus_Num;j++) { H=0.0; J=0.0; L=0.0; N=0.0; if(i==j) { for(intk=0;k<m_Bus_Num;k++) { if(i!=k) { //H+=-m_Bus[i].V*m_Bus[k].V*(m_Matrix_G(getBusIdx(m_Bus[i].Num),getBusIdx(m_Bus[k].Num))*sin(m_Bus[i].theta-m_Bus[k].theta)-m_Matrix_B(getBusIdx(m_Bus[i].Num),getBusIdx(m_Bus[k].Num))*cos(m_Bus[i].theta-m_Bus[k].theta)); //J+=m_Bus[i].V*m_Bus[k].V*(m_Matrix_G(getBusIdx(m_Bus[i].Num),getBusIdx(m_Bus[k].Num))*cos(m_Bus[i].theta-m_Bus[k].theta)+m_Matrix_B(getBusIdx(m_Bus[i].Num),getBusIdx(m_Bus[k].Num))*sin(m_Bus[i].theta-m_Bus[k].theta)); //N+=m_Bus[i].V*m_Bus[k].V*(m_Matrix_G(getBusIdx(m_Bus[i].Num),getBusIdx(m_Bus[k].Num))*cos(m_Bus[i].theta-m_Bus[k].theta)+m_Matrix_B(getBusIdx(m_Bus[i].Num),getBusIdx(m_Bus[k].Num))*sin(m_Bus[i].theta-m_Bus[k].theta)); //L+=m_Bus[i].V*m_Bus[k].V*(m_Matrix_G(getBusIdx(m_Bus[i].Num),getBusIdx(m_Bus[k].Num))*sin(m_Bus[i].theta-m_Bus[k].theta)-m_Matrix_B(getBusIdx(m_Bus[i].Num),getBusIdx(m_Bus[k].Num))*cos(m_Bus[i].theta-m_Bus[k].theta)); H+=-m_Bus[i].V*m_Bus[k].V*(m_Matrix_G(i,k)*sin(m_Bus[i].theta-m_Bus[k].theta)-m_Matrix_B(i,k)*cos(m_Bus[i].theta-m_Bus[k].theta)); J+=m_Bus[i].V*m_Bus[k].V*(m_Matrix_G(i,k)*cos(m_Bus[i].theta-m_Bus[k].theta)+m_Matrix_B(i,k)*sin(m_Bus[i].theta-m_Bus[k].theta)); N+=m_Bus[i].V*m_Bus[k].V*(m_Matrix_G(i,k)*cos(m_Bus[i].theta-m_Bus[k].theta)+m_Matrix_B(i,k)*sin(m_Bus[i].theta-m_Bus[k].theta)); L+=m_Bus[i].V*m_Bus[k].V*(m_Matrix_G(i,k)*sin(m_Bus[i].theta-m_Bus[k].theta)-m_Matrix_B(i,k)*cos(m_Bus[i].theta-m_Bus[k].theta)); } } //N+=2*m_Bus[i].V*m_Bus[i].V*m_Matrix_G(getBusIdx(m_Bus[i].Num),getBusIdx(m_Bus[i].Num)); //L+=-2*m_Bus[i].V*m_Bus[i].V*m_Matrix_B(getBusIdx(m_Bus[i].Num),getBusIdx(m_Bus[i].Num)); N+=2*m_Bus[i].V*m_Bus[i].V*m_Matrix_G(i,i); L+=-2*m_Bus[i].V*m_Bus[i].V*m_Matrix_B(i,i); } else { //H=m_Bus[i].V*m_Bus[j].V*(m_Matrix_G(getBusIdx(m_Bus[i].Num),getBusIdx(m_Bus[j].Num))*sin(m_Bus[i].theta-m_Bus[j].theta)-m_Matrix_B(getBusIdx(m_Bus[i].Num),getBusIdx(m_Bus[j].Num))*cos(m_Bus[i].theta-m_Bus[j].theta)); //J=-m_Bus[i].V*m_Bus[j].V*(m_Matrix_G(getBusIdx(m_Bus[i].Num),getBusIdx(m_Bus[j].Num))*cos(m_Bus[i].theta-m_Bus[j].theta)+m_Matrix_B(getBusIdx(m_Bus[i].Num),getBusIdx(m_Bus[j].Num))*sin(m_Bus[i].theta-m_Bus[j].theta)); //N=-J; //L=H; H=m_Bus[i].V*m_Bus[j].V*(m_Matrix_G(i,j)*sin(m_Bus[i].theta-m_Bus[j].theta)-m_Matrix_B(i,j)*cos(m_Bus[i].theta-m_Bus[j].theta)); J=-m_Bus[i].V*m_Bus[j].V*(m_Matrix_G(i,j)*cos(m_Bus[i].theta-m_Bus[j].theta)+m_Matrix_B(i,j)*sin(m_Bus[i].theta-m_Bus[j].theta)); N=-J; L=H; } //雅可比矩陣 inta,b; switch(m_Bus[i].Type) { case1://PQbus; switch(m_Bus[j].Type) { case1://PQbus //HNJLfourelements m_Jacobi(2*m_Bus_newIdx[i],2*m_Bus_newIdx[j])=H; m_Jacobi(2*m_Bus_newIdx[i],2*m_Bus_newIdx[j]+1)=N; m_Jacobi(2*m_Bus_newIdx[i]+1,2*m_Bus_newIdx[j])=J; m_Jacobi(2*m_Bus_newIdx[i]+1,2*m_Bus_newIdx[j]+1)=L; break; case2://PVbus //HJtwoelements m_Jacobi(2*m_Bus_newIdx[i],m_Bus_newIdx[j]+m_pq_Num)=H; m_Jacobi(2*m_Bus_newIdx[i]+1,m_Bus_newIdx[j]+m_pq_Num)=J; break; case3://SWbus break; } break; case2://PVbus; switch(m_Bus[j].Type) { case1://PQbus //HNtwoelements m_Jacobi(m_Bus_newIdx[i]+m_pq_Num,2*m_Bus_newIdx[j])=H; m_Jacobi(m_Bus_newIdx[i]+m_pq_Num,2*m_Bus_newIdx[j]+1)=N; break; case2://PVbus //H,oneelement m_Jacobi(m_Bus_newIdx[i]+m_pq_Num,m_Bus_newIdx[j]+m_pq_Num)=H; break; case3://SWbus break; } break; case3://SWbus; break; } } } ofstreamfout("J.txt"); for(inti=0;i<equNum;i++) { for(intj=0;j<equNum;j++) fout<<setw(12)<<m_Jacobi(i,j)<<""; fout<<endl; } fout.close(); return0;}intpf::solveLF(){ //TODO inti; intequNum=2*m_pq_Num+m_pv_Num; double*bph=newdouble[equNum]; //1.initialize for(i=0;i<m_Bus_Num;i++) { switch(m_Bus[i].Type) { case1://PQnode { m_Bus[i].V=1; m_Bus[i].theta=0; break; } case2://PVnode m_Bus[i].theta=0; break; case3://SWnode break; } } //2.iterate intmaxIter=20; intp,k; for(i=0;i<maxIter;i++) { //2.1calDeltaS if(calcDeltaS(bph)==1)//判斷是否收斂 { cout<<"一共迭代"<<i+1<<"次收斂"<<endl; break; } //2.2calJacobi; cout<<"第"<<i+1<<"次"<<"雅可比矩陣為"<<endl; this->makeJacobi(); m_Jacobi.outputMatrix(); m_Jacobi.outputMatrixtoFile("Jacobi.txt"); //2.3outputdeltaftoscreen m_Jacobi.solve(equNum,bph); printf("第%d次修正方程為\n",i+1); for(k=0;k<2*m_pq_Num+m_pv_Num;k++) { printf("%7.7f\n",bph[k]); } printf("\n"); printf("第%d次不平衡量為\n",i+1); ofstreamfout("bph.txt"); intp; for(p=0;p<equNum;p++) fout<<bph[p]<<"\n"; fout<<endl; fout.close(); //2.4updatevariables更新電壓相角 /* for(intp=0;p<m_Bus_Num;p++) { if(m_Bus[p].Type==1) { m_Bus[p].theta+=bph[2*(p-m_pv_Num-1)]; m_Bus[p].V+=bph[2*(p-m_pv_Num)-1]*m_Bus[p].V; } if(m_Bus[p].Type==2) { m_Bus[p].theta+=bph[p+2*m_pq_Num-1]; } } */ for(p=0;p<m_Bus_Num;p++) { switch(m_Bus[p].Type) { case1://PQnode { m_Bus[p].theta=m_Bus[p].theta+bph[2*m_Bus_newIdx[p]]; m_Bus[p].V=m_Bus[p].V+bph[2*m_Bus_newIdx[p]+1]*m_Bus[p].V; break; } case2://PVnode m_Bus[p].theta=m_Bus[p].theta+bph[m_pq_Num+m_Bus_newIdx[p]]; break; case3://SWnode break; } } } //3.outputtheresult.if(calcDeltaS(bph)!=1) printf("outputunsolved\n"); return0;}intpf::calcDeltaS(double*bph){ inti,j,k; intanswer=-1; doublemaximum; for(i=0;i<2*m_pq_Num+m_pv_Num;i++) bph[i]=0; for(i=0;i<m_Bus_Num;i++) { switch(m_Bus[i].Type) { case1: //PQnode; for(k=0;k<m_Bus_Num;k++) { //activepowerunblance; bph[2*m_Bus_newIdx[i]]=bph[2*m_Bus_newIdx[i]]+m_Bus[i].V*m_Bus[k].V*(m_Matrix_G(getBusIdx(m_Bus[i].Num),getBusIdx(m_Bus[k].Num))*cos(m_Bus[i].theta-m_Bus[k].theta)+m_Matrix_B(getBusIdx(m_Bus[i].Num),getBusIdx(m_Bus[k].Num))*sin(m_Bus[i].theta-m_Bus[k].theta)); //reactivepowerunblance; bph[2*m_Bus_newIdx[i]+1]=bph[2*m_Bus_newIdx[i]+1]+m_Bus[i].V*m_Bus[k].V*(m_Matrix_G(getBusIdx(m_Bus[i].Num),getBusIdx(m_Bus[k].Num))*sin(m_Bus[i].theta-m_Bus[k].theta)-m_Matrix_B(getBusIdx(m_Bus[i].Num),getBusIdx(m_Bus[k].Num))*cos(m_Bus[i].theta-m_Bus[k].theta)); } bph[2*m_Bus_newIdx[i]]=m_Bus[i].GenP-m_Bus[i].LoadP-bph[2*m_Bus_newIdx[i]]; bph[2*m_Bus_newIdx[i]+1]=m_Bus[i].GenQ-m_Bus[i].LoadQ-bph[2*m_Bus_newIdx[i]+1]; break; case2: //PVnode; for(k=0;k<m_Bus_Num;k++) { //activepowerunblance; bph[m_Bus_newIdx[i]+m_pq_Num]=bph[m_Bus_newIdx[i]+m_pq_Num]+m_Bus[i].V*m_Bus[k].V*(m_Matrix_G(getBusIdx(m_Bus[i].Num),getBusIdx(m_Bus[k].Num))*cos(m_Bus[i].theta-m_Bus[k].theta)+m_Matrix_B(getBusIdx(m_Bus[i].Num),getBusIdx(m_Bus[k].Num))*sin(m_Bus[i].theta-m_Bus[k].theta)); } bph[m_Bus_newIdx[i]+m_pq_Num]=m_Bus[i].GenP-m_Bus[i].LoadP-bph[m_Bus_newIdx[i]+m_pq_Num]; break; case3: //SWnode; break; } } maximum=bph[0]; for(i=0;i<2*m_pq_Num+m_pv_Num;i++) { printf("%7.9f\n",bph[i]); if(maximum<fabs(bph[i]))maximum=fabs(bph[i]); } printf("\n"); if(maximum<1e-6) answer=1; ofstreamfout("bph1.txt"); intp; for(p=0;p<2*m_pq_Num+m_pv_Num;p++) fout<<bph[p]<<"\n"; fout<<endl; fout.close(); returnanswer;}intpf::outputResult(){ ofstreamfout("Result.txt"); intp,q; for(p=0;p<m_Bus_Num;p++) { fout<<m_Bus[p].V<<"\t"; fout<<m_Bus[p].theta*180/3.14<<"\t"; fout<<endl; } fout.close(); intj; for(j=0;j<m_Bus_Num;j++) cout<<"節(jié)點"<<j+1<<"的電壓為"<<m_Bus[j].V<<"\t"<<"相角為"<<m_Bus[j].theta*180/3.14<<endl; return0;}#include"pfMatrix.h"pfMatrix::pfMatrix()//data_<--initializedbelow(afterthe'if/throw'statement){ m_row_num=0; m_col_num=0; m_value=NULL; m_idx=NULL;}pfMatrix::pfMatrix(introws,intcols):m_row_num(rows),m_col_num(cols)//data_<--initializedbelow(afterthe'if/throw'statement){ inti,j;if(rows<=0||cols<=0)throw("Matrixconstructorhaswrongsize");m_value=newdouble*[rows];m_idx=newint[m_row_num]; for(i=0;i<m_row_num;i++) { m_value[i]=newdouble[m_col_num]; m_idx[i]=0; }for(i=0;i<m_row_num;i++) for(j=0;j<m_col_num;j++) m_value[i][j]=0.0;}pfMatrix::~pfMatrix(){ for(inti=0;i<m_row_num;i++) delete[]m_value[i]; delete[]m_value; delete[]m_idx;}double&pfMatrix::operator()(introw,intcol){if(row>=m_row_num||col>=m_col_num){#ifdef_DEBUG_MATRIX charstrTemp[100]; sprintf(strTemp,"row=%5dcol=%5d,Matrixsubscriptoutofbounds\n",row,col);DumpInfo(strTemp);#endifthrow("constMatrixsubscriptoutofbounds");}returnm_value[row][col];}doublepfMatrix::operator()(introw,intcol)const{if(row>=m_row_num||col>=m_col_num){#ifdef_DEBUG_MATRIX charstrTemp[100]; sprintf(strTemp,"row=%5dcol=%5d,Matrixsubscriptoutofbounds",row,col);DumpInfo(strTemp);#endifthrow("constMatrixsubscriptoutofbounds");}returnm_value[row][col];}voidpfMatrix::outputMatrix(){ inti,j; for(i=0;i<m_row_num;i++) { for(j=0;j<m_col_num;j++) { printf("%7.3f\t",m_value[i][j]); }printf("\n");//hereistheendofline } printf("\n");}voidpfMatrix::LUdcmp(){ constdoubleTINY=1.0e-40; inti,imax,j,k; doublebig,temp; double*vv=newdouble[m_row_num]; doubled=1.0; for(i=0;i<m_row_num;i++){ big=0.0; for(j=0;j<m_row_num;j++) if((temp=abs(m_value[i][j]))>big)big=temp; if(big<TINY)throw("pfMatrix::singularmatrix"); vv[i]=1.0/big; } for(k=0;k<m_row_num;k++){ big=0.0; for(i=k;i<m_row_num;i++){ temp=vv[i]*abs(m_value[i][k]); if(temp>big){ big=temp; imax=i; } } if(k!=imax){ for(j=0;j<m_row_num;j++){ temp=m_value[imax][j]; m_value[imax][j]=m_value[k][j]; m_value[k][j]=temp; } d=-d; vv[imax]=vv[k]; } m_idx[k]=imax; if(m_value[k][k]==0.0)m_value[k][k]=TINY; for(i=k+1;i<m_row_num;i++){ temp=m_value[i][k]/=m_value[k][k]; for(j=k+1;j<m_row_num;j++) m_value[i][j]-=temp*m_value[k][j]; } } delete[]vv;}voidpfMatrix::solve(intn,double*b){ LUdcmp(); inti,ii=0,ip,j; doublesum; if(m_col_num!=n||m_row_num!=n) {#ifdef_DEBUG_MATRIX charstrTemp[100]; sprintf(strTemp,"thematrixis%5d*%d,butthevectoris%5d,soitcan'tbesolved!",m_col_num,m_row_num,n);DumpInfo(strTemp);#endif throw("pfMatrix::solvebadsizes"); } for(i=0;i<n;i++){ ip=m_idx[i]; sum=b[ip]; b[ip]=b[i]; if(ii!=0) for(j=ii-1;j<i;j++)sum-=m_value[i][j]*b[j]; elseif(sum!=0.0) ii=i+1; b[i]=sum; } for(i=n-1;i>=0;i--){ sum=b[i]; for(j=i+1;j<n;j++)sum-=m_value[i][j]*b[j]; b[i]=sum/m_value[i][i]; }}voidpfMatrix::setSize(introws,intcols){ inti,j;if(rows<=0||cols<=0)throw("Matrixconstructorhaswrongsize");m_row_num=rows;m_col_num=cols;m_value=newdouble*[rows];m_idx=newint[m_row_num]; for(i=0;i<m_row_num;i++) { m_value[i]=newdouble[m_col_num]; m_idx[i]=0; }for(i=0;i<m_row_num;i++) for(j=0;j<m_col_num;j++) m_value[i][j]=0.0;}voidpfMatrix::outputMatrixtoFile(stringfileName){ ofstreamfout(fileName.c_str()); inti,j; fout<<m_row_num<<"\t"<<m_col_num<<endl; for(i=0;i<m_row_num;i++) { for(j=0;j<m_col_num;j++) fout<<m_value[i][j]<<"\t"; fout<<endl; } fout.close();}voidpfMatrix::readMatrixFromFile(stringfileName){ ifstreamob(fileName.c_str()); inti,j; double*value; ob>>m_row_num>>m_col_num; value=newdouble[m_col_num]; setSize(m_row_num,m_col_num); for(i=0;i<m_row_num;i++) { for(j=0;j<m_col_num;j++) { ob>>value[j]; m_value[i][j]=value[j]; } } delete[]value;}voidpfMatrix::Tokenize(conststring&str,vector<string>&tokens,conststring&delimiters=""){//Skipdelimitersatbeginning.string::size_typelastPos=str.find_first_not_of(delimiters,0);//Findfirst"non-delimiter".string::size_typepos=str.find_first_of(delimiters,lastPos);while(string::npos!=pos||string::npos!=lastPos){//Foundatoken,addittothevector.tokens.push_back(str.substr(lastPos,pos-lastPos));//Skipdelimiters.Notethe"not_of"lastPos=str.find_first_not_of(delimiters,pos);//Findnext"non-delimiter"pos=str.find_first_of(delimiters,lastPos);}}///////////////////////////////////////////////////////// double**branchresistive;//支路功率有功 double**branchreactive;//支路功率無功 double**deltaresistive;//支路網(wǎng)損有功 double**deltareactive;//支路網(wǎng)損無功功率 double*PVreactive;//PV節(jié)點無功功率//分配內(nèi)存空間 branchresistive=(double**)malloc(m_Bus_Num*sizeof(double)); branchreactive=(double**)malloc(m_Bus_Num*sizeof(double)); deltaresistive=(double**)malloc(m_Bus_Num*sizeof(double)); deltareactive=(double**)malloc(m_Bus_Num*sizeof(double)); PVreactive=(double*)malloc(m_pv_Num*sizeof(double));for(i=0;i<m_Bus_Num;i++){branchresistive[i]=(double*)malloc(m_Bus_Num*sizeof(double));branchreactive[i]=(double*)malloc(m_Bus_Num*sizeof(double));deltaresistive[i]=(double*)malloc(m_Bus_Num*sizeof(double));deltareactive[i]=(double*)malloc(m_Bus_Num*sizeof(double));}//初始化數(shù)據(jù)for(i=0;i<m_pv_Num;i++){ PVreactive[i]=0.0;}for(i=0;i<m_Bus_Num;i++) for(j=0;j<m_Bus_Num;j++) { branchresistive[i][j]=0.0; branchreactive[i][j]=0.0; deltaresistive[i][j]=0.0;deltareactive[i][j]=0.0; } //計算各支路功率和網(wǎng)損 for(i=0;i<m_Bus_Num;i++) { for(j=0;j<m_Bus_Num;j++) { if(i!=j) { branchresistive[i][j]=-m_Bus[i].V*m_Bus[i].V*m_Matrix_G(i,j)+m_Bus[i].V*m_Bus[j].V*(m_Matrix_G(i,j)*cos(m_Bus[i].theta-m_Bus[j].theta)+m_Matrix_B(i,j)*sin(m_Bus[i].theta-m_Bus[j].theta)); branchreactive[i][j]=m_Bus[i].V*m_Bus[j].V*(m_Matrix_G(i,j)*sin(m_Bus[i].theta-m_Bus[j].theta)-m_Matrix_B(i,j)*cos(m_Bus[i].theta-m_Bus[j].theta))+m_Bus[i].V*m_Bus[i].V*(m_Matrix_B(i,j)); } } } for(i=0;i<m_Bus_Num;i++) { for(j=i+1;j<m_Bus_Num;j++) { deltaresistive[i][j]=branchresistive[i][j]+branchresistive[j][i]; deltareactive[i][j]=branchreactive[i][j]+branchreactive[j][i]; if(deltareactive[i][j]!=0)//對于彼此之間有支路的兩個節(jié)點,應(yīng)該計入對地導(dǎo)納m_Line[i].B/2的功率損耗,所以重新計算相應(yīng)的支路無功 { branchreactive[i][j]=m_Bus[i].V*m_Bus[j].V*(m_Matrix_G(i,j)*sin(m_Bus[i].theta-m_Bus[j].theta)-m_Matrix_B(i,j)*cos(m_Bus[i].theta-m_Bus[j].theta))+m_Bus[i].V*m_Bus[i].V*(m_Matrix_B(i,j)+m_Line[i].B/2); branchreactive[j][i]=m_Bus[i].V*m_Bus[j].V*(m_Matrix_G(j,i)*sin(m_Bus[j].theta-m_Bus[i].theta)-m_Matrix_B(j,i)*cos(m_Bus[j].theta-m_Bus[i].theta))+m_Bus[j].V*m_Bus[j].V*(m_Matrix_B(j,i)+m_Line[j].B/2); }} } for(i=0;i<m_Bus_Num;i++) { for(j=i+1;j<m_Bus_Num;j++) { deltareactive[i][j]=branchreactive[i][j]+branchreactive[j][i]; zongwangsunresistive=zongwangsunresistive+deltaresistive[i][j]; zongwangsunreactive=zongwangsunreactive+deltareactive[i][j]; }} //計算平衡節(jié)點功率及PV節(jié)點的無功功率 for(i=0;i<m_Bus_Num;i++) { if(m_Bus[i].Type==3) for(j=0;j<m_Bus_Num;j++) { SWresistive=m_Bus[i].V*m_Bus[j].V*(m_Matrix_G(i,j)*cos(m_Bus[j].theta)+m_Matrix_B(i,j)*sin(m_Bus[j].theta)); SWreactive=-m_Bus[i].V*m_Bus[j].V*(m_Matrix_G(i,j)*sin(m_Bus[j].theta)+m_Matrix_B(i,j)*cos(m_Bus[j].theta)); } if(m_Bus[i].Type==2) { for(j=0;j<m_Bus_Num;j++) { PVreactive[k]=PVreactive[k]+m_Bus[i].V*m_Bus[j].V*(m_Matrix_G(i,j)*sin(m_Bus[i].theta-m_Bus[j].theta)-m_Matrix_B(i,j)*cos(m_Bus[i].theta-m_Bus[j].theta)); } k++; } } //輸出支路功率 ofstreamfout1("branchpower.txt"); fout1<<setprecision(6)<<endl; for(p=0;p<m_Bus_Num;p++) { for(q=0;q<m_Bus_Num;q++) if((branchreactive[p][q]!=0)||(branchresistive[p][q]!=0)) fout1<<"S"<<p<<"-"<<q<<"支路:"<<setw(5)<<branchresistive[p][q]<<"+j"<<branchreactive[p][q]<<"\n"; fout1<<endl; } fout1.close();//輸出各支路網(wǎng)損和系統(tǒng)總網(wǎng)損 ofstreamfout2("wangsun.txt"); fout2<<setprecision(6)<<endl; for(p=0;p<m_Bus_Num;p++) { for(q=p+1;q<m_Bus_Num;q++) if((deltareactive[p][q]!=0)||(deltaresistive[p][q]!=0)) fout2<<p<<"-"<<q<<"支路:"<<setw(5)<<deltaresistive[p][q]<<"+j"<<deltareactive[p][q]<<endl; }fout2<<"總網(wǎng)損:"<<setw(5)<<zongwangsunresistive<<"+j"<<zongwangsunreactive<<endl;//輸出PV節(jié)點的無功功率 ofstreamfout3("PVreactive.txt"); fout3<<setprecision(6)<<endl; for(p=0;p<m_pv_Num;p++) { fout3<<"PV節(jié)點功率:"<<setw(5)<<"+j"<<PVreactive[p]<<endl; fout3<<endl; } fout3.close();//輸出平衡節(jié)點的有功和無功功率 ofstreamfout4("SWpower.txt"); fout4<<setprecision(6)<<endl; fout4<<setw(5)<<SWresistive<<"+j"<<SWreactive<<endl; fout4<<endl; fout4.close();return(0);}三、結(jié)果第一次雅克比矩陣:隨后兩次雅克比矩陣收斂后的電壓幅值相角迭代次數(shù):3各節(jié)點電壓幅值和相角:(節(jié)點類型3為平衡節(jié)點,2為PV節(jié)點,3為PQ節(jié)點)幅值相角節(jié)點類型3 1.040 節(jié)點類型2 節(jié)點類型2 節(jié)點類型1 節(jié)點類型1 節(jié)點類型1 節(jié)點類型1 節(jié)點類型1 節(jié)點類型1 各支路功率:(S1-6代表節(jié)點1流向節(jié)點6的功率)各支路網(wǎng)損與總的網(wǎng)損:(0-3支路代表0節(jié)點到3節(jié)點之間支路上損耗的功率)總網(wǎng)損平衡節(jié)點功率:0+j0PV節(jié)點的無功功率:PV節(jié)點功率:0.0665362+jPV節(jié)點功率:-0.108597+j
高考語文試卷一、語言文字運用(15分)1.在下面一段話的空缺處依次填入詞語,最恰當(dāng)?shù)囊唤M是(3分)提到桃花源,許多人會聯(lián)想到瓦爾登湖。真實的瓦爾登湖,早已成為▲的觀光勝地,梭羅的小木屋前也經(jīng)常聚集著▲的游客,不復(fù)有隱居之地的氣息。然而虛構(gòu)的桃花源一直就在我們的心中,哪怕▲在人潮洶涌的現(xiàn)代城市,也可以獲得心靈的寧靜。A.名聞遐邇聞風(fēng)而至雜居 B.名噪一時聞風(fēng)而至棲居C.名噪一時紛至沓來雜居 D.名聞遐邇紛至沓來棲居
溫馨提示
- 1. 本站所有資源如無特殊說明,都需要本地電腦安裝OFFICE2007和PDF閱讀器。圖紙軟件為CAD,CAXA,PROE,UG,SolidWorks等.壓縮文件請下載最新的WinRAR軟件解壓。
- 2. 本站的文檔不包含任何第三方提供的附件圖紙等,如果需要附件,請聯(lián)系上傳者。文件的所有權(quán)益歸上傳用戶所有。
- 3. 本站RAR壓縮包中若帶圖紙,網(wǎng)頁內(nèi)容里面會有圖紙預(yù)覽,若沒有圖紙預(yù)覽就沒有圖紙。
- 4. 未經(jīng)權(quán)益所有人同意不得將文件中的內(nèi)容挪作商業(yè)或盈利用途。
- 5. 人人文庫網(wǎng)僅提供信息存儲空間,僅對用戶上傳內(nèi)容的表現(xiàn)方式做保護處理,對用戶上傳分享的文檔內(nèi)容本身不做任何修改或編輯,并不能對任何下載內(nèi)容負(fù)責(zé)。
- 6. 下載文件中如有侵權(quán)或不適當(dāng)內(nèi)容,請與我們聯(lián)系,我們立即糾正。
- 7. 本站不保證下載資源的準(zhǔn)確性、安全性和完整性, 同時也不承擔(dān)用戶因使用這些下載資源對自己和他人造成任何形式的傷害或損失。
最新文檔
- 2024-2030年高純鈦公司技術(shù)改造及擴產(chǎn)項目可行性研究報告
- 2024-2030年鋁箔伸縮風(fēng)管公司技術(shù)改造及擴產(chǎn)項目可行性研究報告
- 2024-2030年電池管理系統(tǒng)公司技術(shù)改造及擴產(chǎn)項目可行性研究報告
- 2024-2030年水性金屬油墨搬遷改造項目可行性研究報告
- 2024年直播電商合作合同3篇
- 汽車維修承包合同
- 舞者聘用合同夜店駐場表演
- 居民樓外墻保溫施工合同
- 新手編劇培養(yǎng)合同
- 寺廟景觀綠化工程合同
- 全國第三屆職業(yè)技能大賽(數(shù)字孿生應(yīng)用技術(shù))選拔賽理論考試題庫(含答案)
- 應(yīng)用數(shù)理統(tǒng)計知到智慧樹章節(jié)測試課后答案2024年秋中國農(nóng)業(yè)大學(xué)
- 大國三農(nóng)II-農(nóng)業(yè)科技版智慧樹知到期末考試答案章節(jié)答案2024年中國農(nóng)業(yè)大學(xué)
- JBT 1472-2023 泵用機械密封 (正式版)
- 二級公立醫(yī)院績效考核三級手術(shù)目錄(2020版)
- 6人小品《沒有學(xué)習(xí)的人不傷心》臺詞完整版
- 部編本小學(xué)五年級上冊語文期末考試(選擇題)專項訓(xùn)練題及答案
- 讀《讓兒童在問題中學(xué)數(shù)學(xué)》有感范文三篇
- 陳述句改成雙重否定句(課堂PPT)
- 人教版六年級數(shù)學(xué)上冊總復(fù)習(xí)教案
- 自閉癥兒童行為檢核表學(xué)前版
評論
0/150
提交評論