diff --git a/doc/Changelog.md b/doc/Changelog.md index 989833d6..3ed1192a 100644 --- a/doc/Changelog.md +++ b/doc/Changelog.md @@ -4,6 +4,7 @@ **In development** +* [PR104](https://github.com/RoseauTechnologies/Roseau_Load_Flow/pull/104) Remove `roseau.load_flow.utils.BranchType` * [GH99](https://github.com/RoseauTechnologies/Roseau_Load_Flow/issues/99) Add `Line.res_series_currents` and `Line.res_shunt_currents` properties to get the currents in the series and shunt components of lines. Also added `ElectricalNetwork.res_lines` that contains the series losses and currents diff --git a/roseau/load_flow/models/branches.py b/roseau/load_flow/models/branches.py index 15b13214..b83185bb 100644 --- a/roseau/load_flow/models/branches.py +++ b/roseau/load_flow/models/branches.py @@ -10,7 +10,6 @@ from roseau.load_flow.models.core import Element from roseau.load_flow.typing import Id, JsonDict from roseau.load_flow.units import Q_, ureg_wraps -from roseau.load_flow.utils import BranchType logger = logging.getLogger(__name__) @@ -24,7 +23,7 @@ class AbstractBranch(Element): :doc:`Switch model documentation ` """ - branch_type: BranchType + branch_type: str def __init__( self, @@ -130,7 +129,7 @@ def from_dict(cls, data: JsonDict) -> Self: def to_dict(self) -> JsonDict: res = { "id": self.id, - "type": str(self.branch_type), + "type": self.branch_type, "phases1": self.phases1, "phases2": self.phases2, "bus1": self.bus1.id, diff --git a/roseau/load_flow/models/lines/lines.py b/roseau/load_flow/models/lines/lines.py index 178278f3..7adf47b3 100644 --- a/roseau/load_flow/models/lines/lines.py +++ b/roseau/load_flow/models/lines/lines.py @@ -14,7 +14,6 @@ from roseau.load_flow.models.sources import VoltageSource from roseau.load_flow.typing import Id, JsonDict from roseau.load_flow.units import Q_, ureg_wraps -from roseau.load_flow.utils import BranchType logger = logging.getLogger(__name__) @@ -26,7 +25,7 @@ class Switch(AbstractBranch): :doc:`Switch model documentation ` """ - branch_type = BranchType.SWITCH + branch_type = "switch" allowed_phases = frozenset(Bus.allowed_phases | {"a", "b", "c", "n"}) """The allowed phases for a switch are: @@ -135,7 +134,7 @@ class Line(AbstractBranch): :doc:`Line documentation ` """ - branch_type = BranchType.LINE + branch_type = "line" allowed_phases = frozenset(Bus.allowed_phases | {"a", "b", "c", "n"}) """The allowed phases for a line are: diff --git a/roseau/load_flow/models/transformers/transformers.py b/roseau/load_flow/models/transformers/transformers.py index 34bd5b6c..c3adcbd7 100644 --- a/roseau/load_flow/models/transformers/transformers.py +++ b/roseau/load_flow/models/transformers/transformers.py @@ -8,7 +8,6 @@ from roseau.load_flow.models.buses import Bus from roseau.load_flow.models.transformers.parameters import TransformerParameters from roseau.load_flow.typing import Id, JsonDict -from roseau.load_flow.utils import BranchType logger = logging.getLogger(__name__) @@ -22,7 +21,7 @@ class Transformer(AbstractBranch): :doc:`Transformer models documentation ` """ - branch_type = BranchType.TRANSFORMER + branch_type = "transformer" allowed_phases = Bus.allowed_phases """The allowed phases for a transformer are: diff --git a/roseau/load_flow/utils/__init__.py b/roseau/load_flow/utils/__init__.py index b13638af..ac07102f 100644 --- a/roseau/load_flow/utils/__init__.py +++ b/roseau/load_flow/utils/__init__.py @@ -3,7 +3,7 @@ """ from roseau.load_flow.utils.constants import CX, DELTA_P, EPSILON_0, EPSILON_R, MU_0, MU_R, OMEGA, PI, RHO, TAN_D, F from roseau.load_flow.utils.mixins import Identifiable, JsonMixin -from roseau.load_flow.utils.types import BranchType, ConductorType, InsulationType, LineModel, LineType +from roseau.load_flow.utils.types import ConductorType, InsulationType, LineModel, LineType __all__ = [ # Constants @@ -26,5 +26,4 @@ "LineModel", "ConductorType", "InsulationType", - "BranchType", ] diff --git a/roseau/load_flow/utils/types.py b/roseau/load_flow/utils/types.py index 0d014f93..abb8e265 100644 --- a/roseau/load_flow/utils/types.py +++ b/roseau/load_flow/utils/types.py @@ -300,45 +300,3 @@ def without_shunt(cls) -> tuple["LineModel", ...]: The tuple of line models which do not support the shunt. """ return cls.Z_NEUTRAL, cls.Z - - -@unique -class BranchType(Enum): - """The type of 'line' in a network.""" - - LINE = auto() - """The branch is a regular line.""" - TRANSFORMER = auto() - """The branch is a regular transformer.""" - SWITCH = auto() - """The branch is a regular switch.""" - - def __str__(self) -> str: - """Print a `BranchType`. - - Returns: - A printable string of the connection type. - """ - return self.name.lower() - - @classmethod - def from_string(cls, string: str) -> Self: - """Convert a string into a ConnectionType - - Args: - string: - The string to convert - - Returns: - The corresponding ConnectionType. - """ - if string == "line": - return cls.LINE - elif string == "transformer": - return cls.TRANSFORMER - elif string == "switch": - return cls.SWITCH - else: - msg = f"The string {string!r} cannot be converted into a BranchType." - logger.error(msg) - raise RoseauLoadFlowException(msg=msg, code=RoseauLoadFlowExceptionCode.BAD_BRANCH_TYPE)