Skip to content

Commit

Permalink
Fix case9241pegase.mat import
Browse files Browse the repository at this point in the history
Signed-off-by: Geoffroy Jamgotchian <geoffroy.jamgotchian@rte-france.com>
  • Loading branch information
geofjamg committed Dec 17, 2024
1 parent dbeaa45 commit f8c0a4f
Show file tree
Hide file tree
Showing 5 changed files with 743 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -354,6 +354,9 @@ private static void createBranches(MatpowerModel model, ContainersMapping contai

Branch<?> branch;
if (isTransformer(model, mBranch)) {
// we might have a matpower branch with a phase shift and a 0 ratio (0 in matpower just means undefined)
// we need to create an IIDM transformer but we just in that case fix the ratio to 1
double ratio = mBranch.getRatio() == 0 ? 1 : mBranch.getRatio();
TwoWindingsTransformer newTwt = voltageLevel2.getSubstation()
.orElseThrow(() -> new PowsyblException("Substation null! Transformer must be within a substation"))
.newTwoWindingsTransformer()
Expand All @@ -365,7 +368,7 @@ private static void createBranches(MatpowerModel model, ContainersMapping contai
.setBus2(connectedBus2)
.setConnectableBus2(bus2Id)
.setVoltageLevel2(voltageLevel2Id)
.setRatedU1(voltageLevel1.getNominalV() * mBranch.getRatio())
.setRatedU1(voltageLevel1.getNominalV() * ratio)
.setRatedU2(voltageLevel2.getNominalV())
.setR(mBranch.getR() * zb)
.setX(mBranch.getX() * zb)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -95,6 +95,11 @@ void testCase14WithPhaseShifter() throws IOException {
testCase(MatpowerModelFactory.create14WithPhaseShifter());
}

@Test
void testCase14WithPhaseShifterZeroRatioIssue() throws IOException {
testCase(MatpowerModelFactory.readModelJsonFromResources("ieee14-phase-shifter-zero-ratio-issue.json"));
}

@Test
void testCase14WithPhaseShifterSolved() throws IOException {
testCaseSolved(MatpowerModelFactory.create14WithPhaseShifter());
Expand Down
Loading

0 comments on commit f8c0a4f

Please sign in to comment.