Skip to content

Commit

Permalink
Error when transformer has null impedance (#262)
Browse files Browse the repository at this point in the history
  • Loading branch information
alihamdan authored Aug 27, 2024
1 parent b056b67 commit ab8c622
Show file tree
Hide file tree
Showing 4 changed files with 19 additions and 0 deletions.
1 change: 1 addition & 0 deletions doc/Changelog.md
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ og:description: See what's new in the latest release of Roseau Load Flow !

## Unreleased

- {gh-pr}`262` Raise a proper error when a transformer is defined with null impedance.
- {gh-pr}`259` The cache of the license object was not reset after the activation of a new license key.
- {gh-pr}`258` {gh-pr}`261` Add basic plotting functionality in the new `roseau.load_flow.plotting`
module. The `plot_interactive_map` function plots an electrical network on an interactive map using
Expand Down
1 change: 1 addition & 0 deletions roseau/load_flow/exceptions.py
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@ class RoseauLoadFlowExceptionCode(StrEnum):
BAD_TRANSFORMER_WINDINGS = auto()
BAD_TRANSFORMER_TYPE = auto()
BAD_TRANSFORMER_VOLTAGES = auto()
BAD_TRANSFORMER_IMPEDANCE = auto()
BAD_TRANSFORMER_PARAMETERS = auto()

# Switch
Expand Down
12 changes: 12 additions & 0 deletions roseau/load_flow/models/tests/test_transformer_parameters.py
Original file line number Diff line number Diff line change
Expand Up @@ -771,3 +771,15 @@ def test_compute_open_short_circuit_parameters():
psc, vsc = tp._compute_short_circuit_parameters()
assert np.isclose(psc.m, tp.psc.m, rtol=0.001)
assert np.isclose(vsc.m, tp.vsc.m)


def test_ideal_transformer():
# Ideal transformer not yet supported
with pytest.raises(RoseauLoadFlowException) as e:
TransformerParameters(id="test", type="Dyn11", sn=50e3, uhv=20e3, ulv=400, z2=0.0, ym=0.0)
assert e.value.msg == (
"Transformer type 'test' has a null series impedance z2. Ideal transformers are not supported."
)
assert e.value.code == RoseauLoadFlowExceptionCode.BAD_TRANSFORMER_IMPEDANCE
# OK
TransformerParameters(id="test", type="Dyn11", sn=50e3, uhv=20e3, ulv=400, z2=0.0000001, ym=0.0)
5 changes: 5 additions & 0 deletions roseau/load_flow/models/transformers/parameters.py
Original file line number Diff line number Diff line change
Expand Up @@ -98,6 +98,11 @@ def __init__(
logger.error(msg)
raise RoseauLoadFlowException(msg=msg, code=RoseauLoadFlowExceptionCode.BAD_TRANSFORMER_VOLTAGES)

if np.isclose(z2, 0.0):
msg = f"Transformer type {id!r} has a null series impedance z2. Ideal transformers are not supported."
logger.error(msg)
raise RoseauLoadFlowException(msg=msg, code=RoseauLoadFlowExceptionCode.BAD_TRANSFORMER_IMPEDANCE)

self._sn: float = sn
self._uhv: float = uhv
self._ulv: float = ulv
Expand Down

0 comments on commit ab8c622

Please sign in to comment.