Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Default addRatioToLinesWithDifferentNominalVoltageAtBothEnds parameter to true #434

Merged
merged 5 commits into from
Jan 27, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ public class OpenLoadFlowParameters extends AbstractExtension<LoadFlowParameters

public static final boolean LOAD_POWER_FACTOR_CONSTANT_DEFAULT_VALUE = false;

public static final boolean ADD_RATIO_TO_LINES_WITH_DIFFERENT_NOMINAL_VOLTAGE_AT_BOTH_ENDS_DEFAULT_VALUE = false;
public static final boolean ADD_RATIO_TO_LINES_WITH_DIFFERENT_NOMINAL_VOLTAGE_AT_BOTH_ENDS_DEFAULT_VALUE = true;

/**
* Slack bus maximum active power mismatch in MW: 1 Mw => 10^-2 in p.u
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ void testDcParameters() {
void testAcParameters() {
Network network = Mockito.mock(Network.class);
AcLoadFlowParameters acParameters = OpenLoadFlowProvider.createAcParameters(network, new DenseMatrixFactory(), new LoadFlowParameters().setReadSlackBus(true), new OpenLoadFlowParameters(), false, Reporter.NO_OP);
assertEquals("AcLoadFlowParameters(networkParameters=LfNetworkParameters(slackBusSelector=NetworkSlackBusSelector, generatorVoltageRemoteControl=true, minImpedance=false, twtSplitShuntAdmittance=false, breakers=false, plausibleActivePowerLimit=5000.0, addRatioToLinesWithDifferentNominalVoltageAtBothEnds=false, computeMainConnectedComponentOnly=true, countriesToBalance=[], distributedOnConformLoad=false, phaseControl=false, transformerVoltageControl=false, voltagePerReactivePowerControl=false, reactivePowerRemoteControl=false, isDc=false, reactiveLimits=true), equationSystemCreationParameters=AcEquationSystemCreationParameters(forceA1Var=false, branchesWithCurrent=null), newtonRaphsonParameters=NewtonRaphsonParameters(maxIteration=30, voltageInitializer=UniformValueVoltageInitializer, stoppingCriteria=DefaultNewtonRaphsonStoppingCriteria), outerLoops=[DistributedSlackOuterLoop, ReactiveLimitsOuterLoop], matrixFactory=DenseMatrixFactory)",
assertEquals("AcLoadFlowParameters(networkParameters=LfNetworkParameters(slackBusSelector=NetworkSlackBusSelector, generatorVoltageRemoteControl=true, minImpedance=false, twtSplitShuntAdmittance=false, breakers=false, plausibleActivePowerLimit=5000.0, addRatioToLinesWithDifferentNominalVoltageAtBothEnds=true, computeMainConnectedComponentOnly=true, countriesToBalance=[], distributedOnConformLoad=false, phaseControl=false, transformerVoltageControl=false, voltagePerReactivePowerControl=false, reactivePowerRemoteControl=false, isDc=false, reactiveLimits=true), equationSystemCreationParameters=AcEquationSystemCreationParameters(forceA1Var=false, branchesWithCurrent=null), newtonRaphsonParameters=NewtonRaphsonParameters(maxIteration=30, voltageInitializer=UniformValueVoltageInitializer, stoppingCriteria=DefaultNewtonRaphsonStoppingCriteria), outerLoops=[DistributedSlackOuterLoop, ReactiveLimitsOuterLoop], matrixFactory=DenseMatrixFactory)",
acParameters.toString());
}

Expand Down
179 changes: 179 additions & 0 deletions src/test/java/com/powsybl/openloadflow/ac/AcLoadFlowBoundaryTest.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,179 @@
/**
* Copyright (c) 2019, RTE (http://www.rte-france.com)
* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/.
*/
package com.powsybl.openloadflow.ac;

import com.powsybl.iidm.network.*;
import com.powsybl.loadflow.LoadFlow;
import com.powsybl.loadflow.LoadFlowParameters;
import com.powsybl.loadflow.LoadFlowResult;
import com.powsybl.math.matrix.DenseMatrixFactory;
import com.powsybl.openloadflow.OpenLoadFlowParameters;
import com.powsybl.openloadflow.OpenLoadFlowProvider;
import com.powsybl.openloadflow.network.BoundaryFactory;
import com.powsybl.openloadflow.network.SlackBusSelectionMode;
import com.powsybl.openloadflow.network.VoltageControlNetworkFactory;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;

import static com.powsybl.openloadflow.util.LoadFlowAssert.*;
import static org.junit.jupiter.api.Assertions.assertTrue;

/**
* @author Geoffroy Jamgotchian <geoffroy.jamgotchian at rte-france.com>
*/
class AcLoadFlowBoundaryTest {

private Network network;
private Bus bus1;
private Bus bus2;
private DanglingLine dl1;
private Generator g1;

private LoadFlow.Runner loadFlowRunner;

private LoadFlowParameters parameters;

private OpenLoadFlowParameters parametersExt;

@BeforeEach
void setUp() {
network = BoundaryFactory.create();
bus1 = network.getBusBreakerView().getBus("b1");
bus2 = network.getBusBreakerView().getBus("b2");
dl1 = network.getDanglingLine("dl1");
g1 = network.getGenerator("g1");
loadFlowRunner = new LoadFlow.Runner(new OpenLoadFlowProvider(new DenseMatrixFactory()));
parameters = new LoadFlowParameters().setNoGeneratorReactiveLimits(true)
.setDistributedSlack(false);
parametersExt = new OpenLoadFlowParameters()
.setSlackBusSelectionMode(SlackBusSelectionMode.MOST_MESHED);
parameters.addExtension(OpenLoadFlowParameters.class, parametersExt);
}

@Test
void test() {
LoadFlowResult result = loadFlowRunner.run(network, parameters);
assertTrue(result.isOk());

assertVoltageEquals(390, bus1);
assertAngleEquals(0.058104, bus1);
assertVoltageEquals(388.582864, bus2);
assertAngleEquals(0, bus2);
assertActivePowerEquals(101.302, dl1.getTerminal());
assertReactivePowerEquals(149.764, dl1.getTerminal());
}

@Test
void testWithVoltageRegulationOn() {
g1.setTargetQ(0);
g1.setVoltageRegulatorOn(false);
dl1.getGeneration().setVoltageRegulationOn(true);
dl1.getGeneration().setMinP(0);
dl1.getGeneration().setMaxP(10);
dl1.getGeneration().newMinMaxReactiveLimits()
.setMinQ(-100)
.setMaxQ(100)
.add();
LoadFlowResult result = loadFlowRunner.run(network, parameters);
assertTrue(result.isOk());

assertVoltageEquals(390.440, bus1);
assertAngleEquals(0.114371, bus1);
assertVoltageEquals(390.181, bus2);
assertAngleEquals(0, bus2);
assertActivePowerEquals(101.2, dl1.getTerminal());
assertReactivePowerEquals(-0.202, dl1.getTerminal());

parameters.setDistributedSlack(true)
.setNoGeneratorReactiveLimits(false);
LoadFlowResult result2 = loadFlowRunner.run(network, parameters);
assertTrue(result2.isOk());

assertVoltageEquals(390.440, bus1);
assertAngleEquals(0.114371, bus1);
assertVoltageEquals(390.181, bus2);
assertAngleEquals(0, bus2);
assertActivePowerEquals(101.2, dl1.getTerminal());
assertReactivePowerEquals(-0.202, dl1.getTerminal());
}

@Test
void testWithXnode() {
Network network = BoundaryFactory.createWithXnode();
parameters.setNoGeneratorReactiveLimits(false);
parameters.setDistributedSlack(true);
LoadFlowResult result = loadFlowRunner.run(network, parameters);
assertTrue(result.isOk());

assertVoltageEquals(400.000, network.getBusBreakerView().getBus("b1"));
assertVoltageEquals(399.999, network.getBusBreakerView().getBus("xnode"));
assertVoltageEquals(399.999, network.getBusBreakerView().getBus("b3"));
assertVoltageEquals(400.000, network.getBusBreakerView().getBus("b4"));

parametersExt.setAddRatioToLinesWithDifferentNominalVoltageAtBothEnds(false);
LoadFlowResult result2 = loadFlowRunner.run(network, parameters);
assertTrue(result2.isOk());

assertVoltageEquals(400.000, network.getBusBreakerView().getBus("b1"));
assertVoltageEquals(398.139, network.getBusBreakerView().getBus("xnode"));
assertVoltageEquals(417.679, network.getBusBreakerView().getBus("b3"));
assertVoltageEquals(400.000, network.getBusBreakerView().getBus("b4"));
}

@Test
void testWithTieLine() {
Network network = BoundaryFactory.createWithTieLine();
parameters.setNoGeneratorReactiveLimits(false);
parameters.setDistributedSlack(true);
LoadFlowResult result = loadFlowRunner.run(network, parameters);
assertTrue(result.isOk());

assertVoltageEquals(400.000, network.getBusBreakerView().getBus("b1"));
assertVoltageEquals(399.999, network.getBusBreakerView().getBus("b3"));
assertVoltageEquals(400.000, network.getBusBreakerView().getBus("b4"));

parametersExt.setAddRatioToLinesWithDifferentNominalVoltageAtBothEnds(false);
LoadFlowResult result2 = loadFlowRunner.run(network, parameters);
assertTrue(result2.isOk());

assertVoltageEquals(400.000, network.getBusBreakerView().getBus("b1"));
assertVoltageEquals(417.841, network.getBusBreakerView().getBus("b3"));
assertVoltageEquals(400.000, network.getBusBreakerView().getBus("b4"));
}

@Test
void testEquivalentBranch() {
Network network = VoltageControlNetworkFactory.createNetworkWithT2wt();
network.newLine()
.setId("LINE_23")
.setVoltageLevel1("VL_2")
.setVoltageLevel2("VL_3")
.setBus1("BUS_2")
.setBus2("BUS_3")
.setR(1.05)
.setX(0.01)
.setG1(0.)
.setG2(0.)
.setB1(0.)
.setB2(0.)
.add();

parametersExt.setAddRatioToLinesWithDifferentNominalVoltageAtBothEnds(false);
LoadFlowResult result = loadFlowRunner.run(network, parameters);
assertTrue(result.isOk());
assertVoltageEquals(135.0, network.getBusBreakerView().getBus("BUS_1"));
assertVoltageEquals(134.25, network.getBusBreakerView().getBus("BUS_2"));
assertVoltageEquals(33.26, network.getBusBreakerView().getBus("BUS_3"));

parametersExt.setAddRatioToLinesWithDifferentNominalVoltageAtBothEnds(true);
LoadFlowResult result2 = loadFlowRunner.run(network, parameters);
assertTrue(result2.isOk());
assertVoltageEquals(135.0, network.getBusBreakerView().getBus("BUS_1"));
assertVoltageEquals(121.62, network.getBusBreakerView().getBus("BUS_2"));
assertVoltageEquals(0.04, network.getBusBreakerView().getBus("BUS_3"));
}
}

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,7 @@ void remoteVoltageControlT2wtTest() {
.add();
VoltageLevel vl4 = substation.newVoltageLevel()
.setId("VL_4")
.setNominalV(32.0)
.setNominalV(33.0)
.setLowVoltageLimit(0)
.setHighVoltageLimit(100)
.setTopologyKind(TopologyKind.BUS_BREAKER)
Expand Down Expand Up @@ -145,7 +145,7 @@ void remoteVoltageControlT2wtTest() {
.setTargetV(33.0);

LoadFlowResult result = loadFlowRunner.run(network, parameters);
assertVoltageEquals(31.861, bus4);
assertVoltageEquals(32.872, bus4);
assertTrue(result.isOk());
assertEquals(3, t2wt.getRatioTapChanger().getTapPosition());

Expand All @@ -158,7 +158,7 @@ void remoteVoltageControlT2wtTest() {
.setTargetV(33.0);

result = loadFlowRunner.run(network, parameters);
assertVoltageEquals(31.862, bus4); //FIXME: should be 31.861
assertVoltageEquals(32.874, bus4); //FIXME: should be 32.872
assertTrue(result.isOk());
assertEquals(3, t2wt.getRatioTapChanger().getTapPosition());
}
Expand Down Expand Up @@ -408,7 +408,7 @@ void remoteVoltageControlT3wtTest() {
.add();
VoltageLevel vl5 = substation.newVoltageLevel()
.setId("VL_5")
.setNominalV(30.0)
.setNominalV(33.0)
.setLowVoltageLimit(0)
.setHighVoltageLimit(100.0)
.setTopologyKind(TopologyKind.BUS_BREAKER)
Expand Down Expand Up @@ -446,7 +446,7 @@ void remoteVoltageControlT3wtTest() {

LoadFlowResult result = loadFlowRunner.run(network, parameters);
assertTrue(result.isOk());
assertVoltageEquals(31.200, bus5);
assertVoltageEquals(34.329, bus5);

parameters.setTransformerVoltageControlOn(true);
t3wt.getLeg2().getRatioTapChanger()
Expand All @@ -458,7 +458,7 @@ void remoteVoltageControlT3wtTest() {

result = loadFlowRunner.run(network, parameters);
assertTrue(result.isOk());
assertVoltageEquals(31.200, bus5);
assertVoltageEquals(34.329, bus5);
}

/**
Expand Down
Loading