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

Update powsybl to 5.3 #764

Merged
merged 5 commits into from
Jun 8, 2023
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 @@ -52,20 +52,17 @@ protected void interpret(Network network) {
branch = network.getBranch(mrId);
if (Objects.isNull(branch)) {
// check if it's a half line
for (Line line : network.getLines()) {
if (line.isTieLine()) {
TieLine tieLine = (TieLine) line;
if (tieLine.getHalf1().getId().equals(mrId)) {
isHalfLine = true;
tieLineSide = Branch.Side.ONE;
branch = line;
return;
} else if (tieLine.getHalf2().getId().equals(mrId)) {
isHalfLine = true;
tieLineSide = Branch.Side.TWO;
branch = line;
return;
}
for (TieLine tieLine : network.getTieLines()) {
if (tieLine.getDanglingLine1().getId().equals(mrId)) {
isHalfLine = true;
tieLineSide = Branch.Side.ONE;
branch = tieLine;
return;
} else if (tieLine.getDanglingLine2().getId().equals(mrId)) {
isHalfLine = true;
tieLineSide = Branch.Side.TWO;
branch = tieLine;
return;
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -108,9 +108,6 @@ private void interpretWithNetwork(Network network) {
if (interpretAsNetworkIdentifiable(network)) {
return;
}
if (interpretAsHalfLine(network)) {
return;
}
invalidate(format("branch %s was not found in the Network", branchId));

}
Expand All @@ -131,6 +128,9 @@ private boolean interpretAsNetworkIdentifiable(Network network) {
checkBranchNominalVoltage((Branch<?>) cnecElement);
checkBranchCurrentLimits((Branch<?>) cnecElement);
} else if (cnecElement instanceof DanglingLine) {
if (((DanglingLine) cnecElement).isPaired()) {
return interpretAsHalfLine(network);
}
checkDanglingLineNominalVoltage((DanglingLine) cnecElement);
checkDanglingLineCurrentLimits((DanglingLine) cnecElement);
} else {
Expand All @@ -140,19 +140,15 @@ private boolean interpretAsNetworkIdentifiable(Network network) {
}

private boolean interpretAsHalfLine(Network network) {
Optional<TieLine> tieLine = network.getBranchStream()
.filter(TieLine.class::isInstance)
.map(TieLine.class::cast)
.filter(b -> b.getHalf1().getId().equals(branchId) || b.getHalf2().getId().equals(branchId))
.findAny();
Optional<TieLine> tieLine = ((DanglingLine) network.getIdentifiable(branchId)).getTieLine();

if (tieLine.isEmpty()) {
return false;
}

this.branchIdInNetwork = tieLine.get().getId();
this.isHalfLine = true;
this.halfLineSide = tieLine.get().getHalf1().getId().equals(branchId) ? Branch.Side.ONE : Branch.Side.TWO;
this.halfLineSide = tieLine.get().getDanglingLine1().getId().equals(branchId) ? Branch.Side.ONE : Branch.Side.TWO;
checkBranchNominalVoltage(tieLine.get());
checkTieLineCurrentLimits(tieLine.get());
// todo: check if halfLine can be inverted in CGMES format
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ UcteMatchingResult lookForConnectable(String fromNodeId, String toNodeId, String

In such cases, both connectables fit the same from/to/suffix. But instead of returning a
UcteMatchingRule.severalPossibleMatch(), which is reserved for ambiguous situations with wildcards, this
method returns the connectable with the id in the same order than the the ones given in argument of the method.
method returns the connectable with the id in the same order as the ones given in argument of the method.
*/

UcteMatchingResult ucteMatchingResult = lookForMatch(fromNodeId, toNodeId, suffix, connectableTypes);
Expand Down Expand Up @@ -115,14 +115,16 @@ private UcteMatchingResult lookForMatchWithinCollection(String fromNodeId, Strin
if (fromNodeId.endsWith(UcteUtils.WILDCARD_CHARACTER) || toNodeId.endsWith(UcteUtils.WILDCARD_CHARACTER)) {
// if the nodes contains wildCards, we have to look for all possible match

List<UcteMatchingResult> matchedConnetables = ucteConnectables.stream()
List<UcteMatchingResult> matchedConnectables = ucteConnectables.stream()
.filter(ucteConnectable -> ucteConnectable.doesMatch(fromNodeId, toNodeId, suffix, connectableTypes))
.map(ucteConnectable -> ucteConnectable.getUcteMatchingResult(fromNodeId, toNodeId, suffix, connectableTypes))
.collect(Collectors.toList());

if (matchedConnetables.size() == 1) {
return matchedConnetables.get(0);
} else if (matchedConnetables.size() > 1) {
if (matchedConnectables.size() == 1) {
return matchedConnectables.get(0);
} else if (matchedConnectables.size() == 2) {
return UcteMatchingResult.severalPossibleMatch();
} else if (matchedConnectables.size() > 2) {
return UcteMatchingResult.severalPossibleMatch();
} else {
return UcteMatchingResult.notFound();
Expand Down Expand Up @@ -172,7 +174,7 @@ private void addBranches(Network network) {
}

private void addDanglingLines(Network network) {
network.getDanglingLineStream().forEach(danglingLine -> {
network.getDanglingLineStream().filter(danglingLine -> !danglingLine.isPaired()).forEach(danglingLine -> {
// A dangling line is an Injection with a generator convention.
// After an UCTE import, the flow on the dangling line is therefore always from the X_NODE to the other node.
String xNode = danglingLine.getUcteXnodeCode();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,7 @@ private void interpretWithNetworkAnalyzer(UcteNetworkAnalyzer ucteNetworkAnalyze
}

Identifiable<?> networkElement = ucteMatchingResult.getIidmIdentifiable();

this.connectableIdInNetwork = networkElement.getId();

}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
import com.powsybl.iidm.network.TieLine;

import java.util.Objects;
import java.util.Optional;

import static com.farao_community.farao.data.crac_creation.util.ucte.UcteConnectable.Side.TWO;
import static java.lang.String.format;
Expand Down Expand Up @@ -140,19 +141,22 @@ protected void interpretWithNetworkAnalyzer(UcteNetworkAnalyzer networkAnalyzer)
this.connectableIdInNetwork = networkElement.getId();

if (networkElement instanceof TieLine) {
this.isHalfLine = true;
this.halfLineSide = ucteMatchingResult.getSide() == TWO ? Branch.Side.TWO : Branch.Side.ONE;
checkBranchNominalVoltage((TieLine) networkElement);
checkTieLineCurrentLimits((TieLine) networkElement);
interpretTieLine((TieLine) networkElement, ucteMatchingResult.getSide() == TWO ? Branch.Side.TWO : Branch.Side.ONE);
} else if (networkElement instanceof Branch) {
checkBranchNominalVoltage((Branch<?>) networkElement);
checkBranchCurrentLimits((Branch<?>) networkElement);
} else if (networkElement instanceof DanglingLine) {
checkDanglingLineNominalVoltage((DanglingLine) networkElement);
checkDanglingLineCurrentLimits((DanglingLine) networkElement);
interpretDanglingLine((DanglingLine) networkElement);
}
}

private void interpretTieLine(TieLine tieLine, Branch.Side side) {
this.isHalfLine = true;
this.halfLineSide = side;
checkBranchNominalVoltage(tieLine);
checkTieLineCurrentLimits(tieLine);
}

private void checkTieLineCurrentLimits(TieLine tieLine) {
if (tieLine.getCurrentLimits(Branch.Side.ONE).isPresent()) {
this.currentLimitLeft = tieLine.getCurrentLimits(Branch.Side.ONE).orElseThrow().getPermanentLimit();
Expand All @@ -170,6 +174,21 @@ protected void checkBranchNominalVoltage(Branch<?> branch) {
this.nominalVoltageRight = branch.getTerminal2().getVoltageLevel().getNominalV();
}

private void interpretDanglingLine(DanglingLine danglingLine) {
Optional<TieLine> optionalTieLine = danglingLine.getTieLine();
if (optionalTieLine.isPresent()) {
TieLine tieLine = optionalTieLine.get();
this.connectableIdInNetwork = tieLine.getId();
Branch.Side side = tieLine.getDanglingLine1() == danglingLine ? Branch.Side.ONE : Branch.Side.TWO;
// dangling line convention is x node to terminal, so dl 1 is towards terminal 1 (opposite) and dl 2 is towards terminal 2 (direct)
this.isInvertedInNetwork = tieLine.getDanglingLine1() == danglingLine ? !isInvertedInNetwork : isInvertedInNetwork;
interpretTieLine(tieLine, side);
} else {
checkDanglingLineNominalVoltage(danglingLine);
checkDanglingLineCurrentLimits(danglingLine);
}
}

protected void checkDanglingLineNominalVoltage(DanglingLine danglingLine) {
this.nominalVoltageLeft = danglingLine.getTerminal().getVoltageLevel().getNominalV();
this.nominalVoltageRight = nominalVoltageLeft;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,13 +13,16 @@
import com.farao_community.farao.data.crac_creation.creator.cim.crac_creator.CimCracCreationContext;
import com.farao_community.farao.data.crac_creation.creator.cim.xsd.*;
import com.farao_community.farao.data.crac_creation.util.cgmes.CgmesBranchHelper;
import com.powsybl.iidm.network.DanglingLine;
import com.powsybl.iidm.network.Identifiable;
import com.powsybl.iidm.network.Network;
import com.powsybl.iidm.network.TieLine;

import static com.farao_community.farao.data.crac_creation.creator.cim.crac_creator.CimConstants.CONTINGENCY_SERIES_BUSINESS_TYPE;

import java.util.HashSet;
import java.util.List;
import java.util.Optional;
import java.util.Set;
import java.util.stream.Collectors;

Expand Down Expand Up @@ -105,10 +108,19 @@ private String getNetworkElementIdInNetwork(String networkElementIdInCrac) {
CgmesBranchHelper cgmesBranchHelper = new CgmesBranchHelper(networkElementIdInCrac, network);
if (cgmesBranchHelper.isValid()) {
networkElementId = cgmesBranchHelper.getIdInNetwork();
networkElement = cgmesBranchHelper.getBranch();
}
} else {
networkElementId = networkElement.getId();
}

if (networkElement instanceof DanglingLine) {
Optional<TieLine> optionalTieLine = ((DanglingLine) networkElement).getTieLine();
if (optionalTieLine.isPresent()) {
networkElementId = optionalTieLine.get().getId();
}
}

return networkElementId;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -272,11 +272,11 @@ void testCurativeStatesConstraints() {
assertEquals(400., voltageMonitoringResult.getMaxVoltage(vc2), VOLTAGE_TOLERANCE);
assertTrue(Double.isNaN(voltageMonitoringResult.getMinVoltage(vc1b)));
assertTrue(Double.isNaN(voltageMonitoringResult.getMaxVoltage(vc1b)));
assertEquals(399., voltageMonitoringResult.getMinVoltage(vc2b), VOLTAGE_TOLERANCE);
assertEquals(399., voltageMonitoringResult.getMaxVoltage(vc2b), VOLTAGE_TOLERANCE);
assertEquals(400., voltageMonitoringResult.getMinVoltage(vc2b), VOLTAGE_TOLERANCE);
assertEquals(400., voltageMonitoringResult.getMaxVoltage(vc2b), VOLTAGE_TOLERANCE);
assertEquals(List.of("Network element VL2 at state coL1 - curative has a voltage of 368 - 368 kV.",
"Network element VL3 at state coL2 - curative has a voltage of 400 - 400 kV.",
"Network element VL3 at state coL1L2 - curative has a voltage of 399 - 399 kV."),
"Network element VL3 at state coL1L2 - curative has a voltage of 400 - 400 kV."),
voltageMonitoringResult.printConstraints());
}

Expand Down
6 changes: 3 additions & 3 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -138,9 +138,9 @@
<maven.templating.version>1.0.0</maven.templating.version>
<mockito.inline.version>3.5.10</mockito.inline.version>
<powermock.version>2.0.7</powermock.version>
<powsybl.core.version>5.2.0-RC1</powsybl.core.version>
<powsybl.glsk.version>2.2.0</powsybl.glsk.version>
<powsybl.openloadflow.version>1.0.1</powsybl.openloadflow.version>
<powsybl.core.version>5.3.0</powsybl.core.version>
<powsybl.glsk.version>2.4.0</powsybl.glsk.version>
<powsybl.openloadflow.version>1.2.0</powsybl.openloadflow.version>
<slf4j.version>1.7.30</slf4j.version>
<threeten.version>1.5.0</threeten.version>
<xmlunit.core.version>2.8.1</xmlunit.core.version>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -305,7 +305,7 @@ void testConfigWithOpenLoadFlowExtension() throws IOException {
assertNotNull(olfParams);
assertEquals(0.444, olfParams.getMinPlausibleTargetVoltage(), DOUBLE_TOLERANCE);
assertEquals(1.444, olfParams.getMaxPlausibleTargetVoltage(), DOUBLE_TOLERANCE);
assertEquals(111, olfParams.getMaxIteration(), DOUBLE_TOLERANCE);
assertEquals(111, olfParams.getMaxNewtonRaphsonIterations(), DOUBLE_TOLERANCE);

// Compare to json
roundTripTest(parameters, JsonRaoParameters::write, JsonRaoParameters::read, "/RaoParameters_config_withOLFParams.json");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -91,18 +91,25 @@
"lowImpedanceBranchMode" : "REPLACE_BY_ZERO_IMPEDANCE_LINE",
"loadPowerFactorConstant" : false,
"plausibleActivePowerLimit" : 5000.0,
"newtonRaphsonStoppingCriteriaType" : "UNIFORM_CRITERIA",
"maxActivePowerMismatch" : 0.01,
"maxReactivePowerMismatch" : 0.01,
"maxVoltageMismatch" : 1.0E-4,
"maxAngleMismatch" : 1.0E-5,
"maxRatioMismatch" : 1.0E-5,
"maxSusceptanceMismatch" : 1.0E-4,
"slackBusPMaxMismatch" : 1.0,
"voltagePerReactivePowerControl" : false,
"maxIteration" : 30,
"maxNewtonRaphsonIterations" : 15,
"maxOuterLoopIterations" : 20,
"newtonRaphsonConvEpsPerEq" : 1.0E-4,
"voltageInitModeOverride" : "NONE",
"transformerVoltageControlMode" : "WITH_GENERATOR_VOLTAGE_CONTROL",
"shuntVoltageControlMode" : "WITH_GENERATOR_VOLTAGE_CONTROL",
"dcPowerFactor" : 1.0,
"minPlausibleTargetVoltage" : 0.8,
"maxPlausibleTargetVoltage" : 1.2,
"minRealisticVoltage" : 0.5,
"maxRealisticVoltage" : 1.5,
"maxRealisticVoltage" : 2.0,
"lowImpedanceThreshold" : 1.0E-8,
"reactiveRangeCheckMode" : "MAX",
"networkCacheEnabled" : false,
Expand All @@ -112,7 +119,14 @@
"debugDir" : null,
"incrementalTransformerVoltageControlOuterLoopMaxTapShift" : 3,
"secondaryVoltageControl" : false,
"reactiveLimitsMaxPqPvSwitch" : 3
"reactiveLimitsMaxPqPvSwitch" : 3,
"phaseShifterControlMode" : "CONTINUOUS_WITH_DISCRETISATION",
"alwaysUpdateNetwork" : false,
"mostMeshedSlackBusSelectorMaxNominalVoltagePercentile" : 95.0,
"reportedFeatures" : [ ],
"slackBusCountryFilter" : [ ],
"actionableSwitchesIds" : [ ],
"asymmetrical" : false
}
}
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -79,18 +79,25 @@
"lowImpedanceBranchMode" : "REPLACE_BY_ZERO_IMPEDANCE_LINE",
"loadPowerFactorConstant" : false,
"plausibleActivePowerLimit" : 5000.0,
"newtonRaphsonStoppingCriteriaType" : "UNIFORM_CRITERIA",
"maxActivePowerMismatch" : 0.01,
"maxReactivePowerMismatch" : 0.01,
"maxVoltageMismatch" : 1.0E-4,
"maxAngleMismatch" : 1.0E-5,
"maxRatioMismatch" : 1.0E-5,
"maxSusceptanceMismatch" : 1.0E-4,
"slackBusPMaxMismatch" : 1.0,
"voltagePerReactivePowerControl" : false,
"maxIteration" : 111,
"maxNewtonRaphsonIterations" : 111,
"maxOuterLoopIterations" : 20,
"newtonRaphsonConvEpsPerEq" : 1.0E-4,
"voltageInitModeOverride" : "NONE",
"transformerVoltageControlMode" : "WITH_GENERATOR_VOLTAGE_CONTROL",
"shuntVoltageControlMode" : "WITH_GENERATOR_VOLTAGE_CONTROL",
"dcPowerFactor" : 1.0,
"minPlausibleTargetVoltage" : 0.444,
"maxPlausibleTargetVoltage" : 1.444,
"minRealisticVoltage" : 0.5,
"maxRealisticVoltage" : 1.5,
"maxRealisticVoltage" : 2.0,
"lowImpedanceThreshold" : 1.0E-8,
"reactiveRangeCheckMode" : "MAX",
"networkCacheEnabled" : false,
Expand All @@ -100,7 +107,14 @@
"debugDir" : null,
"incrementalTransformerVoltageControlOuterLoopMaxTapShift" : 3,
"secondaryVoltageControl" : false,
"reactiveLimitsMaxPqPvSwitch" : 3
"reactiveLimitsMaxPqPvSwitch" : 3,
"phaseShifterControlMode" : "CONTINUOUS_WITH_DISCRETISATION",
"alwaysUpdateNetwork" : false,
"mostMeshedSlackBusSelectorMaxNominalVoltagePercentile" : 95.0,
"reportedFeatures" : [ ],
"slackBusCountryFilter" : [ ],
"actionableSwitchesIds" : [ ],
"asymmetrical" : false
}
}
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -91,18 +91,25 @@
"lowImpedanceBranchMode" : "REPLACE_BY_ZERO_IMPEDANCE_LINE",
"loadPowerFactorConstant" : false,
"plausibleActivePowerLimit" : 5000.0,
"newtonRaphsonStoppingCriteriaType" : "UNIFORM_CRITERIA",
"maxActivePowerMismatch" : 0.01,
"maxReactivePowerMismatch" : 0.01,
"maxVoltageMismatch" : 1.0E-4,
"maxAngleMismatch" : 1.0E-5,
"maxRatioMismatch" : 1.0E-5,
"maxSusceptanceMismatch" : 1.0E-4,
"slackBusPMaxMismatch" : 1.0,
"voltagePerReactivePowerControl" : false,
"maxIteration" : 30,
"maxNewtonRaphsonIterations" : 15,
"maxOuterLoopIterations" : 20,
"newtonRaphsonConvEpsPerEq" : 1.0E-4,
"voltageInitModeOverride" : "NONE",
"transformerVoltageControlMode" : "WITH_GENERATOR_VOLTAGE_CONTROL",
"shuntVoltageControlMode" : "WITH_GENERATOR_VOLTAGE_CONTROL",
"dcPowerFactor" : 1.0,
"minPlausibleTargetVoltage" : 0.8,
"maxPlausibleTargetVoltage" : 1.2,
"minRealisticVoltage" : 0.5,
"maxRealisticVoltage" : 1.5,
"maxRealisticVoltage" : 2.0,
"lowImpedanceThreshold" : 1.0E-8,
"reactiveRangeCheckMode" : "MAX",
"networkCacheEnabled" : false,
Expand All @@ -112,7 +119,14 @@
"debugDir" : null,
"incrementalTransformerVoltageControlOuterLoopMaxTapShift" : 3,
"secondaryVoltageControl" : false,
"reactiveLimitsMaxPqPvSwitch" : 3
"reactiveLimitsMaxPqPvSwitch" : 3,
"phaseShifterControlMode" : "CONTINUOUS_WITH_DISCRETISATION",
"alwaysUpdateNetwork" : false,
"mostMeshedSlackBusSelectorMaxNominalVoltagePercentile" : 95.0,
"reportedFeatures" : [ ],
"slackBusCountryFilter" : [ ],
"actionableSwitchesIds" : [ ],
"asymmetrical" : false
}
}
},
Expand Down
Loading