Ejemplo n.º 1
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;
 }
Ejemplo n.º 2
0
  @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);
  }
Ejemplo n.º 3
0
  @Test
  public void dclf1() throws Exception {
    IpssCorePlugin.init();
    // IpssCorePlugin.setSparseEqnSolver(SolverType.Native);
    ODMLogger.getLogger().setLevel(Level.WARNING);

    AclfNetwork net =
        IpssAdapter.importAclfNet("testData/psse/v30/Mod_SixBus_2WPsXfr.raw")
            .format(IpssAdapter.FileFormat.PSSE)
            .psseVersion(PsseVersion.PSSE_30)
            .xfrBranchModel(ODMAclfNetMapper.XfrBranchModel.PSSE)
            .load()
            .getAclfNet();
    // System.out.println(net.net2String());
    /*
    net.accept(CoreObjectFactory.createBusNoArrangeVisitor());
    for (Bus b : net.getBusList())
    	System.out.println(b.getId() + ": " + b.getSortNumber());
    	System.out.println(net.formB1Matrix());
    */

    DclfAlgorithm algo = DclfObjectFactory.createDclfAlgorithm(net);
    algo.calculateDclf();

    System.out.println(DclfOutFunc.dclfResults(algo, false));
    assertTrue(Math.abs(algo.getBusPower(net.getBus("Bus1")) - 3.0723) < 0.0001);

    algo.destroy();
  }
Ejemplo n.º 4
0
  @Test
  public void dclf() throws Exception {
    IpssCorePlugin.init();
    // IpssCorePlugin.setSparseEqnSolver(SolverType.Native);
    ODMLogger.getLogger().setLevel(Level.WARNING);

    AclfNetwork net =
        IpssAdapter.importAclfNet("testData/psse/v30/Mod_SixBus_2WPsXfr.raw")
            .format(IpssAdapter.FileFormat.PSSE)
            .psseVersion(PsseVersion.PSSE_30)
            .xfrBranchModel(ODMAclfNetMapper.XfrBranchModel.InterPSS)
            .load()
            .getAclfNet();
    // System.out.println(net.net2String());
    /*
    net.accept(CoreObjectFactory.createBusNoArrangeVisitor());
    for (Bus b : net.getBusList())
    	System.out.println(b.getId() + ": " + b.getSortNumber());
    	System.out.println(net.formB1Matrix());
    */

    // because of InterPSS xfrBranchModel, we need to convert to the PSS/E model
    for (Branch b : net.getBranchList()) {
      AclfBranch branch = (AclfBranch) b;
      if (branch.isXfr() || branch.isPSXfr()) {
        if (branch.getToTurnRatio() != 1.0) {
          branch.setZ(branch.getZ().multiply(branch.getToTurnRatio() * branch.getToTurnRatio()));
          branch.setFromTurnRatio(branch.getFromTurnRatio() / branch.getToTurnRatio());
          branch.setToTurnRatio(1.0);
          if (branch.isPSXfr()) {
            branch.setFromPSXfrAngle(branch.getFromPSXfrAngle() - branch.getToPSXfrAngle());
            branch.setToPSXfrAngle(0.0);
          }
        }
      }
    }

    DclfAlgorithm algo = DclfObjectFactory.createDclfAlgorithm(net);
    algo.calculateDclf();

    System.out.println(DclfOutFunc.dclfResults(algo, false));
    assertTrue(Math.abs(algo.getBusPower(net.getBus("Bus1")) - 3.0723) < 0.0001);

    algo.destroy();
  }
Ejemplo n.º 5
0
  private boolean runLoadflow_internal(AclfNetwork aclfAdjNet, LoadflowAlgorithm algo) {
    algo.setAclfNetwork(aclfAdjNet);
    EditorPluginSpringFactory.getXml2LfAlgorithmMapper()
        .map2Model(this.getAclfCaseData().getAclfAlgorithm(), algo);

    algo.loadflow();

    return aclfAdjNet.isLfConverged();
  }
Ejemplo n.º 6
0
  private void setNameplateAclfNetData(DistNetwork distNet) {
    AclfNetwork net = distNet.getAclfNet();

    for (Bus b : distNet.getBusList()) {
      DistBus bus = (DistBus) b;
      if (bus.getBusCode() == DistBusCode.GENERATOR) {
        GeneratorAptr.f(bus).setAclfBusData(net.getBaseKva());
      } else if (bus.getBusCode() == DistBusCode.SYN_MOTOR) {
        SynMotorAptr.f(bus).setAclfBusData(net.getBaseKva());
      } else if (bus.getBusCode() == DistBusCode.IND_MOTOR) {
        IndMotorAptr.f(bus).setAclfBusData(net.getBaseKva());
      } else if (bus.getBusCode() == DistBusCode.MIXED_LOAD) {
        MixedLoadAptr.f(bus).setAclfBusData(net.getBaseKva());
      }
    }

    for (Branch br : distNet.getBranchList()) {
      DistBranch branch = (DistBranch) br;
      branch.getAcscBranch().setStatus(branch.isActive());
    }
  }
Ejemplo n.º 7
0
 // Update vsh inside the statcom converter
 public void update(AclfNetwork net) throws InterpssException {
   Complex vi = net.getAclfBus(id).getVoltage();
   Complex vsh1 = this.converter.getVth();
   if (type == StatcomControlType.ConstB) { // Control of constant shunt admittance
     Complex vsh = solveConstB(vsh1, vi, this.converter, tunedValue);
     this.converter.setVth(vsh);
   } else if (type
       == StatcomControlType.ConstQ) { // Control of constant shunt reactive power compensation
     Complex vsh = solveConstQ(vsh1, vi, this.converter, tunedValue);
     this.converter.setVth(vsh);
   } else if (type == StatcomControlType.ConstV) { // Control of constant voltage magnitude
     Complex vsh = solveConstV(vsh1, vi, this.converter, tunedValue);
     this.converter.setVth(vsh);
   }
   Complex vsh2 = this.converter.getVth();
   if (type != StatcomControlType.ConstV) err = (vsh1.subtract(vsh2)).abs();
 }
Ejemplo n.º 8
0
  public boolean runCase(SimuContext simuCtx) {
    boolean converge = false;
    if (this.xmlGridOpt.isEnableGridRun()) {
      final AclfNetwork aclfNet = simuCtx.getAclfNet();
      Grid grid = GridEnvHelper.getDefaultGrid();
      if (this.contingencyAnalysis) {
        IpssLogger.getLogger().info("Run Grid contingency analysis");

        try {
          GridContingencyAnalysis analysis =
              GridObjectFactory.createGridContingencyAnalysis(
                  simuCtx.getNetType(), simuCtx.getAclfNet(), grid);
          analysis.setLimitRunCase(this.xmlContingency.isLimitRunCases());
          if (analysis.isLimitRunCase())
            analysis.setMaxRunCase(this.xmlContingency.getMaxRunCases());

          LoadflowAlgorithm algo = simuCtx.getLoadflowAlgorithm();
          EditorPluginSpringFactory.getXml2LfAlgorithmMapper()
              .map2Model(this.xmlContingency.getDefaultAclfAlgorithm(), algo);
          analysis.perform(algo, ContingencyAnalysisType.N1);
          // System.out.println(analysis.getResult(IRemoteResult.DisplayType_SecViolation));
          // System.out.println(analysis.getResult(IRemoteResult.DisplayType_SecAssessment));

          IOutputTextDialog dialog =
              UISpringFactory.getOutputTextDialog("Contingency Analysis Info");
          StringBuffer buffer = new StringBuffer();
          buffer.append(analysis.getResult(IRemoteResult.DisplayType_SecViolation));
          buffer.append(analysis.getResult(IRemoteResult.DisplayType_SecAssessment));
          dialog.display(buffer);
        } catch (InterpssException e) {
          EditorPluginSpringFactory.getEditorDialogUtil()
              .showErrMsgDialog("Grid Aclf Error", e.toString());
          return false;
        }
      } else {
        String nodeId = GridEnvHelper.nodeIdLookup(this.xmlGridOpt.getRemoteNodeName());
        DStabSingleJobTask.RemoteNodeId = nodeId;
        GridRunner.MasterNodeId = grid.getLocalNode().getId().toString();
        try {
          RemoteMessageTable result =
              new GridRunner(grid, "InterPSS Grid Aclf Calculation", simuCtx.getLoadflowAlgorithm())
                  .executeSingleJobTask(this.xmlGridOpt.getTimeout());
          String str = result.getSerializedAclfNet();
          AclfNetwork adjNet = (AclfNetwork) SerializeEMFObjectUtil.loadModel(str);
          adjNet.rebuildLookupTable();
          simuCtx.setAclfNet(adjNet);
          converge = adjNet.isLfConverged();
          if (this.xmlCaseData.getAclfAlgorithm().isDisplaySummary()) {
            IOutputTextDialog dialog =
                UISpringFactory.getOutputTextDialog(
                    "Loadflow Analysis Run by Remote " + this.xmlGridOpt.getRemoteNodeName());
            dialog.display(adjNet);
          }
        } catch (GridException e) {
          EditorPluginSpringFactory.getEditorDialogUtil()
              .showErrMsgDialog("Grid Aclf Error", e.toString());
          return false;
        }
      }
      simuCtx.setAclfNet(aclfNet);
    } else {
      if (this.contingencyAnalysis) {
        IpssLogger.getLogger().info("Run contingency analysis");

        ContingencyAnalysis analysis =
            SimuObjectFactory.createContingencyAnalysis(
                SimuCtxType.ACLF_NETWORK, simuCtx.getAclfNet());
        analysis.setLimitRunCase(this.xmlContingency.isLimitRunCases());
        if (analysis.isLimitRunCase()) analysis.setMaxRunCase(this.xmlContingency.getMaxRunCases());

        LoadflowAlgorithm algo = simuCtx.getLoadflowAlgorithm();
        EditorPluginSpringFactory.getXml2LfAlgorithmMapper()
            .map2Model(this.xmlContingency.getDefaultAclfAlgorithm(), algo);
        analysis.analysis(algo, ContingencyAnalysisType.N1);

        IOutputTextDialog dialog = UISpringFactory.getOutputTextDialog("Contingency Analysis Info");
        dialog.display(ContingencyOutFunc.securityMargin(analysis));
      } else converge = runLoadflow(simuCtx.getAclfNet(), simuCtx);
    }
    return converge;
  }