⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 readepri.c

📁 电力系统分析计算 学习调试程序 UNIX / LINUX / CYGWIN 系统使用
💻 C
📖 第 1 页 / 共 2 页
字号:
    }  /* --------------- BPA '+' Cards -------------------------------- */  /* These cards are assumed to come right after a bus card.     The program associates the card to the last bus defined in     the data set.  */    else if (!strncmp(Line,"+",1) && ACptr!=NULL) {      ACptr->Pl+=GetValue(Line,21,5,0)/Sn;      ACptr->Ql+=GetValue(Line,26,5,0)/Sn;      ACptr->G+=GetValue(Line,31,4,0)/Sn;      ACptr->B+=GetValue(Line,35,4,0)/Sn;      ACptr->Pg+=GetValue(Line,43,5,0)/Sn;      ACptr->Ql-=GetValue(Line,39,4,0)/Sn;    }  /* --------------- X data cards -------------------------------- */    else if (!strncmp(Line,"X  ",3)){      flagPrint=TRUE;      GetStr(Line,7,12,12,Name);      KV=GetValue(Line,15,4,0);      ACptr=ACbusInList(0,Name,KV,Nac,1);      if (ACptr->N==0) { Nac++; ACptr->Num=ACptr->N=Nac;}      GetStr(Line,21,12,12,Name);      KVp=GetValue(Line,29,4,0);      if (KVp>0) {        ACptrp=ACbusInList(0,Name,KVp,Nac,1);        if (ACptrp->N==0) { Nac++; ACptrp->Num=ACptr->N=Nac;}      }      else ACptrp=ACptr;      if (Xcont) ACptrp=ACptr;      if (!strcmp(ACptrp->Type,"B")) {        NXvolt++;        strcpy(ACptrp->Type,"BX");        if (ACptrp!=ACptr) strcpy(ACptr->Type,"B");        ACptr->V=1;        ACptrp->Cont=ACptr;        strcpy(ACptrp->cont,"X");        for(i=1,j=33; i<=8; i++,j=j+6) {          k=GetInt(Line,j,1);          Bx=GetValue(Line,j+1,5,0);          if (k>0 && k<10 && Bx!=0) for(s=1;s<=k;s++) {             ACptr->steps++;             ACptr->Bx[ACptr->steps]=fabs(Bx)/Sn;             if (ACptrp->Bx[0]==0) {               if (Bx>0) ACptr->Bx[0]=1;               else      ACptr->Bx[0]=-1;             } else {               if (ACptr->Bx[0]*Bx<0 && flagPrint) {                 fCustomPrint(stderr,"Input Line-> %d\n%s",LineNum,Line);                 fCustomPrint(stderr,"***Warning: All MVAr compensation steps are assumed to be either positive or negative,\n");                 fCustomPrint(stderr,"            as defined by the first nonzero step on this card. \n");                 flagPrint=FALSE;               }             }          }        }      } else {        fCustomPrint(stderr,"Input Line-> %d\n%s",LineNum,Line);        fCustomPrint(stderr,"***Warning: This bus has been previously defined as a type %s bus, and hence\n",ACptrp->Type);        fCustomPrint(stderr,"            it cannot be defined as a BX remote bus. The BX data will be ignored.\n");      }    }  /* --------------- AC element data -------------------------------- */    else if (!strncmp(Line,"L  ",3)||!strncmp(Line,"T  ",3)||        !strncmp(Line,"E  ",3)){      GetStr(Line,7,12,12,Name);      KV=GetValue(Line,15,4,0);      if (KV==0){         fCustomPrint(stderr,"Input Line-> %d\n%s",LineNum,Line);         ErrorHalt("Base voltage at bus 1 is zero.");         KV=1;      }      ACptr=ACbusInList(0,Name,KV,Nac,1);      if (ACptr->N==0) { Nac++; ACptr->Num=ACptr->N=Nac;}      GetStr(Line,20,12,12,Name);      KVp=GetValue(Line,28,4,0);      if (KVp==0){         fCustomPrint(stderr,"Input Line-> %d\n%s",LineNum,Line);         ErrorHalt("Base voltage at bus 2 is zero.");         KVp=1;      }      ACptrp=ACbusInList(0,Name,KVp,Nac,1);      if (ACptrp->N==0) { Nac++; ACptrp->Num=ACptrp->N=Nac;}      if (ACptr==ACptrp){         fCustomPrint(stderr,"Input Line-> %d\n%s",LineNum,Line);         ErrorHalt("Both AC element buses are the same.");      }      R=GetValue(Line,39,6,5);      X=GetValue(Line,45,6,5);      if (fabs(R)<0.0001 && fabs(X)<0.0001) {         fCustomPrint(stderr,"Input Line-> %d\n%s",LineNum,Line);         ErrorHalt("AC element is a short circuit. Try eliminating it.");         G=B=0;      } else {         G= R/(R*R+X*X);         B= -X/(R*R+X*X);      }      G1=GetValue(Line,51,6,5);      B1=GetValue(Line,57,6,5);      Tap=Taps=1;      Ang=0;      if (!strncmp(Line,"E  ",3)) {         G2=GetValue(Line,63,6,5);         B2=GetValue(Line,69,6,5);         Imax=GetValue(Line,34,4,0)/(Sn*1000/(sqrt(3.0)*KV));      }      else if (!strncmp(Line, "L  ",3)) {        G2=G1;        B2=B1;        Imax=GetValue(Line,34,4,0)/(Sn*1000/(sqrt(3.0)*KV));      } else {         G2=G1; B2=B1;         G1=B1=0;         Tap2=GetValue(Line,68,5,2);         if (Tap2>0) {            Tap1=GetValue(Line,63,5,2)/KV;            if (Tap1<=0) Tap1=1;            Taps=Tap2/KVp;            Tap=Taps/Tap1;         } else Ang=GetValue(Line,63,5,2)*K3;         Imax=GetValue(Line,34,4,0)/Sn;      }      GetStr(Line,32,1,1,str);      Sec=GetInt(Line,33,1);      if (Sec) flag=AddSection(ACptr,ACptrp,Line,str,Sec);      else flag=FALSE;      if (!flag) {          if (!strncmp(Line,"T  ",3)) {             Eptr=ElemInList(ACptr,ACptrp,NacEl,1,"R",str);             if (Eptr==NULL) Eptr=ElemInList(ACptr,ACptrp,NacEl,0,"",str);          }          else Eptr=ElemInList(ACptr,ACptrp,NacEl,0,"",str);          Eptr->Sec=Sec;          Eptr->G=G;          Eptr->B=B;          Eptr->G1=G1;          Eptr->B1=B1;          Eptr->G2=G2;          Eptr->B2=B2;          Eptr->Tap=Tap;          Eptr->Taps=Taps;          Eptr->Ang=Ang;          Eptr->Imax=Imax;          GetStr(Line,4,3,3,Eptr->Owner);          strcpy(Eptr->Zone,"  ");          NacEl++;          GetStr(Line,19,1,1,str);          if (!strcmp(str,"1")) Eptr->Meter=ACptr;          else if (!strcmp(str,"2")) Eptr->Meter=ACptrp;          if (!strncmp(Line,"L  ",3)) strcpy(Eptr->Type,"L");          else if (!strncmp(Line,"E  ",3)) strcpy(Eptr->Type,"E");          else if (!strncmp(Line,"T  ",3)&&strncmp(Eptr->Type,"R",1)) strcpy(Eptr->Type,"T");      }    }  /* ------------ Regulating transformer data ------------------- */    else if (!strncmp(Line,"R  ",3)||!strncmp(Line,"RP ",3)||        !strncmp(Line,"RM ",3)||!strncmp(Line,"RQ ",3)||        !strncmp(Line,"RN ",3)){      GetStr(Line,7,12,12,Name);      KV=GetValue(Line,15,4,0);      ACptr=ACbusInList(0,Name,KV,Nac,1);      if (ACptr->N==0) { Nac++; ACptr->Num=ACptr->N=Nac;}      GetStr(Line,20,12,12,Name);      KVp=GetValue(Line,28,4,0);      ACptrp=ACbusInList(0,Name,KVp,Nac,1);      if (ACptrp->N==0) { Nac++; ACptrp->Num=ACptrp->N=Nac;}      if (ACptr==ACptrp){         fCustomPrint(stderr,"Input Line-> %d\n%s",LineNum,Line);         ErrorHalt("Both AC element buses are the same.");      }      GetStr(Line,32,1,1,str);      Eptr=ElemInList(ACptr,ACptrp,NacEl,1,"T",str);      if (Eptr==NULL) Eptr=ElemInList(ACptr,ACptrp,NacEl,0,"",str);      NacEl++; NregPQ++;      GetStr(Line,34,12,12,Name);      KVs=GetValue(Line,42,4,0);      ACptrs=ACbusInList(0,Name,KVs,Nac,1);      if (ACptrs->N==0) { Nac++; ACptrs->Num=ACptrs->N=Nac;}      if (!strncmp(Line,"R  ",3)){         NregV++;         strcpy(Eptr->Type,"R");         Eptr->Tmax=GetValue(Line,46,5,2)/KV;         Eptr->Tmin=GetValue(Line,51,5,2)/KV;         if(Eptr->Tmax<=0) Eptr->Tmax=1.1;         if(Eptr->Tmin<=0) Eptr->Tmin=0.9;         if(Eptr->Tmax<=Eptr->Tmin) {            fCustomPrint(stderr,"Input Line-> %d\n%s",LineNum,Line);            ErrorHalt("LTC limits are wrong: Tmin > Tmax.");         }         if (!strcmp(ACptrs->Type,"B")) strcpy(ACptrs->Type,"BT");         ACptrs->Reg=AddElemToList(ACptrs->Reg,Eptr);         Eptr->Cont=ACptrs;      }      else if (!strncmp(Line,"RP ",3) || !strncmp(Line,"RM ",3)){         Eptr->Tmax=GetValue(Line,46,5,2)*K3;         Eptr->Tmin=GetValue(Line,51,5,2)*K3;         if(Eptr->Tmax<=Eptr->Tmin) {            fCustomPrint(stderr,"Input Line-> %d\n%s",LineNum,Line);            ErrorHalt("Phase shifter limits are wrong: Amin >= Amax.");         }         if (!strncmp(Line,"RP ",3)) {            strcpy(Eptr->Type,"RP");            Eptr->Cvar=GetValue(Line,58,5,0)/Sn;         } else {            strcpy(Eptr->Type,"RM");            Eptr->Max=GetValue(Line,58,5,0)/Sn;            Eptr->Min=GetValue(Line,63,5,0)/Sn;            if(Eptr->Max<=Eptr->Min) {               fCustomPrint(stderr,"Input Line-> %d\n%s",LineNum,Line);               ErrorHalt("Phase shifter limits are wrong: Pmin >= Pmax.");            }         }         if (ACptrs!=ACptr && ACptrs!=ACptrp) ACptrs=ACptr;         Eptr->Cont=ACptrs;         Eptr->Ncont=ACptrs->Ncont;         ACptrs->Reg=AddElemToList(ACptrs->Reg,Eptr);         ACptrs->Ncont++;      }      else if (!strncmp(Line,"RQ ",3) || !strncmp(Line,"RN ",3)){         Eptr->Tmax=GetValue(Line,46,5,2)/KV;         Eptr->Tmin=GetValue(Line,51,5,2)/KV;         if(Eptr->Tmax<0) Eptr->Tmax=1.1;         if(Eptr->Tmin<0) Eptr->Tmin=0.9;         if(Eptr->Tmax<=Eptr->Tmin) {            fCustomPrint(stderr,"Input Line-> %d\n%s",LineNum,Line);            ErrorHalt("LTC limits are wrong: Tmin >= Tmax.");         }         if (!strncmp(Line,"RQ ",3)){            strcpy(Eptr->Type,"RQ");            Eptr->Cvar=GetValue(Line,58,5,0)/Sn;         } else {            strcpy(Eptr->Type,"RN");            Eptr->Max=GetValue(Line,58,5,0)/Sn;            Eptr->Min=GetValue(Line,63,5,0)/Sn;            if(Eptr->Max<=Eptr->Min) {               fCustomPrint(stderr,"Input Line-> %d\n%s",LineNum,Line);               ErrorHalt("LTC limits are wrong: Qmin >= Qmax.");            }         }         if (ACptrs!=ACptr && ACptrs!=ACptrp) ACptrs=ACptr;         Eptr->Cont=ACptrs;         Eptr->Ncont=ACptrs->Ncont;         ACptrs->Reg=AddElemToList(ACptrs->Reg,Eptr);         ACptrs->Ncont++;      }    }  /* -------------------- DC data -------------------------------- */    else if (!strncmp(Line,"BD ",3) || !strncmp(Line,"BZ ",3)||        !strncmp(Line,"LD ",3)) ReadEPRIdc(Line);  /* ------------------------ Area data -------------------------- */    else if (!strncmp(Line,"A  ",3)) {      GetStr(Line,4,10,30,Name);      Aptr=(AreaData *) AreaInList(0,Name,Narea);      if (Aptr->N==0) { Narea++; Aptr->N=Narea;}      else {         fCustomPrint(stderr,"Input Line-> %d\n%s",LineNum,Line);         ErrorHalt("The Area was previously defined (check A cards).");      }      Aptr->P=GetValue(Line,27,8,0)/Sn;      GetStr(Line,14,12,12,Name);      KV=GetValue(Line,22,4,0);      ACptr=ACbusInList(0,Name,KV,Nac,1);      if (ACptr->N==0) { Nac++; ACptr->Num=ACptr->N=Nac;}      ACptr->Area=Aptr;      Aptr->Slack=Aptr->BSptr=ACptr;      for (i=36, j=1; i<=63; i=i+3, j++) GetStr(Line,i,2,2,Aptr->Zone[j]);    }  /* ---------------------- Solution data ------------------------ */    else if (!strncmp(Line,"SOL",3)) {      GetStr(Line,31,12,12,Name);      KV=GetValue(Line,39,4,0);      AngSlack=GetValue(Line,46,10,4);      AngSlack=AngSlack*K3;      ACptr=ACbusInList(0,Name,KV,Nac,1);      if (ACptr->N==0) { Nac++; ACptr->Num=ACptr->N=Nac;}      if(!strpbrk(ACptr->Type,"S")){         strcat(ACptr->Type,"S");         Nslack++;      }      MaxIter=GetInt(Line,24,5);    }                         /* FACTS */ /* ---------------------- SVC data ------------------------ */    else if (!strncmp(Line,"FS ",3)) ReadSVC(Line); /* ---------------------- TCSC data ------------------------ */    else if (!strncmp(Line,"FC ",3)) ReadTCSC(Line); /* ---------------------- STATCOM data ------------------------ */    else if (!strncmp(Line,"FT ",3)) ReadSTATCOM(Line);                      /* END FACTS */    else if (!strncmp(Line,"END",3)||!strncmp(Line,"FIM",3)) break;    else if (strncmp(Line,"ZZ",2)&&strncmp(Line,"D",1)&&strncmp(Line,"9999",4)) {      fCustomPrint(stderr,"Input Line-> %d\n%s",LineNum,Line);      fCustomPrint(stderr,"***Warning: The program will ignore this line.\n");    }  }  fclose(InputDataFile);  NacEl-=NregPQ;  NregPQ-=NregV;  if (MaxIter==0) MaxIter=50;}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -