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

📄 readieee.cpp

📁 用于潮流计算的程序请让我下载我需要的吧感谢了啊
💻 CPP
📖 第 1 页 / 共 2 页
字号:
          }
          if(Eptr->Tmax==Eptr->Tmin) {
            strcpy(Eptr->Type,"T");
            Eptr->Tmax=Eptr->Tmin=0;
          }
          else if (strcmp(ACptrs->Type,"BG") && strcmp(ACptrs->Type,"BQ") ) {
            NregV++;
            ACptrs->Reg=(ElementList *) AddElemToList(ACptrs->Reg,Eptr);
            Eptr->Cont=ACptrs;
            Eptr->Min=GetValue(Line,113,7,5);
            Eptr->Max=GetValue(Line,120,7,5);
            if(Eptr->Max<0) Eptr->Max=1.;
            if(Eptr->Min<0) Eptr->Min=1.;
            if(Eptr->Max<Eptr->Min) {
              fCustomPrint(stderr,"Input Line-> %d\n%s",LineNum,Line);
              ErrorHalt("LTC limits are wrong: Vmin > Vmax.");
            }
            if(Eptr->Max==Eptr->Min) {
              strcpy(Eptr->Type,"R");
              strcpy(ACptrs->Type,"BT");
              ACptrs->V=Eptr->Max;
              if (ACptrs->V==0) ACptrs->V=1.;
              Eptr->Max=Eptr->Min=0;
            }
            else {
              strcpy(Eptr->Type,"RV");
              if (strcmp(ACptrs->Type,"BT")) strcpy(ACptrs->Type,"BR");
              if(ACptrs->Vmax>Eptr->Max||ACptrs->Vmax==0)
                ACptrs->Vmax=Eptr->Max;
              if(ACptrs->Vmin>Eptr->Min||ACptrs->Vmin==0) {
                ACptrs->Vmin=Eptr->Min;
                if (ACptrs->Vmin==0) ACptr->Vmin=0.00001;
              }
            }
          }
	  else {
            strcpy(Eptr->Type,"T");
            Eptr->Tmax=Eptr->Tmin=0;
            fCustomPrint(stderr,"Input Line-> %d\n%s",LineNum,Line);
            fCustomPrint(stderr,"***Warning: The controlled bus of this LTC is not PQ (check BUS DATA cards).\n");
            fCustomPrint(stderr,"            It will be treated as a fixed tap transformer.\n");
          }
        }
        else if(k==3) {
          Eptr->Tmin=GetValue(Line,91,7,2);
          Eptr->Tmax=GetValue(Line,98,7,2);
          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(Eptr->Tmax==Eptr->Tmin) {
            strcpy(Eptr->Type,"T");
            Eptr->Tmin=Eptr->Tmax=0;
          }
          else {
            NregPQ++;
            if (ACptrs!=ACptr && ACptrs!=ACptrp) ACptrs=ACptr;
            ACptrs->Reg=(ElementList *) AddElemToList(ACptrs->Reg,Eptr);
            Eptr->Cont=ACptrs;
            Eptr->Min=GetValue(Line,113,7,5)/Sn;
            Eptr->Max=GetValue(Line,120,7,5)/Sn;
            if(Eptr->Max<Eptr->Min) {
              fCustomPrint(stderr,"Input Line-> %d\n%s",LineNum,Line);
              ErrorHalt("LTC limits are wrong: Qmin > Qmax.");
            }
            if(Eptr->Max==Eptr->Min) {
              strcpy(Eptr->Type,"RQ");
              Eptr->Cvar=Eptr->Max;
              Eptr->Max=Eptr->Min=0;
            }
            else strcpy(Eptr->Type,"RN");
            Eptr->Ncont=ACptrs->Ncont;
            ACptrs->Ncont++;
          }
        }
        else if(k==4) {
          Eptr->Tmin=GetValue(Line,91,7,2)*K3;
          Eptr->Tmax=GetValue(Line,98,7,2)*K3;
          if(Eptr->Tmax<Eptr->Tmin) {
            fCustomPrint(stderr,"Input Line-> %d\n%s",LineNum,Line);
            ErrorHalt("LTC limits are wrong: Tmin > Tmax.");
          }
          if(Eptr->Tmax==Eptr->Tmin){
            strcpy(Eptr->Type,"T");
            Eptr->Tmin=Eptr->Tmax=0;
          }
          else {
            NregPQ++;
            if (ACptrs!=ACptr && ACptrs!=ACptrp) ACptrs=ACptr;
            ACptrs->Reg=(ElementList *) AddElemToList(ACptrs->Reg,Eptr);
            Eptr->Cont=ACptrs;
            Eptr->Min=GetValue(Line,113,7,5)/Sn;
            Eptr->Max=GetValue(Line,120,7,5)/Sn;
            if(Eptr->Max<Eptr->Min) {
              fCustomPrint(stderr,"Input Line-> %d\n%s",LineNum,Line);
              ErrorHalt("LTC limits are wrong: Pmin > Pmax.");
            }
            if(Eptr->Max==Eptr->Min) {
              strcpy(Eptr->Type,"RP");
              Eptr->Cvar=Eptr->Max;
              Eptr->Max=Eptr->Min=0;
            }
            else strcpy(Eptr->Type,"RM");
            Eptr->Ncont=ACptrs->Ncont;
            ACptrs->Ncont++;
          }
        }
      }
    }

  /* -------------------- Area data -------------------------------- */
    else if(!strncmp(Line,"INTERCHANGE DATA",11)) for(;;){
      AreaIntData:
      if (fgets(Line,BUFLEN,InputDataFile)==NULL){
        ErrorHalt("Missing -9 card in INTERCHANGE DATA.");
        break;
      }
      LineNum++;
      if(Line[0]=='%') goto AreaIntData;
      if(!strncmp(Line,"-9",2)) break;
      flag=TRUE;
      i=GetInt(Line,1,NumAreaDigits);
      Aptr=(AreaData *) AreaInList(i,"",Narea);
      if (Aptr->N==0) {
        fCustomPrint(stderr,"Input Line-> %d\n%s",LineNum,Line);
        ErrorHalt("The Area does not contain any buses (check BUS DATA cards).");
      }
      GetStr(Line,46,30,30,Name);
      for (j=0;j<=29;j++) {
        if (Name[j]!=' ') break;
        if (j==29) empty=TRUE;
      }
      if (empty||(strpbrk(Name,"0")&&strlen(Name)==1)) {
        empty=FALSE;
        strcpy(Name,"AREA_");
        GetStr(Line,1,4,4,str);
        for(j=0;j<=3;j++) if(str[j]!=' ') break;
        strcat(Name,&str[j]);
        for(j=strlen(Name);j<=29;Name[j]=' ',j++);
        Name[30]='\0';
      }
      strcpy(Aptr->Name,Name);
      i=GetInt(Line,4,NumBusDigits);
      ACptr=(ACbusData *) ACbusInList(i,"",0.,Nac,1);
      if (ACptr->N==0) {
        fCustomPrint(stderr,"Input Line-> %d\n%s",LineNum,Line);
        ErrorHalt("The area slack bus has not been defined (check BUS DATA cards).");
      }
      if (ACptr->Area!=Aptr) {
        fCustomPrint(stderr,"Input Line-> %d\n%s",LineNum,Line);
        ErrorHalt("The slack bus is not in the area (check BUS DATA cards).");
      }
      Aptr->Slack=Aptr->BSptr=ACptr;
      Aptr->P=GetValue(Line,21,8,1)/Sn;
    }

  /* -------------------- Tie Lines data -------------------------------- */
    else if(!strncmp(Line,"TIE LINE DATA",3)) for(;;){
      TieLineData:
      if (fgets(Line,BUFLEN,InputDataFile)==NULL){
        ErrorHalt("Missing -999 card in TIE LINE DATA.");
        break;
      }
      LineNum++;
      if(Line[0]=='%') goto TieLineData;
      if(!strncmp(Line,"-999",4)) break;
      i=GetInt(Line,1,NumBusDigits);
      ACptr=(ACbusData *) ACbusInList(i,"",0.,Nac,1);
      if (ACptr->N==0) {
        fCustomPrint(stderr,"Input Line-> %d\n%s",LineNum,Line);
        ErrorHalt("The metered bus has not been defined (check BUS DATA cards).");
      }
      i=GetInt(Line,11,NumBusDigits);
      ACptrp=(ACbusData *) ACbusInList(i,"",0.,Nac,1);
      if (ACptrp->N==0) {
        fCustomPrint(stderr,"Input Line-> %d\n%s",LineNum,Line);
        ErrorHalt("The nonmetered bus has not been defined (check BUS DATA cards).");
      }
      GetStr(Line,CircData,1,1,str);
      for(ELptr=ACptr->Elem;ELptr!=NULL;ELptr=ELptr->Next){
        Eptr=ELptr->Eptr;
        if (((Eptr->From==ACptr && Eptr->To==ACptrp)||
             (Eptr->From==ACptrp && Eptr->To==ACptr))&&
            !strcmp(Eptr->Ckt,str)) break;
      }
      if (ELptr!=NULL) {
        if (Eptr->Meter==NULL) Eptr->Meter=ACptr;
        else {
          fCustomPrint(stderr,"Input Line-> %d\n%s",LineNum,Line);
		  fCustomPrint(stderr,"***Warning: This tie line was already defined (check circuit code).\n");        }
      }
      else {
        fCustomPrint(stderr,"Input Line-> %d\n%s",LineNum,Line);
        fCustomPrint(stderr,"***Warning: This element has not been defined (check BRANCH DATA cards).\n");
      }
    }

  /* -------------------- DC data -------------------------------- */
    else if (!strncmp(Line,"BD ",3) || !strncmp(Line,"BZ ",3)||
             !strncmp(Line,"LD ",3)) ReadEPRIdc(Line);

                        /* 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 OF DATA",11)) break;
    else if(flagp && Line[0]!='C' ) {
      fCustomPrint(stderr,"Input Line-> %d\n%s",LineNum,Line);
      fCustomPrint(stderr,"***Warning: The program will ignore this line.\n");
    }
  }
  fclose(InputDataFile);

  if (!flag) {
    Narea=0;
    for(ACptr=dataPtr->ACbus;ACptr!=NULL;ACptr->Area=NULL,ACptr=ACptr->Next);
  }
  MaxIter=50;
  for (ACptr=dataPtr->ACbus;ACptr!=NULL;ACptr=ACptr->Next)
    if(strpbrk(ACptr->Type,"G")){
      ACptrp=(ACbusData *) ACbusInList(ACptr->Nc,"",0.,Nac,1);
      if (ACptrp->N==0) {
         fCustomPrint(stderr,"Error: The voltage controlled bus %d %s\n",ACptrp->Num,ACptrp->Name);
         fCustomPrint(stderr,"       has not been defined.  Check AC bus data.\n");
         /*WriteSummary();
         exit(ERROREXIT);*/
         InputError=TRUE;
      }
      if(!strcmp(ACptrp->Type,"B")) strcpy(ACptrp->Type,"BC");
      else if(strcmp(ACptrp->Type,"BC")) {
         fCustomPrint(stderr,"Error: The voltage controlled bus %d %s\n",ACptrp->Num,ACptrp->Name);
         fCustomPrint(stderr,"       is not a PQ bus.  Check AC bus data.\n");
         /*WriteSummary();
         exit(ERROREXIT);*/
         InputError=TRUE;
      }
      ACptr->Cont=ACptrp;
      ACptrp->VCont=ACptrp->V=ACptr->VCont;
      ACptrp->Cont=NULL;
      ACptrp->Kbg++;
      if (flag2Vcontrol) {
         ACptrp->Kbg1=ACptrp->Kbg1+ACptr->Qmax;
         ACptrp->Kbg2=ACptrp->Kbg2+ACptr->Qmin;
      }
      if(ACptrp->Kbg>1) {
        if (!flag2Vcontrol) {
           fCustomPrint(stderr,"***Warning: The IEEE common format assumes that multiple generators\n");
           fCustomPrint(stderr,"            controlling voltage at bus %d %s\n",ACptrp->Num,ACptrp->Name);
           fCustomPrint(stderr,"            share equally the control.\n");
        }
        fCustomPrint(stderr,"***Warning: The program will use the first generator controlling bus \n");
        fCustomPrint(stderr,"            to define the remote voltage at bus %d %s\n",ACptrp->Num,ACptrp->Name);
      }
    }
}

⌨️ 快捷键说明

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