Skip to content

Commit

Permalink
update : created tests for two windings transformers copy on a subnet…
Browse files Browse the repository at this point in the history
…work

Signed-off-by: Naledi EL CHEIKH <[email protected]>
  • Loading branch information
Naledi EL CHEIKH committed Jan 15, 2025
1 parent 6f9651c commit 8cf68b9
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -40,8 +40,7 @@ class TwoWindingsTransformerAdderImpl extends AbstractBranchAdder<TwoWindingsTra
TwoWindingsTransformerAdderImpl(SubstationImpl substation, TwoWindingsTransformer copiedTwoWindingsTransformer) {
this.substation = substation;
this.copiedTwoWindingsTransformer = copiedTwoWindingsTransformer;
TwoWindingsTransformerAdderImpl twoWindingsTransformerImpl = this;
TwoWindingsTransformerAdder.fillTwoWindingsTransformerAdder(twoWindingsTransformerImpl, copiedTwoWindingsTransformer);
TwoWindingsTransformerAdder.fillTwoWindingsTransformerAdder(this, copiedTwoWindingsTransformer);
}

@Override
Expand Down Expand Up @@ -161,7 +160,5 @@ public TwoWindingsTransformer add() {
getNetwork().getIndex().checkAndAdd(transformer);
getNetwork().getListeners().notifyCreation(transformer);
return transformer;

}

}
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
import java.util.stream.Stream;

import static org.junit.jupiter.api.Assertions.*;
import static com.powsybl.iidm.network.tck.AbstractTwoWindingsTransformerTest.areTwoWindingsTransformersIdentical;

/**
* @author Olivier Perrin {@literal <olivier.perrin at rte-france.com>}
Expand Down Expand Up @@ -214,7 +215,17 @@ public void testTwoWindingsTransformersCreation() {
addTwoWindingsTransformer(substation1, "twt1", "vl1_0", 380, "vl1_1", 90);

// On subnetwork2
addTwoWindingsTransformer(substation2, "twt2", "vl2_0", 380, "vl2_1", 90);
TwoWindingsTransformer transformer1 = addTwoWindingsTransformer(substation2, "twt2", "vl2_0", 380, "vl2_1", 90);

TwoWindingsTransformer transformer2 = substation2.newTwoWindingsTransformer(transformer1)
.setId("twt3")
.setBus1(getBusId("vl2_0"))
.setBus2(getBusId("vl2_1"))
.add();

// Tests if copy proceeds
assertNotNull(transformer2);
assertTrue(areTwoWindingsTransformersIdentical(transformer1, transformer2));

// Detach all
assertTrue(subnetwork1.isDetachable());
Expand All @@ -224,7 +235,7 @@ public void testTwoWindingsTransformersCreation() {
// - Check Transformers
assertEquals(1, network.getTwoWindingsTransformerCount());
assertEquals(1, n1.getTwoWindingsTransformerCount());
assertEquals(1, n2.getTwoWindingsTransformerCount());
assertEquals(2, n2.getTwoWindingsTransformerCount());
assertNetworks(network, network, network.getTwoWindingsTransformer("twt0"));
assertNetworks(n1, n1, n1.getTwoWindingsTransformer("twt1"));
assertNetworks(n2, n2, n2.getTwoWindingsTransformer("twt2"));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -257,14 +257,12 @@ public void testTwoWindingsTransformersCopier() {
assertNotNull(limits1);

transformer1.getOperationalLimitsGroup1("group1").get().newActivePowerLimits().setPermanentLimit(220.0).add();
transformer1.setSelectedOperationalLimitsGroup1("group1");
Optional<ActivePowerLimits> optionalActivePowerLimits1 = transformer1.getActivePowerLimits1();
assertTrue(optionalActivePowerLimits1.isPresent());
ActivePowerLimits activePowerLimits1 = optionalActivePowerLimits1.get();
assertNotNull(activePowerLimits1);

transformer1.getOperationalLimitsGroup1("group1").get().newApparentPowerLimits().setPermanentLimit(220.0).add();
transformer1.setSelectedOperationalLimitsGroup1("group1");
Optional<ApparentPowerLimits> optionalApparentPowerLimits1 = transformer1.getApparentPowerLimits1();
assertTrue(optionalApparentPowerLimits1.isPresent());
ApparentPowerLimits apparentPowerLimits1 = optionalApparentPowerLimits1.get();
Expand Down

0 comments on commit 8cf68b9

Please sign in to comment.