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

PSSE: Fix transformers with voltage control and not defined controlled bus #3160

Merged
merged 3 commits into from
Sep 26, 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 @@ -143,7 +143,7 @@ public Network importData(ReadOnlyDataSource dataSource, NetworkFactory networkF
PssePowerFlowModel pssePowerFlowModel = PowerFlowDataFactory.create(ext, version).read(dataSource, ext, context);
pssePowerFlowModel.getCaseIdentification().validate();

new PsseFixDuplicateIds(pssePowerFlowModel, context.getVersion()).fix();
new PsseFixes(pssePowerFlowModel, context.getVersion()).fix();
PsseValidation psseValidation = new PsseValidation(pssePowerFlowModel, context.getVersion());
if (!psseValidation.isValidCase()) {
throw new PsseException("The PSS/E file is not a valid case");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,7 @@
import com.powsybl.commons.datasource.ResourceDataSource;
import com.powsybl.commons.datasource.ResourceSet;
import com.powsybl.commons.test.AbstractSerDeTest;
import com.powsybl.iidm.network.Importer;
import com.powsybl.iidm.network.Network;
import com.powsybl.iidm.network.NetworkFactory;
import com.powsybl.iidm.network.*;
import com.powsybl.iidm.network.impl.NetworkFactoryImpl;
import com.powsybl.iidm.serde.NetworkSerDe;
import com.powsybl.psse.model.PsseException;
Expand Down Expand Up @@ -294,4 +292,22 @@ void dataSourceExistsTest() {
void importTest14ZipLoad() throws IOException {
importTest("IEEE_14_buses_zip_load", "IEEE_14_buses_zip_load.raw", false);
}

@Test
void importTestTransformersWithVoltageControlAndNotDefinedControlledBusV33() {
ReadOnlyDataSource dataSource = new ResourceDataSource("TransformersWithVoltageControlAndNotDefinedControlledBus", new ResourceSet("/", "TransformersWithVoltageControlAndNotDefinedControlledBus.raw"));
Network network = new PsseImporter().importData(dataSource, new NetworkFactoryImpl(), new Properties());

TwoWindingsTransformer t2w = network.getTwoWindingsTransformer("T-1-4-1 ");
assertNotNull(t2w);
assertNull(t2w.getRatioTapChanger());

ThreeWindingsTransformer t3w = network.getThreeWindingsTransformer("T-4-2-7-1 ");
assertNotNull(t3w);
assertNull(t3w.getLeg1().getRatioTapChanger());
assertNotNull(t3w.getLeg2().getRatioTapChanger());
assertFalse(t3w.getLeg2().getRatioTapChanger().isRegulating());
assertNotNull(t3w.getLeg3().getRatioTapChanger());
assertFalse(t3w.getLeg3().getRatioTapChanger().isRegulating());
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
0, 100.00, 33, 0, 0, 60.00 / September 03, 2016 22:35:15; Simulator Version 20 Beta; BuildDate 2016_7_25


1,'1 ', 18.0000,2, 1, 1, 1,1.04000, -6.5957, 1.10000, 0.90000, 1.10000, 0.90000
2,'2 ', 18.0000,2, 1, 1, 1,1.04000, -6.5957, 1.10000, 0.90000, 1.10000, 0.90000
3,'3 ', 18.0000,2, 1, 1, 1,1.02000, -37.1199, 1.10000, 0.90000, 1.10000, 0.90000
4,'4 ', 500.0000,1, 1, 1, 1,1.01691, -11.4772, 1.10000, 0.90000, 1.10000, 0.90000
5,'5 ', 500.0000,1, 1, 1, 1,0.97278, -42.3008, 1.10000, 0.90000, 1.10000, 0.90000
6,'6 ', 500.0000,3, 1, 1, 1,1.00000, -57.1678, 1.10000, 0.90000, 1.10000, 0.90000
7,'7 ', 16.0000,2, 1, 1, 1,1.00000, 0.000000, 1.10000, 0.90000, 1.10000, 0.90000
0 / END OF BUS DATA, BEGIN LOAD DATA
4,'1 ',1, 1, 1, 1400.000, 100.000, 0.000, 0.000, 0.000, 0.000, 1,1
5,'1 ',1, 1, 1, 2000.000, 100.000, 0.000, 0.000, 0.000, 0.000, 1,1
5,'2 ',0, 1, 1, 0.000, 50.000, 0.000, 0.000, 0.000, 0.000, 1,1
6,'1 ',1, 1, 1, 10000.000, 2000.000, 0.000, 0.000, 0.000, 0.000, 1,1
7,'1 ',1, 1, 1, 1.000, 1.000, 0.000, 0.000, 0.000, 0.000, 1,1
0 / END OF LOAD DATA, BEGIN FIXED SHUNT DATA
0 / END OF FIXED SHUNT DATA, BEGIN GENERATOR DATA
1,'1 ', 1404.000, 434.409, 9900.000, -9900.000,1.04000, 0, 1560.000, 0.00190, 0.29000, 0.00000, 0.00000,1.00000,1, 100.0, 1560.000, 0.000, 1,1.0000, 0,1.0000, 0,1.0000, 0,1.0000,0, 1.0000
2,'1 ', 1404.000, 434.409, 9900.000, -9900.000,1.04000, 0, 1560.000, 0.00190, 0.29000, 0.00000, 0.00000,1.00000,1, 100.0, 1560.000, 0.000, 1,1.0000, 0,1.0000, 0,1.0000, 0,1.0000,0, 1.0000
3,'1 ', 800.000, 466.250, 9900.000, -9900.000,1.02000, 0, 890.000, 0.00000, 0.33700, 0.00000, 0.00000,1.00000,1, 100.0, 890.000, 0.000, 1,1.0000, 0,1.0000, 0,1.0000, 0,1.0000,0, 1.0000
6,'1 ', 9792.007, 2049.823, 9900.000, -9900.000,1.00000, 0,100000.000, 0.00000, 0.20000, 0.00000, 0.00000,1.00000,1, 100.0, 20000.000, 0.000, 1,1.0000, 0,1.0000, 0,1.0000, 0,1.0000,0, 1.0000
0 / END OF GENERATOR DATA, BEGIN BRANCH DATA
4, 5,'1 ', 0.00000, 0.03600,0.00000,10451.00,10452.00,10453.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
5, 6,'1 ', 0.00000, 0.12000,0.00000,10561.00,10562.00,10563.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
1, 4, 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.00641, 100.00
1.00000, 18.000, 0.000, 10140.00, 10141.00, 10142.00, 1, 0, 1.50000, 0.51000, 1.50000, 0.51000, 22, 0, 0.00000, 0.00000
1.00000,500.000
4, 2, 7,'1 ',2,3,2, 1.44572E+5, 4.10000E-4,2,'AEPTM1T ',1, 1,1.0000, 0,1.0000, 0,1.0000, 0,1.0000,' '
3.34279E+5, 1.34320E-1, 440.00, 2.62298E+5, 2.08070E-1, 280.00, 1.51500E+3, 1.06520E-1, 160.00,0.98627, -10.1187
500.000, 500.000, 0.000, 101.00, 102.00, 103.00, 1, 0,444.0000,356.0000, 1.10000, 0.90000, 22, 0, 0.00000, 0.00000, 0.000
18.2370, 18.000, 0.000, 201.00, 202.00, 203.00, 1, 0, 1.10000, 0.90000, 1.10000, 0.90000, 1, 0, 0.00000, 0.00000, 0.000
15.9980, 15.998, 0.000, 301.00, 302.00, 303.00, 1, 0, 1.10000, 0.90000, 1.10000, 0.90000, 1, 0, 0.00000, 0.00000, 0.000
3, 5, 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.01120, 100.00
1.00000, 18.000, 0.000,10000.00, 0.00, 0.00,1, 3, 1.05000, 0.95000, 1.10000, 0.95000, 22, 0, 0.00000, 0.00000
1.00000, 18.000
0 / END OF TRANSFORMER DATA, BEGIN AREA DATA
1, 0, 0.000, 1.000,'1 '
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,'1 '
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, BEGIN INDUCTION MACHINE DATA
0 /END OF INDUCTION MACHINE DATA
Q
Original file line number Diff line number Diff line change
Expand Up @@ -18,18 +18,23 @@
* @author Luma Zamarreño {@literal <zamarrenolm at aia.es>}
* @author José Antonio Marqués {@literal <marquesja at aia.es>}
*/
public class PsseFixDuplicateIds {
public class PsseFixes {

private static final Logger LOGGER = LoggerFactory.getLogger(PsseFixDuplicateIds.class);
private static final Logger LOGGER = LoggerFactory.getLogger(PsseFixes.class);
private final PssePowerFlowModel model;
private final PsseVersion version;

public PsseFixDuplicateIds(PssePowerFlowModel model, PsseVersion version) {
public PsseFixes(PssePowerFlowModel model, PsseVersion version) {
this.model = Objects.requireNonNull(model);
this.version = Objects.requireNonNull(version);
}

public void fix() {
fixDuplicatedIds();
fixTransformersWindingCod();
}

private void fixDuplicatedIds() {
fixDuplicatedIds(model.getLoads(), l -> l.getI() + "-" + l.getId(), this::loadFixer);
fixDuplicatedIds(model.getGenerators(), g -> g.getI() + "-" + g.getId(), this::generatorFixer);
fixDuplicatedIds(model.getFixedShunts(), sh -> sh.getI() + "-" + sh.getId(), this::fixedShuntFixer);
Expand All @@ -41,6 +46,18 @@ public void fix() {
}
}

private void fixTransformersWindingCod() {
model.getTransformers().forEach(psseTransformer -> {
if (psseTransformer.getK() == 0) { // TwoWindingsTransformers
fixTransformerWindingCod(psseTransformer, psseTransformer.getWinding1(), "Winding1");
} else {
fixTransformerWindingCod(psseTransformer, psseTransformer.getWinding1(), "Winding1");
fixTransformerWindingCod(psseTransformer, psseTransformer.getWinding2(), "Winding2");
fixTransformerWindingCod(psseTransformer, psseTransformer.getWinding3(), "Winding3");
}
});
}

private String sortedBuses(int... buses) {
Arrays.sort(buses);
return Arrays.toString(buses);
Expand Down Expand Up @@ -137,6 +154,13 @@ private String transformerFixer(PsseTransformer transformer, Set<String> usedIds
return fixedId;
}

private void fixTransformerWindingCod(PsseTransformer transformer, PsseTransformerWinding winding, String windingTag) {
if (Math.abs(winding.getCod()) == 1 && winding.getCont() == 0) {
warn(transformer, windingTag, winding.getCod(), 0);
winding.setCod(0);
}
}

private void warn(String type, int i, String id, String fixedId) {
if (LOGGER.isWarnEnabled()) {
if (id.equals(fixedId)) {
Expand Down Expand Up @@ -167,6 +191,12 @@ private void warn(PsseTransformer transformer, String id, String fixedId) {
}
}

private void warn(PsseTransformer transformer, String windingTag, int cod, int fixedCod) {
if (LOGGER.isWarnEnabled()) {
LOGGER.warn("Transformer {} Cod fixed: I {} J {} K {} CKT {}. Cod '{}' Fixed Cod '{}'. Controlled bus is not defined (cont == 0).", windingTag, transformer.getI(), transformer.getJ(), transformer.getK(), transformer.getCkt(), cod, fixedCod);
}
}

@FunctionalInterface
public interface IdFixer<T> {
String fix(T t, Set<String> usedIds);
Expand Down