Skip to content
New issue

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

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

Already on GitHub? Sign in to your account

Check measurement point are connected #342

Merged
merged 9 commits into from
May 17, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -142,7 +142,7 @@ private static Stream<Arguments> provideAutomationSystemModelData() {
Arguments.of("/dynamicModels/overloadManagementTwoLevels.groovy", DynamicTwoLevelsOverloadManagementSystem.class, EurostagTutorialExample1Factory.create(), "AM_NHV1_NHV2_1", "CLA", "CurrentLimitAutomatonTwoLevels"),
Arguments.of("/dynamicModels/tapChanger.groovy", TapChangerAutomationSystem.class, EurostagTutorialExample1Factory.create(), "TC", "tc", "TapChangerAutomaton"),
Arguments.of("/dynamicModels/tapChangerBlockingBusBar.groovy", TapChangerBlockingAutomationSystem.class, FourSubstationsNodeBreakerFactory.create(), "ZAB", "ZAB", "TapChangerBlockingAutomaton2"),
Arguments.of("/dynamicModels/tapChangerBlocking.groovy", TapChangerBlockingAutomationSystem.class, EurostagTutorialExample1Factory.create(), "ZAB", "ZAB", "TapChangerBlockingAutomaton3"),
Arguments.of("/dynamicModels/tapChangerBlocking.groovy", TapChangerBlockingAutomationSystem.class, EurostagTutorialExample1Factory.createWithLFResults(), "ZAB", "ZAB", "TapChangerBlockingAutomaton3"),
Arguments.of("/dynamicModels/phaseShifterI.groovy", PhaseShifterIAutomationSystem.class, EurostagTutorialExample1Factory.create(), "PS_NGEN_NHV1", "ps", "PhaseShifterI"),
Arguments.of("/dynamicModels/phaseShifterP.groovy", PhaseShifterPAutomationSystem.class, EurostagTutorialExample1Factory.create(), "PS_NGEN_NHV1", "ps", "PhaseShifterP"),
Arguments.of("/dynamicModels/underVoltage.groovy", UnderVoltageAutomationSystem.class, EurostagTutorialExample1Factory.create(), "UV_GEN", "uv", "UnderVoltageAutomaton")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,7 @@
*/
package com.powsybl.dynawaltz.builders;

import com.powsybl.iidm.network.Identifiable;
import com.powsybl.iidm.network.IdentifiableType;
import com.powsybl.iidm.network.Network;
import com.powsybl.iidm.network.*;

/**
* @author Laurent Issertial {@literal <laurent.issertial at rte-france.com>}
Expand All @@ -21,8 +19,28 @@ public final class BuildersUtil {
private BuildersUtil() {
}

/**
* Returns the ActionConnectionPoint (bus or busbar section) identified by the staticId parameter
* Verifies the point is energized and in main connected component, if not returns null
* @param network the network containing the ActionConnectionPoint
* @param staticId the identifiable id
* @return the energized action connection point if found, <code>null</code> instead
*/
public static Identifiable<?> getActionConnectionPoint(Network network, String staticId) {
Lisrte marked this conversation as resolved.
Show resolved Hide resolved
Identifiable<?> point = network.getBusbarSection(staticId);
return point != null ? point : network.getBusBreakerView().getBus(staticId);
BusbarSection busbarSection = network.getBusbarSection(staticId);
if (busbarSection != null) {
return isEnergizedBus(busbarSection.getTerminal().getBusBreakerView().getBus()) ? busbarSection : null;
}
Bus bus = network.getBusBreakerView().getBus(staticId);
return isEnergizedBus(bus) ? bus : null;
}

/**
* Verifies a bus is energized and in main connected component
* @param bus the reviewed bus
* @return <code>true</code> if energized, <code>false</code> if not
*/
private static boolean isEnergizedBus(Bus bus) {
return bus != null && !Double.isNaN(bus.getV()) && bus.isInMainConnectedComponent();
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
import java.util.Optional;

/**
* Interface for buses used by automatons for measure or event for various actions
* Interface for buses and busbar sections used by automatons for measure or event for various actions
* @author Laurent Issertial {@literal <laurent.issertial at rte-france.com>}
*/
public interface ActionConnectionPoint extends Model {
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
/**
* 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/.
* SPDX-License-Identifier: MPL-2.0
*/
package com.powsybl.dynawaltz.models;

import com.powsybl.dynawaltz.builders.BuildersUtil;
import com.powsybl.iidm.network.Network;
import com.powsybl.iidm.network.test.EurostagTutorialExample1Factory;
import com.powsybl.iidm.network.test.HvdcTestNetwork;
import org.junit.jupiter.api.Test;

import static org.junit.jupiter.api.Assertions.assertNull;
/**
* @author Laurent Issertial {@literal <laurent.issertial at rte-france.com>}
*/
class ActionConnectionPointTest {

@Test
void voltageOffBus() {
Network network = EurostagTutorialExample1Factory.create();
assertNull(BuildersUtil.getActionConnectionPoint(network, "NGEN"));
}

@Test
void voltageOffBusBarSection() {
Network network = HvdcTestNetwork.createBase();
assertNull(BuildersUtil.getActionConnectionPoint(network, "BBS1"));
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,6 @@
import com.powsybl.dynawaltz.models.automationsystems.TapChangerAutomationSystemBuilder;
import com.powsybl.dynawaltz.models.automationsystems.TapChangerBlockingAutomationSystemBuilder;
import com.powsybl.dynawaltz.models.loads.LoadOneTransformerBuilder;
import com.powsybl.iidm.network.Bus;
import com.powsybl.iidm.network.VoltageLevel;
import com.powsybl.iidm.network.test.EurostagTutorialExample1Factory;
import org.junit.jupiter.api.Test;
import org.xml.sax.SAXException;
Expand All @@ -26,10 +24,14 @@ class EmptyTapChangerBlockingAutomationSystemXmlTest extends AbstractDynamicMode

@Override
protected void setupNetwork() {
network = EurostagTutorialExample1Factory.create();
VoltageLevel vlload = network.getVoltageLevel("VLLOAD");
Bus nload = network.getBusBreakerView().getBus("NLOAD");
vlload.newLoad().setId("LOAD2").setBus(nload.getId()).setConnectableBus(nload.getId()).setP0(600.0).setQ0(200.0).add();
network = EurostagTutorialExample1Factory.createWithLFResults();
network.getVoltageLevel("VLLOAD").newLoad()
.setId("LOAD2")
.setBus("NLOAD")
.setConnectableBus("NLOAD")
.setP0(600.0)
.setQ0(200.0)
.add();
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ class TapChangerAutomationSystemXmlTest extends AbstractDynamicModelXmlTest {

@Override
protected void setupNetwork() {
network = EurostagTutorialExample1Factory.create();
network = EurostagTutorialExample1Factory.createWithLFResults();
VoltageLevel vlload = network.getVoltageLevel("VLLOAD");
Bus nload = network.getBusBreakerView().getBus("NLOAD");
vlload.newLoad().setId("LOAD2").setBus(nload.getId()).setConnectableBus(nload.getId()).setP0(600.0).setQ0(200.0).add();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,6 @@
import com.powsybl.dynawaltz.models.loads.LoadTwoTransformersTapChangersBuilder;
import com.powsybl.dynawaltz.models.transformers.TransformerFixedRatioBuilder;
import com.powsybl.dynawaltz.models.automationsystems.TapChangerBlockingAutomationSystemBuilder;
import com.powsybl.iidm.network.Bus;
import com.powsybl.iidm.network.VoltageLevel;
import com.powsybl.iidm.network.test.EurostagTutorialExample1Factory;
import org.junit.jupiter.api.Test;
import org.xml.sax.SAXException;
Expand All @@ -31,10 +29,14 @@ class TapChangerBlockingAutomationSystemXmlTest extends AbstractDynamicModelXmlT

@Override
protected void setupNetwork() {
network = EurostagTutorialExample1Factory.create();
VoltageLevel vlload = network.getVoltageLevel("VLLOAD");
Bus nload = network.getBusBreakerView().getBus("NLOAD");
vlload.newLoad().setId("LOAD2").setBus(nload.getId()).setConnectableBus(nload.getId()).setP0(600.0).setQ0(200.0).add();
network = EurostagTutorialExample1Factory.createWithLFResults();
network.getVoltageLevel("VLLOAD").newLoad()
.setId("LOAD2")
.setBus("NLOAD")
.setConnectableBus("NLOAD")
.setP0(600.0)
.setQ0(200.0)
.add();
}

@Override
Expand Down
Loading