Skip to content

Commit

Permalink
Merge branch 'main' into emf_subnetworks
Browse files Browse the repository at this point in the history
  • Loading branch information
annetill authored Sep 28, 2023
2 parents bfc1b87 + c74e1a2 commit fdaedb7
Show file tree
Hide file tree
Showing 4 changed files with 165 additions and 10 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@
*/
public final class CseGlskDocument implements GlskDocument {
private static final Logger LOGGER = LoggerFactory.getLogger(CseGlskDocument.class);
private static final String LINEAR_GLSK_NOT_HANDLED = "CSE GLSK document does not handle Linear GLSK conversion";
private static final String DATA_CHRONOLOGY_NOT_HANDLED = "CSE GLSK document only supports hourly data";
private static final String COUNTRIES_IN_AREA_KEY = "countriesInArea";
private static final String COUNTRIES_OUT_AREA_KEY = "countriesOutArea";

Expand Down Expand Up @@ -170,19 +170,14 @@ public List<GlskPoint> getGlskPoints(String zone) {
return cseGlskPoints.getOrDefault(zone, Collections.emptyList());
}

@Override
public ZonalData<SensitivityVariableSet> getZonalGlsks(Network network) {
throw new NotImplementedException(LINEAR_GLSK_NOT_HANDLED);
}

@Override
public ZonalData<SensitivityVariableSet> getZonalGlsks(Network network, Instant instant) {
throw new NotImplementedException(LINEAR_GLSK_NOT_HANDLED);
throw new NotImplementedException(DATA_CHRONOLOGY_NOT_HANDLED);
}

@Override
public ZonalDataChronology<SensitivityVariableSet> getZonalGlsksChronology(Network network) {
throw new NotImplementedException(LINEAR_GLSK_NOT_HANDLED);
throw new NotImplementedException(DATA_CHRONOLOGY_NOT_HANDLED);
}

@Override
Expand Down Expand Up @@ -214,11 +209,11 @@ private boolean isHybridCseGlskPoint(GlskPoint zonalGlskPoint) {

@Override
public ZonalData<Scalable> getZonalScalable(Network network, Instant instant) {
throw new NotImplementedException("CSE GLSK document does only support hourly data");
throw new NotImplementedException(DATA_CHRONOLOGY_NOT_HANDLED);
}

@Override
public ZonalDataChronology<Scalable> getZonalScalableChronology(Network network) {
throw new NotImplementedException("CSE GLSK document does only support hourly data");
throw new NotImplementedException(DATA_CHRONOLOGY_NOT_HANDLED);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,11 @@
import com.powsybl.glsk.commons.ZonalData;
import com.powsybl.iidm.modification.scalable.Scalable;
import com.powsybl.iidm.network.Network;
import org.apache.commons.lang3.NotImplementedException;
import org.junit.jupiter.api.Test;

import java.io.InputStream;
import java.time.Instant;
import java.util.List;

import static org.junit.jupiter.api.Assertions.*;
Expand Down Expand Up @@ -705,4 +707,15 @@ void checkNewMethodsExist() {
glskDocument = GlskDocumentImporters.importAndValidateGlsk(getClass().getResourceAsStream("/testGlskMerged.xml"));
assertNotNull(glskDocument);
}

@Test
void checkExceptionWhenCallingNotImplementedFeatures() {
Network network = Network.read("testCase.xiidm", getClass().getResourceAsStream("/testCase.xiidm"));
GlskDocument glskDocument = GlskDocumentImporters.importGlsk(getClass().getResourceAsStream("/testGlsk.xml"));
assertThrows(NotImplementedException.class, () -> glskDocument.getZonalScalableChronology(network));
assertThrows(NotImplementedException.class, () -> glskDocument.getZonalGlsksChronology(network));
Instant testInstant = Instant.now();
assertThrows(NotImplementedException.class, () -> glskDocument.getZonalScalable(network, testInstant));
assertThrows(NotImplementedException.class, () -> glskDocument.getZonalGlsks(network, testInstant));
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,68 @@
/*
* Copyright (c) 2023, RTE (http://www.rte-france.com)
* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/.
* SPDX-License-Identifier: MPL-2.0
*/
package com.powsybl.glsk.cse;

import com.powsybl.glsk.api.GlskDocument;
import com.powsybl.glsk.api.io.GlskDocumentImporters;
import com.powsybl.glsk.commons.GlskException;
import com.powsybl.iidm.network.Network;
import com.powsybl.sensitivity.SensitivityVariableSet;
import org.junit.jupiter.api.Test;

import static org.junit.jupiter.api.Assertions.*;

/**
* @author Sebastien Murgey {@literal <sebastien.murgey at rte-france.com>}
*/
class ZonalGlsksTest {
private static final double EPSILON = 1e-3;

@Test
void checkZonalGlskFromManualGskBlocks() {
Network network = Network.read("testCase.xiidm", getClass().getResourceAsStream("/testCase.xiidm"));
CseGlskDocument cseGlskDocument = CseGlskDocument.importGlsk(getClass().getResourceAsStream("/testGlskOnlyLinear.xml"), false, true);
SensitivityVariableSet manualGlskSensi = cseGlskDocument.getZonalGlsks(network).getData("FR_MANUAL");

assertNotNull(manualGlskSensi);
assertEquals(0.7, manualGlskSensi.getVariable("FFR1AA1 _generator").getWeight(), EPSILON);
assertEquals(0.3, manualGlskSensi.getVariable("FFR3AA1 _generator").getWeight(), EPSILON);
}

@Test
void checkZonalGlskFromProportionalGskBlocks() {
Network network = Network.read("testCase.xiidm", getClass().getResourceAsStream("/testCase.xiidm"));
GlskDocument cseGlskDocument = GlskDocumentImporters.importGlsk(getClass().getResourceAsStream("/testGlskOnlyLinear.xml"));
SensitivityVariableSet glskSensi = cseGlskDocument.getZonalGlsks(network).getData("FR_PROPGSK");

assertNotNull(glskSensi);
assertEquals(0.286, glskSensi.getVariable("FFR1AA1 _generator").getWeight(), EPSILON);
assertEquals(0.286, glskSensi.getVariable("FFR2AA1 _generator").getWeight(), EPSILON);
assertEquals(0.428, glskSensi.getVariable("FFR3AA1 _generator").getWeight(), EPSILON);
}

@Test
void checkZonalGlskFromProportionalGlskBlocks() {
Network network = Network.read("testCase.xiidm", getClass().getResourceAsStream("/testCase.xiidm"));
CseGlskDocument cseGlskDocument = CseGlskDocument.importGlsk(getClass().getResourceAsStream("/testGlskOnlyLinear.xml"), false, true);
SensitivityVariableSet glskSensi = cseGlskDocument.getZonalGlsks(network).getData("FR_PROPGLSK");

assertNotNull(glskSensi);
assertEquals(0.2, glskSensi.getVariable("FFR1AA1 _generator").getWeight(), EPSILON);
assertEquals(0.2, glskSensi.getVariable("FFR2AA1 _generator").getWeight(), EPSILON);
assertEquals(0.3, glskSensi.getVariable("FFR3AA1 _generator").getWeight(), EPSILON);
assertEquals(0.067, glskSensi.getVariable("FFR1AA1 _load").getWeight(), EPSILON);
assertEquals(0.233, glskSensi.getVariable("FFR2AA1 _load").getWeight(), EPSILON);
}

@Test
void checkZonalGlskFailsWithNonLinearGlskBlocks() {
Network network = Network.read("testCase.xiidm", getClass().getResourceAsStream("/testCase.xiidm"));
CseGlskDocument cseGlskDocument = CseGlskDocument.importGlsk(getClass().getResourceAsStream("/testGlsk.xml"), false, true);
assertThrows(GlskException.class, () -> cseGlskDocument.getZonalGlsks(network));
}
}
79 changes: 79 additions & 0 deletions glsk/glsk-document-cse/src/test/resources/testGlskOnlyLinear.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,79 @@
<?xml version="1.0" encoding="utf-8"?>
<GSKDocument DtdVersion="5" DtdRelease="0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="gsk-document.xsd">
<DocumentIdentification v="testGlsk"/>
<DocumentVersion v="1"/>
<DocumentType v="Z02"/>
<ProcessType v="Z02"/>
<SenderIdentification v="10VCSEEH4MMD-NDO" codingScheme="A01"/>
<SenderRole v="A36"/>
<ReceiverIdentification v="10X1001A1001A345" codingScheme="A01"/>
<ReceiverRole v="A04"/>
<CreationDateTime v="2020-09-15T17:59:09Z"/>
<GSKTimeInterval v="2020-09-16T22:00Z/2020-09-16T23:00Z"/>
<Domain v="10YDOM-1001A061T" codingScheme="A01"/>
<TimeSeries>
<TimeSeriesIdentification v="1"/>
<BusinessType v="Z02"/>
<Area v="FR_MANUAL" codingScheme="A01"/>
<Name v="FR_MANUAL"/>
<TimeInterval v="2020-09-16T22:00Z/2020-09-16T22:59Z"/>
<ManualGSKBlock>
<Factor v="1"/>
<Node>
<Name v="FFR1AA1 "/>
<Factor v="70"/>
</Node>
<Node>
<Name v="FFR3AA1 "/>
<Factor v="30"/>
</Node>
</ManualGSKBlock>
</TimeSeries>
<TimeSeries>
<TimeSeriesIdentification v="1"/>
<BusinessType v="Z02"/>
<Area v="FR_PROPGSK" codingScheme="A01"/>
<Name v="FR_PROPGSK"/>
<TimeInterval v="2020-09-16T22:00Z/2020-09-16T22:59Z"/>
<PropGSKBlock>
<Factor v="1"/>
<Node>
<Name v="FFR1AA1 "/>
</Node>
<Node>
<Name v="FFR2AA1 "/>
</Node>
<Node>
<Name v="FFR3AA1 "/>
</Node>
</PropGSKBlock>
</TimeSeries>
<TimeSeries>
<TimeSeriesIdentification v="1"/>
<BusinessType v="Z02"/>
<Area v="FR_PROPGLSK" codingScheme="A01"/>
<Name v="FR_PROPGLSK"/>
<TimeInterval v="2020-09-16T22:00Z/2020-09-16T22:59Z"/>
<PropGSKBlock>
<Factor v="0.7"/>
<Node>
<Name v="FFR1AA1 "/>
</Node>
<Node>
<Name v="FFR2AA1 "/>
</Node>
<Node>
<Name v="FFR3AA1 "/>
</Node>
</PropGSKBlock>
<PropLSKBlock>
<Factor v="0.3"/>
<Node>
<Name v="FFR1AA1 "/>
</Node>
<Node>
<Name v="FFR2AA1 "/>
</Node>
</PropLSKBlock>
</TimeSeries>
</GSKDocument>

0 comments on commit fdaedb7

Please sign in to comment.