LoadFlowResultsCompletion implements CandidateComputation { @Override public void run(Network network, ComputationManager computationManager) { Objects.requireNonNull(network); LOGGER.info("Running {} on network {}, variant {}", getName(), network.getId(), network.getVariantManager().getWorkingVariantId()); LOGGER.info("LoadFlowResultsCompletionParameters={}", parameters); LOGGER.info("LoadFlowParameters={}", lfParameters); network.getLineStream() .filter(l -> l.getTerminal1().getBusView().getBus() != l.getTerminal2().getBusView().getBus()) .forEach(line -> { BranchData lineData = new BranchData(line, parameters.getEpsilonX(), parameters.isApplyReactanceCorrection()); completeTerminalData(line.getTerminal(Side.ONE), Side.ONE, lineData); completeTerminalData(line.getTerminal(Side.TWO), Side.TWO, lineData); }); network.getTwoWindingsTransformerStream().forEach(twt -> { int phaseAngleClock = 0; TwoWindingsTransformerPhaseAngleClock phaseAngleClockExtension = twt.getExtension(TwoWindingsTransformerPhaseAngleClock.class); if (phaseAngleClockExtension != null) { phaseAngleClock = phaseAngleClockExtension.getPhaseAngleClock(); } BranchData twtData = new BranchData(twt, phaseAngleClock, parameters.getEpsilonX(), parameters.isApplyReactanceCorrection(), lfParameters.isTwtSplitShuntAdmittance()); completeTerminalData(twt.getTerminal(Side.ONE), Side.ONE, twtData); completeTerminalData(twt.getTerminal(Side.TWO), Side.TWO, twtData); }); network.getShuntCompensatorStream().forEach(sh -> { Terminal terminal = sh.getTerminal(); if (terminal.isConnected() && Double.isNaN(terminal.getQ()) && terminal.getBusView().getBus() != null && terminal.getBusView().getBus().isInMainConnectedComponent()) { double v = terminal.getBusView().getBus().getV(); double q = -sh.getB() * v * v; LOGGER.debug("Shunt {}, setting q = {}", sh, q); terminal.setQ(q); } }); network.getThreeWindingsTransformerStream().forEach(twt -> { int phaseAngleClock2 = 0; int phaseAngleClock3 = 0; ThreeWindingsTransformerPhaseAngleClock phaseAngleClockExtension = twt.getExtension(ThreeWindingsTransformerPhaseAngleClock.class); if (phaseAngleClockExtension != null) { phaseAngleClock2 = phaseAngleClockExtension.getPhaseAngleClockLeg2(); phaseAngleClock3 = phaseAngleClockExtension.getPhaseAngleClockLeg3(); } TwtData twtData = new TwtData(twt, phaseAngleClock2, phaseAngleClock3, parameters.getEpsilonX(), parameters.isApplyReactanceCorrection(), lfParameters.isTwtSplitShuntAdmittance()); completeTerminalData(twt.getLeg1().getTerminal(), ThreeWindingsTransformer.Side.ONE, twtData); completeTerminalData(twt.getLeg2().getTerminal(), ThreeWindingsTransformer.Side.TWO, twtData); completeTerminalData(twt.getLeg3().getTerminal(), ThreeWindingsTransformer.Side.THREE, twtData); }); Z0FlowsCompletion z0FlowsCompletion = new Z0FlowsCompletion(network, z0checker); z0FlowsCompletion.complete(); } LoadFlowResultsCompletion(LoadFlowResultsCompletionParameters parameters, LoadFlowParameters lfParameters);  LoadFlowResultsCompletion(); Z0LineChecker z0checker(); @Override String getName(); @Override void run(Network network, ComputationManager computationManager); static final String NAME; }
@Test public void run() throws Exception { setNanValues(); LoadFlowResultsCompletionParameters parameters = new LoadFlowResultsCompletionParameters(); LoadFlowParameters lfParameters = new LoadFlowParameters(); CandidateComputation computation = new LoadFlowResultsCompletion(parameters, lfParameters); assertEquals(LoadFlowResultsCompletion.NAME, computation.getName()); computation.run(network, null); checkResultsCompletion(); }