return new BranchData(t.branch.id, r, x, rho1, rho2,
private void completeTerminalData(Terminal terminal, Side side, BranchData branchData) { if (terminal.isConnected() && terminal.getBusView().getBus().isInMainConnectedComponent()) { if (Double.isNaN(terminal.getP())) { LOGGER.debug("Branch {}, Side {}: setting p = {}", branchData.getId(), side, branchData.getComputedP(side)); terminal.setP(branchData.getComputedP(side)); } if (Double.isNaN(terminal.getQ())) { LOGGER.debug("Branch {}, Side {}: setting q = {}", branchData.getId(), side, branchData.getComputedQ(side)); terminal.setQ(branchData.getComputedQ(side)); } } }
LOG.debug("Results for " + title + " branch " + b.getId()); LOG.debug("End1"); LOG.debug(String.format(" V = %14.6f %14.6f", b.getComputedU1(), Math.toDegrees(b.getComputedTheta1()))); LOG.debug(String.format(" S expected = %14.6f %14.6f", t.expectedFlow1.p, t.expectedFlow1.q)); LOG.debug(String.format(" S actual = %14.6f %14.6f", b.getComputedP1(), b.getComputedQ1())); LOG.debug(String.format(" diff = %14.6f %14.6f", Math.abs(t.expectedFlow1.p - b.getComputedP1()), Math.abs(t.expectedFlow1.q - b.getComputedQ1()))); LOG.debug(String.format(" tolerance = %14.6f %14.6f", t.config.toleranceFlow, LOG.debug("End2"); LOG.debug(String.format(" V = %14.6f %14.6f", b.getComputedU2(), Math.toDegrees(b.getComputedTheta2()))); LOG.debug(String.format(" S expected = %14.6f %14.6f", t.expectedFlow2.p, t.expectedFlow2.q)); LOG.debug(String.format(" S actual = %14.6f %14.6f", b.getComputedP2(), b.getComputedQ2())); LOG.debug(String.format(" diff = %14.6f %14.6f", Math.abs(t.expectedFlow2.p - b.getComputedP2()),
this.r = r; this.x = x; double fixedX = getFixedX(x, epsilonX, applyReactanceCorrection); z = Math.hypot(r, fixedX); y = 1 / z; this.mainComponent1 = mainComponent1; this.mainComponent2 = mainComponent2; computeValues();
Bus connectableBus2 = twt.getTerminal2().getBusView().getConnectableBus(); r = getR(twt); x = getX(twt); double fixedX = getFixedX(x, epsilonX, applyReactanceCorrection); z = Math.hypot(r, fixedX); y = 1 / z; ksi = Math.atan2(r, fixedX); rho1 = getRho1(twt); rho2 = 1f; u1 = bus1 != null ? bus1.getV() : Double.NaN; alpha1 = twt.getPhaseTapChanger() != null ? Math.toRadians(twt.getPhaseTapChanger().getCurrentStep().getAlpha()) : 0f; alpha2 = 0f; g1 = getG1(twt, specificCompatibility); g2 = specificCompatibility ? twt.getG() / 2 : 0f; b1 = getB1(twt, specificCompatibility); b2 = specificCompatibility ? twt.getB() / 2 : 0f; p1 = twt.getTerminal1().getP(); mainComponent2 = bus2 != null ? bus2.isInMainConnectedComponent() : connectableMainComponent2; computeValues();
private BranchData checkTestCase(String title, BranchTestCase t) { BranchData b = piModelFlows(t); logTestCase(title, t, b); assertEquals(t.expectedFlow1.p, b.getComputedP1(), t.config.toleranceFlow); assertEquals(t.expectedFlow1.q, b.getComputedQ1(), t.config.toleranceFlow); if (!Double.isNaN(t.expectedFlow2.p)) { assertEquals(t.expectedFlow2.p, b.getComputedP2(), t.config.toleranceFlow); } if (!Double.isNaN(t.expectedFlow2.q)) { assertEquals(t.expectedFlow2.q, b.getComputedQ2(), t.config.toleranceFlow); } return b; }
computedP1 = leg1BranchData.getComputedP1(); computedQ1 = leg1BranchData.getComputedQ1(); BranchData leg2BranchData = legBranchData(twt.getId(), Side.TWO, twt.getLeg2(), ratedU0, starVoltage, epsilonX, applyReactanceCorrection); computedP2 = leg2BranchData.getComputedP1(); computedQ2 = leg2BranchData.getComputedQ1(); BranchData leg3BranchData = legBranchData(twt.getId(), Side.THREE, twt.getLeg3(), ratedU0, starVoltage, epsilonX, applyReactanceCorrection); computedP3 = leg3BranchData.getComputedP1(); computedQ3 = leg3BranchData.getComputedQ1();
@Test public void testCAS2EntsoeLoadFlowExplicitLineAndPhaseShifterMovedToEnd1() { BranchTestCase line = cas2EntsoeLoadFlowExplicitLine(); BranchTestCase pst = cas2EntsoeLoadFlowExplicitPhaseShiftTransformer(); Flow load = cas2EntsoeLoadFlowExplicitLoad(); Flow generator = cas2EntsoeLoadFlowExplicitGenerator(); // Move phase shift from end 2 to end 1 pst.branch.end1.tap.rho = 1 / pst.branch.end2.tap.rho; pst.branch.end1.tap.alpha = -pst.branch.end2.tap.alpha; double rho2square = pst.branch.end2.tap.rho * pst.branch.end2.tap.rho; double dz = 100 * (1 / rho2square - 1); double dy = 100 * (rho2square - 1); pst.branch.end1.tap.r = dz; pst.branch.end1.tap.x = dz; pst.branch.end1.tap.g = dy; pst.branch.end1.tap.b = dy; pst.branch.end2.tap.rho = 1; pst.branch.end2.tap.alpha = 0; BranchData pline = piModelFlows(line); BranchData ppst = piModelFlows(pst); LOG.debug(""); LOG.debug("Balance at ends of parallel branches " + pline.getId() + ", " + ppst.getId()); LOG.debug("After moving phase shifter to side 1"); Flow line1 = flow(pline, Side.ONE); Flow line2 = flow(pline, Side.TWO); Flow pst1 = flow(ppst, Side.ONE); Flow pst2 = flow(ppst, Side.TWO); checkBusBalance("End 1", TOLERANCE_BALANCE_EXACT, TOLERANCE_BALANCE_EXACT, line1, pst1, load); checkBusBalance("End 2", 1e-2, 1e-4, line2, pst2, generator); }
@Test public void testCAS2EntsoeLoadFlowExplicitLineAndPhaseShifter() { BranchTestCase line = cas2EntsoeLoadFlowExplicitLine(); BranchTestCase pst = cas2EntsoeLoadFlowExplicitPhaseShiftTransformer(); Flow load = cas2EntsoeLoadFlowExplicitLoad(); Flow generator = cas2EntsoeLoadFlowExplicitGenerator(); // Obtain flows at both ends of line and phase shifter BranchData pline = piModelFlows(line); BranchData ppst = piModelFlows(pst); // And check bus balance at each side // At end1 (load) the mismatch should be zero // because load values are given with all significant digits // and voltages have been copied from Excel documentation, // where they have sufficient precision // At end2 (generator, slack bus) the mismatch should be small: // generator injection in P and Q are provided with low precision // (P with 10e-2, Q with 10e-4) LOG.debug(""); LOG.debug("Balance at ends of parallel branches " + pline.getId() + ", " + ppst.getId()); Flow line1 = flow(pline, Side.ONE); Flow line2 = flow(pline, Side.TWO); Flow pst1 = flow(ppst, Side.ONE); Flow pst2 = flow(ppst, Side.TWO); checkBusBalance("End 1", TOLERANCE_BALANCE_EXACT, TOLERANCE_BALANCE_EXACT, line1, pst1, load); checkBusBalance("End 2", 1e-2, 1e-4, line2, pst2, generator); }
double fixedX = getFixedX(x, epsilonX, applyReactanceCorrection); z = Math.hypot(r, fixedX); y = 1 / z; mainComponent2 = bus2 != null ? bus2.isInMainConnectedComponent() : connectableMainComponent2; computeValues();
private Flow flow(BranchData b, Side side) { Flow f = new Flow(); f.id = b.getId(); f.p = b.getComputedP(side); f.q = b.getComputedQ(side); return f; }
BranchData lineData = new BranchData(line, parameters.getEpsilonX(), parameters.isApplyReactanceCorrection()); BranchData twtData = new BranchData(twt, parameters.getEpsilonX(), parameters.isApplyReactanceCorrection(),
private static BranchData legBranchData(String twtId, Side side, LegBase<?> leg, double g, double b, double ratedU0, Complex starVoltage, double epsilonX, boolean applyReactanceCorrection) { String branchId = twtId + "_" + side; double r = side == Side.ONE ? leg.getR() : adjustedR((Leg2or3) leg); double x = side == Side.ONE ? leg.getX() : adjustedX((Leg2or3) leg); double uk = getV(leg); double thetak = getTheta(leg); double u0 = starVoltage.abs(); double theta0 = starVoltage.getArgument(); double gk = 0; double bk = 0; double g0 = g; double b0 = b; double rhok = side == Side.ONE ? 1.0 : rho((Leg2or3) leg, ratedU0); double alphak = 0; double rho0 = 1; double alpha0 = 0; boolean buskMainComponent = true; boolean bus0MainComponent = true; boolean buskConnected = true; boolean bus0Connected = true; double flowPk = Double.NaN; double flowQk = Double.NaN; double flowP0 = Double.NaN; double flowQ0 = Double.NaN; return new BranchData(branchId, r, x, rhok, rho0, uk, u0, thetak, theta0, alphak, alpha0, gk, g0, bk, b0, flowPk, flowQk, flowP0, flowQ0, buskConnected, bus0Connected, buskMainComponent, bus0MainComponent, epsilonX, applyReactanceCorrection); }