Skip to content

Commit

Permalink
Add tests for BranchObservability and InjectionObservability extensio…
Browse files Browse the repository at this point in the history
…ns (#38)

* Add tests for BranchObservability and InjectionObservability extensions

Signed-off-by: Franck LECUYER <[email protected]>
  • Loading branch information
FranckLecuyer authored Jun 18, 2024
1 parent 34bccba commit 0535b2d
Show file tree
Hide file tree
Showing 5 changed files with 187 additions and 0 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
/**
* Copyright (c) 2024, RTE (http://www.rte-france.com)
* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/.
*/
package com.powsybl.network.store.tck.extensions;

import com.powsybl.iidm.network.tck.extensions.AbstractBranchObservabilityTest;
import com.powsybl.network.store.server.NetworkStoreApplication;
import org.junit.runner.RunWith;
import org.springframework.boot.test.context.SpringBootTest;
import org.springframework.test.context.ContextConfiguration;
import org.springframework.test.context.ContextHierarchy;
import org.springframework.test.context.TestPropertySource;
import org.springframework.test.context.junit4.SpringRunner;

@RunWith(SpringRunner.class)
@SpringBootTest(webEnvironment = SpringBootTest.WebEnvironment.DEFINED_PORT)
@ContextHierarchy({
@ContextConfiguration(classes = {NetworkStoreApplication.class})
})
@TestPropertySource(properties = { "spring.config.location=classpath:application.yaml" })
class BranchObservabilityIT extends AbstractBranchObservabilityTest {
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
/**
* Copyright (c) 2024, RTE (http://www.rte-france.com)
* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/.
*/
package com.powsybl.network.store.tck.extensions;

import com.powsybl.iidm.network.tck.extensions.AbstractInjectionObservabilityTest;
import com.powsybl.network.store.server.NetworkStoreApplication;
import org.junit.runner.RunWith;
import org.springframework.boot.test.context.SpringBootTest;
import org.springframework.test.context.ContextConfiguration;
import org.springframework.test.context.ContextHierarchy;
import org.springframework.test.context.TestPropertySource;
import org.springframework.test.context.junit4.SpringRunner;

@RunWith(SpringRunner.class)
@SpringBootTest(webEnvironment = SpringBootTest.WebEnvironment.DEFINED_PORT)
@ContextHierarchy({
@ContextConfiguration(classes = {NetworkStoreApplication.class})
})
@TestPropertySource(properties = { "spring.config.location=classpath:application.yaml" })
class InjectionObservabilityIT extends AbstractInjectionObservabilityTest {
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
/**
* Copyright (c) 2024, RTE (http://www.rte-france.com)
* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/.
*/
package com.powsybl.network.store.tck.extensions;

import com.powsybl.iidm.network.tck.extensions.AbstractThreeWindingsTransformerToBeEstimatedTest;
import com.powsybl.network.store.server.NetworkStoreApplication;
import org.junit.runner.RunWith;
import org.springframework.boot.test.context.SpringBootTest;
import org.springframework.test.context.ContextConfiguration;
import org.springframework.test.context.ContextHierarchy;
import org.springframework.test.context.TestPropertySource;
import org.springframework.test.context.junit4.SpringRunner;

@RunWith(SpringRunner.class)
@SpringBootTest(webEnvironment = SpringBootTest.WebEnvironment.DEFINED_PORT)
@ContextHierarchy({
@ContextConfiguration(classes = {NetworkStoreApplication.class})
})
@TestPropertySource(properties = { "spring.config.location=classpath:application.yaml" })
class ThreeWindingsTransformerToBeEstimatedIT extends AbstractThreeWindingsTransformerToBeEstimatedTest {
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
/**
* Copyright (c) 2024, RTE (http://www.rte-france.com)
* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/.
*/
package com.powsybl.network.store.tck.extensions;

import com.powsybl.iidm.network.tck.extensions.AbstractTwoWindingsTransformerToBeEstimatedTest;
import com.powsybl.network.store.server.NetworkStoreApplication;
import org.junit.runner.RunWith;
import org.springframework.boot.test.context.SpringBootTest;
import org.springframework.test.context.ContextConfiguration;
import org.springframework.test.context.ContextHierarchy;
import org.springframework.test.context.TestPropertySource;
import org.springframework.test.context.junit4.SpringRunner;

@RunWith(SpringRunner.class)
@SpringBootTest(webEnvironment = SpringBootTest.WebEnvironment.DEFINED_PORT)
@ContextHierarchy({
@ContextConfiguration(classes = {NetworkStoreApplication.class})
})
@TestPropertySource(properties = { "spring.config.location=classpath:application.yaml" })
class TwoWindingsTransformerToBeEstimatedIT extends AbstractTwoWindingsTransformerToBeEstimatedTest {
}
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
import com.powsybl.computation.local.LocalComputationManager;
import com.powsybl.iidm.network.*;
import com.powsybl.iidm.network.extensions.*;
import com.powsybl.iidm.network.test.BatteryNetworkFactory;
import com.powsybl.iidm.network.test.EurostagTutorialExample1Factory;
import com.powsybl.iidm.network.test.HvdcTestNetwork;
import com.powsybl.iidm.network.test.SvcTestCaseFactory;
Expand Down Expand Up @@ -1311,6 +1312,7 @@ public void testMeasurements() {

try (NetworkStoreService service = createNetworkStoreService(randomServerPort)) {
Network network = service.getNetwork(service.getNetworkIds().keySet().iterator().next());

TwoWindingsTransformer twoWindingsTransformer = network.getTwoWindingsTransformer("NHV2_NLOAD");

Measurements measurements = twoWindingsTransformer.getExtension(Measurements.class);
Expand Down Expand Up @@ -1381,6 +1383,7 @@ public void testDiscreteMeasurements() {

try (NetworkStoreService service = createNetworkStoreService(randomServerPort)) {
Network network = service.getNetwork(service.getNetworkIds().keySet().iterator().next());

TwoWindingsTransformer twoWindingsTransformer = network.getTwoWindingsTransformer("NHV2_NLOAD");
DiscreteMeasurements measurements = twoWindingsTransformer.getExtension(DiscreteMeasurements.class);
assertNotNull(measurements);
Expand Down Expand Up @@ -1430,6 +1433,90 @@ public void testDiscreteMeasurements() {
}
}

@Test
public void testBranchObservability() {
try (NetworkStoreService service = createNetworkStoreService(randomServerPort)) {
Network network = BatteryNetworkFactory.create(service.getNetworkFactory());
Line line = network.getLine("NHV1_NHV2_1");
line.newExtension(BranchObservabilityAdder.class)
.withObservable(true)
.withStandardDeviationP1(0.02d)
.withStandardDeviationP2(0.04d)
.withRedundantP1(true)
.withRedundantP2(false)
.withStandardDeviationQ1(0.5d)
.withStandardDeviationQ2(1.0d)
.withRedundantQ1(false)
.withRedundantQ2(true)
.add();
service.flush(network);
}

try (NetworkStoreService service = createNetworkStoreService(randomServerPort)) {
Network network = service.getNetwork(service.getNetworkIds().keySet().iterator().next());
Line line = network.getLine("NHV1_NHV2_1");

BranchObservability<Line> branchObservability = line.getExtension(BranchObservability.class);
assertEquals("branchObservability", branchObservability.getName());
assertEquals("NHV1_NHV2_1", branchObservability.getExtendable().getId());

assertTrue(branchObservability.isObservable());
assertEquals(0.02d, branchObservability.getQualityP1().getStandardDeviation(), 0d);
assertEquals(0.04d, branchObservability.getQualityP2().getStandardDeviation(), 0d);
assertTrue(branchObservability.getQualityP1().isRedundant().isPresent());
assertTrue(branchObservability.getQualityP1().isRedundant().get());
assertTrue(branchObservability.getQualityP2().isRedundant().isPresent());
assertFalse(branchObservability.getQualityP2().isRedundant().get());

assertEquals(0.5d, branchObservability.getQualityQ1().getStandardDeviation(), 0d);
assertEquals(1.0d, branchObservability.getQualityQ2().getStandardDeviation(), 0d);
assertTrue(branchObservability.getQualityQ1().isRedundant().isPresent());
assertFalse(branchObservability.getQualityQ1().isRedundant().get());
assertTrue(branchObservability.getQualityQ2().isRedundant().isPresent());
assertTrue(branchObservability.getQualityQ2().isRedundant().get());
}
}

@Test
public void testInjectionObservability() {
try (NetworkStoreService service = createNetworkStoreService(randomServerPort)) {
Network network = BatteryNetworkFactory.create(service.getNetworkFactory());
Generator generator = network.getGenerator("GEN");
generator.newExtension(InjectionObservabilityAdder.class)
.withObservable(false)
.withStandardDeviationP(0.02d)
.withStandardDeviationQ(0.03d)
.withStandardDeviationV(0.04d)
.withRedundantP(true)
.withRedundantQ(false)
.withRedundantV(true)
.add();
service.flush(network);
}

try (NetworkStoreService service = createNetworkStoreService(randomServerPort)) {
Network network = service.getNetwork(service.getNetworkIds().keySet().iterator().next());
Generator generator = network.getGenerator("GEN");

InjectionObservability<Generator> generatorObservability = generator.getExtension(InjectionObservability.class);
assertEquals("injectionObservability", generatorObservability.getName());
assertEquals("GEN", generatorObservability.getExtendable().getId());

assertFalse(generatorObservability.isObservable());
assertEquals(0.02d, generatorObservability.getQualityP().getStandardDeviation(), 0d);
assertTrue(generatorObservability.getQualityP().isRedundant().isPresent());
assertTrue(generatorObservability.getQualityP().isRedundant().get());

assertEquals(0.03d, generatorObservability.getQualityQ().getStandardDeviation(), 0d);
assertTrue(generatorObservability.getQualityQ().isRedundant().isPresent());
assertFalse(generatorObservability.getQualityQ().isRedundant().get());

assertEquals(0.04d, generatorObservability.getQualityV().getStandardDeviation(), 0d);
assertTrue(generatorObservability.getQualityV().isRedundant().isPresent());
assertTrue(generatorObservability.getQualityV().isRedundant().get());
}
}

@Test
public void test2wtToBeEstimated() {
try (NetworkStoreService service = createNetworkStoreService(randomServerPort)) {
Expand Down

0 comments on commit 0535b2d

Please sign in to comment.