From c43495679e3d1c1cf71a690313aa50defff80a57 Mon Sep 17 00:00:00 2001 From: Peter Mitri Date: Fri, 14 Apr 2023 18:08:09 +0200 Subject: [PATCH 01/10] Allow defining GLSK on DanglingLine Signed-off-by: Peter Mitri --- .../glsk/api/GlskRegisteredResource.java | 9 +++- .../GlskPointLinearGlskConverter.java | 46 ++++++++++++++----- .../glsk/api/util/converters/NetworkUtil.java | 5 ++ .../glsk/cim/CimGlskRegisteredResource.java | 6 +++ .../glsk/cse/CseGlskRegisteredResource.java | 17 +++++++ .../glsk/ucte/UcteGlskRegisteredResource.java | 17 +++++++ 6 files changed, 87 insertions(+), 13 deletions(-) diff --git a/glsk/glsk-document-api/src/main/java/com/powsybl/glsk/api/GlskRegisteredResource.java b/glsk/glsk-document-api/src/main/java/com/powsybl/glsk/api/GlskRegisteredResource.java index 7dfcc5b0..36faf754 100644 --- a/glsk/glsk-document-api/src/main/java/com/powsybl/glsk/api/GlskRegisteredResource.java +++ b/glsk/glsk-document-api/src/main/java/com/powsybl/glsk/api/GlskRegisteredResource.java @@ -6,6 +6,8 @@ */ package com.powsybl.glsk.api; +import com.powsybl.iidm.network.Network; + import java.util.Optional; /** @@ -50,7 +52,7 @@ public interface GlskRegisteredResource { Optional getMinimumCapacity(); /** - * @return the genrator Id according to type of Glsk File + * @return the generator Id according to type of Glsk File */ String getGeneratorId(); @@ -58,4 +60,9 @@ public interface GlskRegisteredResource { * @return the load Id according to the type of Glsk File */ String getLoadId(); + + /** + * @return the dangling line Id according to the type of Glsk File + */ + String getDanglingLineId(Network network); } diff --git a/glsk/glsk-document-api/src/main/java/com/powsybl/glsk/api/util/converters/GlskPointLinearGlskConverter.java b/glsk/glsk-document-api/src/main/java/com/powsybl/glsk/api/util/converters/GlskPointLinearGlskConverter.java index feabded0..f2bfab06 100644 --- a/glsk/glsk-document-api/src/main/java/com/powsybl/glsk/api/util/converters/GlskPointLinearGlskConverter.java +++ b/glsk/glsk-document-api/src/main/java/com/powsybl/glsk/api/util/converters/GlskPointLinearGlskConverter.java @@ -119,6 +119,12 @@ private static void convertCountryProportional(Network network, GlskShiftKey gls * @param weightedSensitivityVariables linearGlsk to be filled */ private static void convertExplicitProportional(Network network, GlskShiftKey glskShiftKey, List weightedSensitivityVariables) { + List danglingLines = glskShiftKey.getRegisteredResourceArrayList().stream() + .map(rr -> rr.getDanglingLineId(network)) + .map(network::getDanglingLine) + .filter(NetworkUtil::isCorrect) + .collect(Collectors.toList()); + double totalP = danglingLines.stream().mapToDouble(NetworkUtil::pseudoP0).sum(); //Generator A04 or Load A05 if (glskShiftKey.getPsrType().equals("A04")) { //Generator A04 @@ -127,9 +133,10 @@ private static void convertExplicitProportional(Network network, GlskShiftKey gl .map(network::getGenerator) .filter(NetworkUtil::isCorrect) .collect(Collectors.toList()); - double totalP = generators.stream().mapToDouble(NetworkUtil::pseudoTargetP).sum(); + totalP += generators.stream().mapToDouble(NetworkUtil::pseudoTargetP).sum(); + double finalTotalP = totalP; generators.forEach(generator -> weightedSensitivityVariables.add(new WeightedSensitivityVariable(generator.getId(), - glskShiftKey.getQuantity().floatValue() * (float) NetworkUtil.pseudoTargetP(generator) / (float) totalP))); + glskShiftKey.getQuantity().floatValue() * (float) NetworkUtil.pseudoTargetP(generator) / (float) finalTotalP))); } else if (glskShiftKey.getPsrType().equals("A05")) { //Load A05 List loads = glskShiftKey.getRegisteredResourceArrayList().stream() @@ -137,13 +144,17 @@ private static void convertExplicitProportional(Network network, GlskShiftKey gl .map(network::getLoad) .filter(NetworkUtil::isCorrect) .collect(Collectors.toList()); - double totalLoad = loads.stream().mapToDouble(NetworkUtil::pseudoP0).sum(); + totalP += loads.stream().mapToDouble(NetworkUtil::pseudoP0).sum(); + double finalTotalP = totalP; loads.forEach(load -> weightedSensitivityVariables.add(new WeightedSensitivityVariable(load.getId(), - glskShiftKey.getQuantity().floatValue() * (float) NetworkUtil.pseudoP0(load) / (float) totalLoad))); + glskShiftKey.getQuantity().floatValue() * (float) NetworkUtil.pseudoP0(load) / (float) finalTotalP))); } else { //unknown PsrType throw new GlskException("convertExplicitProportional PsrType not supported"); } + double finalTotalP = totalP; + danglingLines.forEach(danglingLine -> weightedSensitivityVariables.add(new WeightedSensitivityVariable(danglingLine.getId(), + glskShiftKey.getQuantity().floatValue() * (float) NetworkUtil.pseudoP0(danglingLine) / (float) finalTotalP))); } /** @@ -153,31 +164,42 @@ private static void convertExplicitProportional(Network network, GlskShiftKey gl */ private static void convertParticipationFactor(Network network, GlskShiftKey glskShiftKey, List weightedSensitivityVariables) { //Generator A04 or Load A05 + List danglingLineResources = glskShiftKey.getRegisteredResourceArrayList().stream() + .filter(danglingLineResource -> NetworkUtil.isCorrect(network.getDanglingLine(danglingLineResource.getDanglingLineId(network)))) + .collect(Collectors.toList()); + double totalFactor = danglingLineResources.stream().mapToDouble(GlskRegisteredResource::getParticipationFactor).sum(); if (glskShiftKey.getPsrType().equals("A04")) { //Generator A04 List generatorResources = glskShiftKey.getRegisteredResourceArrayList().stream() - .filter(generatorResource -> NetworkUtil.isCorrect(network.getGenerator(generatorResource.getGeneratorId()))) - .collect(Collectors.toList()); - double totalFactor = generatorResources.stream().mapToDouble(GlskRegisteredResource::getParticipationFactor).sum(); + .filter(generatorResource -> NetworkUtil.isCorrect(network.getGenerator(generatorResource.getGeneratorId()))) + .collect(Collectors.toList()); + totalFactor += generatorResources.stream().mapToDouble(GlskRegisteredResource::getParticipationFactor).sum(); if (totalFactor < 1e-10) { throw new GlskException("total factor is zero"); } + double finalTotalFactor2 = totalFactor; generatorResources.forEach(generatorResource -> weightedSensitivityVariables.add(new WeightedSensitivityVariable(generatorResource.getGeneratorId(), - glskShiftKey.getQuantity().floatValue() * (float) generatorResource.getParticipationFactor() / (float) totalFactor))); + glskShiftKey.getQuantity().floatValue() * (float) generatorResource.getParticipationFactor() / (float) finalTotalFactor2))); } else if (glskShiftKey.getPsrType().equals("A05")) { //Load A05 List loadResources = glskShiftKey.getRegisteredResourceArrayList().stream() - .filter(loadResource -> NetworkUtil.isCorrect(network.getLoad(loadResource.getLoadId()))) - .collect(Collectors.toList()); - double totalFactor = loadResources.stream().mapToDouble(GlskRegisteredResource::getParticipationFactor).sum(); + .filter(loadResource -> + loadResource.getmRID().contains("XLI_OB1") || + NetworkUtil.isCorrect(network.getLoad(loadResource.getLoadId()))) + .collect(Collectors.toList()); + totalFactor += loadResources.stream().mapToDouble(GlskRegisteredResource::getParticipationFactor).sum(); if (totalFactor < 1e-10) { throw new GlskException("total factor is zero"); } + double finalTotalFactor = totalFactor; loadResources.forEach(loadResource -> weightedSensitivityVariables.add(new WeightedSensitivityVariable(loadResource.getLoadId(), - glskShiftKey.getQuantity().floatValue() * (float) loadResource.getParticipationFactor() / (float) totalFactor))); + glskShiftKey.getQuantity().floatValue() * (float) loadResource.getParticipationFactor() / (float) finalTotalFactor))); } else { //unknown PsrType throw new GlskException("convertParticipationFactor PsrType not supported"); } + double finalTotalFactor1 = totalFactor; + danglingLineResources.forEach(danglingLineResource -> weightedSensitivityVariables.add(new WeightedSensitivityVariable(danglingLineResource.getDanglingLineId(network), + glskShiftKey.getQuantity().floatValue() * (float) danglingLineResource.getParticipationFactor() / (float) finalTotalFactor1))); } } diff --git a/glsk/glsk-document-api/src/main/java/com/powsybl/glsk/api/util/converters/NetworkUtil.java b/glsk/glsk-document-api/src/main/java/com/powsybl/glsk/api/util/converters/NetworkUtil.java index 7ba5f176..0cc8a43f 100644 --- a/glsk/glsk-document-api/src/main/java/com/powsybl/glsk/api/util/converters/NetworkUtil.java +++ b/glsk/glsk-document-api/src/main/java/com/powsybl/glsk/api/util/converters/NetworkUtil.java @@ -6,6 +6,7 @@ */ package com.powsybl.glsk.api.util.converters; +import com.powsybl.iidm.network.DanglingLine; import com.powsybl.iidm.network.Generator; import com.powsybl.iidm.network.Injection; import com.powsybl.iidm.network.Load; @@ -28,6 +29,10 @@ static double pseudoP0(Load load) { return Math.max(MINIMAL_ABS_POWER_VALUE, Math.abs(load.getP0())); } + static double pseudoP0(DanglingLine danglingLine) { + return Math.max(MINIMAL_ABS_POWER_VALUE, Math.abs(danglingLine.getP0())); + } + static boolean isCorrect(Injection injection) { return injection != null && injection.getTerminal().isConnected() && diff --git a/glsk/glsk-document-cim/src/main/java/com/powsybl/glsk/cim/CimGlskRegisteredResource.java b/glsk/glsk-document-cim/src/main/java/com/powsybl/glsk/cim/CimGlskRegisteredResource.java index dd66c525..262cee27 100644 --- a/glsk/glsk-document-cim/src/main/java/com/powsybl/glsk/cim/CimGlskRegisteredResource.java +++ b/glsk/glsk-document-cim/src/main/java/com/powsybl/glsk/cim/CimGlskRegisteredResource.java @@ -8,6 +8,7 @@ package com.powsybl.glsk.cim; import com.powsybl.glsk.api.AbstractGlskRegisteredResource; +import com.powsybl.iidm.network.Network; import org.w3c.dom.Element; import java.util.Objects; @@ -40,4 +41,9 @@ public String getGeneratorId() { public String getLoadId() { return mRID; } + + @Override + public String getDanglingLineId(Network network) { + return mRID; + } } diff --git a/glsk/glsk-document-cse/src/main/java/com/powsybl/glsk/cse/CseGlskRegisteredResource.java b/glsk/glsk-document-cse/src/main/java/com/powsybl/glsk/cse/CseGlskRegisteredResource.java index b6ff31d9..23491430 100644 --- a/glsk/glsk-document-cse/src/main/java/com/powsybl/glsk/cse/CseGlskRegisteredResource.java +++ b/glsk/glsk-document-cse/src/main/java/com/powsybl/glsk/cse/CseGlskRegisteredResource.java @@ -7,10 +7,14 @@ package com.powsybl.glsk.cse; import com.powsybl.glsk.api.AbstractGlskRegisteredResource; +import com.powsybl.iidm.network.Identifiable; +import com.powsybl.iidm.network.Network; import java.math.BigDecimal; import java.util.Objects; import java.util.Optional; +import java.util.Set; +import java.util.stream.Collectors; /** * @author Sebastien Murgey {@literal } @@ -45,6 +49,19 @@ public String getLoadId() { return mRID + "_load"; } + @Override + public String getDanglingLineId(Network network) { + Set danglingLines = network.getDanglingLineStream() + .filter(dl -> dl.getUcteXnodeCode().equals(mRID)) + .map(Identifiable::getId) + .collect(Collectors.toSet()); + if (danglingLines.size() != 1) { + // No or multiple dangling lines found for Xnode + return null; + } + return danglingLines.iterator().next(); + } + Optional getInitialFactor() { return Optional.ofNullable(initialFactor); } diff --git a/glsk/glsk-document-ucte/src/main/java/com/powsybl/glsk/ucte/UcteGlskRegisteredResource.java b/glsk/glsk-document-ucte/src/main/java/com/powsybl/glsk/ucte/UcteGlskRegisteredResource.java index be53f336..dc7c791b 100644 --- a/glsk/glsk-document-ucte/src/main/java/com/powsybl/glsk/ucte/UcteGlskRegisteredResource.java +++ b/glsk/glsk-document-ucte/src/main/java/com/powsybl/glsk/ucte/UcteGlskRegisteredResource.java @@ -8,9 +8,13 @@ package com.powsybl.glsk.ucte; import com.powsybl.glsk.api.AbstractGlskRegisteredResource; +import com.powsybl.iidm.network.Identifiable; +import com.powsybl.iidm.network.Network; import org.w3c.dom.Element; import java.util.Objects; +import java.util.Set; +import java.util.stream.Collectors; /** * @author Joris Mancini {@literal } @@ -38,4 +42,17 @@ public String getGeneratorId() { public String getLoadId() { return mRID + "_load"; } + + @Override + public String getDanglingLineId(Network network) { + Set danglingLines = network.getDanglingLineStream() + .filter(dl -> dl.getUcteXnodeCode().equals(mRID)) + .map(Identifiable::getId) + .collect(Collectors.toSet()); + if (danglingLines.size() != 1) { + // No or multiple dangling lines found for Xnode + return null; + } + return danglingLines.iterator().next(); + } } From 90b362e5cd2d956e14cf77bbb868f0b939906000 Mon Sep 17 00:00:00 2001 From: Peter Mitri Date: Tue, 18 Apr 2023 16:25:08 +0200 Subject: [PATCH 02/10] Update GlskPointScalableConverter & unit tests Signed-off-by: Peter Mitri --- .../glsk/api/GlskRegisteredResource.java | 1 + .../GlskPointLinearGlskConverter.java | 9 +- .../GlskPointScalableConverter.java | 92 ++++-- glsk/glsk-document-cim/pom.xml | 5 + .../glsk/cim/CimGlskRegisteredResource.java | 1 + .../GlskPointLinearGlskConverterTest.java | 127 +++++--- .../GlskPointScalableConverterTest.java | 250 ++++++++++++---- .../test/resources/GlskB42ExplicitGskLsk.xml | 8 - .../test/resources/GlskB42ExplicitIIDM.xml | 4 - .../GlskB42ExplicitWithDanglingLines.xml | 77 +++++ .../GlskB43ParticipationFactorGskLsk.xml | 8 +- ...icipationFactorGskLskWithDanglingLines.xml | 65 +++++ .../resources/testCaseWithDanglingLines.xiidm | 273 ++++++++++++++++++ glsk/glsk-document-cse/pom.xml | 5 + .../glsk/cse/CseGlskRegisteredResource.java | 1 + .../glsk/cse/CseGlskDocumentImporterTest.java | 178 +++++++++++- .../resources/testCaseWithDanglingLines.xiidm | 273 ++++++++++++++++++ .../resources/testGlskWithDanglingLines.xml | 167 +++++++++++ glsk/glsk-document-ucte/pom.xml | 5 + .../glsk/ucte/UcteGlskRegisteredResource.java | 1 + .../ucte/UcteGlskDocumentImporterTest.java | 7 +- .../glsk/ucte/UcteGlskValueProviderTest.java | 18 ++ .../test/resources/GlskWithDanglingLines.xml | 47 +++ .../resources/testCaseWithDanglingLines.xiidm | 273 ++++++++++++++++++ 24 files changed, 1751 insertions(+), 144 deletions(-) create mode 100644 glsk/glsk-document-cim/src/test/resources/GlskB42ExplicitWithDanglingLines.xml create mode 100644 glsk/glsk-document-cim/src/test/resources/GlskB43ParticipationFactorGskLskWithDanglingLines.xml create mode 100644 glsk/glsk-document-cim/src/test/resources/testCaseWithDanglingLines.xiidm create mode 100644 glsk/glsk-document-cse/src/test/resources/testCaseWithDanglingLines.xiidm create mode 100644 glsk/glsk-document-cse/src/test/resources/testGlskWithDanglingLines.xml create mode 100644 glsk/glsk-document-ucte/src/test/resources/GlskWithDanglingLines.xml create mode 100644 glsk/glsk-document-ucte/src/test/resources/testCaseWithDanglingLines.xiidm diff --git a/glsk/glsk-document-api/src/main/java/com/powsybl/glsk/api/GlskRegisteredResource.java b/glsk/glsk-document-api/src/main/java/com/powsybl/glsk/api/GlskRegisteredResource.java index 36faf754..018202d3 100644 --- a/glsk/glsk-document-api/src/main/java/com/powsybl/glsk/api/GlskRegisteredResource.java +++ b/glsk/glsk-document-api/src/main/java/com/powsybl/glsk/api/GlskRegisteredResource.java @@ -13,6 +13,7 @@ /** * Registered Resource: a generator or a load, with its participation factor * @author Pengbo Wang {@literal } + * @author Peter Mitri {@literal } */ public interface GlskRegisteredResource { diff --git a/glsk/glsk-document-api/src/main/java/com/powsybl/glsk/api/util/converters/GlskPointLinearGlskConverter.java b/glsk/glsk-document-api/src/main/java/com/powsybl/glsk/api/util/converters/GlskPointLinearGlskConverter.java index f2bfab06..f15ffd00 100644 --- a/glsk/glsk-document-api/src/main/java/com/powsybl/glsk/api/util/converters/GlskPointLinearGlskConverter.java +++ b/glsk/glsk-document-api/src/main/java/com/powsybl/glsk/api/util/converters/GlskPointLinearGlskConverter.java @@ -23,6 +23,7 @@ /** * Convert a single GlskPoint to LinearGlsk * @author Pengbo Wang {@literal } + * @author Peter Mitri {@literal } */ public final class GlskPointLinearGlskConverter { private static final Logger LOGGER = LoggerFactory.getLogger(GlskPointLinearGlskConverter.class); @@ -121,6 +122,7 @@ private static void convertCountryProportional(Network network, GlskShiftKey gls private static void convertExplicitProportional(Network network, GlskShiftKey glskShiftKey, List weightedSensitivityVariables) { List danglingLines = glskShiftKey.getRegisteredResourceArrayList().stream() .map(rr -> rr.getDanglingLineId(network)) + .filter(Objects::nonNull) .map(network::getDanglingLine) .filter(NetworkUtil::isCorrect) .collect(Collectors.toList()); @@ -165,7 +167,8 @@ private static void convertExplicitProportional(Network network, GlskShiftKey gl private static void convertParticipationFactor(Network network, GlskShiftKey glskShiftKey, List weightedSensitivityVariables) { //Generator A04 or Load A05 List danglingLineResources = glskShiftKey.getRegisteredResourceArrayList().stream() - .filter(danglingLineResource -> NetworkUtil.isCorrect(network.getDanglingLine(danglingLineResource.getDanglingLineId(network)))) + .filter(danglingLineResource -> danglingLineResource.getDanglingLineId(network) != null && + NetworkUtil.isCorrect(network.getDanglingLine(danglingLineResource.getDanglingLineId(network)))) .collect(Collectors.toList()); double totalFactor = danglingLineResources.stream().mapToDouble(GlskRegisteredResource::getParticipationFactor).sum(); if (glskShiftKey.getPsrType().equals("A04")) { @@ -198,8 +201,8 @@ private static void convertParticipationFactor(Network network, GlskShiftKey gls //unknown PsrType throw new GlskException("convertParticipationFactor PsrType not supported"); } - double finalTotalFactor1 = totalFactor; + double finalTotalFactor = totalFactor; danglingLineResources.forEach(danglingLineResource -> weightedSensitivityVariables.add(new WeightedSensitivityVariable(danglingLineResource.getDanglingLineId(network), - glskShiftKey.getQuantity().floatValue() * (float) danglingLineResource.getParticipationFactor() / (float) finalTotalFactor1))); + glskShiftKey.getQuantity().floatValue() * (float) danglingLineResource.getParticipationFactor() / (float) finalTotalFactor))); } } diff --git a/glsk/glsk-document-api/src/main/java/com/powsybl/glsk/api/util/converters/GlskPointScalableConverter.java b/glsk/glsk-document-api/src/main/java/com/powsybl/glsk/api/util/converters/GlskPointScalableConverter.java index 23af8408..0376c4b3 100644 --- a/glsk/glsk-document-api/src/main/java/com/powsybl/glsk/api/util/converters/GlskPointScalableConverter.java +++ b/glsk/glsk-document-api/src/main/java/com/powsybl/glsk/api/util/converters/GlskPointScalableConverter.java @@ -125,16 +125,16 @@ private static Scalable convertMeritOrder(Network network, GlskPoint glskPoint) .filter(glskShiftKey -> glskShiftKey.getMeritOrderPosition() > 0) .sorted(Comparator.comparingInt(GlskShiftKey::getMeritOrderPosition)) .map(glskShiftKey -> { - GlskRegisteredResource generatorRegisteredResource = Objects.requireNonNull(glskShiftKey.getRegisteredResourceArrayList()).get(0); - return getGeneratorScalableWithLimits(network, generatorRegisteredResource); + GlskRegisteredResource resource = Objects.requireNonNull(glskShiftKey.getRegisteredResourceArrayList()).get(0); + return isGenerator(network, resource) ? getGeneratorScalableWithLimits(network, resource) : getDanglingLineScalableWithLimits(network, resource); }).toArray(Scalable[]::new)); Scalable downScalable = Scalable.stack(glskPoint.getGlskShiftKeys().stream() .filter(glskShiftKey -> glskShiftKey.getMeritOrderPosition() < 0) .sorted(Comparator.comparingInt(GlskShiftKey::getMeritOrderPosition).reversed()) .map(glskShiftKey -> { - GlskRegisteredResource generatorRegisteredResource = Objects.requireNonNull(glskShiftKey.getRegisteredResourceArrayList()).get(0); - return getGeneratorScalableWithLimits(network, generatorRegisteredResource); + GlskRegisteredResource resource = Objects.requireNonNull(glskShiftKey.getRegisteredResourceArrayList()).get(0); + return isGenerator(network, resource) ? getGeneratorScalableWithLimits(network, resource) : getDanglingLineScalableWithLimits(network, resource); }).toArray(Scalable[]::new)); return Scalable.upDown(upScalable, downScalable); } @@ -188,6 +188,14 @@ private static void convertCountryProportional(Network network, GlskShiftKey gls * @param scalables list of scalable */ private static void convertExplicitProportional(Network network, GlskShiftKey glskShiftKey, List percentages, List scalables) { + List danglingLines = glskShiftKey.getRegisteredResourceArrayList().stream() + .map(rr -> rr.getDanglingLineId(network)) + .filter(Objects::nonNull) + .map(network::getDanglingLine) + .filter(NetworkUtil::isCorrect) + .collect(Collectors.toList()); + double totalP = danglingLines.stream().mapToDouble(NetworkUtil::pseudoP0).sum(); + if (glskShiftKey.getPsrType().equals("A04")) { LOGGER.debug("GLSK Type B42, not empty registered resources list --> (explicit/manual) proportional GSK"); @@ -196,11 +204,12 @@ private static void convertExplicitProportional(Network network, GlskShiftKey gl .map(network::getGenerator) .filter(NetworkUtil::isCorrect) .collect(Collectors.toList()); - double totalP = generators.stream().mapToDouble(NetworkUtil::pseudoTargetP).sum(); + totalP += generators.stream().mapToDouble(NetworkUtil::pseudoTargetP).sum(); + double finalTotalP = totalP; generators.forEach(generator -> { // Calculate factor of each generator - float factor = (float) (glskShiftKey.getQuantity().floatValue() * NetworkUtil.pseudoTargetP(generator) / totalP); + float factor = (float) (glskShiftKey.getQuantity().floatValue() * NetworkUtil.pseudoTargetP(generator) / finalTotalP); percentages.add(100 * factor); // In case of global shift key limitation we will limit the generator proportionally to // its participation in the global proportional scalable @@ -214,15 +223,23 @@ private static void convertExplicitProportional(Network network, GlskShiftKey gl .map(network::getLoad) .filter(NetworkUtil::isCorrect) .collect(Collectors.toList()); - double totalP = loads.stream().mapToDouble(NetworkUtil::pseudoP0).sum(); + totalP += loads.stream().mapToDouble(NetworkUtil::pseudoP0).sum(); + double finalTotalP1 = totalP; loads.forEach(load -> { - float loadPercentage = (float) (100 * glskShiftKey.getQuantity().floatValue() * NetworkUtil.pseudoP0(load) / totalP); + float loadPercentage = (float) (100 * glskShiftKey.getQuantity().floatValue() * NetworkUtil.pseudoP0(load) / finalTotalP1); // For now glsk shift key maximum shift is not handled for loads by lack of specification percentages.add(loadPercentage); scalables.add(Scalable.onLoad(load.getId(), -Double.MAX_VALUE, Double.MAX_VALUE)); }); } + double finalTotalP = totalP; + danglingLines.forEach(danglingLine -> { + float danglingLinePercentage = (float) (100 * glskShiftKey.getQuantity().floatValue() * NetworkUtil.pseudoP0(danglingLine) / finalTotalP); + // For now glsk shift key maximum shift is not handled for dangling lines by lack of specification + percentages.add(danglingLinePercentage); + scalables.add(Scalable.onDanglingLine(danglingLine.getId(), -Double.MAX_VALUE, Double.MAX_VALUE)); + }); } /** @@ -233,6 +250,12 @@ private static void convertExplicitProportional(Network network, GlskShiftKey gl * @param scalables list of scalable */ private static void convertParticipationFactor(Network network, GlskShiftKey glskShiftKey, List percentages, List scalables) { + List danglingLineResources = glskShiftKey.getRegisteredResourceArrayList().stream() + .filter(danglingLineResource -> danglingLineResource.getDanglingLineId(network) != null && + NetworkUtil.isCorrect(network.getDanglingLine(danglingLineResource.getDanglingLineId(network)))) + .collect(Collectors.toList()); + double totalFactor = danglingLineResources.stream().mapToDouble(GlskRegisteredResource::getParticipationFactor).sum(); + if (glskShiftKey.getPsrType().equals("A04")) { LOGGER.debug("GLSK Type B43 GSK"); @@ -240,10 +263,11 @@ private static void convertParticipationFactor(Network network, GlskShiftKey gls .filter(generatorResource -> NetworkUtil.isCorrect(network.getGenerator(generatorResource.getGeneratorId()))) .collect(Collectors.toList()); - double totalFactor = generatorResources.stream().mapToDouble(GlskRegisteredResource::getParticipationFactor).sum(); + totalFactor += generatorResources.stream().mapToDouble(GlskRegisteredResource::getParticipationFactor).sum(); + double finalTotalFactor = totalFactor; generatorResources.forEach(generatorResource -> { - float generatorPercentage = (float) (100 * glskShiftKey.getQuantity().floatValue() * generatorResource.getParticipationFactor() / totalFactor); + float generatorPercentage = (float) (100 * glskShiftKey.getQuantity().floatValue() * generatorResource.getParticipationFactor() / finalTotalFactor); percentages.add(generatorPercentage); scalables.add(getGeneratorScalableWithLimits(network, generatorResource)); }); @@ -253,20 +277,31 @@ private static void convertParticipationFactor(Network network, GlskShiftKey gls .filter(loadResource -> NetworkUtil.isCorrect(network.getLoad(loadResource.getLoadId()))) .collect(Collectors.toList()); - double totalFactor = loadResources.stream().mapToDouble(GlskRegisteredResource::getParticipationFactor).sum(); + totalFactor += loadResources.stream().mapToDouble(GlskRegisteredResource::getParticipationFactor).sum(); + double finalTotalFactor = totalFactor; loadResources.forEach(loadResource -> { - float loadPercentage = (float) (100 * glskShiftKey.getQuantity().floatValue() * loadResource.getParticipationFactor() / totalFactor); + float loadPercentage = (float) (100 * glskShiftKey.getQuantity().floatValue() * loadResource.getParticipationFactor() / finalTotalFactor); percentages.add(loadPercentage); scalables.add(getLoadScalableWithLimits(network, loadResource)); }); } + double finalTotalFactor = totalFactor; + danglingLineResources.forEach(danglingLineResource -> { + float loadPercentage = (float) (100 * glskShiftKey.getQuantity().floatValue() * danglingLineResource.getParticipationFactor() / finalTotalFactor); + percentages.add(loadPercentage); + scalables.add(getDanglingLineScalableWithLimits(network, danglingLineResource)); + }); } private static Country getSubstationNullableCountry(Optional substation) { return substation.map(Substation::getNullableCountry).orElse(null); } + private static boolean isGenerator(Network network, GlskRegisteredResource glskRegisteredResource) { + return network.getGenerator(glskRegisteredResource.getGeneratorId()) != null; + } + private static Scalable getGeneratorScalableWithLimits(Network network, GlskRegisteredResource generatorRegisteredResource) { String generatorId = generatorRegisteredResource.getGeneratorId(); double incomingMaxP = generatorRegisteredResource.getMaximumCapacity().orElse(Double.MAX_VALUE); @@ -289,10 +324,10 @@ private static Scalable getGeneratorScalableWithLimits(Network network, GlskRegi return Scalable.onGenerator(generatorId, incomingMinP, incomingMaxP); } - private static Scalable getLoadScalableWithLimits(Network network, GlskRegisteredResource generatorRegisteredResource) { - String loadId = generatorRegisteredResource.getLoadId(); - double incomingMaxP = generatorRegisteredResource.getMaximumCapacity().orElse(Double.MAX_VALUE); - double incomingMinP = generatorRegisteredResource.getMinimumCapacity().orElse(-Double.MAX_VALUE); + private static Scalable getLoadScalableWithLimits(Network network, GlskRegisteredResource loadRegisteredResource) { + String loadId = loadRegisteredResource.getLoadId(); + double incomingMaxP = loadRegisteredResource.getMaximumCapacity().orElse(Double.MAX_VALUE); + double incomingMinP = loadRegisteredResource.getMinimumCapacity().orElse(-Double.MAX_VALUE); // Fixes some inconsistencies between GLSK and network that may raise an exception in // PowSyBl when actually scaling the network. // TODO: Solve this issue in PowSyBl framework. @@ -304,10 +339,33 @@ private static Scalable getLoadScalableWithLimits(Network network, GlskRegistere incomingMaxP = loadP0; } if (!Double.isNaN(incomingMinP) && incomingMinP > loadP0) { - LOGGER.warn("load '{}' has initial P0 that is above GLSK min P. Extending GLSK min P from {} to {}.", loadId, incomingMinP, loadP0); + LOGGER.warn("Load '{}' has initial P0 that is above GLSK min P. Extending GLSK min P from {} to {}.", loadId, incomingMinP, loadP0); incomingMinP = loadP0; } } return Scalable.onLoad(loadId, incomingMinP, incomingMaxP); } + + private static Scalable getDanglingLineScalableWithLimits(Network network, GlskRegisteredResource danglingLineRegisteredResource) { + String danglingLineId = danglingLineRegisteredResource.getDanglingLineId(network); + // We have to invert min and max because dangling lines act like loads but are scaled but in generator convention + double incomingMinP = -danglingLineRegisteredResource.getMaximumCapacity().orElse(Double.MAX_VALUE); + double incomingMaxP = -danglingLineRegisteredResource.getMinimumCapacity().orElse(-Double.MAX_VALUE); + // Fixes some inconsistencies between GLSK and network that may raise an exception in + // PowSyBl when actually scaling the network. + // TODO: Solve this issue in PowSyBl framework. + DanglingLine danglingLine = network.getDanglingLine(danglingLineId); + if (danglingLine != null) { + double danglingLineP0 = danglingLine.getP0(); + if (!Double.isNaN(incomingMaxP) && incomingMaxP < danglingLineP0) { + LOGGER.warn("Dangling line '{}' has initial P0 that is above GLSK max P. Extending GLSK max P from {} to {}.", danglingLineId, incomingMaxP, danglingLineP0); + incomingMaxP = danglingLineP0; + } + if (!Double.isNaN(incomingMinP) && incomingMinP > danglingLineP0) { + LOGGER.warn("Dangling line '{}' has initial P0 that is above GLSK min P. Extending GLSK min P from {} to {}.", danglingLineId, incomingMinP, danglingLineP0); + incomingMinP = danglingLineP0; + } + } + return Scalable.onDanglingLine(danglingLineId, incomingMinP, incomingMaxP); + } } diff --git a/glsk/glsk-document-cim/pom.xml b/glsk/glsk-document-cim/pom.xml index 52fdb0f7..59f15d4a 100644 --- a/glsk/glsk-document-cim/pom.xml +++ b/glsk/glsk-document-cim/pom.xml @@ -28,6 +28,11 @@ powsybl-config-test test + + com.powsybl + powsybl-entsoe-util + test + com.powsybl powsybl-iidm-impl diff --git a/glsk/glsk-document-cim/src/main/java/com/powsybl/glsk/cim/CimGlskRegisteredResource.java b/glsk/glsk-document-cim/src/main/java/com/powsybl/glsk/cim/CimGlskRegisteredResource.java index 262cee27..0e98a6e8 100644 --- a/glsk/glsk-document-cim/src/main/java/com/powsybl/glsk/cim/CimGlskRegisteredResource.java +++ b/glsk/glsk-document-cim/src/main/java/com/powsybl/glsk/cim/CimGlskRegisteredResource.java @@ -15,6 +15,7 @@ /** * @author Joris Mancini {@literal } + * @author Peter Mitri {@literal } */ public class CimGlskRegisteredResource extends AbstractGlskRegisteredResource { diff --git a/glsk/glsk-document-cim/src/test/java/com/powsybl/glsk/api/util/converters/GlskPointLinearGlskConverterTest.java b/glsk/glsk-document-cim/src/test/java/com/powsybl/glsk/api/util/converters/GlskPointLinearGlskConverterTest.java index eca20dd9..02b99b3c 100644 --- a/glsk/glsk-document-cim/src/test/java/com/powsybl/glsk/api/util/converters/GlskPointLinearGlskConverterTest.java +++ b/glsk/glsk-document-cim/src/test/java/com/powsybl/glsk/api/util/converters/GlskPointLinearGlskConverterTest.java @@ -10,11 +10,9 @@ import com.powsybl.glsk.api.GlskPoint; import com.powsybl.glsk.commons.GlskException; import com.powsybl.glsk.cim.CimGlskDocument; -import com.google.common.math.DoubleMath; import com.powsybl.iidm.network.Network; import com.powsybl.sensitivity.SensitivityVariableSet; import com.powsybl.sensitivity.WeightedSensitivityVariable; -import org.junit.jupiter.api.Assertions; import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.Test; import org.slf4j.Logger; @@ -22,28 +20,20 @@ import java.io.InputStream; +import static org.junit.jupiter.api.Assertions.assertEquals; import static org.junit.jupiter.api.Assertions.assertThrows; /** * @author Pengbo Wang {@literal } * @author Sebastien Murgey {@literal } + * @author Peter Mitri {@literal } */ class GlskPointLinearGlskConverterTest { + // TODO : detail existing tests private static final Logger LOGGER = LoggerFactory.getLogger(GlskPointLinearGlskConverterTest.class); - private static final String GLSKB42COUNTRYIIDM = "/GlskB42CountryIIDM.xml"; - private static final String GLSKB42COUNTRYQUANTITY = "/GlskB42CountryQuantity.xml"; - private static final String GLSKB42EXPLICITGSKLSK = "/GlskB42ExplicitGskLsk.xml"; - private static final String GLSKB43GSKLSK = "/GlskB43ParticipationFactorGskLsk.xml"; - private static final String GLSKB43GSKZERO = "/GlskB43ParticipationFactorGskZero.xml"; - private static final String GLSKB43LSKZERO = "/GlskB43ParticipationFactorLskZero.xml"; + private static final double DOUBLE_TOLERANCE = 1e-4; private Network testNetwork; - private GlskPoint glskPointCountry; - private GlskPoint glskPointCountryQuantity; - private GlskPoint glskPointExplicitGskLsk; - private GlskPoint glskPointParticipationFactorGskLsk; - private GlskPoint glskPointParticipationFactorGskZero; - private GlskPoint glskPointParticipationFactorLskZero; private InputStream getResourceAsStream(String resource) { return getClass().getResourceAsStream(resource); @@ -52,13 +42,6 @@ private InputStream getResourceAsStream(String resource) { @BeforeEach void setUp() { testNetwork = Network.read("testCase.xiidm", getClass().getResourceAsStream("/testCase.xiidm")); - - glskPointCountry = CimGlskDocument.importGlsk(getResourceAsStream(GLSKB42COUNTRYIIDM)).getGlskPoints().get(0); - glskPointCountryQuantity = CimGlskDocument.importGlsk(getResourceAsStream(GLSKB42COUNTRYQUANTITY)).getGlskPoints().get(0); - glskPointExplicitGskLsk = CimGlskDocument.importGlsk(getResourceAsStream(GLSKB42EXPLICITGSKLSK)).getGlskPoints().get(0); - glskPointParticipationFactorGskLsk = CimGlskDocument.importGlsk(getResourceAsStream(GLSKB43GSKLSK)).getGlskPoints().get(0); - glskPointParticipationFactorGskZero = CimGlskDocument.importGlsk(getResourceAsStream(GLSKB43GSKZERO)).getGlskPoints().get(0); - glskPointParticipationFactorLskZero = CimGlskDocument.importGlsk(getResourceAsStream(GLSKB43LSKZERO)).getGlskPoints().get(0); } /** @@ -66,42 +49,106 @@ void setUp() { */ @Test void testConvertGlskPointToLinearGlskB42Country() { + GlskPoint glsk = CimGlskDocument.importGlsk(getResourceAsStream("/GlskB42CountryIIDM.xml")).getGlskPoints().get(0); + SensitivityVariableSet linearGlsk = GlskPointLinearGlskConverter.convert(testNetwork, glsk); + + assertEquals(3, linearGlsk.getVariables().size()); + assertEquals(0.2857, linearGlsk.getVariable("FFR1AA1 _generator").getWeight(), DOUBLE_TOLERANCE); // 2000/7000 = 0.2857 + assertEquals(0.2857, linearGlsk.getVariable("FFR2AA1 _generator").getWeight(), DOUBLE_TOLERANCE); // 2000/7000 = 0.2857 + assertEquals(0.4286, linearGlsk.getVariable("FFR3AA1 _generator").getWeight(), DOUBLE_TOLERANCE); // 3000/7000 = 0.4286 - SensitivityVariableSet linearGlsk = GlskPointLinearGlskConverter.convert(testNetwork, glskPointCountry); - linearGlsk.getVariables().forEach(variable -> LOGGER.info("GenCountry: " + variable.getId() + "; factor = " + variable.getWeight())); //log - double totalfactor = linearGlsk.getVariables().stream().mapToDouble(WeightedSensitivityVariable::getWeight).sum(); - Assertions.assertTrue(DoubleMath.fuzzyEquals(1.0, totalfactor, 0.0001)); + double totalFactor = linearGlsk.getVariables().stream().mapToDouble(WeightedSensitivityVariable::getWeight).sum(); + assertEquals(1.0, totalFactor, DOUBLE_TOLERANCE); } @Test void testConvertGlskPointToLinearGlskB42CountryQuantity() { - - SensitivityVariableSet linearGlsk = GlskPointLinearGlskConverter.convert(testNetwork, glskPointCountryQuantity); - linearGlsk.getVariables().forEach(variable -> LOGGER.info("Country: " + variable.getId() + "; factor = " + variable.getWeight())); //log - double totalfactor = linearGlsk.getVariables().stream().mapToDouble(WeightedSensitivityVariable::getWeight).sum(); - Assertions.assertTrue(DoubleMath.fuzzyEquals(1.0, totalfactor, 0.0001)); + GlskPoint glsk = CimGlskDocument.importGlsk(getResourceAsStream("/GlskB42CountryQuantity.xml")).getGlskPoints().get(0); + SensitivityVariableSet linearGlsk = GlskPointLinearGlskConverter.convert(testNetwork, glsk); + + assertEquals(6, linearGlsk.getVariables().size()); + assertEquals(0.1714, linearGlsk.getVariable("FFR1AA1 _generator").getWeight(), DOUBLE_TOLERANCE); // 2000/7000 * 0.6 = 0.1714 + assertEquals(0.1714, linearGlsk.getVariable("FFR2AA1 _generator").getWeight(), DOUBLE_TOLERANCE); // 2000/7000 * 0.6 = 0.1714 + assertEquals(0.2571, linearGlsk.getVariable("FFR3AA1 _generator").getWeight(), DOUBLE_TOLERANCE); // 3000/7000 * 0.6 = 0.2571 + assertEquals(0.0667, linearGlsk.getVariable("FFR1AA1 _load").getWeight(), DOUBLE_TOLERANCE); // 1000/6000 * 0.4 = 0.0667 + assertEquals(0.2333, linearGlsk.getVariable("FFR2AA1 _load").getWeight(), DOUBLE_TOLERANCE); // 3500/6000 * 0.4 = 0.2333 + assertEquals(0.1, linearGlsk.getVariable("FFR3AA1 _load").getWeight(), DOUBLE_TOLERANCE); // 1500/6000 * 0.4 = 0.1 + + double totalFactor = linearGlsk.getVariables().stream().mapToDouble(WeightedSensitivityVariable::getWeight).sum(); + assertEquals(1.0, totalFactor, DOUBLE_TOLERANCE); } @Test void testConvertGlskPointToLinearGlskB42Explicit() { - SensitivityVariableSet linearGlsk = GlskPointLinearGlskConverter.convert(testNetwork, glskPointExplicitGskLsk); - linearGlsk.getVariables().forEach(variable -> LOGGER.info("Explicit: " + variable.getId() + "; factor = " + variable.getWeight())); //log - double totalfactor = linearGlsk.getVariables().stream().mapToDouble(WeightedSensitivityVariable::getWeight).sum(); - Assertions.assertTrue(DoubleMath.fuzzyEquals(1.0, totalfactor, 0.0001)); + GlskPoint glsk = CimGlskDocument.importGlsk(getResourceAsStream("/GlskB42ExplicitGskLsk.xml")).getGlskPoints().get(0); + SensitivityVariableSet linearGlsk = GlskPointLinearGlskConverter.convert(testNetwork, glsk); + + assertEquals(4, linearGlsk.getVariables().size()); + assertEquals(0.3, linearGlsk.getVariable("FFR1AA1 _generator").getWeight(), DOUBLE_TOLERANCE); // 2000/4000 * 0.6 = 30 % + assertEquals(0.3, linearGlsk.getVariable("FFR2AA1 _generator").getWeight(), DOUBLE_TOLERANCE); // 2000/4000 * 0.6 = 30 % + assertEquals(0.28, linearGlsk.getVariable("FFR2AA1 _load").getWeight(), DOUBLE_TOLERANCE); // 3500/5000 * 0.4 = 28 % + assertEquals(0.12, linearGlsk.getVariable("FFR3AA1 _load").getWeight(), DOUBLE_TOLERANCE); // 1500/5000 * 0.4 = 12 % + + double totalFactor = linearGlsk.getVariables().stream().mapToDouble(WeightedSensitivityVariable::getWeight).sum(); + assertEquals(1.0, totalFactor, DOUBLE_TOLERANCE); } @Test void testConvertGlskPointToLinearGlskB43() { - SensitivityVariableSet linearGlsk = GlskPointLinearGlskConverter.convert(testNetwork, glskPointParticipationFactorGskLsk); - linearGlsk.getVariables().forEach(variable -> LOGGER.info("Factor: " + variable.getId() + "; factor = " + variable.getWeight())); //log - double totalfactor = linearGlsk.getVariables().stream().mapToDouble(WeightedSensitivityVariable::getWeight).sum(); - Assertions.assertTrue(DoubleMath.fuzzyEquals(1.0, totalfactor, 0.0001)); + GlskPoint glsk = CimGlskDocument.importGlsk(getResourceAsStream("/GlskB43ParticipationFactorGskLsk.xml")).getGlskPoints().get(0); + SensitivityVariableSet linearGlsk = GlskPointLinearGlskConverter.convert(testNetwork, glsk); + + assertEquals(4, linearGlsk.getVariables().size()); + assertEquals(0.42, linearGlsk.getVariable("FFR1AA1 _generator").getWeight(), DOUBLE_TOLERANCE); // 0.7 * 0.6 = 42 % + assertEquals(0.18, linearGlsk.getVariable("FFR2AA1 _generator").getWeight(), DOUBLE_TOLERANCE); // 0.3 * 0.6 = 18 % + assertEquals(0.08, linearGlsk.getVariable("FFR1AA1 _load").getWeight(), DOUBLE_TOLERANCE); // 0.2 * 0.4 = 8 % + assertEquals(0.32, linearGlsk.getVariable("FFR2AA1 _load").getWeight(), DOUBLE_TOLERANCE); // 0.8 * 0.4 = 32 % + + double totalFactor = linearGlsk.getVariables().stream().mapToDouble(WeightedSensitivityVariable::getWeight).sum(); + assertEquals(1.0, totalFactor, DOUBLE_TOLERANCE); } @Test void testConvertGlskPointToLinearGlskB43Zero() { - assertThrows(GlskException.class, () -> GlskPointLinearGlskConverter.convert(testNetwork, glskPointParticipationFactorGskZero)); - assertThrows(GlskException.class, () -> GlskPointLinearGlskConverter.convert(testNetwork, glskPointParticipationFactorLskZero)); + GlskPoint gsk = CimGlskDocument.importGlsk(getResourceAsStream("/GlskB43ParticipationFactorGskZero.xml")).getGlskPoints().get(0); + assertThrows(GlskException.class, () -> GlskPointLinearGlskConverter.convert(testNetwork, gsk)); + GlskPoint lsk = CimGlskDocument.importGlsk(getResourceAsStream("/GlskB43ParticipationFactorLskZero.xml")).getGlskPoints().get(0); + assertThrows(GlskException.class, () -> GlskPointLinearGlskConverter.convert(testNetwork, lsk)); + } + + @Test + void testB42ExplicitWithDanglingLines() { + testNetwork = Network.read("testCaseWithDanglingLines.xiidm", getClass().getResourceAsStream("/testCaseWithDanglingLines.xiidm")); + GlskPoint glsk = CimGlskDocument.importGlsk(getResourceAsStream("/GlskB42ExplicitWithDanglingLines.xml")).getGlskPoints().get(0); + SensitivityVariableSet linearGlsk = GlskPointLinearGlskConverter.convert(testNetwork, glsk); + + assertEquals(8, linearGlsk.getVariables().size()); + assertEquals(0.15, linearGlsk.getVariable("FFR1AA1 _generator").getWeight(), DOUBLE_TOLERANCE); // 2/8 * 0.6 = 15 % + assertEquals(0.15, linearGlsk.getVariable("FFR2AA1 _generator").getWeight(), DOUBLE_TOLERANCE); // 2/8 * 0.6 = 15 % + assertEquals(0.225, linearGlsk.getVariable("FFR3AA1 _generator").getWeight(), DOUBLE_TOLERANCE); // 3/8 * 0.6 = 22.5 % + assertEquals(0.075, linearGlsk.getVariable("DDE3AA1 XNODE_1A 1").getWeight(), DOUBLE_TOLERANCE); // 1/8 * 0.6 = 7.5 % + assertEquals(0.0571, linearGlsk.getVariable("FFR1AA1 _load").getWeight(), DOUBLE_TOLERANCE); // 1/7 * 0.4 = 5.7 % + assertEquals(0.20, linearGlsk.getVariable("FFR2AA1 _load").getWeight(), DOUBLE_TOLERANCE); // 3.5/7 * 0.4 = 20 % + assertEquals(0.0857, linearGlsk.getVariable("FFR3AA1 _load").getWeight(), DOUBLE_TOLERANCE); // 1.5/7 * 0.4 = 8.6 % + assertEquals(0.0571, linearGlsk.getVariable("BBE2AA1 XNODE_1B 1").getWeight(), DOUBLE_TOLERANCE); // 1/7 * 0.4 = 5.7 % + + double totalFactor = linearGlsk.getVariables().stream().mapToDouble(WeightedSensitivityVariable::getWeight).sum(); + assertEquals(1.0, totalFactor, DOUBLE_TOLERANCE); } + @Test + void testConvertGlskPointToLinearGlskB43WithDanglingLines() { + testNetwork = Network.read("testCaseWithDanglingLines.xiidm", getClass().getResourceAsStream("/testCaseWithDanglingLines.xiidm")); + GlskPoint glsk = CimGlskDocument.importGlsk(getResourceAsStream("/GlskB43ParticipationFactorGskLskWithDanglingLines.xml")).getGlskPoints().get(0); + SensitivityVariableSet linearGlsk = GlskPointLinearGlskConverter.convert(testNetwork, glsk); + + assertEquals(4, linearGlsk.getVariables().size()); + assertEquals(0.42, linearGlsk.getVariable("FFR1AA1 _generator").getWeight(), DOUBLE_TOLERANCE); // 0.6 * 0.7 = 42 % + assertEquals(0.18, linearGlsk.getVariable("DDE3AA1 XNODE_1A 1").getWeight(), DOUBLE_TOLERANCE); // 0.6 * 0.3 = 18 % + assertEquals(0.16, linearGlsk.getVariable("FFR1AA1 _load").getWeight(), DOUBLE_TOLERANCE); // 0.4 * 0.4 = 16 % + assertEquals(0.24, linearGlsk.getVariable("BBE2AA1 XNODE_1B 1").getWeight(), DOUBLE_TOLERANCE); // 0.4 * 0.6 = 24 % + + double totalFactor = linearGlsk.getVariables().stream().mapToDouble(WeightedSensitivityVariable::getWeight).sum(); + assertEquals(1.0, totalFactor, DOUBLE_TOLERANCE); + } } diff --git a/glsk/glsk-document-cim/src/test/java/com/powsybl/glsk/api/util/converters/GlskPointScalableConverterTest.java b/glsk/glsk-document-cim/src/test/java/com/powsybl/glsk/api/util/converters/GlskPointScalableConverterTest.java index f105d077..f180812b 100644 --- a/glsk/glsk-document-cim/src/test/java/com/powsybl/glsk/api/util/converters/GlskPointScalableConverterTest.java +++ b/glsk/glsk-document-cim/src/test/java/com/powsybl/glsk/api/util/converters/GlskPointScalableConverterTest.java @@ -6,38 +6,27 @@ */ package com.powsybl.glsk.api.util.converters; -import com.google.common.math.DoubleMath; import com.powsybl.glsk.api.GlskPoint; import com.powsybl.glsk.cim.CimGlskDocument; import com.powsybl.iidm.modification.scalable.Scalable; -import com.powsybl.iidm.network.Generator; import com.powsybl.iidm.network.Network; -import org.junit.jupiter.api.Assertions; import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.Test; import java.io.InputStream; +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertNotNull; + /** * @author Pengbo Wang {@literal } + * @author Peter Mitri {@literal } */ class GlskPointScalableConverterTest { - private static final String GLSKB45TEST = "/GlskB45test.xml"; - private static final String GLSKB42COUNTRYIIDM = "/GlskB42CountryIIDM.xml"; - private static final String GLSKB42COUNTRYGSKLSK = "/GlskB42CountryGskLsk.xml"; - private static final String GLSKB42EXPLICITIIDM = "/GlskB42ExplicitIIDM.xml"; - private static final String GLSKB42EXPLICITGSKLSK = "/GlskB42ExplicitGskLsk.xml"; - private static final String GLSKB43 = "/GlskB43ParticipationFactorIIDM.xml"; - private static final String GLSKB43GSKLSK = "/GlskB43ParticipationFactorGskLsk.xml"; + private static final double DOUBLE_TOLERANCE = 1e-3; + private static final double FUZZY_TOLERANCE = 0.5; private Network testNetwork; - private GlskPoint glskPointCountry; - private GlskPoint glskPointCountryGskLsk; - private GlskPoint glskPointExplicit; - private GlskPoint glskPointExplicitGskLsk; - private GlskPoint glskPointParticipationFactor; - private GlskPoint glskPointParticipationFactorGskLsk; - private GlskPoint glskMeritOrder; private InputStream getResourceAsStream(String resource) { return getClass().getResourceAsStream(resource); @@ -46,15 +35,6 @@ private InputStream getResourceAsStream(String resource) { @BeforeEach void setUp() { testNetwork = Network.read("testCase.xiidm", getClass().getResourceAsStream("/testCase.xiidm")); - - glskPointCountry = CimGlskDocument.importGlsk(getResourceAsStream(GLSKB42COUNTRYIIDM)).getGlskPoints().get(0); - glskPointCountryGskLsk = CimGlskDocument.importGlsk(getResourceAsStream(GLSKB42COUNTRYGSKLSK)).getGlskPoints().get(0); - glskPointExplicit = CimGlskDocument.importGlsk(getResourceAsStream(GLSKB42EXPLICITIIDM)).getGlskPoints().get(0); - glskPointExplicitGskLsk = CimGlskDocument.importGlsk(getResourceAsStream(GLSKB42EXPLICITGSKLSK)).getGlskPoints().get(0); - glskPointParticipationFactor = CimGlskDocument.importGlsk(getResourceAsStream(GLSKB43)).getGlskPoints().get(0); - glskPointParticipationFactorGskLsk = CimGlskDocument.importGlsk(getResourceAsStream(GLSKB43GSKLSK)).getGlskPoints().get(0); - glskMeritOrder = CimGlskDocument.importGlsk(getResourceAsStream(GLSKB45TEST)).getGlskPoints().get(0); - } /** @@ -62,59 +42,219 @@ void setUp() { */ @Test void testConvertGlskPointToScalableB45MeritOrder() { - Scalable scalable = GlskPointScalableConverter.convert(testNetwork, glskMeritOrder); - double done = scalable.scale(testNetwork, 100.0); - Assertions.assertTrue(DoubleMath.fuzzyEquals(6, done, 0.0001)); - Generator generator1 = testNetwork.getGenerator("FFR1AA1 _generator"); - Generator generator2 = testNetwork.getGenerator("FFR2AA1 _generator"); - Assertions.assertTrue(DoubleMath.fuzzyEquals(2001., generator1.getTargetP(), 0.0001)); - Assertions.assertTrue(DoubleMath.fuzzyEquals(2002., generator2.getTargetP(), 0.0001)); - done = scalable.scale(testNetwork, -3000.0); - Assertions.assertTrue(DoubleMath.fuzzyEquals(-3000., done, 0.0001)); - Assertions.assertTrue(DoubleMath.fuzzyEquals(0., generator1.getTargetP(), 0.0001)); - Assertions.assertTrue(DoubleMath.fuzzyEquals(1003., generator2.getTargetP(), 0.0001)); + GlskPoint glsk = CimGlskDocument.importGlsk(getResourceAsStream("/GlskB45test.xml")).getGlskPoints().get(0); + Scalable scalable = GlskPointScalableConverter.convert(testNetwork, glsk); + assertNotNull(scalable); + assertEquals(2000., testNetwork.getGenerator("FFR1AA1 _generator").getTargetP(), DOUBLE_TOLERANCE); + assertEquals(2000., testNetwork.getGenerator("FFR2AA1 _generator").getTargetP(), DOUBLE_TOLERANCE); + assertEquals(3000., testNetwork.getGenerator("FFR3AA1 _generator").getTargetP(), DOUBLE_TOLERANCE); + assertEquals(1000., testNetwork.getLoad("FFR1AA1 _load").getP0(), DOUBLE_TOLERANCE); + assertEquals(3500., testNetwork.getLoad("FFR2AA1 _load").getP0(), DOUBLE_TOLERANCE); + assertEquals(1500., testNetwork.getLoad("FFR3AA1 _load").getP0(), DOUBLE_TOLERANCE); + + double done = scalable.scale(testNetwork, 100.); + assertEquals(6., done, DOUBLE_TOLERANCE); + assertEquals(2001., testNetwork.getGenerator("FFR1AA1 _generator").getTargetP(), DOUBLE_TOLERANCE); + assertEquals(2002., testNetwork.getGenerator("FFR2AA1 _generator").getTargetP(), DOUBLE_TOLERANCE); + assertEquals(3003., testNetwork.getGenerator("FFR3AA1 _generator").getTargetP(), DOUBLE_TOLERANCE); + assertEquals(1000., testNetwork.getLoad("FFR1AA1 _load").getP0(), DOUBLE_TOLERANCE); // untouched + assertEquals(3500., testNetwork.getLoad("FFR2AA1 _load").getP0(), DOUBLE_TOLERANCE); // untouched + assertEquals(1500., testNetwork.getLoad("FFR3AA1 _load").getP0(), DOUBLE_TOLERANCE); // untouched + + done = scalable.scale(testNetwork, -3000.0); + assertEquals(-3000., done, DOUBLE_TOLERANCE); + assertEquals(0., testNetwork.getGenerator("FFR1AA1 _generator").getTargetP(), DOUBLE_TOLERANCE); + assertEquals(1003., testNetwork.getGenerator("FFR2AA1 _generator").getTargetP(), DOUBLE_TOLERANCE); + assertEquals(3003., testNetwork.getGenerator("FFR3AA1 _generator").getTargetP(), DOUBLE_TOLERANCE); + assertEquals(1000., testNetwork.getLoad("FFR1AA1 _load").getP0(), DOUBLE_TOLERANCE); // untouched + assertEquals(3500., testNetwork.getLoad("FFR2AA1 _load").getP0(), DOUBLE_TOLERANCE); // untouched + assertEquals(1500., testNetwork.getLoad("FFR3AA1 _load").getP0(), DOUBLE_TOLERANCE); // untouched } @Test void testConvertGlskPointToScalableB42Country() { - Scalable scalable = GlskPointScalableConverter.convert(testNetwork, glskPointCountry); - double done = scalable.scale(testNetwork, 100.0); - Assertions.assertTrue(DoubleMath.fuzzyEquals(100, done, 0.0001)); + GlskPoint glsk = CimGlskDocument.importGlsk(getResourceAsStream("/GlskB42CountryIIDM.xml")).getGlskPoints().get(0); + Scalable scalable = GlskPointScalableConverter.convert(testNetwork, glsk); + + assertNotNull(scalable); + assertEquals(2000., testNetwork.getGenerator("FFR1AA1 _generator").getTargetP(), DOUBLE_TOLERANCE); + assertEquals(2000., testNetwork.getGenerator("FFR2AA1 _generator").getTargetP(), DOUBLE_TOLERANCE); + assertEquals(3000., testNetwork.getGenerator("FFR3AA1 _generator").getTargetP(), DOUBLE_TOLERANCE); + assertEquals(1000., testNetwork.getLoad("FFR1AA1 _load").getP0(), DOUBLE_TOLERANCE); + assertEquals(3500., testNetwork.getLoad("FFR2AA1 _load").getP0(), DOUBLE_TOLERANCE); + assertEquals(1500., testNetwork.getLoad("FFR3AA1 _load").getP0(), DOUBLE_TOLERANCE); + + double done = scalable.scale(testNetwork, 700.); + assertEquals(700., done, DOUBLE_TOLERANCE); + assertEquals(2200., testNetwork.getGenerator("FFR1AA1 _generator").getTargetP(), DOUBLE_TOLERANCE); // 2000/7000 * 700 = +200 + assertEquals(2200., testNetwork.getGenerator("FFR2AA1 _generator").getTargetP(), DOUBLE_TOLERANCE); // 2000/7000 * 700 = +200 + assertEquals(3300., testNetwork.getGenerator("FFR3AA1 _generator").getTargetP(), DOUBLE_TOLERANCE); // 3000/7000 * 700 = +300 + assertEquals(1000., testNetwork.getLoad("FFR1AA1 _load").getP0(), DOUBLE_TOLERANCE); // untouched + assertEquals(3500., testNetwork.getLoad("FFR2AA1 _load").getP0(), DOUBLE_TOLERANCE); // untouched + assertEquals(1500., testNetwork.getLoad("FFR3AA1 _load").getP0(), DOUBLE_TOLERANCE); // untouched } @Test void testConvertGlskPointToScalableB42CountryGskLsk() { - Scalable scalable = GlskPointScalableConverter.convert(testNetwork, glskPointCountryGskLsk); - double done = scalable.scale(testNetwork, 100.0); - Assertions.assertTrue(DoubleMath.fuzzyEquals(100, done, 0.0001)); + GlskPoint glsk = CimGlskDocument.importGlsk(getResourceAsStream("/GlskB42CountryGskLsk.xml")).getGlskPoints().get(0); + Scalable scalable = GlskPointScalableConverter.convert(testNetwork, glsk); + + assertNotNull(scalable); + assertEquals(2000., testNetwork.getGenerator("FFR1AA1 _generator").getTargetP(), DOUBLE_TOLERANCE); + assertEquals(2000., testNetwork.getGenerator("FFR2AA1 _generator").getTargetP(), DOUBLE_TOLERANCE); + assertEquals(3000., testNetwork.getGenerator("FFR3AA1 _generator").getTargetP(), DOUBLE_TOLERANCE); + assertEquals(1000., testNetwork.getLoad("FFR1AA1 _load").getP0(), DOUBLE_TOLERANCE); + assertEquals(3500., testNetwork.getLoad("FFR2AA1 _load").getP0(), DOUBLE_TOLERANCE); + assertEquals(1500., testNetwork.getLoad("FFR3AA1 _load").getP0(), DOUBLE_TOLERANCE); + + double done = scalable.scale(testNetwork, -1000.); + assertEquals(-1000., done, DOUBLE_TOLERANCE); + assertEquals(1829., testNetwork.getGenerator("FFR1AA1 _generator").getTargetP(), FUZZY_TOLERANCE); // 2000/7000 * 0.6 = 17.1 % + assertEquals(1829., testNetwork.getGenerator("FFR2AA1 _generator").getTargetP(), FUZZY_TOLERANCE); // 2000/7000 * 0.6 = 17.1 % + assertEquals(2743., testNetwork.getGenerator("FFR3AA1 _generator").getTargetP(), FUZZY_TOLERANCE); // 3000/7000 * 0.6 = 25.7 % + assertEquals(1067., testNetwork.getLoad("FFR1AA1 _load").getP0(), FUZZY_TOLERANCE); // 1000/6000 * 0.4 = 6.7 % + assertEquals(3733., testNetwork.getLoad("FFR2AA1 _load").getP0(), FUZZY_TOLERANCE); // 3500/6000 * 0.4 = 23.3 % + assertEquals(1600., testNetwork.getLoad("FFR3AA1 _load").getP0(), FUZZY_TOLERANCE); // 1500/6000 * 0.4 = 10 % } @Test void testConvertGlskPointToScalableB42ExplicitGskLsk() { - Scalable scalable = GlskPointScalableConverter.convert(testNetwork, glskPointExplicitGskLsk); - double done = scalable.scale(testNetwork, 100.0); - Assertions.assertTrue(DoubleMath.fuzzyEquals(100, done, 0.0001)); + GlskPoint glsk = CimGlskDocument.importGlsk(getResourceAsStream("/GlskB42ExplicitGskLsk.xml")).getGlskPoints().get(0); + Scalable scalable = GlskPointScalableConverter.convert(testNetwork, glsk); + + assertNotNull(scalable); + assertEquals(2000., testNetwork.getGenerator("FFR1AA1 _generator").getTargetP(), DOUBLE_TOLERANCE); + assertEquals(2000., testNetwork.getGenerator("FFR2AA1 _generator").getTargetP(), DOUBLE_TOLERANCE); + assertEquals(3000., testNetwork.getGenerator("FFR3AA1 _generator").getTargetP(), DOUBLE_TOLERANCE); + assertEquals(1000., testNetwork.getLoad("FFR1AA1 _load").getP0(), DOUBLE_TOLERANCE); + assertEquals(3500., testNetwork.getLoad("FFR2AA1 _load").getP0(), DOUBLE_TOLERANCE); + assertEquals(1500., testNetwork.getLoad("FFR3AA1 _load").getP0(), DOUBLE_TOLERANCE); + + double done = scalable.scale(testNetwork, 1000.); + assertEquals(1000., done, DOUBLE_TOLERANCE); + assertEquals(2300., testNetwork.getGenerator("FFR1AA1 _generator").getTargetP(), DOUBLE_TOLERANCE); // 2000/4000 * 0.6 = 30 % + assertEquals(2300., testNetwork.getGenerator("FFR2AA1 _generator").getTargetP(), DOUBLE_TOLERANCE); // 2000/4000 * 0.6 = 30 % + assertEquals(3000., testNetwork.getGenerator("FFR3AA1 _generator").getTargetP(), DOUBLE_TOLERANCE); // excluded + assertEquals(1000., testNetwork.getLoad("FFR1AA1 _load").getP0(), DOUBLE_TOLERANCE); // excluded + assertEquals(3220., testNetwork.getLoad("FFR2AA1 _load").getP0(), DOUBLE_TOLERANCE); // 3500/5000 * 0.4 = 28 % + assertEquals(1380., testNetwork.getLoad("FFR3AA1 _load").getP0(), DOUBLE_TOLERANCE); // 1500/5000 * 0.4 = 12 % } @Test void testConvertGlskPointToScalableB43GskLsk() { - Scalable scalable = GlskPointScalableConverter.convert(testNetwork, glskPointParticipationFactorGskLsk); - double done = scalable.scale(testNetwork, 100.0); - Assertions.assertTrue(DoubleMath.fuzzyEquals(100, done, 0.0001)); + GlskPoint glsk = CimGlskDocument.importGlsk(getResourceAsStream("/GlskB43ParticipationFactorGskLsk.xml")).getGlskPoints().get(0); + Scalable scalable = GlskPointScalableConverter.convert(testNetwork, glsk); + + assertNotNull(scalable); + assertEquals(2000., testNetwork.getGenerator("FFR1AA1 _generator").getTargetP(), DOUBLE_TOLERANCE); + assertEquals(2000., testNetwork.getGenerator("FFR2AA1 _generator").getTargetP(), DOUBLE_TOLERANCE); + assertEquals(3000., testNetwork.getGenerator("FFR3AA1 _generator").getTargetP(), DOUBLE_TOLERANCE); + assertEquals(1000., testNetwork.getLoad("FFR1AA1 _load").getP0(), DOUBLE_TOLERANCE); + assertEquals(3500., testNetwork.getLoad("FFR2AA1 _load").getP0(), DOUBLE_TOLERANCE); + assertEquals(1500., testNetwork.getLoad("FFR3AA1 _load").getP0(), DOUBLE_TOLERANCE); + + double done = scalable.scale(testNetwork, 500.); + assertEquals(500., done, DOUBLE_TOLERANCE); + assertEquals(2210., testNetwork.getGenerator("FFR1AA1 _generator").getTargetP(), DOUBLE_TOLERANCE); // 0.7 * 0.6 = 42 % + assertEquals(2090., testNetwork.getGenerator("FFR2AA1 _generator").getTargetP(), DOUBLE_TOLERANCE); // 0.3 * 0.6 = 18 % + assertEquals(3000., testNetwork.getGenerator("FFR3AA1 _generator").getTargetP(), DOUBLE_TOLERANCE); // untouched + assertEquals(960., testNetwork.getLoad("FFR1AA1 _load").getP0(), DOUBLE_TOLERANCE); // 0.2 * 0.4 = 8 % + assertEquals(3340., testNetwork.getLoad("FFR2AA1 _load").getP0(), DOUBLE_TOLERANCE); // 0.8 * 0.4 = 32 % + assertEquals(1500., testNetwork.getLoad("FFR3AA1 _load").getP0(), DOUBLE_TOLERANCE); // untouched } @Test void testConvertGlskPointToScalableB42Explicit() { - Scalable scalable = GlskPointScalableConverter.convert(testNetwork, glskPointExplicit); - double done = scalable.scale(testNetwork, 100.0); - Assertions.assertTrue(DoubleMath.fuzzyEquals(100, done, 0.0001)); + GlskPoint glsk = CimGlskDocument.importGlsk(getResourceAsStream("/GlskB42ExplicitIIDM.xml")).getGlskPoints().get(0); + Scalable scalable = GlskPointScalableConverter.convert(testNetwork, glsk); + + assertNotNull(scalable); + assertEquals(2000., testNetwork.getGenerator("FFR1AA1 _generator").getTargetP(), DOUBLE_TOLERANCE); + assertEquals(2000., testNetwork.getGenerator("FFR2AA1 _generator").getTargetP(), DOUBLE_TOLERANCE); + assertEquals(3000., testNetwork.getGenerator("FFR3AA1 _generator").getTargetP(), DOUBLE_TOLERANCE); + assertEquals(1000., testNetwork.getLoad("FFR1AA1 _load").getP0(), DOUBLE_TOLERANCE); + assertEquals(3500., testNetwork.getLoad("FFR2AA1 _load").getP0(), DOUBLE_TOLERANCE); + assertEquals(1500., testNetwork.getLoad("FFR3AA1 _load").getP0(), DOUBLE_TOLERANCE); + + double done = scalable.scale(testNetwork, -500.); + assertEquals(-500., done, DOUBLE_TOLERANCE); + assertEquals(1800., testNetwork.getGenerator("FFR1AA1 _generator").getTargetP(), DOUBLE_TOLERANCE); // 2000/5000 * 500 = -200 + assertEquals(2000., testNetwork.getGenerator("FFR2AA1 _generator").getTargetP(), DOUBLE_TOLERANCE); // untouched + assertEquals(2700., testNetwork.getGenerator("FFR3AA1 _generator").getTargetP(), DOUBLE_TOLERANCE); // 3000/5000 * 500 = -300 + assertEquals(1000., testNetwork.getLoad("FFR1AA1 _load").getP0(), DOUBLE_TOLERANCE); // untouched + assertEquals(3500., testNetwork.getLoad("FFR2AA1 _load").getP0(), DOUBLE_TOLERANCE); // untouched + assertEquals(1500., testNetwork.getLoad("FFR3AA1 _load").getP0(), DOUBLE_TOLERANCE); // untouched } @Test void testConvertGlskPointToScalableB43() { - Scalable scalable = GlskPointScalableConverter.convert(testNetwork, glskPointParticipationFactor); - double done = scalable.scale(testNetwork, 100.0); - Assertions.assertTrue(DoubleMath.fuzzyEquals(100, done, 0.0001)); + GlskPoint glsk = CimGlskDocument.importGlsk(getResourceAsStream("/GlskB43ParticipationFactorIIDM.xml")).getGlskPoints().get(0); + Scalable scalable = GlskPointScalableConverter.convert(testNetwork, glsk); + + assertNotNull(scalable); + assertEquals(2000., testNetwork.getGenerator("FFR1AA1 _generator").getTargetP(), DOUBLE_TOLERANCE); + assertEquals(2000., testNetwork.getGenerator("FFR2AA1 _generator").getTargetP(), DOUBLE_TOLERANCE); + assertEquals(3000., testNetwork.getGenerator("FFR3AA1 _generator").getTargetP(), DOUBLE_TOLERANCE); + assertEquals(1000., testNetwork.getLoad("FFR1AA1 _load").getP0(), DOUBLE_TOLERANCE); + assertEquals(3500., testNetwork.getLoad("FFR2AA1 _load").getP0(), DOUBLE_TOLERANCE); + assertEquals(1500., testNetwork.getLoad("FFR3AA1 _load").getP0(), DOUBLE_TOLERANCE); + + double done = scalable.scale(testNetwork, 1000.); + assertEquals(1000., done, DOUBLE_TOLERANCE); + assertEquals(2382., testNetwork.getGenerator("FFR1AA1 _generator").getTargetP(), FUZZY_TOLERANCE); // 0.618/(0.618+0.618+0.382) = 38.2 % + assertEquals(2382., testNetwork.getGenerator("FFR2AA1 _generator").getTargetP(), FUZZY_TOLERANCE); // 0.618/(0.618+0.618+0.382) = 38.2 % + assertEquals(3236., testNetwork.getGenerator("FFR3AA1 _generator").getTargetP(), FUZZY_TOLERANCE); // 0.382/(0.618+0.618+0.382) = 23.6 % + assertEquals(1000., testNetwork.getLoad("FFR1AA1 _load").getP0(), DOUBLE_TOLERANCE); // untouched + assertEquals(3500., testNetwork.getLoad("FFR2AA1 _load").getP0(), DOUBLE_TOLERANCE); // untouched + assertEquals(1500., testNetwork.getLoad("FFR3AA1 _load").getP0(), DOUBLE_TOLERANCE); // untouched + } + + @Test + void testConvertGlskPointToScalableB42ExplicitGskLskWithDanglingLines() { + testNetwork = Network.read("testCaseWithDanglingLines.xiidm", getClass().getResourceAsStream("/testCaseWithDanglingLines.xiidm")); + GlskPoint glsk = CimGlskDocument.importGlsk(getResourceAsStream("/GlskB42ExplicitWithDanglingLines.xml")).getGlskPoints().get(0); + Scalable scalable = GlskPointScalableConverter.convert(testNetwork, glsk); + + assertNotNull(scalable); + assertEquals(2000., testNetwork.getGenerator("FFR1AA1 _generator").getTargetP(), DOUBLE_TOLERANCE); + assertEquals(2000., testNetwork.getGenerator("FFR2AA1 _generator").getTargetP(), DOUBLE_TOLERANCE); + assertEquals(3000., testNetwork.getGenerator("FFR3AA1 _generator").getTargetP(), DOUBLE_TOLERANCE); + assertEquals(-1000., testNetwork.getDanglingLine("DDE3AA1 XNODE_1A 1").getP0(), DOUBLE_TOLERANCE); + assertEquals(1000., testNetwork.getLoad("FFR1AA1 _load").getP0(), DOUBLE_TOLERANCE); + assertEquals(3500., testNetwork.getLoad("FFR2AA1 _load").getP0(), DOUBLE_TOLERANCE); + assertEquals(1500., testNetwork.getLoad("FFR3AA1 _load").getP0(), DOUBLE_TOLERANCE); + assertEquals(1000., testNetwork.getDanglingLine("BBE2AA1 XNODE_1B 1").getP0(), DOUBLE_TOLERANCE); + + double done = scalable.scale(testNetwork, -1000.); + assertEquals(-1000., done, DOUBLE_TOLERANCE); + assertEquals(1850., testNetwork.getGenerator("FFR1AA1 _generator").getTargetP(), FUZZY_TOLERANCE); // 2/8 * 0.6 = 15 % + assertEquals(1850., testNetwork.getGenerator("FFR2AA1 _generator").getTargetP(), FUZZY_TOLERANCE); // 2/8 * 0.6 = 15 % + assertEquals(2775., testNetwork.getGenerator("FFR3AA1 _generator").getTargetP(), FUZZY_TOLERANCE); // 3/8 * 0.6 = 22.5 % + assertEquals(-925., testNetwork.getDanglingLine("DDE3AA1 XNODE_1A 1").getP0(), FUZZY_TOLERANCE); // 1/8 * 0.6 = 7.5 % + assertEquals(1057., testNetwork.getLoad("FFR1AA1 _load").getP0(), FUZZY_TOLERANCE); // 1/7 * 0.4 = 5.7 % + assertEquals(3700., testNetwork.getLoad("FFR2AA1 _load").getP0(), FUZZY_TOLERANCE); // 3.5/7 * 0.4 = 20 % + assertEquals(1586., testNetwork.getLoad("FFR3AA1 _load").getP0(), FUZZY_TOLERANCE); // 1.5/7 * 0.4 = 8.6 % + assertEquals(1057., testNetwork.getDanglingLine("BBE2AA1 XNODE_1B 1").getP0(), FUZZY_TOLERANCE); // 1/7 * 0.4 = 5.7 % + } + + @Test + void testConvertGlskPointToScalableB43GskLskWithDanglingLines() { + testNetwork = Network.read("testCaseWithDanglingLines.xiidm", getClass().getResourceAsStream("/testCaseWithDanglingLines.xiidm")); + GlskPoint glsk = CimGlskDocument.importGlsk(getResourceAsStream("/GlskB43ParticipationFactorGskLskWithDanglingLines.xml")).getGlskPoints().get(0); + Scalable scalable = GlskPointScalableConverter.convert(testNetwork, glsk); + + assertNotNull(scalable); + assertEquals(2000., testNetwork.getGenerator("FFR1AA1 _generator").getTargetP(), DOUBLE_TOLERANCE); + assertEquals(-1000., testNetwork.getDanglingLine("DDE3AA1 XNODE_1A 1").getP0(), DOUBLE_TOLERANCE); + assertEquals(1000., testNetwork.getLoad("FFR1AA1 _load").getP0(), DOUBLE_TOLERANCE); + assertEquals(1000., testNetwork.getDanglingLine("BBE2AA1 XNODE_1B 1").getP0(), DOUBLE_TOLERANCE); + + double done = scalable.scale(testNetwork, 1000.); + assertEquals(1000., done, DOUBLE_TOLERANCE); + assertEquals(2420., testNetwork.getGenerator("FFR1AA1 _generator").getTargetP(), DOUBLE_TOLERANCE); // 0.6 * 0.7 = 42 % + assertEquals(-1180., testNetwork.getDanglingLine("DDE3AA1 XNODE_1A 1").getP0(), DOUBLE_TOLERANCE); // 0.6 * 0.3 = 18 % + assertEquals(840., testNetwork.getLoad("FFR1AA1 _load").getP0(), DOUBLE_TOLERANCE); // 0.4 * 0.4 = 16 % + assertEquals(760., testNetwork.getDanglingLine("BBE2AA1 XNODE_1B 1").getP0(), DOUBLE_TOLERANCE); // 0.4 * 0.6 = 24 % } } diff --git a/glsk/glsk-document-cim/src/test/resources/GlskB42ExplicitGskLsk.xml b/glsk/glsk-document-cim/src/test/resources/GlskB42ExplicitGskLsk.xml index 458abce5..5928012a 100644 --- a/glsk/glsk-document-cim/src/test/resources/GlskB42ExplicitGskLsk.xml +++ b/glsk/glsk-document-cim/src/test/resources/GlskB42ExplicitGskLsk.xml @@ -41,19 +41,11 @@ FFR2AA1 _generator FFR2AA1 _generator - - FFR3AA1 _generator - FFR3AA1 _generator - B42 A05 0.4 - - FFR1AA1 _load - FFR1AA1 _load - FFR2AA1 _load FFR2AA1 _load diff --git a/glsk/glsk-document-cim/src/test/resources/GlskB42ExplicitIIDM.xml b/glsk/glsk-document-cim/src/test/resources/GlskB42ExplicitIIDM.xml index 9fdfb011..f5b4046d 100644 --- a/glsk/glsk-document-cim/src/test/resources/GlskB42ExplicitIIDM.xml +++ b/glsk/glsk-document-cim/src/test/resources/GlskB42ExplicitIIDM.xml @@ -36,10 +36,6 @@ FFR1AA1 _generator FFR1AA1 _generator - - - - FFR3AA1 _generator FFR3AA1 _generator diff --git a/glsk/glsk-document-cim/src/test/resources/GlskB42ExplicitWithDanglingLines.xml b/glsk/glsk-document-cim/src/test/resources/GlskB42ExplicitWithDanglingLines.xml new file mode 100644 index 00000000..6a978f88 --- /dev/null +++ b/glsk/glsk-document-cim/src/test/resources/GlskB42ExplicitWithDanglingLines.xml @@ -0,0 +1,77 @@ + + + 49V000000000017G-20180829-F717 + 1 + B22 + A49 + 49V000000000017G + A36 + 10XDE-RWENET---W + A04 + 2018-10-02T12:21:00Z + + A42 + + + 2018-08-28T22:00Z + 2018-08-29T22:00Z + + 10YDOM-REGION-1V + + GLSK_B42_country + 10YFR-RTE------C + A03 + + + 2018-08-28T22:00Z + 2018-08-29T22:00Z + + PT60M + + 1 + + B42 + A04 + 0.6 + + FFR1AA1 _generator + FFR1AA1 _generator + + + FFR2AA1 _generator + FFR2AA1 _generator + + + FFR3AA1 _generator + FFR3AA1 _generator + + + DDE3AA1 XNODE_1A 1 + DDE3AA1 XNODE_1A 1 + + + + B42 + A05 + 0.4 + + FFR1AA1 _load + FFR1AA1 _load + + + FFR2AA1 _load + FFR2AA1 _load + + + FFR3AA1 _load + FFFR3AA1 _load + + + BBE2AA1 XNODE_1B 1 + DBBE2AA1 XNODE_1B 1 + + + + + + \ No newline at end of file diff --git a/glsk/glsk-document-cim/src/test/resources/GlskB43ParticipationFactorGskLsk.xml b/glsk/glsk-document-cim/src/test/resources/GlskB43ParticipationFactorGskLsk.xml index c183a2bc..dacaae31 100644 --- a/glsk/glsk-document-cim/src/test/resources/GlskB43ParticipationFactorGskLsk.xml +++ b/glsk/glsk-document-cim/src/test/resources/GlskB43ParticipationFactorGskLsk.xml @@ -36,12 +36,12 @@ FFR1AA1 _generator FFR1AA1 _generator - 0.5 + 0.7 FFR2AA1 _generator FFR2AA1 _generator - 0.5 + 0.3 @@ -51,12 +51,12 @@ FFR1AA1 _load FFR1AA1 _load - 0.5 + 0.2 FFR2AA1 _load FFR2AA1 _load - 0.5 + 0.8 diff --git a/glsk/glsk-document-cim/src/test/resources/GlskB43ParticipationFactorGskLskWithDanglingLines.xml b/glsk/glsk-document-cim/src/test/resources/GlskB43ParticipationFactorGskLskWithDanglingLines.xml new file mode 100644 index 00000000..4b39e07c --- /dev/null +++ b/glsk/glsk-document-cim/src/test/resources/GlskB43ParticipationFactorGskLskWithDanglingLines.xml @@ -0,0 +1,65 @@ + + + 49V000000000017G-20180829-F717 + 1 + B22 + A49 + 49V000000000017G + A36 + 10XDE-RWENET---W + A04 + 2018-10-02T12:21:00Z + + A42 + + + 2018-08-28T22:00Z + 2018-08-29T22:00Z + + 10YDOM-REGION-1V + + GLSK_B43_participation_factor + 10YFR-RTE------C + A03 + + + 2018-08-28T22:00Z + 2018-08-29T22:00Z + + PT60M + + 1 + + B43 + A04 + 0.6 + + FFR1AA1 _generator + FFR1AA1 _generator + 0.7 + + + DDE3AA1 XNODE_1A 1 + DDE3AA1 XNODE_1A 1 + 0.3 + + + + B43 + A05 + 0.4 + + FFR1AA1 _load + FFR1AA1 _load + 0.4 + + + BBE2AA1 XNODE_1B 1 + BBE2AA1 XNODE_1B 1 + 0.6 + + + + + + \ No newline at end of file diff --git a/glsk/glsk-document-cim/src/test/resources/testCaseWithDanglingLines.xiidm b/glsk/glsk-document-cim/src/test/resources/testCaseWithDanglingLines.xiidm new file mode 100644 index 00000000..1490b114 --- /dev/null +++ b/glsk/glsk-document-cim/src/test/resources/testCaseWithDanglingLines.xiidm @@ -0,0 +1,273 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/glsk/glsk-document-cse/pom.xml b/glsk/glsk-document-cse/pom.xml index 76ae4bbc..fde1b645 100644 --- a/glsk/glsk-document-cse/pom.xml +++ b/glsk/glsk-document-cse/pom.xml @@ -54,6 +54,11 @@ powsybl-config-test test + + com.powsybl + powsybl-entsoe-util + test + com.powsybl powsybl-iidm-xml-converter diff --git a/glsk/glsk-document-cse/src/main/java/com/powsybl/glsk/cse/CseGlskRegisteredResource.java b/glsk/glsk-document-cse/src/main/java/com/powsybl/glsk/cse/CseGlskRegisteredResource.java index 23491430..05b3c085 100644 --- a/glsk/glsk-document-cse/src/main/java/com/powsybl/glsk/cse/CseGlskRegisteredResource.java +++ b/glsk/glsk-document-cse/src/main/java/com/powsybl/glsk/cse/CseGlskRegisteredResource.java @@ -18,6 +18,7 @@ /** * @author Sebastien Murgey {@literal } + * @author Peter Mitri {@literal } */ public class CseGlskRegisteredResource extends AbstractGlskRegisteredResource { private final Double initialFactor; diff --git a/glsk/glsk-document-cse/src/test/java/com/powsybl/glsk/cse/CseGlskDocumentImporterTest.java b/glsk/glsk-document-cse/src/test/java/com/powsybl/glsk/cse/CseGlskDocumentImporterTest.java index efd64e76..1a7fb368 100644 --- a/glsk/glsk-document-cse/src/test/java/com/powsybl/glsk/cse/CseGlskDocumentImporterTest.java +++ b/glsk/glsk-document-cse/src/test/java/com/powsybl/glsk/cse/CseGlskDocumentImporterTest.java @@ -20,13 +20,11 @@ import java.io.InputStream; import java.util.List; -import static org.junit.jupiter.api.Assertions.assertEquals; -import static org.junit.jupiter.api.Assertions.assertFalse; -import static org.junit.jupiter.api.Assertions.assertNotNull; -import static org.junit.jupiter.api.Assertions.assertThrows; +import static org.junit.jupiter.api.Assertions.*; /** * @author Sebastien Murgey {@literal } + * @author Peter Mitri {@literal } */ class CseGlskDocumentImporterTest { private static final double EPSILON = 1e-3; @@ -35,7 +33,6 @@ class CseGlskDocumentImporterTest { void checkCseGlskDocumentImporterCorrectlyImportManualGskBlocks() { CseGlskDocument cseGlskDocument = CseGlskDocument.importGlsk(getClass().getResourceAsStream("/testGlsk.xml"), false); List list = cseGlskDocument.getGlskPoints("FR_MANUAL"); - assertFalse(list.isEmpty()); assertEquals(1, list.size()); assertEquals(1, list.get(0).getGlskShiftKeys().size()); assertEquals(2, list.get(0).getGlskShiftKeys().get(0).getRegisteredResourceArrayList().size()); @@ -60,7 +57,6 @@ void checkCseGlskDocumentImporterCorrectlyConvertManualGskBlocks() { void checkCseGlskDocumentImporterCorrectlyImportReserveGskBlocks() { CseGlskDocument cseGlskDocument = CseGlskDocument.importGlsk(getClass().getResourceAsStream("/testGlsk.xml"), false); List list = cseGlskDocument.getGlskPoints("FR_RESERVE"); - assertFalse(list.isEmpty()); assertEquals(1, list.size()); assertEquals(1, list.get(0).getGlskShiftKeys().size()); assertEquals(2, list.get(0).getGlskShiftKeys().get(0).getRegisteredResourceArrayList().size()); @@ -132,7 +128,6 @@ void checkCseGlskDocumentImporterCorrectlyConvertReserveGskBlocksUpWithReachingL void checkCseGlskDocumentImporterCorrectlyImportPropGskBlocks() { CseGlskDocument cseGlskDocument = CseGlskDocument.importGlsk(getClass().getResourceAsStream("/testGlsk.xml"), false); List list = cseGlskDocument.getGlskPoints("FR_PROPGSK"); - assertFalse(list.isEmpty()); assertEquals(1, list.size()); assertEquals(1, list.get(0).getGlskShiftKeys().size()); assertEquals(3, list.get(0).getGlskShiftKeys().get(0).getRegisteredResourceArrayList().size()); @@ -159,7 +154,6 @@ void checkCseGlskDocumentImporterCorrectlyConvertPropGskBlocks() { void checkCseGlskDocumentImporterCorrectlyImportPropGlskBlocks() { CseGlskDocument cseGlskDocument = CseGlskDocument.importGlsk(getClass().getResourceAsStream("/testGlsk.xml"), false); List list = cseGlskDocument.getGlskPoints("FR_PROPGLSK"); - assertFalse(list.isEmpty()); assertEquals(1, list.size()); assertEquals(2, list.get(0).getGlskShiftKeys().size()); assertEquals(2, list.get(0).getGlskShiftKeys().get(0).getRegisteredResourceArrayList().size()); @@ -202,7 +196,6 @@ void checkCseGlskDocumentImporterCorrectlyConvertPropLskBlocksWithPassingLoadsAs void checkCseGlskDocumentImporterCorrectlyImportMeritOrderGskBlocks() { CseGlskDocument cseGlskDocument = CseGlskDocument.importGlsk(getClass().getResourceAsStream("/testGlsk.xml"), false); List list = cseGlskDocument.getGlskPoints("FR_MERITORDER"); - assertFalse(list.isEmpty()); assertEquals(1, list.size()); assertEquals(7, list.get(0).getGlskShiftKeys().size()); assertEquals(1, list.get(0).getGlskShiftKeys().get(0).getRegisteredResourceArrayList().size()); @@ -442,4 +435,171 @@ void checkCseGlskDocumentImporterCorrectlyImportMergedGlsk() { assertEquals(1, siSecondRegisteredResources.size()); assertEquals("SI01AA01", siSecondRegisteredResources.get(0).getName()); } + + @Test + void checkCseGlskDocumentImporterCorrectlyImportManualGskBlocksWithDanglingLines() { + CseGlskDocument cseGlskDocument = CseGlskDocument.importGlsk(getClass().getResourceAsStream("/testGlskWithDanglingLines.xml"), false); + List list = cseGlskDocument.getGlskPoints("FR_MANUAL"); + assertEquals(1, list.size()); + assertEquals(1, list.get(0).getGlskShiftKeys().size()); + assertEquals(2, list.get(0).getGlskShiftKeys().get(0).getRegisteredResourceArrayList().size()); + } + + @Test + void checkCseGlskDocumentImporterCorrectlyConvertManualGskBlocksWithDanglingLines() { + Network network = Network.read("testCaseWithDanglingLines.xiidm", getClass().getResourceAsStream("/testCaseWithDanglingLines.xiidm")); + GlskDocument glskDocument = GlskDocumentImporters.importGlsk(getClass().getResourceAsStream("/testGlskWithDanglingLines.xml")); + Scalable manualScalable = glskDocument.getZonalScalable(network).getData("FR_MANUAL"); + + assertNotNull(manualScalable); + assertEquals(2000., network.getGenerator("FFR1AA1 _generator").getTargetP(), EPSILON); + assertEquals(1000., network.getDanglingLine("BBE2AA1 XNODE_1B 1").getP0(), EPSILON); + + manualScalable.scale(network, 1000.); + assertEquals(2700., network.getGenerator("FFR1AA1 _generator").getTargetP(), EPSILON); + assertEquals(700., network.getDanglingLine("BBE2AA1 XNODE_1B 1").getP0(), EPSILON); + } + + @Test + void checkCseGlskDocumentImporterCorrectlyImportPropGskBlocksWithDanglingLines() { + CseGlskDocument cseGlskDocument = CseGlskDocument.importGlsk(getClass().getResourceAsStream("/testGlskWithDanglingLines.xml"), false); + List list = cseGlskDocument.getGlskPoints("FR_PROPGSK"); + assertEquals(1, list.size()); + assertEquals(1, list.get(0).getGlskShiftKeys().size()); + assertEquals(3, list.get(0).getGlskShiftKeys().get(0).getRegisteredResourceArrayList().size()); + } + + @Test + void checkCseGlskDocumentImporterCorrectlyConvertPropGskBlocksWithDanglingLines() { + Network network = Network.read("testCaseWithDanglingLines.xiidm", getClass().getResourceAsStream("/testCaseWithDanglingLines.xiidm")); + GlskDocument glskDocument = GlskDocumentImporters.importGlsk(getClass().getResourceAsStream("/testGlskWithDanglingLines.xml")); + Scalable propGskScalable = glskDocument.getZonalScalable(network).getData("FR_PROPGSK"); + + assertNotNull(propGskScalable); + assertEquals(2000., network.getGenerator("FFR1AA1 _generator").getTargetP(), EPSILON); + assertEquals(-1000., network.getDanglingLine("DDE3AA1 XNODE_1A 1").getP0(), EPSILON); + assertEquals(1000, network.getDanglingLine("BBE2AA1 XNODE_1B 1").getP0(), EPSILON); + + propGskScalable.scale(network, 400.); + assertEquals(2200., network.getGenerator("FFR1AA1 _generator").getTargetP(), EPSILON); + assertEquals(-1100., network.getDanglingLine("DDE3AA1 XNODE_1A 1").getP0(), EPSILON); + assertEquals(900., network.getDanglingLine("BBE2AA1 XNODE_1B 1").getP0(), EPSILON); + } + + @Test + void checkCseGlskDocumentImporterCorrectlyImportPropGlskBlocksWithDanglingLines() { + CseGlskDocument cseGlskDocument = CseGlskDocument.importGlsk(getClass().getResourceAsStream("/testGlskWithDanglingLines.xml"), false); + List list = cseGlskDocument.getGlskPoints("FR_PROPGLSK"); + assertEquals(1, list.size()); + assertEquals(2, list.get(0).getGlskShiftKeys().size()); + assertEquals(2, list.get(0).getGlskShiftKeys().get(0).getRegisteredResourceArrayList().size()); + assertEquals(3, list.get(0).getGlskShiftKeys().get(1).getRegisteredResourceArrayList().size()); + } + + @Test + void checkCseGlskDocumentImporterCorrectlyConvertPropGlskBlocksWithDanglingLines() { + Network network = Network.read("testCaseWithDanglingLines.xiidm", getClass().getResourceAsStream("/testCaseWithDanglingLines.xiidm")); + GlskDocument glskDocument = GlskDocumentImporters.importGlsk(getClass().getResourceAsStream("/testGlskWithDanglingLines.xml")); + Scalable propGlskScalable = glskDocument.getZonalScalable(network).getData("FR_PROPGLSK"); + + assertNotNull(propGlskScalable); + assertEquals(2000., network.getGenerator("FFR1AA1 _generator").getTargetP(), EPSILON); + assertEquals(2000., network.getGenerator("FFR2AA1 _generator").getTargetP(), EPSILON); + assertEquals(1000., network.getDanglingLine("BBE2AA1 XNODE_1B 1").getP0(), EPSILON); + assertEquals(1000., network.getLoad("FFR1AA1 _load").getP0(), EPSILON); + assertEquals(-1000., network.getDanglingLine("DDE3AA1 XNODE_1A 1").getP0(), EPSILON); + + propGlskScalable.scale(network, -1000.); + assertEquals(1720., network.getGenerator("FFR1AA1 _generator").getTargetP(), EPSILON); // 28 % + assertEquals(1720., network.getGenerator("FFR2AA1 _generator").getTargetP(), EPSILON); // 28 % + assertEquals(1140., network.getDanglingLine("BBE2AA1 XNODE_1B 1").getP0(), EPSILON); // 14 % + assertEquals(1150., network.getLoad("FFR1AA1 _load").getP0(), EPSILON); // 15 % + assertEquals(-850., network.getDanglingLine("DDE3AA1 XNODE_1A 1").getP0(), EPSILON); // 15 % + } + + @Test + void checkCseGlskDocumentImporterCorrectlyImportMeritOrderGskBlocksWithDanglingLines() { + CseGlskDocument cseGlskDocument = CseGlskDocument.importGlsk(getClass().getResourceAsStream("/testGlskWithDanglingLines.xml"), false); + List list = cseGlskDocument.getGlskPoints("FR_MERITORDER"); + assertEquals(1, list.size()); + assertEquals(7, list.get(0).getGlskShiftKeys().size()); + assertEquals(1, list.get(0).getGlskShiftKeys().get(0).getRegisteredResourceArrayList().size()); + assertEquals(1, list.get(0).getGlskShiftKeys().get(1).getRegisteredResourceArrayList().size()); + assertEquals(1, list.get(0).getGlskShiftKeys().get(2).getRegisteredResourceArrayList().size()); + assertEquals(1, list.get(0).getGlskShiftKeys().get(3).getRegisteredResourceArrayList().size()); + assertEquals(1, list.get(0).getGlskShiftKeys().get(1).getRegisteredResourceArrayList().size()); + assertEquals(1, list.get(0).getGlskShiftKeys().get(2).getRegisteredResourceArrayList().size()); + assertEquals(1, list.get(0).getGlskShiftKeys().get(3).getRegisteredResourceArrayList().size()); + } + + @Test + void checkCseGlskDocumentImporterCorrectlyConvertMeritOrderGskBlocksDownWithDanglingLines() { + Network network = Network.read("testCaseWithDanglingLines.xiidm", getClass().getResourceAsStream("/testCaseWithDanglingLines.xiidm")); + GlskDocument glskDocument = GlskDocumentImporters.importGlsk(getClass().getResourceAsStream("/testGlskWithDanglingLines.xml")); + Scalable meritOrderGskScalable = glskDocument.getZonalScalable(network).getData("FR_MERITORDER"); + + assertNotNull(meritOrderGskScalable); + assertEquals(1000., network.getDanglingLine("BBE2AA1 XNODE_1B 1").getP0(), EPSILON); + assertEquals(-1000., network.getDanglingLine("DDE3AA1 XNODE_1A 1").getP0(), EPSILON); + assertEquals(2000., network.getGenerator("FFR1AA1 _generator").getTargetP(), EPSILON); + + meritOrderGskScalable.scale(network, -4500.); + assertEquals(2000., network.getDanglingLine("BBE2AA1 XNODE_1B 1").getP0(), EPSILON); // -1000 + assertEquals(2000., network.getDanglingLine("DDE3AA1 XNODE_1A 1").getP0(), EPSILON); // -3000 + assertEquals(1500., network.getGenerator("FFR1AA1 _generator").getTargetP(), EPSILON); // -500 + + } + + @Test + void checkCseGlskDocumentImporterCorrectlyConvertMeritOrderGskBlocksUpWithDanglingLines() { + Network network = Network.read("testCaseWithDanglingLines.xiidm", getClass().getResourceAsStream("/testCaseWithDanglingLines.xiidm")); + GlskDocument glskDocument = GlskDocumentImporters.importGlsk(getClass().getResourceAsStream("/testGlskWithDanglingLines.xml")); + Scalable meritOrderGskScalable = glskDocument.getZonalScalable(network).getData("FR_MERITORDER"); + + assertNotNull(meritOrderGskScalable); + assertEquals(2000., network.getGenerator("FFR1AA1 _generator").getTargetP(), EPSILON); + assertEquals(-1000., network.getDanglingLine("DDE3AA1 XNODE_1A 1").getP0(), EPSILON); + assertEquals(1000., network.getDanglingLine("BBE2AA1 XNODE_1B 1").getP0(), EPSILON); + + meritOrderGskScalable.scale(network, 6500.); + assertEquals(6000., network.getGenerator("FFR1AA1 _generator").getTargetP(), EPSILON); // +4000 + assertEquals(-2000., network.getDanglingLine("DDE3AA1 XNODE_1A 1").getP0(), EPSILON); // +1000 + assertEquals(-500., network.getDanglingLine("BBE2AA1 XNODE_1B 1").getP0(), EPSILON); // +1500 + } + + @Test + void checkCseGlskDocumentImporterCorrectlyConvertMeritOrderGskBlocksWithTargetPIssueDownWithDanglingLines() { + Network network = Network.read("testCaseWithDanglingLines.xiidm", getClass().getResourceAsStream("/testCaseWithDanglingLines.xiidm")); + GlskDocument glskDocument = GlskDocumentImporters.importGlsk(getClass().getResourceAsStream("/testGlskWithDanglingLines.xml")); + Scalable meritOrderGskScalable = glskDocument.getZonalScalable(network).getData("FR_MERIT_ISSUE_PC"); + + assertNotNull(meritOrderGskScalable); + assertEquals(1000., network.getDanglingLine("BBE2AA1 XNODE_1B 1").getP0(), EPSILON); + assertEquals(-1000., network.getDanglingLine("DDE3AA1 XNODE_1A 1").getP0(), EPSILON); + assertEquals(2000., network.getGenerator("FFR1AA1 _generator").getTargetP(), EPSILON); + + double done = meritOrderGskScalable.scale(network, -4500.); + assertEquals(-3500., done, EPSILON); + assertEquals(1000., network.getDanglingLine("BBE2AA1 XNODE_1B 1").getP0(), EPSILON); // -0 + assertEquals(500., network.getDanglingLine("DDE3AA1 XNODE_1A 1").getP0(), EPSILON); // -1500 + assertEquals(0., network.getGenerator("FFR1AA1 _generator").getTargetP(), EPSILON); // -2000 + } + + @Test + void checkCseGlskDocumentImporterCorrectlyConvertMeritOrderGskBlocksWithTargetPIssueUpWithDanglingLines() { + Network network = Network.read("testCaseWithDanglingLines.xiidm", getClass().getResourceAsStream("/testCaseWithDanglingLines.xiidm")); + GlskDocument glskDocument = GlskDocumentImporters.importGlsk(getClass().getResourceAsStream("/testGlskWithDanglingLines.xml")); + Scalable meritOrderGskScalable = glskDocument.getZonalScalable(network).getData("FR_MERIT_ISSUE_PC"); + + assertNotNull(meritOrderGskScalable); + assertEquals(2000., network.getGenerator("FFR1AA1 _generator").getTargetP(), EPSILON); + assertEquals(-1000., network.getDanglingLine("DDE3AA1 XNODE_1A 1").getP0(), EPSILON); + assertEquals(1000., network.getDanglingLine("BBE2AA1 XNODE_1B 1").getP0(), EPSILON); + + double done = meritOrderGskScalable.scale(network, 6500.); + assertEquals(5500., done, EPSILON); + assertEquals(6000., network.getGenerator("FFR1AA1 _generator").getTargetP(), EPSILON); // +4000 + assertEquals(-1000., network.getDanglingLine("DDE3AA1 XNODE_1A 1").getP0(), EPSILON); // +0 + assertEquals(-500., network.getDanglingLine("BBE2AA1 XNODE_1B 1").getP0(), EPSILON); // +1500 + } } diff --git a/glsk/glsk-document-cse/src/test/resources/testCaseWithDanglingLines.xiidm b/glsk/glsk-document-cse/src/test/resources/testCaseWithDanglingLines.xiidm new file mode 100644 index 00000000..1490b114 --- /dev/null +++ b/glsk/glsk-document-cse/src/test/resources/testCaseWithDanglingLines.xiidm @@ -0,0 +1,273 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/glsk/glsk-document-cse/src/test/resources/testGlskWithDanglingLines.xml b/glsk/glsk-document-cse/src/test/resources/testGlskWithDanglingLines.xml new file mode 100644 index 00000000..decef750 --- /dev/null +++ b/glsk/glsk-document-cse/src/test/resources/testGlskWithDanglingLines.xml @@ -0,0 +1,167 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/glsk/glsk-document-ucte/pom.xml b/glsk/glsk-document-ucte/pom.xml index 6294d871..52718577 100644 --- a/glsk/glsk-document-ucte/pom.xml +++ b/glsk/glsk-document-ucte/pom.xml @@ -28,6 +28,11 @@ powsybl-config-test test + + com.powsybl + powsybl-entsoe-util + test + com.powsybl powsybl-iidm-impl diff --git a/glsk/glsk-document-ucte/src/main/java/com/powsybl/glsk/ucte/UcteGlskRegisteredResource.java b/glsk/glsk-document-ucte/src/main/java/com/powsybl/glsk/ucte/UcteGlskRegisteredResource.java index dc7c791b..9e700231 100644 --- a/glsk/glsk-document-ucte/src/main/java/com/powsybl/glsk/ucte/UcteGlskRegisteredResource.java +++ b/glsk/glsk-document-ucte/src/main/java/com/powsybl/glsk/ucte/UcteGlskRegisteredResource.java @@ -18,6 +18,7 @@ /** * @author Joris Mancini {@literal } + * @author Peter Mitri {@literal } */ public class UcteGlskRegisteredResource extends AbstractGlskRegisteredResource { diff --git a/glsk/glsk-document-ucte/src/test/java/com/powsybl/glsk/ucte/UcteGlskDocumentImporterTest.java b/glsk/glsk-document-ucte/src/test/java/com/powsybl/glsk/ucte/UcteGlskDocumentImporterTest.java index 4cd08383..c9853dcb 100644 --- a/glsk/glsk-document-ucte/src/test/java/com/powsybl/glsk/ucte/UcteGlskDocumentImporterTest.java +++ b/glsk/glsk-document-ucte/src/test/java/com/powsybl/glsk/ucte/UcteGlskDocumentImporterTest.java @@ -6,7 +6,6 @@ */ package com.powsybl.glsk.ucte; -import com.google.common.math.DoubleMath; import com.powsybl.glsk.api.GlskRegisteredResource; import com.powsybl.glsk.api.GlskShiftKey; import com.powsybl.glsk.api.io.GlskDocumentImporters; @@ -68,9 +67,9 @@ void testUcteGlskDocumentImporterFull() { //test factor LSK + GSK = 1 for (int i = 0; i < ucteGlskDocument.getListGlskSeries().size(); i++) { for (int j = 0; j < ucteGlskDocument.getListGlskSeries().get(i).getUcteGlskBlocks().size(); j++) { - assertTrue(DoubleMath.fuzzyEquals(1.0, + assertEquals(1.0, ucteGlskDocument.getListGlskSeries().get(i).getUcteGlskBlocks().get(j).getGlskShiftKeys().stream().mapToDouble(GlskShiftKey::getQuantity).sum(), - 1e-5)); + 1e-5); } } @@ -98,7 +97,7 @@ void testExceptionCases() { } @Test - void testFileNotFound() throws FileNotFoundException { + void testFileNotFound() { assertThrows(FileNotFoundException.class, () -> GlskDocumentImporters.importGlsk("/nonExistingFile.xml")); } diff --git a/glsk/glsk-document-ucte/src/test/java/com/powsybl/glsk/ucte/UcteGlskValueProviderTest.java b/glsk/glsk-document-ucte/src/test/java/com/powsybl/glsk/ucte/UcteGlskValueProviderTest.java index 589487a5..7dc3a82a 100644 --- a/glsk/glsk-document-ucte/src/test/java/com/powsybl/glsk/ucte/UcteGlskValueProviderTest.java +++ b/glsk/glsk-document-ucte/src/test/java/com/powsybl/glsk/ucte/UcteGlskValueProviderTest.java @@ -25,6 +25,7 @@ * FlowBased Glsk Values Provider Test for Ucte format * * @author Baptiste Seguinot {@literal } + * @author Peter Mitri {@literal } */ class UcteGlskValueProviderTest { @@ -167,4 +168,21 @@ void testZeroLsk() { ZonalData ucteGlskProvider = ucteGlskDocument.getZonalGlsks(network, instant); assertNull(ucteGlskProvider.getData("10YFR-RTE------C")); } + + @Test + void testWithDanglingLines() { + Network network = Network.read("testCaseWithDanglingLines.xiidm", getClass().getResourceAsStream("/testCaseWithDanglingLines.xiidm")); + Instant instant = Instant.parse("2016-07-29T10:00:00Z"); + UcteGlskDocument ucteGlskDocument = UcteGlskDocument.importGlsk(getClass().getResourceAsStream("/GlskWithDanglingLines.xml")); + ZonalData ucteGlskProvider = ucteGlskDocument.getZonalGlsks(network, instant); + SensitivityVariableSet linearGlsk = ucteGlskProvider.getData("10YFR-RTE------C"); + + assertNotNull(linearGlsk); + assertEquals(5, linearGlsk.getVariables().size()); + assertEquals(0.2, linearGlsk.getVariable("FFR1AA1 _generator").getWeight(), EPSILON); // 2000/3000 * 0.3 = 0.2 + assertEquals(0.1, linearGlsk.getVariable("DDE3AA1 XNODE_1A 1").getWeight(), EPSILON); // 1000/3000 * 0.3 = 0.1 + assertEquals(0.1272, linearGlsk.getVariable("FFR1AA1 _load").getWeight(), EPSILON); // 1000/5500 * 0.7 = 0.1272 + assertEquals(0.4454, linearGlsk.getVariable("FFR2AA1 _load").getWeight(), EPSILON); // 3500/5500 * 0.7 = 0.4454 + assertEquals(0.1272, linearGlsk.getVariable("BBE2AA1 XNODE_1B 1").getWeight(), EPSILON); // 1000/5500 * 0.7 = 0.1272 + } } diff --git a/glsk/glsk-document-ucte/src/test/resources/GlskWithDanglingLines.xml b/glsk/glsk-document-ucte/src/test/resources/GlskWithDanglingLines.xml new file mode 100644 index 00000000..3f89f8b4 --- /dev/null +++ b/glsk/glsk-document-ucte/src/test/resources/GlskWithDanglingLines.xml @@ -0,0 +1,47 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/glsk/glsk-document-ucte/src/test/resources/testCaseWithDanglingLines.xiidm b/glsk/glsk-document-ucte/src/test/resources/testCaseWithDanglingLines.xiidm new file mode 100644 index 00000000..1490b114 --- /dev/null +++ b/glsk/glsk-document-ucte/src/test/resources/testCaseWithDanglingLines.xiidm @@ -0,0 +1,273 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + From 1afa6ed2440d4f5081e7f7cb7f23fc30b5671ca0 Mon Sep 17 00:00:00 2001 From: Peter Mitri Date: Tue, 18 Apr 2023 16:51:40 +0200 Subject: [PATCH 03/10] remove duplicated code Signed-off-by: Peter Mitri --- .../java/com/powsybl/glsk/api/util/Util.java | 17 +++++++++++++++++ .../glsk/cse/CseGlskRegisteredResource.java | 14 ++------------ .../glsk/ucte/UcteGlskRegisteredResource.java | 14 ++------------ 3 files changed, 21 insertions(+), 24 deletions(-) diff --git a/glsk/glsk-document-api/src/main/java/com/powsybl/glsk/api/util/Util.java b/glsk/glsk-document-api/src/main/java/com/powsybl/glsk/api/util/Util.java index a2d2e5df..e9b8d8be 100644 --- a/glsk/glsk-document-api/src/main/java/com/powsybl/glsk/api/util/Util.java +++ b/glsk/glsk-document-api/src/main/java/com/powsybl/glsk/api/util/Util.java @@ -7,13 +7,18 @@ package com.powsybl.glsk.api.util; import com.powsybl.glsk.commons.GlskException; +import com.powsybl.iidm.network.Identifiable; +import com.powsybl.iidm.network.Network; import org.w3c.dom.Element; import org.w3c.dom.Node; import java.util.Optional; +import java.util.Set; +import java.util.stream.Collectors; /** * @author Joris Mancini {@literal } + * @author Peter Mitri {@literal } */ public final class Util { @@ -25,4 +30,16 @@ public static Node getUniqueNode(Element glskBlockElement, String tag) { return Optional.ofNullable(glskBlockElement.getElementsByTagName(tag).item(0)) .orElseThrow(() -> new GlskException(String.format("Impossible to import GLSK: <%s> tag is missing", tag))); } + + public static String findDanglingLineIdForXndoe(Network network, String xnode) { + Set danglingLines = network.getDanglingLineStream() + .filter(dl -> dl.getUcteXnodeCode().equals(xnode)) + .map(Identifiable::getId) + .collect(Collectors.toSet()); + if (danglingLines.size() != 1) { + // No / multiple dangling lines found for Xnode + return null; + } + return danglingLines.iterator().next(); + } } diff --git a/glsk/glsk-document-cse/src/main/java/com/powsybl/glsk/cse/CseGlskRegisteredResource.java b/glsk/glsk-document-cse/src/main/java/com/powsybl/glsk/cse/CseGlskRegisteredResource.java index 05b3c085..f4f2f17e 100644 --- a/glsk/glsk-document-cse/src/main/java/com/powsybl/glsk/cse/CseGlskRegisteredResource.java +++ b/glsk/glsk-document-cse/src/main/java/com/powsybl/glsk/cse/CseGlskRegisteredResource.java @@ -7,14 +7,12 @@ package com.powsybl.glsk.cse; import com.powsybl.glsk.api.AbstractGlskRegisteredResource; -import com.powsybl.iidm.network.Identifiable; +import com.powsybl.glsk.api.util.Util; import com.powsybl.iidm.network.Network; import java.math.BigDecimal; import java.util.Objects; import java.util.Optional; -import java.util.Set; -import java.util.stream.Collectors; /** * @author Sebastien Murgey {@literal } @@ -52,15 +50,7 @@ public String getLoadId() { @Override public String getDanglingLineId(Network network) { - Set danglingLines = network.getDanglingLineStream() - .filter(dl -> dl.getUcteXnodeCode().equals(mRID)) - .map(Identifiable::getId) - .collect(Collectors.toSet()); - if (danglingLines.size() != 1) { - // No or multiple dangling lines found for Xnode - return null; - } - return danglingLines.iterator().next(); + return Util.findDanglingLineIdForXndoe(network, mRID); } Optional getInitialFactor() { diff --git a/glsk/glsk-document-ucte/src/main/java/com/powsybl/glsk/ucte/UcteGlskRegisteredResource.java b/glsk/glsk-document-ucte/src/main/java/com/powsybl/glsk/ucte/UcteGlskRegisteredResource.java index 9e700231..adb62ce3 100644 --- a/glsk/glsk-document-ucte/src/main/java/com/powsybl/glsk/ucte/UcteGlskRegisteredResource.java +++ b/glsk/glsk-document-ucte/src/main/java/com/powsybl/glsk/ucte/UcteGlskRegisteredResource.java @@ -8,13 +8,11 @@ package com.powsybl.glsk.ucte; import com.powsybl.glsk.api.AbstractGlskRegisteredResource; -import com.powsybl.iidm.network.Identifiable; +import com.powsybl.glsk.api.util.Util; import com.powsybl.iidm.network.Network; import org.w3c.dom.Element; import java.util.Objects; -import java.util.Set; -import java.util.stream.Collectors; /** * @author Joris Mancini {@literal } @@ -46,14 +44,6 @@ public String getLoadId() { @Override public String getDanglingLineId(Network network) { - Set danglingLines = network.getDanglingLineStream() - .filter(dl -> dl.getUcteXnodeCode().equals(mRID)) - .map(Identifiable::getId) - .collect(Collectors.toSet()); - if (danglingLines.size() != 1) { - // No or multiple dangling lines found for Xnode - return null; - } - return danglingLines.iterator().next(); + return Util.findDanglingLineIdForXndoe(network, mRID); } } From 44faa025f27fb4b06be72afbe09c3b3789813c2c Mon Sep 17 00:00:00 2001 From: Peter Mitri Date: Tue, 18 Apr 2023 16:53:41 +0200 Subject: [PATCH 04/10] small correction Signed-off-by: Peter Mitri --- .../api/util/converters/GlskPointLinearGlskConverter.java | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/glsk/glsk-document-api/src/main/java/com/powsybl/glsk/api/util/converters/GlskPointLinearGlskConverter.java b/glsk/glsk-document-api/src/main/java/com/powsybl/glsk/api/util/converters/GlskPointLinearGlskConverter.java index f15ffd00..135d3a2e 100644 --- a/glsk/glsk-document-api/src/main/java/com/powsybl/glsk/api/util/converters/GlskPointLinearGlskConverter.java +++ b/glsk/glsk-document-api/src/main/java/com/powsybl/glsk/api/util/converters/GlskPointLinearGlskConverter.java @@ -186,9 +186,7 @@ private static void convertParticipationFactor(Network network, GlskShiftKey gls } else if (glskShiftKey.getPsrType().equals("A05")) { //Load A05 List loadResources = glskShiftKey.getRegisteredResourceArrayList().stream() - .filter(loadResource -> - loadResource.getmRID().contains("XLI_OB1") || - NetworkUtil.isCorrect(network.getLoad(loadResource.getLoadId()))) + .filter(loadResource -> NetworkUtil.isCorrect(network.getLoad(loadResource.getLoadId()))) .collect(Collectors.toList()); totalFactor += loadResources.stream().mapToDouble(GlskRegisteredResource::getParticipationFactor).sum(); if (totalFactor < 1e-10) { From 3bed6104b2a3e156f86a4aa3bc4f5210e881058c Mon Sep 17 00:00:00 2001 From: Peter Mitri Date: Tue, 18 Apr 2023 17:23:28 +0200 Subject: [PATCH 05/10] update unit tests Signed-off-by: Peter Mitri --- .../ucte/UcteGlskDocumentImporterTest.java | 6 +- .../20160729_0000_GSK_allday_full.xml | 5862 ++++++++--------- .../20160729_0000_GSK_allday_test.xml | 14 +- .../20160729_0000_GSK_allday_wrong.xml | 5862 ++++++++--------- 4 files changed, 5871 insertions(+), 5873 deletions(-) diff --git a/glsk/glsk-document-ucte/src/test/java/com/powsybl/glsk/ucte/UcteGlskDocumentImporterTest.java b/glsk/glsk-document-ucte/src/test/java/com/powsybl/glsk/ucte/UcteGlskDocumentImporterTest.java index c9853dcb..6c4e0bda 100644 --- a/glsk/glsk-document-ucte/src/test/java/com/powsybl/glsk/ucte/UcteGlskDocumentImporterTest.java +++ b/glsk/glsk-document-ucte/src/test/java/com/powsybl/glsk/ucte/UcteGlskDocumentImporterTest.java @@ -67,9 +67,7 @@ void testUcteGlskDocumentImporterFull() { //test factor LSK + GSK = 1 for (int i = 0; i < ucteGlskDocument.getListGlskSeries().size(); i++) { for (int j = 0; j < ucteGlskDocument.getListGlskSeries().get(i).getUcteGlskBlocks().size(); j++) { - assertEquals(1.0, - ucteGlskDocument.getListGlskSeries().get(i).getUcteGlskBlocks().get(j).getGlskShiftKeys().stream().mapToDouble(GlskShiftKey::getQuantity).sum(), - 1e-5); + assertEquals(1.0, ucteGlskDocument.getListGlskSeries().get(i).getUcteGlskBlocks().get(j).getGlskShiftKeys().stream().mapToDouble(GlskShiftKey::getQuantity).sum(), 1e-5); } } @@ -113,7 +111,7 @@ void testGetGlskPointForInstant() { double factor = result.get("10YNL----------L").getGlskShiftKeys().get(0) .getRegisteredResourceArrayList() .stream() - .filter(glskRegisteredResource -> glskRegisteredResource.getmRID().equals("N_EC-42 ")) + .filter(glskRegisteredResource -> glskRegisteredResource.getmRID().equals("IOJDAEQD")) .mapToDouble(GlskRegisteredResource::getParticipationFactor) .findFirst() .orElseThrow(() -> new RuntimeException("Not good")); diff --git a/glsk/glsk-document-ucte/src/test/resources/20160729_0000_GSK_allday_full.xml b/glsk/glsk-document-ucte/src/test/resources/20160729_0000_GSK_allday_full.xml index f6ab49d9..8fbbf142 100644 --- a/glsk/glsk-document-ucte/src/test/resources/20160729_0000_GSK_allday_full.xml +++ b/glsk/glsk-document-ucte/src/test/resources/20160729_0000_GSK_allday_full.xml @@ -19,107 +19,107 @@ - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + @@ -132,91 +132,91 @@ - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + @@ -228,718 +228,718 @@ - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + @@ -951,171 +951,171 @@ - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + @@ -1123,171 +1123,171 @@ - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + @@ -1295,171 +1295,171 @@ - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + @@ -1467,171 +1467,171 @@ - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + @@ -1639,171 +1639,171 @@ - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + @@ -1811,171 +1811,171 @@ - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + @@ -1983,171 +1983,171 @@ - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + @@ -2155,171 +2155,171 @@ - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + @@ -2327,171 +2327,171 @@ - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + @@ -2499,171 +2499,171 @@ - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + @@ -2671,171 +2671,171 @@ - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + @@ -2843,171 +2843,171 @@ - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + @@ -3015,171 +3015,171 @@ - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + @@ -3187,171 +3187,171 @@ - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + @@ -3359,171 +3359,171 @@ - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + @@ -3531,171 +3531,171 @@ - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + @@ -3703,171 +3703,171 @@ - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + @@ -3875,171 +3875,171 @@ - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + @@ -4047,171 +4047,171 @@ - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + @@ -4219,171 +4219,171 @@ - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + @@ -4391,171 +4391,171 @@ - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + @@ -4563,171 +4563,171 @@ - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + @@ -4735,171 +4735,171 @@ - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + @@ -4907,167 +4907,167 @@ - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + @@ -5080,91 +5080,91 @@ - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + @@ -5172,91 +5172,91 @@ - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + @@ -5264,91 +5264,91 @@ - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + @@ -5361,2168 +5361,2168 @@ - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + @@ -7543,159 +7543,159 @@ - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + @@ -7707,507 +7707,507 @@ - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + @@ -8219,1307 +8219,1307 @@ - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + @@ -9531,67 +9531,67 @@ - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + @@ -9603,13 +9603,13 @@ - + - + - + @@ -9621,31 +9621,31 @@ - + - + - + - + - + - + - + - + - + @@ -9657,10 +9657,10 @@ - + - + @@ -9672,73 +9672,73 @@ - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + @@ -9750,235 +9750,235 @@ - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + @@ -9986,259 +9986,259 @@ - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + @@ -10246,235 +10246,235 @@ - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + diff --git a/glsk/glsk-document-ucte/src/test/resources/20160729_0000_GSK_allday_test.xml b/glsk/glsk-document-ucte/src/test/resources/20160729_0000_GSK_allday_test.xml index 3eb9d34c..c3f23300 100644 --- a/glsk/glsk-document-ucte/src/test/resources/20160729_0000_GSK_allday_test.xml +++ b/glsk/glsk-document-ucte/src/test/resources/20160729_0000_GSK_allday_test.xml @@ -19,13 +19,13 @@ - + - + - + @@ -37,16 +37,16 @@ - + - + - + - + diff --git a/glsk/glsk-document-ucte/src/test/resources/20160729_0000_GSK_allday_wrong.xml b/glsk/glsk-document-ucte/src/test/resources/20160729_0000_GSK_allday_wrong.xml index 38bd0b8c..edfec634 100644 --- a/glsk/glsk-document-ucte/src/test/resources/20160729_0000_GSK_allday_wrong.xml +++ b/glsk/glsk-document-ucte/src/test/resources/20160729_0000_GSK_allday_wrong.xml @@ -19,107 +19,107 @@ - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + @@ -132,91 +132,91 @@ - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + @@ -228,718 +228,718 @@ - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + @@ -951,171 +951,171 @@ - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + @@ -1123,171 +1123,171 @@ - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + @@ -1295,171 +1295,171 @@ - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + @@ -1467,171 +1467,171 @@ - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + @@ -1639,171 +1639,171 @@ - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + @@ -1811,171 +1811,171 @@ - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + @@ -1983,171 +1983,171 @@ - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + @@ -2155,171 +2155,171 @@ - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + @@ -2327,171 +2327,171 @@ - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + @@ -2499,171 +2499,171 @@ - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + @@ -2671,171 +2671,171 @@ - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + @@ -2843,171 +2843,171 @@ - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + @@ -3015,171 +3015,171 @@ - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + @@ -3187,171 +3187,171 @@ - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + @@ -3359,171 +3359,171 @@ - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + @@ -3531,171 +3531,171 @@ - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + @@ -3703,171 +3703,171 @@ - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + @@ -3875,171 +3875,171 @@ - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + @@ -4047,171 +4047,171 @@ - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + @@ -4219,171 +4219,171 @@ - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + @@ -4391,171 +4391,171 @@ - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + @@ -4563,171 +4563,171 @@ - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + @@ -4735,171 +4735,171 @@ - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + @@ -4907,167 +4907,167 @@ - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + @@ -5080,91 +5080,91 @@ - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + @@ -5172,91 +5172,91 @@ - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + @@ -5264,91 +5264,91 @@ - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + @@ -5361,2168 +5361,2168 @@ - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + @@ -7543,159 +7543,159 @@ - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + @@ -7707,507 +7707,507 @@ - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + @@ -8219,1307 +8219,1307 @@ - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + @@ -9531,67 +9531,67 @@ - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + @@ -9603,13 +9603,13 @@ - + - + - + @@ -9621,31 +9621,31 @@ - + - + - + - + - + - + - + - + - + @@ -9657,10 +9657,10 @@ - + - + @@ -9672,73 +9672,73 @@ - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + @@ -9750,235 +9750,235 @@ - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + @@ -9986,259 +9986,259 @@ - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + @@ -10246,235 +10246,235 @@ - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + From 4d1a57bb9b7ab87c0cd4a7f0de5f362f6286bd1f Mon Sep 17 00:00:00 2001 From: Peter Mitri Date: Tue, 18 Apr 2023 17:29:02 +0200 Subject: [PATCH 06/10] small correction Signed-off-by: Peter Mitri --- .../glsk/api/util/converters/GlskPointScalableConverter.java | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/glsk/glsk-document-api/src/main/java/com/powsybl/glsk/api/util/converters/GlskPointScalableConverter.java b/glsk/glsk-document-api/src/main/java/com/powsybl/glsk/api/util/converters/GlskPointScalableConverter.java index 0376c4b3..3ff24a2d 100644 --- a/glsk/glsk-document-api/src/main/java/com/powsybl/glsk/api/util/converters/GlskPointScalableConverter.java +++ b/glsk/glsk-document-api/src/main/java/com/powsybl/glsk/api/util/converters/GlskPointScalableConverter.java @@ -225,9 +225,9 @@ private static void convertExplicitProportional(Network network, GlskShiftKey gl .collect(Collectors.toList()); totalP += loads.stream().mapToDouble(NetworkUtil::pseudoP0).sum(); - double finalTotalP1 = totalP; + double finalTotalP = totalP; loads.forEach(load -> { - float loadPercentage = (float) (100 * glskShiftKey.getQuantity().floatValue() * NetworkUtil.pseudoP0(load) / finalTotalP1); + float loadPercentage = (float) (100 * glskShiftKey.getQuantity().floatValue() * NetworkUtil.pseudoP0(load) / finalTotalP); // For now glsk shift key maximum shift is not handled for loads by lack of specification percentages.add(loadPercentage); scalables.add(Scalable.onLoad(load.getId(), -Double.MAX_VALUE, Double.MAX_VALUE)); From 69c582ef1567d7b0ab264265b9d886a5c9d1a585 Mon Sep 17 00:00:00 2001 From: Peter Mitri Date: Fri, 22 Sep 2023 17:29:12 +0200 Subject: [PATCH 07/10] review Signed-off-by: Peter Mitri --- .../GlskPointLinearGlskConverter.java | 42 +++++++++++-------- glsk/glsk-document-cim/pom.xml | 5 --- glsk/glsk-document-cse/pom.xml | 5 --- .../glsk/cse/CseGlskDocumentImporterTest.java | 8 ++-- glsk/glsk-document-ucte/pom.xml | 5 --- pom.xml | 4 +- 6 files changed, 30 insertions(+), 39 deletions(-) diff --git a/glsk/glsk-document-api/src/main/java/com/powsybl/glsk/api/util/converters/GlskPointLinearGlskConverter.java b/glsk/glsk-document-api/src/main/java/com/powsybl/glsk/api/util/converters/GlskPointLinearGlskConverter.java index 135d3a2e..cc1ccc5e 100644 --- a/glsk/glsk-document-api/src/main/java/com/powsybl/glsk/api/util/converters/GlskPointLinearGlskConverter.java +++ b/glsk/glsk-document-api/src/main/java/com/powsybl/glsk/api/util/converters/GlskPointLinearGlskConverter.java @@ -136,9 +136,10 @@ private static void convertExplicitProportional(Network network, GlskShiftKey gl .filter(NetworkUtil::isCorrect) .collect(Collectors.toList()); totalP += generators.stream().mapToDouble(NetworkUtil::pseudoTargetP).sum(); - double finalTotalP = totalP; - generators.forEach(generator -> weightedSensitivityVariables.add(new WeightedSensitivityVariable(generator.getId(), - glskShiftKey.getQuantity().floatValue() * (float) NetworkUtil.pseudoTargetP(generator) / (float) finalTotalP))); + for (Generator generator : generators) { + weightedSensitivityVariables.add(new WeightedSensitivityVariable(generator.getId(), + glskShiftKey.getQuantity().floatValue() * (float) NetworkUtil.pseudoTargetP(generator) / (float) totalP)); + } } else if (glskShiftKey.getPsrType().equals("A05")) { //Load A05 List loads = glskShiftKey.getRegisteredResourceArrayList().stream() @@ -147,16 +148,18 @@ private static void convertExplicitProportional(Network network, GlskShiftKey gl .filter(NetworkUtil::isCorrect) .collect(Collectors.toList()); totalP += loads.stream().mapToDouble(NetworkUtil::pseudoP0).sum(); - double finalTotalP = totalP; - loads.forEach(load -> weightedSensitivityVariables.add(new WeightedSensitivityVariable(load.getId(), - glskShiftKey.getQuantity().floatValue() * (float) NetworkUtil.pseudoP0(load) / (float) finalTotalP))); + for (Load load : loads) { + weightedSensitivityVariables.add(new WeightedSensitivityVariable(load.getId(), + glskShiftKey.getQuantity().floatValue() * (float) NetworkUtil.pseudoP0(load) / (float) totalP)); + } } else { //unknown PsrType throw new GlskException("convertExplicitProportional PsrType not supported"); } - double finalTotalP = totalP; - danglingLines.forEach(danglingLine -> weightedSensitivityVariables.add(new WeightedSensitivityVariable(danglingLine.getId(), - glskShiftKey.getQuantity().floatValue() * (float) NetworkUtil.pseudoP0(danglingLine) / (float) finalTotalP))); + for (DanglingLine danglingLine : danglingLines) { + weightedSensitivityVariables.add(new WeightedSensitivityVariable(danglingLine.getId(), + glskShiftKey.getQuantity().floatValue() * (float) NetworkUtil.pseudoP0(danglingLine) / (float) totalP)); + } } /** @@ -180,9 +183,10 @@ private static void convertParticipationFactor(Network network, GlskShiftKey gls if (totalFactor < 1e-10) { throw new GlskException("total factor is zero"); } - double finalTotalFactor2 = totalFactor; - generatorResources.forEach(generatorResource -> weightedSensitivityVariables.add(new WeightedSensitivityVariable(generatorResource.getGeneratorId(), - glskShiftKey.getQuantity().floatValue() * (float) generatorResource.getParticipationFactor() / (float) finalTotalFactor2))); + for (GlskRegisteredResource generatorResource : generatorResources) { + weightedSensitivityVariables.add(new WeightedSensitivityVariable(generatorResource.getGeneratorId(), + glskShiftKey.getQuantity().floatValue() * (float) generatorResource.getParticipationFactor() / (float) totalFactor)); + } } else if (glskShiftKey.getPsrType().equals("A05")) { //Load A05 List loadResources = glskShiftKey.getRegisteredResourceArrayList().stream() @@ -192,15 +196,17 @@ private static void convertParticipationFactor(Network network, GlskShiftKey gls if (totalFactor < 1e-10) { throw new GlskException("total factor is zero"); } - double finalTotalFactor = totalFactor; - loadResources.forEach(loadResource -> weightedSensitivityVariables.add(new WeightedSensitivityVariable(loadResource.getLoadId(), - glskShiftKey.getQuantity().floatValue() * (float) loadResource.getParticipationFactor() / (float) finalTotalFactor))); + for (GlskRegisteredResource loadResource : loadResources) { + weightedSensitivityVariables.add(new WeightedSensitivityVariable(loadResource.getLoadId(), + glskShiftKey.getQuantity().floatValue() * (float) loadResource.getParticipationFactor() / (float) totalFactor)); + } } else { //unknown PsrType throw new GlskException("convertParticipationFactor PsrType not supported"); } - double finalTotalFactor = totalFactor; - danglingLineResources.forEach(danglingLineResource -> weightedSensitivityVariables.add(new WeightedSensitivityVariable(danglingLineResource.getDanglingLineId(network), - glskShiftKey.getQuantity().floatValue() * (float) danglingLineResource.getParticipationFactor() / (float) finalTotalFactor))); + for (GlskRegisteredResource danglingLineResource : danglingLineResources) { + weightedSensitivityVariables.add(new WeightedSensitivityVariable(danglingLineResource.getDanglingLineId(network), + glskShiftKey.getQuantity().floatValue() * (float) danglingLineResource.getParticipationFactor() / (float) totalFactor)); + } } } diff --git a/glsk/glsk-document-cim/pom.xml b/glsk/glsk-document-cim/pom.xml index 5a8896d5..b5ad44fd 100644 --- a/glsk/glsk-document-cim/pom.xml +++ b/glsk/glsk-document-cim/pom.xml @@ -28,11 +28,6 @@ powsybl-config-test test - - com.powsybl - powsybl-entsoe-util - test - com.powsybl powsybl-iidm-impl diff --git a/glsk/glsk-document-cse/pom.xml b/glsk/glsk-document-cse/pom.xml index c6369edb..070dfab9 100644 --- a/glsk/glsk-document-cse/pom.xml +++ b/glsk/glsk-document-cse/pom.xml @@ -54,11 +54,6 @@ powsybl-config-test test - - com.powsybl - powsybl-entsoe-util - test - com.powsybl powsybl-iidm-xml-converter diff --git a/glsk/glsk-document-cse/src/test/java/com/powsybl/glsk/cse/CseGlskDocumentImporterTest.java b/glsk/glsk-document-cse/src/test/java/com/powsybl/glsk/cse/CseGlskDocumentImporterTest.java index 502bd014..4890f0e8 100644 --- a/glsk/glsk-document-cse/src/test/java/com/powsybl/glsk/cse/CseGlskDocumentImporterTest.java +++ b/glsk/glsk-document-cse/src/test/java/com/powsybl/glsk/cse/CseGlskDocumentImporterTest.java @@ -445,7 +445,7 @@ void checkCseGlskDocumentImporterCorrectlyImportMergedGlsk() { @Test void checkCseGlskDocumentImporterCorrectlyImportManualGskBlocksWithDanglingLines() { - CseGlskDocument cseGlskDocument = CseGlskDocument.importGlsk(getClass().getResourceAsStream("/testGlskWithDanglingLines.xml"), false); + CseGlskDocument cseGlskDocument = CseGlskDocument.importGlsk(getClass().getResourceAsStream("/testGlskWithDanglingLines.xml"), false, false); List list = cseGlskDocument.getGlskPoints("FR_MANUAL"); assertEquals(1, list.size()); assertEquals(1, list.get(0).getGlskShiftKeys().size()); @@ -469,7 +469,7 @@ void checkCseGlskDocumentImporterCorrectlyConvertManualGskBlocksWithDanglingLine @Test void checkCseGlskDocumentImporterCorrectlyImportPropGskBlocksWithDanglingLines() { - CseGlskDocument cseGlskDocument = CseGlskDocument.importGlsk(getClass().getResourceAsStream("/testGlskWithDanglingLines.xml"), false); + CseGlskDocument cseGlskDocument = CseGlskDocument.importGlsk(getClass().getResourceAsStream("/testGlskWithDanglingLines.xml"), false, false); List list = cseGlskDocument.getGlskPoints("FR_PROPGSK"); assertEquals(1, list.size()); assertEquals(1, list.get(0).getGlskShiftKeys().size()); @@ -495,7 +495,7 @@ void checkCseGlskDocumentImporterCorrectlyConvertPropGskBlocksWithDanglingLines( @Test void checkCseGlskDocumentImporterCorrectlyImportPropGlskBlocksWithDanglingLines() { - CseGlskDocument cseGlskDocument = CseGlskDocument.importGlsk(getClass().getResourceAsStream("/testGlskWithDanglingLines.xml"), false); + CseGlskDocument cseGlskDocument = CseGlskDocument.importGlsk(getClass().getResourceAsStream("/testGlskWithDanglingLines.xml"), false, false); List list = cseGlskDocument.getGlskPoints("FR_PROPGLSK"); assertEquals(1, list.size()); assertEquals(2, list.get(0).getGlskShiftKeys().size()); @@ -526,7 +526,7 @@ void checkCseGlskDocumentImporterCorrectlyConvertPropGlskBlocksWithDanglingLines @Test void checkCseGlskDocumentImporterCorrectlyImportMeritOrderGskBlocksWithDanglingLines() { - CseGlskDocument cseGlskDocument = CseGlskDocument.importGlsk(getClass().getResourceAsStream("/testGlskWithDanglingLines.xml"), false); + CseGlskDocument cseGlskDocument = CseGlskDocument.importGlsk(getClass().getResourceAsStream("/testGlskWithDanglingLines.xml"), false, false); List list = cseGlskDocument.getGlskPoints("FR_MERITORDER"); assertEquals(1, list.size()); assertEquals(7, list.get(0).getGlskShiftKeys().size()); diff --git a/glsk/glsk-document-ucte/pom.xml b/glsk/glsk-document-ucte/pom.xml index dbb4cd5a..d1b21b8c 100644 --- a/glsk/glsk-document-ucte/pom.xml +++ b/glsk/glsk-document-ucte/pom.xml @@ -28,11 +28,6 @@ powsybl-config-test test - - com.powsybl - powsybl-entsoe-util - test - com.powsybl powsybl-iidm-impl diff --git a/pom.xml b/pom.xml index e47316ad..4cfc4035 100644 --- a/pom.xml +++ b/pom.xml @@ -15,7 +15,7 @@ com.powsybl powsybl-parent - 13 + 9 @@ -57,7 +57,7 @@ - 17 + 11 5.3.2 1.2.3 From b3ad98e69782eaae51bbf07165b14b0e9be0c931 Mon Sep 17 00:00:00 2001 From: Peter Mitri Date: Fri, 22 Sep 2023 17:36:23 +0200 Subject: [PATCH 08/10] review Signed-off-by: Peter Mitri --- .../GlskPointScalableConverter.java | 42 ++++++++----------- 1 file changed, 18 insertions(+), 24 deletions(-) diff --git a/glsk/glsk-document-api/src/main/java/com/powsybl/glsk/api/util/converters/GlskPointScalableConverter.java b/glsk/glsk-document-api/src/main/java/com/powsybl/glsk/api/util/converters/GlskPointScalableConverter.java index 3ff24a2d..965674a1 100644 --- a/glsk/glsk-document-api/src/main/java/com/powsybl/glsk/api/util/converters/GlskPointScalableConverter.java +++ b/glsk/glsk-document-api/src/main/java/com/powsybl/glsk/api/util/converters/GlskPointScalableConverter.java @@ -206,16 +206,15 @@ private static void convertExplicitProportional(Network network, GlskShiftKey gl .collect(Collectors.toList()); totalP += generators.stream().mapToDouble(NetworkUtil::pseudoTargetP).sum(); - double finalTotalP = totalP; - generators.forEach(generator -> { + for (Generator generator : generators) { // Calculate factor of each generator - float factor = (float) (glskShiftKey.getQuantity().floatValue() * NetworkUtil.pseudoTargetP(generator) / finalTotalP); + float factor = (float) (glskShiftKey.getQuantity().floatValue() * NetworkUtil.pseudoTargetP(generator) / totalP); percentages.add(100 * factor); // In case of global shift key limitation we will limit the generator proportionally to // its participation in the global proportional scalable double maxGeneratorValue = NetworkUtil.pseudoTargetP(generator) + factor * glskShiftKey.getMaximumShift(); scalables.add(Scalable.onGenerator(generator.getId(), -Double.MAX_VALUE, maxGeneratorValue)); - }); + } } else if (glskShiftKey.getPsrType().equals("A05")) { LOGGER.debug("GLSK Type B42, not empty registered resources list --> (explicit/manual) proportional LSK"); List loads = glskShiftKey.getRegisteredResourceArrayList().stream() @@ -225,21 +224,19 @@ private static void convertExplicitProportional(Network network, GlskShiftKey gl .collect(Collectors.toList()); totalP += loads.stream().mapToDouble(NetworkUtil::pseudoP0).sum(); - double finalTotalP = totalP; - loads.forEach(load -> { - float loadPercentage = (float) (100 * glskShiftKey.getQuantity().floatValue() * NetworkUtil.pseudoP0(load) / finalTotalP); + for (Load load : loads) { + float loadPercentage = (float) (100 * glskShiftKey.getQuantity().floatValue() * NetworkUtil.pseudoP0(load) / totalP); // For now glsk shift key maximum shift is not handled for loads by lack of specification percentages.add(loadPercentage); scalables.add(Scalable.onLoad(load.getId(), -Double.MAX_VALUE, Double.MAX_VALUE)); - }); + } } - double finalTotalP = totalP; - danglingLines.forEach(danglingLine -> { - float danglingLinePercentage = (float) (100 * glskShiftKey.getQuantity().floatValue() * NetworkUtil.pseudoP0(danglingLine) / finalTotalP); + for (DanglingLine danglingLine : danglingLines) { + float danglingLinePercentage = (float) (100 * glskShiftKey.getQuantity().floatValue() * NetworkUtil.pseudoP0(danglingLine) / totalP); // For now glsk shift key maximum shift is not handled for dangling lines by lack of specification percentages.add(danglingLinePercentage); scalables.add(Scalable.onDanglingLine(danglingLine.getId(), -Double.MAX_VALUE, Double.MAX_VALUE)); - }); + } } /** @@ -265,12 +262,11 @@ private static void convertParticipationFactor(Network network, GlskShiftKey gls totalFactor += generatorResources.stream().mapToDouble(GlskRegisteredResource::getParticipationFactor).sum(); - double finalTotalFactor = totalFactor; - generatorResources.forEach(generatorResource -> { - float generatorPercentage = (float) (100 * glskShiftKey.getQuantity().floatValue() * generatorResource.getParticipationFactor() / finalTotalFactor); + for (GlskRegisteredResource generatorResource : generatorResources) { + float generatorPercentage = (float) (100 * glskShiftKey.getQuantity().floatValue() * generatorResource.getParticipationFactor() / totalFactor); percentages.add(generatorPercentage); scalables.add(getGeneratorScalableWithLimits(network, generatorResource)); - }); + } } else if (glskShiftKey.getPsrType().equals("A05")) { LOGGER.debug("GLSK Type B43 LSK"); List loadResources = glskShiftKey.getRegisteredResourceArrayList().stream() @@ -279,19 +275,17 @@ private static void convertParticipationFactor(Network network, GlskShiftKey gls totalFactor += loadResources.stream().mapToDouble(GlskRegisteredResource::getParticipationFactor).sum(); - double finalTotalFactor = totalFactor; - loadResources.forEach(loadResource -> { - float loadPercentage = (float) (100 * glskShiftKey.getQuantity().floatValue() * loadResource.getParticipationFactor() / finalTotalFactor); + for (GlskRegisteredResource loadResource : loadResources) { + float loadPercentage = (float) (100 * glskShiftKey.getQuantity().floatValue() * loadResource.getParticipationFactor() / totalFactor); percentages.add(loadPercentage); scalables.add(getLoadScalableWithLimits(network, loadResource)); - }); + } } - double finalTotalFactor = totalFactor; - danglingLineResources.forEach(danglingLineResource -> { - float loadPercentage = (float) (100 * glskShiftKey.getQuantity().floatValue() * danglingLineResource.getParticipationFactor() / finalTotalFactor); + for (GlskRegisteredResource danglingLineResource : danglingLineResources) { + float loadPercentage = (float) (100 * glskShiftKey.getQuantity().floatValue() * danglingLineResource.getParticipationFactor() / totalFactor); percentages.add(loadPercentage); scalables.add(getDanglingLineScalableWithLimits(network, danglingLineResource)); - }); + } } private static Country getSubstationNullableCountry(Optional substation) { From c88c835783c1cd125b27edbe9f56009012e3175e Mon Sep 17 00:00:00 2001 From: Peter Mitri Date: Fri, 22 Sep 2023 17:40:31 +0200 Subject: [PATCH 09/10] remove todo Signed-off-by: Peter Mitri --- .../api/util/converters/GlskPointLinearGlskConverterTest.java | 1 - 1 file changed, 1 deletion(-) diff --git a/glsk/glsk-document-cim/src/test/java/com/powsybl/glsk/api/util/converters/GlskPointLinearGlskConverterTest.java b/glsk/glsk-document-cim/src/test/java/com/powsybl/glsk/api/util/converters/GlskPointLinearGlskConverterTest.java index 02b99b3c..b7654a8d 100644 --- a/glsk/glsk-document-cim/src/test/java/com/powsybl/glsk/api/util/converters/GlskPointLinearGlskConverterTest.java +++ b/glsk/glsk-document-cim/src/test/java/com/powsybl/glsk/api/util/converters/GlskPointLinearGlskConverterTest.java @@ -29,7 +29,6 @@ * @author Peter Mitri {@literal } */ class GlskPointLinearGlskConverterTest { - // TODO : detail existing tests private static final Logger LOGGER = LoggerFactory.getLogger(GlskPointLinearGlskConverterTest.class); private static final double DOUBLE_TOLERANCE = 1e-4; From 9041b2168ffde53349352b1640d0ceec124a0703 Mon Sep 17 00:00:00 2001 From: Peter Mitri Date: Fri, 22 Sep 2023 17:42:18 +0200 Subject: [PATCH 10/10] revert unnecessary changes Signed-off-by: Peter Mitri --- pom.xml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/pom.xml b/pom.xml index 4cfc4035..e47316ad 100644 --- a/pom.xml +++ b/pom.xml @@ -15,7 +15,7 @@ com.powsybl powsybl-parent - 9 + 13 @@ -57,7 +57,7 @@ - 11 + 17 5.3.2 1.2.3