Skip to content

Add method to get the terminal of a 3-winding transformer from one of its voltage level ids #3355

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 3 commits into
base: main
Choose a base branch
from

Conversation

EtienneLt
Copy link
Contributor

@EtienneLt EtienneLt commented Mar 12, 2025

Please check if the PR fulfills these requirements

  • The commit message follows our guidelines
  • Tests for the changes have been added (for bug fixes / features)
  • Docs have been added / updated (for bug fixes / features)
  • A PR or issue has been opened in all impacted repositories (if any)

Does this PR already have an issue describing the problem?
No

What kind of change does this PR introduce?
Feature

What is the new behavior (if this is a feature change)?
Enable to get the terminal of a leg basing on only the voltageLevel's Id

Does this PR introduce a breaking change or deprecate an API?

  • Yes
  • No

Migration steps:
Custom IIDM implementation maintainers should implement the following method in their ThreeWindingsTransformer's implementations:

Terminal getTerminal(String voltageLevelId);

@EtienneLt EtienneLt self-assigned this Mar 12, 2025
Signed-off-by: Etienne LESOT <[email protected]>
@olperr1 olperr1 changed the title add getTerminal(voltageLevelId) for threeWindingsTransformer Add method to get the terminal of a 3-winding transformer from one of its voltage level ids Apr 15, 2025
boolean side2 = getLeg2().getTerminal().getVoltageLevel().getId().equals(voltageLevelId);
boolean side3 = getLeg3().getTerminal().getVoltageLevel().getId().equals(voltageLevelId);
if (side1 && side2 && side3) {
throw new PowsyblException("the three terminals are connected to the same voltage level " + voltageLevelId);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
throw new PowsyblException("the three terminals are connected to the same voltage level " + voltageLevelId);
throw new PowsyblException("The three terminals are connected to the same voltage level " + voltageLevelId);

if (side1 && side2 && side3) {
throw new PowsyblException("the three terminals are connected to the same voltage level " + voltageLevelId);
} else if (side1 && side2 || side3 && side1 || side2 && side3) {
throw new PowsyblException("two of the three terminals are connected to the same voltage level " + voltageLevelId);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
throw new PowsyblException("two of the three terminals are connected to the same voltage level " + voltageLevelId);
throw new PowsyblException("Two of the three terminals are connected to the same voltage level " + voltageLevelId);

.add()
.add();
message = assertThrows(PowsyblException.class, () -> transformer4.getTerminal("vl1")).getMessage();
assertEquals("the three terminals are connected to the same voltage level vl1", message);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
assertEquals("the three terminals are connected to the same voltage level vl1", message);
assertEquals("The three terminals are connected to the same voltage level vl1", message);

assertEquals(transformer.getTerminal("vl1").getBusBreakerView().getConnectableBus(),
transformer.getLeg1().getTerminal().getBusBreakerView().getConnectableBus());
String message = assertThrows(PowsyblException.class, () -> transformer.getTerminal("vl2")).getMessage();
assertEquals("two of the three terminals are connected to the same voltage level vl2", message);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
assertEquals("two of the three terminals are connected to the same voltage level vl2", message);
assertEquals("Two of the three terminals are connected to the same voltage level vl2", message);

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants