📄 writeiee.cpp
字号:
R=Eptr->G/(Eptr->G*Eptr->G+Eptr->B*Eptr->B);
X= -Eptr->B/(Eptr->G*Eptr->G+Eptr->B*Eptr->B);
Print(OutFile,1,9,6,R);
Print(OutFile,1,9,6,X);
if (Eptr->B1==Eptr->B2) Print(OutFile,1,9,5,Eptr->B1+Eptr->B2);
else Print(OutFile,1,9,5,0.);
Imax=ceil(Eptr->Imax*Sn);
if (Imax>99999) fprintf(OutFile,"99999");
else fprintf(OutFile," %5.0lf",Imax);
fprintf(OutFile,"%12s","");
if(strpbrk(Eptr->Type,"R")) {
if (Eptr->Cont->Num<=9999) sprintf(Num,"%4d",Eptr->Cont->Num);
else strcpy(Num,"****");
fprintf(OutFile," %4s",Num);
if (strpbrk(Eptr->Type,"PQNM")) fprintf(OutFile," 0 ");
else {
if(Eptr->Cont==Eptr->From||Eptr->Cont==Eptr->To) fprintf(OutFile," 0 ");
else fprintf(OutFile," 1 ");
}
} else fprintf(OutFile," 0 0 ");
if(strpbrk(Eptr->Type,"RT")) {
if(card) fprintf(OutFile,"\n");
if(Eptr->Tap) Print(OutFile,1,6,4,1/Eptr->Tap);
else Print(OutFile,1,6,4,0.);
Print(OutFile,1,7,2,Eptr->Ang/K3);
if(!strcmp(Eptr->Type,"RP") || !strcmp(Eptr->Type,"RM")) {
Print(OutFile,1,6,2,Eptr->Tmin/K3);
Print(OutFile,1,6,2,Eptr->Tmax/K3);
}
else if(strpbrk(Eptr->Type,"R")) {
Print(OutFile,1,6,2,Eptr->Tmin);
Print(OutFile,1,6,2,Eptr->Tmax);
}
else {
Print(OutFile,1,6,2,0.);
Print(OutFile,1,6,2,0.);
}
Print(OutFile,1,6,5,0.);
if(!strcmp(Eptr->Type,"RP") || !strcmp(Eptr->Type,"RQ")) {
Print(OutFile,1,6,5,Eptr->Cvar*Sn);
Print(OutFile,1,6,5,Eptr->Cvar*Sn);
}
else if(strpbrk(Eptr->Type,"NM")) {
Print(OutFile,1,6,5,Eptr->Min*Sn);
Print(OutFile,1,6,5,Eptr->Max*Sn);
}
else if(!strcmp(Eptr->Type,"R")) {
Print(OutFile,1,6,5,Eptr->Cont->V);
Print(OutFile,1,6,5,Eptr->Cont->V);
}
else if(strpbrk(Eptr->Type,"V")) {
Print(OutFile,1,6,5,Eptr->Cont->Vmin);
Print(OutFile,1,6,5,Eptr->Cont->Vmax);
}
else {
Print(OutFile,1,6,5,0.);
Print(OutFile,1,6,5,0.);
}
}
fprintf(OutFile,"\n");
}
fprintf(OutFile,"-999\n");
/* ------------------------- Area results ---------------------------*/
fprintf(OutFile,"LOSS ZONES FOLLOW %5d ITEMS\n",0);
fprintf(OutFile,"-99\n");
if(Narea>1) fprintf(OutFile,"INTERCHANGE DATA FOLLOWS %5d ITEMS\n",Narea);
else fprintf(OutFile,"INTERCHANGE DATA FOLLOWS %5d ITEMS\n",0);
if(Narea>1) for(Aptr=dataPtr->Area;Aptr!=NULL;Aptr=Aptr->Next){
if (Aptr->N<=99) sprintf(Area,"%2d",Aptr->N);
else strcpy(Area,"**");
if (Aptr->BSptr->Num<=9999) sprintf(Num,"%4d",Aptr->BSptr->Num);
else strcpy(Num,"****");
fprintf(OutFile,"%2s %4s %12s",Area,Num,Aptr->BSptr->Name);
Print(OutFile,1,7,1,Aptr->P*Sn);
fprintf(OutFile,"%15s %30s\n","",Aptr->Name);
}
fprintf(OutFile,"-9\n");
fprintf(OutFile,"TIE LINES FOLLOW %5d ITEMS\n",Nties);
if(Nties) for(Eptr=dataPtr->Element;Eptr!=NULL;Eptr=Eptr->Next){
if(Eptr->From->Area!=Eptr->To->Area) {
ACptr=Eptr->Meter;
if (ACptr->Num<=9999) sprintf(Num,"%4d",ACptr->Num);
else strcpy(Num,"****");
if (ACptr->Area->N<=99) sprintf(Area,"%2d",ACptr->Area->N);
else strcpy(Area,"**");
fprintf(OutFile,"%4s %2s",Num,Area);
if (Eptr->Meter==Eptr->From) ACptr=Eptr->To;
else ACptr=Eptr->From;
if (ACptr->Num<=9999) sprintf(Num,"%4d",ACptr->Num);
else strcpy(Num,"****");
if (ACptr->Area->N<=99) sprintf(Area,"%2d",ACptr->Area->N);
else strcpy(Area,"**");
fprintf(OutFile," %4s %2s %1s\n",Num,Area,Eptr->Ckt);
}
}
fprintf(OutFile,"-999\n");
/* --------------------- DC bus results -----------------------------*/
for(DCptrR=dataPtr->DCbus;DCptrR!=NULL;DCptrR=DCptrR->Next){
DCptrI=DCptrR->To;
if(!strcmp(DCptrR->Type,"R")){
Vn=DCptrR->Vn; In=Sn/Vn;
DCptrR->Xc=DCptrR->Xc*Vn/In/DCptrR->Nbr;
DCptrI->Xc=DCptrI->Xc*Vn/In/DCptrI->Nbr;
DCptrI->Ntrf=DCptrI->Ntrf*Vn/DCptrI->AC->KV;
DCptrR->Ntrf=DCptrR->Ntrf/DCptrR->Nbr;
DCptrI->Ntrf=DCptrI->Ntrf/DCptrI->Nbr;
for(i=1;i<=2;i++){
if(i==1) DCptr=DCptrR;
else DCptr=DCptrI;
fprintf(OutFile,"BD %8sGROUND %12s",DCptr->Name,DCptr->AC->Name);
fprintf(OutFile," %2s%2.0lf",DCptr->Zone,DCptr->Nbr);
Print(OutFile,0,5,3,DCptr->Xc);
Print(OutFile,0,5,4,DCptr->Ntrf);
Print(OutFile,0,5,3,0.);
if(DCptr->Tap>=DCptr->TapMin) Print(OutFile,0,5,3,DCptr->TapMin);
else {
Print(OutFile,0,5,3,(floor(DCptr->Tap*1000.)*.001));
flag=TRUE;
}
if(DCptr->Tap<=DCptr->TapMax) Print(OutFile,0,5,3,DCptr->TapMax);
else {
Print(OutFile,0,5,3,(ceil(DCptr->Tap*1000.)*.001));
flag=TRUE;
}
if(flag){
flag=FALSE;
if (!strcmp(DCptr->Cont1,"AL")||!strcmp(DCptr->Cont1,"GA")) strcpy(DCptr->Cont1,"AT");
else if (!strcmp(DCptr->Cont2,"AL")||!strcmp(DCptr->Cont2,"GA")) strcpy(DCptr->Cont2,"AT");
else strcpy(DCptr->Cont1,"AT");
}
Print(OutFile,0,4,1,DCptr->AlfaMin/K3);
Print(OutFile,0,4,1,DCptr->AlfaMax/K3);
Print(OutFile,0,4,1,DCptr->GammaMin/K3);
fprintf(OutFile,"\nBZ %8sGROUND %12s",DCptr->Name,DCptr->AC->Name);
fprintf(OutFile," %2s%2s",DCptr->Cont1,DCptr->Cont2);
for(j=1;j<=2;j++){
if(j==1) strcpy(str,DCptr->Cont1);
else strcpy(str,DCptr->Cont2);
if(!strcmp(str,"VD")) Print(OutFile,0,6,2,DCptr->Vd*Vn);
if(!strcmp(str,"ID")) Print(OutFile,0,6,2,DCptr->Id*In*1000);
if(!strcmp(str,"PA")) Print(OutFile,0,6,2,fabs(DCptr->P)*Sn);
if(!strcmp(str,"QA")) Print(OutFile,0,6,2,fabs(DCptr->Q)*Sn);
if(!strcmp(str,"AT")) Print(OutFile,0,6,2,DCptr->Tap);
if(!strcmp(str,"AL")) Print(OutFile,0,6,2,DCptr->Alfa/K3);
if(!strcmp(str,"GA")) Print(OutFile,0,6,2,DCptr->Gamma/K3);
}
fprintf(OutFile,"%1s\n",DCptr->Type);
}
fprintf(OutFile,"LD %8s%8s",DCptrR->Name,DCptrI->Name);
fprintf(OutFile," %2s",DCptrR->Lzone);
Print(OutFile,3,6,2,DCptrR->Rd*Vn/In);
Print(OutFile,0,6,2,DCptrR->Ld*Vn/In*1000);
fprintf(OutFile,"\n");
}
}
/* FACTS */
/* --------------------- SVC results ----------------------------- */
for(SVCptr=dataPtr->SVCbus;SVCptr!=NULL;SVCptr=SVCptr->Next){
fprintf(OutFile,"%2s",SVCptr->Type);
if(SVCptr->From->Area!=NULL) fprintf(OutFile," %2d ",SVCptr->From->Area->N);
else fprintf(OutFile," %2d ",0);
fprintf(OutFile,"%12s ",SVCptr->From->Name);
fprintf(OutFile,"%12s",SVCptr->Ctrl->Name);
Vn=SVCptr->Ctrl->KV;
Ssvc=SVCptr->SVC_base;
Print(OutFile,1,7,6,SVCptr->Xc*Ssvc/Sn);
Print(OutFile,1,7,6,SVCptr->Xl*Ssvc/Sn);
Print(OutFile,0,3,0,SVCptr->AlphaMin/K3);
Print(OutFile,0,3,0,SVCptr->AlphaMax/K3);
Print(OutFile,0,2,0,SVCptr->slope*100.0*Ssvc/Sn);
Print(OutFile,0,4,1,SVCptr->SVC_base);
Print(OutFile,1,3,2,SVCptr->Vref);
fprintf(OutFile,"%12s"," ");
Print(OutFile,1,4,1,SVCptr->alpha_svc/K3);
fprintf(OutFile,"\n");
}
/* --------------------- TCSC results ----------------------------- */
for(TCSCptr=dataPtr->TCSCbus;TCSCptr!=NULL;TCSCptr=TCSCptr->Next){
fprintf(OutFile,"%2s",TCSCptr->Type);
if(TCSCptr->From->Area!=NULL) fprintf(OutFile," %2d ",TCSCptr->From->Area->N);
else fprintf(OutFile," %2d ",0);
fprintf(OutFile,"%12s ",TCSCptr->From->Name);
fprintf(OutFile,"%12s",TCSCptr->To->Name);
Vn=TCSCptr->From->KV;
Stcsc=TCSCptr->TCSC_base;
Xc=TCSCptr->Xc;
Max=TCSCptr->Max;
Print(OutFile,1,7,6,TCSCptr->Xc*Stcsc/Sn);
Print(OutFile,1,7,6,TCSCptr->Xl*Stcsc/Sn);
Print(OutFile,0,3,0,TCSCptr->AlphaMin/K3);
Print(OutFile,0,3,0,TCSCptr->AlphaMax/K3);
if (!strcmp(TCSCptr->Cont,"X")) Print(OutFile,1,7,3,100.0/(TCSCptr->Bset*Max*Xc));
else if (!strcmp(TCSCptr->Cont,"P")) Print(OutFile,1,7,3,TCSCptr->Control*Sn);
else if (!strcmp(TCSCptr->Cont,"I")) Print(OutFile,1,7,3,TCSCptr->Control*Sn/Vn);
else if (!strcmp(TCSCptr->Cont,"D")) Print(OutFile,1,7,3,TCSCptr->Control/K3);
fprintf(OutFile,"%c",TCSCptr->Cont[0]);
Print(OutFile,0,4,1,Stcsc);
Print(OutFile,0,5,1,TCSCptr->alpha_tcsc/K3);
Print(OutFile,0,3,1,TCSCptr->Max);
fprintf(OutFile,"\n");
}
/* --------------------- STATCOM results ----------------------------- */
for(STATCOMptr=dataPtr->STATCOMbus;STATCOMptr!=NULL;STATCOMptr=STATCOMptr->Next){
fprintf(OutFile,"%2s",STATCOMptr->Type);
if(STATCOMptr->From->Area!=NULL) fprintf(OutFile," %2d ",STATCOMptr->From->Area->N);
else fprintf(OutFile," %2d ",0);
fprintf(OutFile,"%12s ",STATCOMptr->From->Name);
fprintf(OutFile,"%12s",STATCOMptr->Ctrl->Name);
Vn=STATCOMptr->From->KV;
Sstatcom=STATCOMptr->MVA;
G=STATCOMptr->G;
B=STATCOMptr->B;
X=-B/(G*G+B*B);
Print(OutFile,1,5,4,STATCOMptr->R*Sstatcom/Sn);
Print(OutFile,1,5,4,X*Sstatcom/Sn);
Print(OutFile,1,5,4,STATCOMptr->Gc*Sn/Sstatcom);
Print(OutFile,1,5,3,STATCOMptr->Imin*Sn/Sstatcom);
Print(OutFile,1,5,3,STATCOMptr->Imax*Sn/Sstatcom);
Print(OutFile,1,2,0,STATCOMptr->slope*100.0*Sstatcom/Sn);
Print(OutFile,1,4,0,STATCOMptr->MVA);
Print(OutFile,1,3,2,STATCOMptr->Vref);
if (!strcmp(STATCOMptr->Cont1,"PW")) {
fprintf(OutFile,"%1s","W");
Print(OutFile,1,5,4,STATCOMptr->Vdc);
} else {
fprintf(OutFile,"%1s","P");
Print(OutFile,1,5,4,STATCOMptr->k);
}
fprintf(OutFile,"\n");
}
/* END OF FACTS */
fprintf(OutFile,"END OF DATA\n");
fclose(OutFile);
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -