Skip to content

PSS/E import - support boundary trafo between area #3401

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

Open
wants to merge 7 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 5 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
8 changes: 5 additions & 3 deletions docs/grid_exchange_formats/psse/import.md
Original file line number Diff line number Diff line change
Expand Up @@ -245,6 +245,8 @@ Every _Area interchange_ single line record represents one area in PowSyBl grid
- **VoltageLevels** - a set of voltage levels of the area. The set is created from `VoltageLevels` objects that
correspond
to PSS®E buses within the given area.
- **AreaBoundaries** – a list of area boundaries. Boundary terminals are determined from the boundary (AC) lines and
HVDC lines. The boundary lines are always identified such that one of their terminals belongs to the area. This
terminal is marked as a boundary terminal and included to area boundaries.
- **AreaBoundaries** – a list of area boundaries. Boundary terminals are determined from the boundary (AC) lines,
HVDC lines and transformers. The boundary lines or boundary transformers are always identified such that one of
their terminals belongs to the area. This terminal is marked as a boundary terminal and included to area boundaries.
Similarly, three-winding transformers are considered boundary transformers only if some, but not all, of their
terminals belong to the area.
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
import com.powsybl.psse.model.pf.PsseArea;
import com.powsybl.psse.model.pf.PsseBus;

import java.util.ArrayList;
import java.util.List;
import java.util.Set;
import java.util.stream.Collectors;
Expand Down Expand Up @@ -60,35 +61,48 @@ private void addAreaBoundaries(Area area) {
Set<VoltageLevel> areaVoltageLevels = extractVoltageLevels(area);
addLineBoundaryTerminals(area, areaVoltageLevels);
addHvdcLinesBoundaryTerminals(area, areaVoltageLevels);
addTransformerTwoWindingsBoundaryTerminals(area, areaVoltageLevels);
addTransformerTreeWindingsBoundaryTerminals(area, areaVoltageLevels);
}

private void addLineBoundaryTerminals(Area area, Set<VoltageLevel> areaVoltageLevels) {
getNetwork().getLines().forEach(line ->
processTerminals(line.getTerminal1(), line.getTerminal2(), area, areaVoltageLevels, IS_AC));
processTerminals(line.getTerminals(), area, areaVoltageLevels, IS_AC));
}

private void addHvdcLinesBoundaryTerminals(Area area, Set<VoltageLevel> areaVoltageLevels) {
getNetwork().getHvdcLines().forEach(line -> processTerminals(
line.getConverterStation1().getTerminal(),
line.getConverterStation2().getTerminal(),
List.of(line.getConverterStation1().getTerminal(), line.getConverterStation2().getTerminal()),
area, areaVoltageLevels, IS_DC));
}

private void processTerminals(Terminal terminal1, Terminal terminal2, Area area, Set<VoltageLevel> areaVoltageLevels,
private void addTransformerTwoWindingsBoundaryTerminals(Area area, Set<VoltageLevel> areaVoltageLevels) {
getNetwork().getTwoWindingsTransformers().forEach(trf ->
processTerminals(trf.getTerminals(), area, areaVoltageLevels, IS_AC));
}

private void addTransformerTreeWindingsBoundaryTerminals(Area area, Set<VoltageLevel> areaVoltageLevels) {
getNetwork().getThreeWindingsTransformers().forEach(trf ->
processTerminals(trf.getTerminals(), area, areaVoltageLevels, IS_AC)
);
}

private void processTerminals(List<? extends Terminal> terminals, Area area, Set<VoltageLevel> areaVoltageLevels,
boolean isAC) {
var boundaryTerminal = boundaryTerminal(terminal1, terminal2, areaVoltageLevels);
if (boundaryTerminal != null) {
addAreaBoundary(area, boundaryTerminal, isAC);
var boundaryTerminals = boundaryTerminal(terminals, areaVoltageLevels);
for (var terminal : boundaryTerminals) {
addAreaBoundary(area, terminal, isAC);
}
}

private Terminal boundaryTerminal(Terminal terminal1, Terminal terminal2, Set<VoltageLevel> areaVoltageLevels) {
var isTerminal1InArea = areaVoltageLevels.contains(terminal1.getVoltageLevel());
var isTerminal2InArea = areaVoltageLevels.contains(terminal2.getVoltageLevel());
if (isTerminal1InArea != isTerminal2InArea) {
return isTerminal1InArea ? terminal1 : terminal2;
private Terminal[] boundaryTerminal(List<? extends Terminal> terminals, Set<VoltageLevel> areaVoltageLevels) {
var terminalsInArea = new ArrayList<Terminal>();
for (var terminal : terminals) {
if (areaVoltageLevels.contains(terminal.getVoltageLevel())) {
terminalsInArea.add(terminal);
}
}
return null;
return terminals.size() > terminalsInArea.size() ? terminalsInArea.toArray(new Terminal[0]) : new Terminal[0];
}

private Set<VoltageLevel> extractVoltageLevels(Area area) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,11 +16,7 @@
import com.powsybl.commons.parameters.Parameter;
import com.powsybl.commons.parameters.ParameterDefaultValueConfig;
import com.powsybl.commons.parameters.ParameterType;
import com.powsybl.iidm.network.Importer;
import com.powsybl.iidm.network.Network;
import com.powsybl.iidm.network.NetworkFactory;
import com.powsybl.iidm.network.Substation;
import com.powsybl.iidm.network.VoltageLevel;
import com.powsybl.iidm.network.*;
import com.powsybl.iidm.network.util.ContainersMapping;
import com.powsybl.psse.converter.extensions.PsseConversionContextExtensionAdder;
import com.powsybl.psse.converter.extensions.PsseModelExtensionAdder;
Expand Down Expand Up @@ -112,9 +108,9 @@ private boolean exists(ReadOnlyDataSource dataSource, String ext) throws IOExcep
return PowerFlowDataFactory.create(ext).isValidFile(dataSource, ext);
} catch (PsseException | IOException e) {
LOGGER.error(String.format("Invalid content in filename %s.%s: %s",
dataSource.getBaseName(),
ext,
e.getMessage()));
dataSource.getBaseName(),
ext,
e.getMessage()));
}
}
return false;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,9 @@
*/
package com.powsybl.psse.converter;

import com.powsybl.commons.datasource.*;
import com.powsybl.commons.datasource.ReadOnlyDataSource;
import com.powsybl.commons.datasource.ResourceDataSource;
import com.powsybl.commons.datasource.ResourceSet;
import com.powsybl.commons.test.AbstractSerDeTest;
import com.powsybl.iidm.network.*;
import com.powsybl.iidm.network.impl.NetworkFactoryImpl;
Expand All @@ -17,13 +19,13 @@
import com.powsybl.psse.model.io.Context;
import com.powsybl.psse.model.pf.PssePowerFlowModel;
import com.powsybl.psse.model.pf.io.PowerFlowRawData33;
import java.time.ZonedDateTime;
import org.junit.jupiter.api.Test;

import java.io.IOException;
import java.io.InputStream;
import java.nio.file.Files;
import java.nio.file.Path;
import java.time.ZonedDateTime;
import java.util.List;
import java.util.Properties;

Expand Down Expand Up @@ -203,6 +205,16 @@ void twoTerminalDcwithTwoAreas() throws IOException {
importTest("twoTerminalDcwithTwoAreas", "twoTerminalDcwithTwoAreas.raw", false);
}

@Test
void twoTerminalDcwithTwoAreasTrf() throws IOException {
importTest("two_area_case_trf", "two_area_case_trf.raw", false);
}

@Test
void twoTerminalDcwithTwoAreasTrf3w() throws IOException {
importTest("two_area_case_trf3w", "two_area_case_trf3w.raw", false);
}

@Test
void importTest14BusesDuplicateIds() throws IOException {
Network n = importTest("IEEE_14_buses_duplicate_ids", "IEEE_14_buses_duplicate_ids.raw", false);
Expand Down
87 changes: 87 additions & 0 deletions psse/psse-converter/src/test/resources/two_area_case_trf.raw
Original file line number Diff line number Diff line change
@@ -0,0 +1,87 @@
0, 100.00, 33, 0, 0, 60.00 / October 01, 2013 18:37:53
08/19/93 UW ARCHIVE 100.0 1962 W IEEE 14 Bus Test Case

1,'Bus 1 ', 400.0000,3, 1, 1, 1,1.06000, 0.0000
2,'Bus 2 ', 400.0000,2, 1, 1, 1,1.04500, -4.9826
3,'Bus 3 ', 400.0000,2, 1, 1, 1,1.01000, -12.7250
4,'Bus 4 ', 400.0000,1, 1, 1, 1,1.01767, -10.3128
5,'Bus 5 ', 400.0000,1, 1, 1, 1,1.01951, -8.7738
6,'Bus 6 ', 110.0000,2, 2, 1, 1,1.07000, -14.2209
7,'Bus 7 ', 110.0000,1, 2, 1, 1,1.06152, -13.3596
8,'Bus 8 ', 110.0000,2, 2, 1, 1,1.09000, -13.3596
9,'Bus 9 ', 110.0000,1, 2, 1, 1,1.05593, -14.9385
10,'Bus 10 ', 110.0000,1, 2, 1, 1,1.05099, -15.0972
11,'Bus 11 ', 110.0000,1, 2, 1, 1,1.05691, -14.7906
12,'Bus 12 ', 110.0000,1, 2, 1, 1,1.05519, -15.0755
13,'Bus 13 ', 110.0000,1, 2, 1, 1,1.05038, -15.1562
14,'Bus 14 ', 110.0000,1, 2, 1, 1,1.03553, -16.0336
0 / END OF BUS DATA, BEGIN LOAD DATA
2,'1 ',1, 1, 1, 21.700, 12.700, 0.000, 0.000, 0.000, -0.000, 1,1
3,'1 ',1, 1, 1, 94.200, 19.000, 0.000, 0.000, 0.000, -0.000, 1,1
4,'1 ',1, 1, 1, 47.800, -3.900, 0.000, 0.000, 0.000, -0.000, 1,1
5,'1 ',1, 1, 1, 7.600, 1.600, 0.000, 0.000, 0.000, -0.000, 1,1
6,'1 ',1, 1, 1, 11.200, 7.500, 0.000, 0.000, 0.000, -0.000, 1,1
9,'1 ',1, 1, 1, 29.500, 16.600, 0.000, 0.000, 0.000, -0.000, 1,1
10,'1 ',1, 1, 1, 9.000, 5.800, 0.000, 0.000, 0.000, -0.000, 1,1
11,'1 ',1, 1, 1, 3.500, 1.800, 0.000, 0.000, 0.000, -0.000, 1,1
12,'1 ',1, 1, 1, 6.100, 1.600, 0.000, 0.000, 0.000, -0.000, 1,1
13,'1 ',1, 1, 1, 13.500, 5.800, 0.000, 0.000, 0.000, -0.000, 1,1
14,'1 ',1, 1, 1, 14.900, 5.000, 0.000, 0.000, 0.000, -0.000, 1,1
0 / END OF LOAD DATA, BEGIN FIXED SHUNT DATA
9,' 1', 1, 0.000, 19.000
0 / END OF FIXED SHUNT DATA, BEGIN GENERATOR DATA
1,'1 ', 232.392, -16.549, 0.000, 0.000,1.06000, 0, 615.000, 0.00000, 1.00000, 0.00000, 0.00000,1.00000,1, 100.0, 10000.000,-10000.000, 1,1.0000, 0,1.0000, 0,1.0000, 0,1.0000,0, 1.0000
2,'1 ', 40.000, 43.556, 50.000, -40.000,1.04500, 0, 60.000, 0.00000, 1.00000, 0.00000, 0.00000,1.00000,1, 100.0, 10000.000,-10000.000, 1,1.0000, 0,1.0000, 0,1.0000, 0,1.0000,0, 1.0000
3,'1 ', 0.000, 25.075, 40.000, 0.000,1.01000, 0, 60.000, 0.00000, 1.00000, 0.00000, 0.00000,1.00000,1, 100.0, 10000.000,-10000.000, 1,1.0000, 0,1.0000, 0,1.0000, 0,1.0000,0, 1.0000
6,'1 ', 0.000, 12.730, 24.000, -6.000,1.07000, 0, 25.000, 0.00000, 1.00000, 0.00000, 0.00000,1.00000,1, 100.0, 10000.000,-10000.000, 1,1.0000, 0,1.0000, 0,1.0000, 0,1.0000,0, 1.0000
8,'1 ', 0.000, 17.623, 24.000, -6.000,1.09000, 0, 25.000, 0.00000, 1.00000, 0.00000, 0.00000,1.00000,1, 100.0, 10000.000,-10000.000, 1,1.0000, 0,1.0000, 0,1.0000, 0,1.0000,0, 1.0000
0 / END OF GENERATOR DATA, BEGIN BRANCH DATA
1, 2,'1 ', 0.01938, 0.05917,0.05280, 0.00, 0.00, 0.00, 0.00000, 0.00000, 0.00000, 0.00000,1,1, 0.0, 1,1.0000, 0,1.0000, 0,1.0000, 0,1.0000
1, 5,'1 ', 0.05403, 0.22304,0.04920, 0.00, 0.00, 0.00, 0.00000, 0.00000, 0.00000, 0.00000,1,1, 0.0, 1,1.0000, 0,1.0000, 0,1.0000, 0,1.0000
2, 3,'1 ', 0.04699, 0.19797,0.04380, 0.00, 0.00, 0.00, 0.00000, 0.00000, 0.00000, 0.00000,1,1, 0.0, 1,1.0000, 0,1.0000, 0,1.0000, 0,1.0000
2, 4,'1 ', 0.05811, 0.17632,0.03400, 0.00, 0.00, 0.00, 0.00000, 0.00000, 0.00000, 0.00000,1,1, 0.0, 1,1.0000, 0,1.0000, 0,1.0000, 0,1.0000
2, 5,'1 ', 0.05695, 0.17388,0.03460, 0.00, 0.00, 0.00, 0.00000, 0.00000, 0.00000, 0.00000,1,1, 0.0, 1,1.0000, 0,1.0000, 0,1.0000, 0,1.0000
3, 4,'1 ', 0.06701, 0.17103,0.01280, 0.00, 0.00, 0.00, 0.00000, 0.00000, 0.00000, 0.00000,1,1, 0.0, 1,1.0000, 0,1.0000, 0,1.0000, 0,1.0000
4, 5,'1 ', 0.01335, 0.04211,0.00000, 0.00, 0.00, 0.00, 0.00000, 0.00000, 0.00000, 0.00000,1,1, 0.0, 1,1.0000, 0,1.0000, 0,1.0000, 0,1.0000
6, 11,'1 ', 0.09498, 0.19890,0.00000, 0.00, 0.00, 0.00, 0.00000, 0.00000, 0.00000, 0.00000,1,1, 0.0, 1,1.0000, 0,1.0000, 0,1.0000, 0,1.0000
6, 12,'1 ', 0.12291, 0.25581,0.00000, 0.00, 0.00, 0.00, 0.00000, 0.00000, 0.00000, 0.00000,1,1, 0.0, 1,1.0000, 0,1.0000, 0,1.0000, 0,1.0000
6, 13,'1 ', 0.06615, 0.13027,0.00000, 0.00, 0.00, 0.00, 0.00000, 0.00000, 0.00000, 0.00000,1,1, 0.0, 1,1.0000, 0,1.0000, 0,1.0000, 0,1.0000
7, 8,'1 ', 0.00000, 0.17615,0.00000, 0.00, 0.00, 0.00, 0.00000, 0.00000, 0.00000, 0.00000,1,1, 0.0, 1,1.0000, 0,1.0000, 0,1.0000, 0,1.0000
7, 9,'1 ', 0.00000, 0.11001,0.00000, 0.00, 0.00, 0.00, 0.00000, 0.00000, 0.00000, 0.00000,1,1, 0.0, 1,1.0000, 0,1.0000, 0,1.0000, 0,1.0000
9, 10,'1 ', 0.03181, 0.08450,0.00000, 0.00, 0.00, 0.00, 0.00000, 0.00000, 0.00000, 0.00000,1,1, 0.0, 1,1.0000, 0,1.0000, 0,1.0000, 0,1.0000
9, 14,'1 ', 0.12711, 0.27038,0.00000, 0.00, 0.00, 0.00, 0.00000, 0.00000, 0.00000, 0.00000,1,1, 0.0, 1,1.0000, 0,1.0000, 0,1.0000, 0,1.0000
10, 11,'1 ', 0.08205, 0.19207,0.00000, 0.00, 0.00, 0.00, 0.00000, 0.00000, 0.00000, 0.00000,1,1, 0.0, 1,1.0000, 0,1.0000, 0,1.0000, 0,1.0000
12, 13,'1 ', 0.22092, 0.19988,0.00000, 0.00, 0.00, 0.00, 0.00000, 0.00000, 0.00000, 0.00000,1,1, 0.0, 1,1.0000, 0,1.0000, 0,1.0000, 0,1.0000
13, 14,'1 ', 0.17093, 0.34802,0.00000, 0.00, 0.00, 0.00, 0.00000, 0.00000, 0.00000, 0.00000,1,1, 0.0, 1,1.0000, 0,1.0000, 0,1.0000, 0,1.0000
0 / END OF BRANCH DATA, BEGIN TRANSFORMER DATA
4, 7, 0,'1 ',1,1,1, 0.00000, 0.00000,2,' ',1, 1,1.0000, 0,1.0000, 0,1.0000, 0,1.0000
0.00000, 0.20912, 100.00
0.97800, 0.000, 0.000, 0.00, 0.00, 0.00,0, 0, 1.50000, 0.51000, 1.50000, 0.51000,159, 0, 0.00000, 0.00000
1.00000, 0.000
4, 9, 0,'1 ',1,1,1, 0.00000, 0.00000,2,' ',1, 1,1.0000, 0,1.0000, 0,1.0000, 0,1.0000
0.00000, 0.55618, 100.00
0.96900, 0.000, 0.000, 0.00, 0.00, 0.00,0, 0, 1.50000, 0.51000, 1.50000, 0.51000,159, 0, 0.00000, 0.00000
1.00000, 0.000
5, 6, 0,'1 ',1,1,1, 0.00000, 0.00000,2,' ',1, 1,1.0000, 0,1.0000, 0,1.0000, 0,1.0000
0.00000, 0.25202, 100.00
0.93200, 0.000, 0.000, 0.00, 0.00, 0.00,0, 0, 1.50000, 0.51000, 1.50000, 0.51000,159, 0, 0.00000, 0.00000
1.00000, 0.000
0 / END OF TRANSFORMER DATA, BEGIN AREA DATA
1, 2, 0.000, 999.990,'area 1-5 '
2, 6, 0.000, 999.990,'area 6-14 '

0 / END OF AREA DATA, BEGIN TWO-TERMINAL DC DATA
0 / END OF TWO-TERMINAL DC DATA, BEGIN VOLTAGE SOURCE CONVERTER DATA
0 / END OF VOLTAGE SOURCE CONVERTER DATA, BEGIN IMPEDANCE CORRECTION DATA
0 / END OF IMPEDANCE CORRECTION DATA, BEGIN MULTI-TERMINAL DC DATA
0 / END OF MULTI-TERMINAL DC DATA, BEGIN MULTI-SECTION LINE DATA
0 / END OF MULTI-SECTION LINE DATA, BEGIN ZONE DATA
1,'IEEE 14 '
0 / END OF ZONE DATA, BEGIN INTER-AREA TRANSFER DATA
0 / END OF INTER-AREA TRANSFER DATA, BEGIN OWNER DATA
1,'1'
0 / END OF OWNER DATA, BEGIN FACTS CONTROL DEVICE DATA
0 / END OF FACTS CONTROL DEVICE DATA, BEGIN SWITCHED SHUNT DATA
0 /END OF SWITCHED SHUNT DATA, BEGIN GNE DEVICE DATA
0 /END OF GNE DEVICE DATA
Q
Loading
Loading