@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();
  }
  @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();
  }