1、华北电力大学潮流上机课程设计报告课程设计报告(20142015年度第一学期)名称:电力系统潮流上机院系:电气与电子工程学院班级:电气1215学号:学生姓名:指导教师:王莉丽设计周数:两周成绩:日期:2015年1月4日一、课程设计的目的与要求培养学生的电力系统潮流计算机编程能力,掌握计算机潮流计算的相关知识二、设计正文(详细内容见附录)1 手算2 计算机计算3 思考题三、课程设计总结或结论四、参考文献1. 电力系统分析基础,李庚银,机械工业出版社,2011年,第一版;2. 电力系统稳态分析,陈珩,中国电力出版社,2007年,第三版;附录(包括:1.手算过程及结果;2.计算机计算流程图、表格、数据
2、;3.思考题答案)附录1. 手算过程及结果2. 计算机计算流程图3.完整的潮流程序头文件(定义变量):#defineBus_Num9#defineLine_Num9#definePrecision1e-5structBus intNo; floatVoltage,Phase,GenP,GenQ,LoadP,LoadQ; intType;gBusBus_Num;structLine intNo,No_I,No_J; floatR,X,B,k;gLineLine_Num;floatgY_GBus_NumBus_Num,gY_BBus_NumBus_Num;floatgDelta_PBus_Num-
3、1,gDelta_QBus_Num-1,gDelta_PQ2*(Bus_Num-1);floatgJaccobi2*(Bus_Num-1)2*(Bus_Num-1);floatgDelta_fBus_Num-1,gDelta_eBus_Num-1,gDelta_fe2*(Bus_Num-1);floatgfBus_Num,geBus_Num;主程序:/flow.cpp:主项目文件#includestdafx.h#includeNEquation.h#includemath.h#includestdio.h#includeconfig.husingnamespaceSystem;voidtest
4、()NEquationob1; ob1.SetSize(2); ob1.Data(0,0)=1; ob1.Data(0,1)=2; ob1.Data(1,0)=2; ob1.Data(1,1)=1;ob1.Value(0)=4; ob1.Value(1)=6; ob1.Run();printf(x1=%fn,ob1.Value(0); printf(x2=%fn,ob1.Value(1);voidGetData()/ReadthedataFILE*fp; inti; fp=fopen(E:1121960726flowdatadata.txt,r); if(fp=NULL) printf(Can
5、notopenthefilenameddata.txtn); return; for(i=0;i=Bus_Num-1;i+) fscanf(fp,%d,%f,%f,%f,%f,%f,%f,%d,&gBusi.No,&gBusi.Voltage,&gBusi.Phase, &gBusi.GenP,&gBusi.GenQ,&gBusi.LoadP,&gBusi.LoadQ,&gBusi.Type); for(i=0;i=Line_Num-1;i+) fscanf(fp,%d,%d,%d,%f,%f,%f,%f,&gLinei.No,&gLinei.No_I,&gLinei.No_J, &gLine
6、i.R,&gLinei.X,&gLinei.B,&gLinei.k); fclose(fp);voidGetYMatrix()inti,j,bus1,bus2;floatr,x,d,g,b,g1,b1,g2,b2,g3,b3;FILE*fp;for(i=0;i=Bus_Num-1;i+)for(j=0;j=Bus_Num-1;j+)gY_Gij=0;gY_Bij=0;for(i=0;i=Line_Num-1;i+)if(gLinei.k=0)bus1=gLinei.No_I-1;bus2=gLinei.No_J-1;r=gLinei.R;x=gLinei.X;d=r*r+x*x;g=r/d;b
7、=-x/d;gY_Gbus1bus1=gY_Gbus1bus1+g; gY_Gbus2bus2=gY_Gbus2bus2+g; gY_Gbus1bus2=gY_Gbus1bus2-g; gY_Gbus2bus1=gY_Gbus2bus1-g;gY_Bbus1bus1=gY_Bbus1bus1+b+gLinei.B;gY_Bbus2bus2=gY_Bbus2bus2+b+gLinei.B;gY_Bbus1bus2=gY_Bbus1bus2-b;gY_Bbus2bus1=gY_Bbus2bus1-b;elsebus1=gLinei.No_I-1;bus2=gLinei.No_J-1;x=gLine
8、i.X;d=r*r+x*x;g=r/d;b=-x/d;g1=g/gLinei.k;b1=b/gLinei.k;g2=g*(1-gLinei.k)/(gLinei.k*gLinei.k); b2=b*(1-gLinei.k)/(gLinei.k*gLinei.k); g3=g*(gLinei.k-1)/gLinei.k;b3=b*(gLinei.k-1)/gLinei.k;gY_Gbus1bus1=gY_Gbus1bus1+g1+g2;gY_Gbus2bus2=gY_Gbus2bus2+g1+g3;gY_Gbus1bus2=gY_Gbus1bus2-g1;gY_Gbus2bus1=gY_Gbus
9、2bus1-g1;gY_Bbus1bus1=gY_Bbus1bus1+b1+b2;gY_Bbus2bus2=gY_Bbus2bus2+b1+b3;gY_Bbus1bus2=gY_Bbus1bus2-b1;gY_Bbus2bus1=gY_Bbus2bus1-b1;/outputtheYmatrix fp=fopen(E:1121960726flowdataymatrix.txt,w); if(fp=NULL) printf(Cannotopenthefilenamedymatrix.txtn); return; fprintf(fp,-YMatrix-n); for(i=0;i=Bus_Num-
10、1;i+) for(j=0;j=Bus_Num-1;j+) fprintf(fp,Y(%d,%d)=(%10.5f,%10.5f)n,i+1,j+1,gY_Gij,gY_Bij); fclose(fp); voidSetInitial() inti; for(i=0;i=Bus_Num-1;i+) if(gBusi.Type=3) gfi=gBusi.Voltage*sin(gBusi.Phase); gei=gBusi.Voltage*cos(gBusi.Phase); else gfi=0; gei=1; voidGetUnbalance()inti,j;FILE*fp;for(i=0;i
11、=Bus_Num-2;i+)gDelta_Pi=gBusi+1.GenP-gBusi+1.LoadP;if(gBusi+1.Type=2)/PV节2点?gDelta_Qi=gBusi+1.Voltage*gBusi+1.Voltage-(gei+1*gei+1+gfi+1*gfi+1);elsegDelta_Qi=gBusi+1.GenQ-gBusi+1.LoadQ;for(j=0;j=Bus_Num-1;j+)gDelta_Pi=gDelta_Pi-gei+1*(gY_Gi+1j*gej-gY_Bi+1j*gfj)-gfi+1*(gY_Gi+1j*gfj+gY_Bi+1j*gej);if(g
12、Busi+1.Type=1)/PQ节2点?gDelta_Qi=gDelta_Qi-gfi+1*(gY_Gi+1j*gej-gY_Bi+1j*gfj)+gei+1*(gY_Gi+1j*gfj+gY_Bi+1j*gej);for(i=0;i=Bus_Num-2;i+)/合?并?gDelta_PQ2*i=gDelta_Pi;gDelta_PQ2*i+1=gDelta_Qi;fp=fopen(E:1121960726flowdataunbalance.txt,w);if(fp=NULL)printf(无法打开文件:”unbalance.txtn);return;fprintf(fp,-Unbalanc
13、e-n);for(i=0;i=2*Bus_Num-3;i+)fprintf(fp,Unbalance%d=%10.5fn,i+1,gDelta_PQi);fclose(fp); voidGetJaccobi()inti,j;floatgaBus_Num-1,gbBus_Num-1;FILE*fp;for(i=0;i=Bus_Num-2;i+)/计算注入电流gai=0;gbi=0;for(j=0;j=Bus_Num-1;j+)gai=gai+gY_Gi+1j*gej-gY_Bi+1j*gfj;gbi=gbi+gY_Gi+1j*gfj+gY_Bi+1j*gej;for(i=0;i=Bus_Num-
14、2;i+)for(j=0;j=Bus_Num-2;j+)if(i!=j)gJaccobi2*i2*j=-gY_Bi+1j+1*gei+1+gY_Gi+1j+1*gfi+1; gJaccobi2*i2*j+1=gY_Gi+1j+1*gei+1+gY_Bi+1j+1*gfi+1; if(gBusi+1.Type=2)/PV节2点?gJaccobi2*i+12*j=0;gJaccobi2*i+12*j+1=0;else/PQgJaccobi2*i+12*j=-gJaccobi2*i2*j+1;gJaccobi2*i+12*j+1=gJaccobi2*i2*j;elsegJaccobi2*i2*j=-
15、gY_Bi+1j+1*gei+1+gY_Gi+1j+1*gfi+1+gbi; gJaccobi2*i2*j+1=gY_Gi+1j+1*gei+1+gY_Bi+1j+1*gfi+1+gai; if(gBusi+1.Type=2)/PV节2点?gJaccobi2*i+12*j=2*gfi+1;gJaccobi2*i+12*j+1=2*gei+1;else/PQ节点gJaccobi2*i+12*j=-gY_Gi+1j+1*gei+1-gY_Bi+1j+1*gfi+1+gai;gJaccobi2*i+12*j+1=-gY_Bi+1j+1*gei+1+gY_Gi+1j+1*gfi+1-gbi;fp=fo
16、pen(,w);if(fp=NULL)printf(无法打开文件:”jaccobi.txtn);return;fprintf(fp,-JaccobiMatrix-n);for(i=0;i=2*Bus_Num-3;i+)for(j=0;j=2*Bus_Num-3;j+)fprintf(fp,jaccobi(%d,%d)=%10.5fn,i+1,j+1,gJaccobiij);fclose(fp);voidGetRevised()inti,j;FILE*fp;NEquationob1;/解矩阵方程ob1.SetSize(2*(Bus_Num-1);for(i=0;i=2*Bus_Num-3;i+)
17、for(j=0;j=2*Bus_Num-3;j+)ob1.Data(i,j)=gJaccobiij;for(i=0;i=2*Bus_Num-3;i+)ob1.Value(i)=gDelta_PQi;ob1.Run();for(i=0;i=Bus_Num-2;i+)gDelta_fi=ob1.Value(2*i);gDelta_ei=ob1.Value(2*i+1);gDelta_fe2*i=gDelta_fi;gDelta_fe2*i+1=gDelta_ei;fp=fopen(E:1121960726flowdatarevised.txt,w);if(fp=NULL)printf(无法打开文件
18、:”revised.txtn);return;fprintf(fp,-Revised-n);for(i=0;i=2*Bus_Num-3;i+)fprintf(fp,revised%d=%10.5fn,i+1,gDelta_fei);fclose(fp);voidGetNewValue()inti;FILE*fp;for(i=0;i=Bus_Num-2;i+)gfi+1=gfi+1+gDelta_fi;gei+1=gei+1+gDelta_ei;fp=fopen(E:1121960726flowdatanewvalue.txt,w);if(fp=NULL)printf(无法打开文件:”newva
19、lue.txtn);return;fprintf(fp,-NewValue-n);for(i=0;i=Bus_Num-2;i+)fprintf(fp,f(%d)=%10.5f,e(%d)=%10.5fn,i+1,gfi+1,i+1,gei+1);fclose(fp);intmain(arrayargs)inti,Count_Num; floatmaxValue; /test(); GetData(); GetYMatrix(); SetInitial(); for(Count_Num=0;Count_Num=100;Count_Num+) GetUnbalance(); GetJaccobi(
20、); GetRevised(); GetNewValue(); maxValue=fabs(gDelta_fe0); for(i=1;i=2*(Bus_Num-1)-1;i+) if(maxValuefabs(gDelta_fei) maxValue=fabs(gDelta_fei); if(maxValuePrecision) break; printf(%dn,Count_Num); for(i=0;i=Bus_Num-1;i+) printf(%10.5fn,sqrt(gei*gei+gfi*gfi); while(true) return0;计算结果:(1)原始数据:(2)节点导纳矩阵: (3)Jacobi矩阵:(4)NewVoltageValue:(5)不平衡量:(6)修正量:(6)结果:3. 回答思考题1. 潮流计算的方法有哪些?各有何特点?2.如果交给你一个任务,请你用已有的潮流计算软件计算北京城市电网的潮流,你应该做哪些工作?(收集哪些数据,如何整理,计算结果如何分析)3.设计中遇到的问题和解决的办法。
copyright@ 2008-2022 冰豆网网站版权所有
经营许可证编号:鄂ICP备2022015515号-1