示例#1
0
  @Test
  public void sampleTest() {
    AcscNetwork faultNet = CoreObjectFactory.createAcscNetwork();
    SampleCases.load_SC_5BusSystem(faultNet);
    // System.out.println(faultNet.net2String());

    assertTrue((faultNet.getBusList().size() == 5 && faultNet.getBranchList().size() == 5));

    SimpleFaultAlgorithm algo = CoreObjectFactory.createSimpleFaultAlgorithm(faultNet);
    AcscBusFault fault = CoreObjectFactory.createAcscBusFault("2", algo);
    fault.setFaultCode(SimpleFaultCode.GROUND_3P);
    fault.setZLGFault(new Complex(0.0, 0.0));
    fault.setZLLFault(new Complex(0.0, 0.0));

    algo.calculateBusFault(fault);
    // System.out.println(fault.toString(faultBus.getBaseVoltage(), faultNet.getBaseKva()));
    /*
    fault amps(1): (  0.0000 + j 32.57143) pu
    fault amps(2): (  0.0000 + j  0.0000) pu
    fault amps(0): (  0.0000 + j  0.0000) pu
    */
    assertTrue(
        TestUtilFunc.compare(
            fault.getFaultResult().getSCCurrent_012(), 0.0, 0.0, 0.0, 32.57142857157701, 0.0, 0.0));

    // System.out.println(AcscOut.faultResult2String(faultNet));
  }
  private void mapFault(AcscFaultAnalysisXmlType scAnalysisXml) throws InterpssException {
    String idStr =
        scAnalysisXml.getName() != null ? scAnalysisXml.getName() : scAnalysisXml.getDesc();

    if (scAnalysisXml.getAcscFault() == null)
      throw new InterpssException("acscAnalysis.fault not defined");

    AcscBaseFaultXmlType faultXml = scAnalysisXml.getAcscFault().getValue();
    if (faultXml.getFaultType() == AcscFaultTypeEnumType.BUS_FAULT) {
      AcscBusFaultXmlType busFaultXml = (AcscBusFaultXmlType) faultXml;
      String faultBusId = busFaultXml.getRefBus().getBusId();
      AcscBusFault acscBusFault = CoreObjectFactory.createAcscBusFault(faultBusId, acscFaultNet);
      acscAglo.addBusFault(faultBusId, idStr, acscBusFault);

      AcscBus bus = acscFaultNet.getBus(faultBusId);
      double baseV = bus.getBaseVoltage();
      double baseKVA = bus.getNetwork().getBaseKva();

      setBusFaultInfo(busFaultXml, acscBusFault, baseV, baseKVA);
    } else if (faultXml.getFaultType() == AcscFaultTypeEnumType.BRANCH_FAULT) {
      AcscBranchFaultXmlType braFaultXml = (AcscBranchFaultXmlType) faultXml;
      String faultBranchId = braFaultXml.getRefBranch().getBranchId();
      AcscBranchFault acscBraFault =
          CoreObjectFactory.createAcscBranchFault(faultBranchId, acscFaultNet);
      acscAglo.addBranchFault(faultBranchId, idStr, acscBraFault);

      AcscBranch acscBra = acscFaultNet.getBranch(faultBranchId);
      double baseV = acscBra.getFromAclfBus().getBaseVoltage();
      double baseKVA = acscBra.getNetwork().getBaseKva();

      setBranchFaultInfo(braFaultXml, acscBraFault, baseV, baseKVA);
    } else if (faultXml.getFaultType() == AcscFaultTypeEnumType.BRANCH_OUTAGE) {
      throw new InterpssException("Acsc branch outtage fault not implemented");
    }
  }
示例#3
0
 // Calculate Vsh to match the tuned constant V
 private Complex solveConstV(Complex vsh1, Complex vi, ConverterLF converter, double tunedValue)
     throws InterpssException {
   // 1. Change the bus type to be PV bus, Solve the load flow, get the Qsh to be compensated
   AclfNetwork tempNetwork = CoreObjectFactory.createAclfNetwork(this.net.serialize());
   tempNetwork.getAclfBus(id).setGenCode(AclfGenCode.GEN_PV);
   tempNetwork.getAclfBus(id).setVoltageMag(tunedValue);
   double p = tempNetwork.getAclfBus(id).getLoadP();
   double q = tempNetwork.getAclfBus(id).getLoadQ();
   tempNetwork.getAclfBus(id).setGenP(-p);
   tempNetwork.getAclfBus(id).setLoadP(0.0);
   tempNetwork.getAclfBus(id).setLoadQ(0.0);
   LoadflowAlgorithm algo = CoreObjectFactory.createLoadflowAlgorithm(tempNetwork);
   tempNetwork.accept(algo);
   double qsh = tempNetwork.getAclfBus(id).getGenResults().getImaginary() + q;
   // 2. Calculate Vsh with constantQ control, control to Qsh
   Complex vsh =
       solveConstQ(converter.getVth(), tempNetwork.getAclfBus(id).getVoltage(), converter, qsh);
   net.getAclfBus(id)
       .setVoltage(
           tempNetwork
               .getAclfBus(id)
               .getVoltage()); // Bus voltage should be updated, otherwise there will be a non-zero
   // p
   //		System.out.println(converter.getSij(net).getReal() + "+j" +
   // converter.getSij(net).getImaginary());
   err = 0.0;
   return vsh;
 }
示例#4
0
  public DynamicEvent addBusFaultEvent(
      String faultBusId,
      SimpleFaultCode code,
      double startTime,
      double durationTime,
      Complex Zlg,
      Complex Zll) {
    // define an event, set the event id and event type.
    DynamicEvent event1 =
        DStabObjectFactory.createDEvent(
            "BusFault_" + code + "@" + faultBusId,
            "Bus Fault @" + faultBusId,
            DynamicEventType.BUS_FAULT,
            dstabNet);
    event1.setStartTimeSec(startTime);
    event1.setDurationSec(durationTime);

    // define a bus fault
    DStabBus faultBus = dstabNet.getDStabBus(faultBusId);
    AcscBusFault fault =
        CoreObjectFactory.createAcscBusFault("Bus Fault 3P@" + faultBusId, dstabNet);
    fault.setBus(faultBus);
    fault.setFaultCode(code);
    fault.setZLGFault(Zlg);
    fault.setZLLFault(Zll);

    // add this fault to the event, must be consist with event type definition before.
    event1.setBusFault(fault);
    return event1;
  }
  @Test
  public void aclf1() throws Exception {
    IpssCorePlugin.init();
    // IpssCorePlugin.setSparseEqnSolver(SolverType.Native);
    ODMLogger.getLogger().setLevel(Level.WARNING);

    AclfNetwork net =
        IpssAdapter.importAclfNet("testData/psse/v30/Mod_SixBus_2WPsXfr.raw")
            .setFormat(IpssAdapter.FileFormat.PSSE)
            .setPsseVersion(PsseVersion.PSSE_30)
            .xfrBranchModel(ODMAclfNetMapper.XfrBranchModel.PSSE)
            .load(true, "output/odm.xml")
            .getAclfNet();
    // System.out.println(net.net2String());

    net.accept(CoreObjectFactory.createLfAlgoVisitor());

    assertTrue(net.isLfConverged());

    System.out.println(CorePluginFunction.AclfResultBusStyle.f(net));
    AclfSwingBus swing = net.getBus("Bus1").toSwingBus();
    Complex p = swing.getGenResults(UnitType.PU);
    assertTrue(Math.abs(p.getReal() - 3.2955) < 0.0001);
    assertTrue(Math.abs(p.getImaginary() - 0.9571) < 0.0001);
  }
示例#6
0
 @Override
 public boolean correctorStep() {
   LoadflowAlgorithm algo = CoreObjectFactory.createLoadflowAlgorithm();
   algo.setNrSolver(corrStepSolver);
   if (!this.cpfAlgo.getAclfNetwork().accept(algo)) {
     return false;
   }
   return true;
 }
示例#7
0
  @Test
  public void dslTest() {
    AcscNetwork faultNet = CoreObjectFactory.createAcscNetwork();
    SampleCases.load_SC_5BusSystem(faultNet);
    // System.out.println(faultNet.net2String());

    assertTrue((faultNet.getBusList().size() == 5 && faultNet.getBranchList().size() == 5));

    AcscFaultAnalysisXmlType acscCaseXml = createCase();
    IFaultResult result = new AcscDslODMRunner(faultNet).runAcsc(acscCaseXml);

    assertTrue(
        TestUtilFunc.compare(
            result.getSCCurrent_012(), 0.0, 0.0, 0.0, 32.57142857157701, 0.0, 0.0));
  }
示例#8
0
 /**
  * get the ownerId field
  *
  * @param id
  * @return
  */
 @SuppressWarnings(value = "unchecked")
 public TBaseDSL setOwnerId(String id) {
   Owner owner = CoreObjectFactory.createOwner(id, net);
   this.obj.setOwner(owner);
   return (TBaseDSL) this;
 }
示例#9
0
 /**
  * get the zone number field
  *
  * @param n
  * @return
  */
 @SuppressWarnings(value = "unchecked")
 public TBaseDSL setZoneNumber(int n) {
   Zone zone = CoreObjectFactory.createZone(n, net);
   this.obj.setZone(zone);
   return (TBaseDSL) this;
 }
示例#10
0
 /**
  * get the area number fields
  *
  * @param n
  * @return
  */
 @SuppressWarnings(value = "unchecked")
 public TBaseDSL setAreaNumber(int n) {
   Area area = CoreObjectFactory.createArea(n, net);
   this.obj.setArea(area);
   return (TBaseDSL) this;
 }
示例#11
0
  @Override
  public boolean solveCPF() {

    this.iteration = 0;
    this.outCnt = 0;
    lastLFConverged = true; // as a flag
    saveFlag = true;
    while (this.iteration < cpfAlgo.getCPFMaxInteration()) {
      IpssLogger.getLogger().info("CPF analysis Itr:" + this.iteration);
      /*
       * dynamically determine continuation parameter after four iterations
       * or last corrector step not converged.
       */

      if (this.iteration > 3 || !this.lastLFConverged) {
        IpssLogger.getLogger()
            .info(
                "update continuation parameter, last sort Number is #"
                    + this.getSortNumOfContParam()
                    + ",  now is #"
                    + getNextStepContParam());
        this.setSorNumofContParam(getNextStepContParam());
      }

      // run preStepSolver and update network buses' voltage with solved result;

      this.predStepSolver.stepSolver();
      /*
       * output the deltaX for test
       */
      //		  System.out.println("predictive
      // deltaXL"+this.predStepSolver.getDeltaXLambda().toString());

      // perform corrector step analysis
      LoadflowAlgorithm algo = CoreObjectFactory.createLoadflowAlgorithm();
      algo.setTolerance(this.cpfAlgo.getPflowTolerance());
      algo.setMaxIterations(this.cpfAlgo.getPfMaxInteration());
      // corrector step solver is just a customized Newton-Raphson solver;
      algo.setNrSolver(this.corrStepSolver);

      // if corrector step is not converged ,apply step size control
      if (!this.cpfAlgo.getAclfNetwork().accept(algo)) {
        if (this.cpfAlgo.getStepSize() < this.cpfAlgo.getMinStepSize() && this.iteration > 1) {
          IpssLogger.getLogger()
              .severe(
                  "predictor step size ="
                      + this.cpfAlgo.getStepSize()
                      + ",  is small enough,yet convergance problems still remains!");
          return false;
        }
        // step size control in the following step if this corrector step is not converged!
        this.predStepSolver.enableStepSizeControl(true);
        this.backToLastConvgState(); // back to the last converged state;
        IpssLogger.getLogger()
            .warning(
                "the previous Predictor step-size seems to be too large, need to be controlled");
        this.saveFlag = false;
      }

      /*
       * if corrector step is converged to the 'lower' curve because of too-large step size
       * in the predictor step; apply step control in the predictor step;
       */
      //		  else
      // if(!this.predStepSolver.isCrossMaxPwrPnt()&&(this.lambda.getValue()<this.convg_lambda)){
      //			  IpssLogger.getLogger().warning("this step lamba="+this.lambda.getValue()+"last
      // converged lambda="+this.convg_lambda+"\n"+
      //			  		", the corrector step converged in the 'lower' curve,back to last state and apply
      // step control");
      //			  this.predStepSolver.enableStepSizeControl(true);
      //			  this.backToLastConvgState();
      //			  this.saveFlag=false;
      //		  }
      else if (isCpfStopCriteriaMeet()) {
        IpssLogger.getLogger().info("one analysis Stop Criteria is meeted,CPF analysis end!");
        return true;
      }

      // save the last converged network state
      if (this.saveFlag) this.saveConvgState();

      // save the intermediate state for result output;
      if (this.cpfAlgo.getAclfNetwork().isLfConverged()) {
        this.lambdaList.add(this.getLambda().getValue());
        int index = 0;
        for (Bus b : this.cpfAlgo.getAclfNetwork().getBusList()) {
          AclfBus bus = (AclfBus) b;

          if (this.iteration == 0) {
            Hashtable<Integer, Double> ht =
                new Hashtable<Integer, Double>(this.cpfAlgo.getMaxIterations());
            ht.put(outCnt, bus.getVoltageMag());
            this.busPVCurveList.add(ht);

            this.pvOutPutList.add(bus.getVoltageMag() + ",");
          } else {
            String v = this.pvOutPutList.get(index);
            v += bus.getVoltageMag() + ",";
            this.pvOutPutList.set(index, v);

            this.busPVCurveList.get(index).put(outCnt, bus.getVoltageMag());
          }
          index++;
        }
        outCnt++;
      }
      IpssLogger.getLogger()
          .info(
              "converged? ="
                  + this.cpfAlgo.getAclfNetwork().isLfConverged()
                  + ", lambda="
                  + this.getLambda().getValue());

      this.iteration++;
      this.lastLFConverged = this.cpfAlgo.getAclfNetwork().isLfConverged();
      this.saveFlag = true;
      //		  System.out.println(AclfOutFunc.loadFlowSummary(cpfAlgo.getAclfNetwork()));
    }
    IpssLogger.getLogger().info("not converged within the max iteration!");
    return false;
  }