Skip to content

Commit

Permalink
fix error creating branches of type PowerTransformer
Browse files Browse the repository at this point in the history
Signed-off-by: Martin Moraga <martin.moraga@eonerc.rwth-aachen.de>
  • Loading branch information
martinmoraga committed Feb 23, 2024
1 parent 787c04f commit 302b45e
Showing 1 changed file with 15 additions and 12 deletions.
27 changes: 15 additions & 12 deletions pyvolt/network.py
Original file line number Diff line number Diff line change
Expand Up @@ -220,16 +220,16 @@ def load_cim_data(self, res, base_apparent_power):
self.branches.append(Branch(uuid=uuid_ACLineSegment, r=ACLineSegment.r, x=ACLineSegment.x,
start_node=start_node, end_node=end_node,
base_voltage=base_voltage, base_apparent_power=base_apparent_power))

#create branches type powerTransformer
for power_transformer in list_PowerTransformer:
uuid_power_transformer = power_transformer.mRID
nodes = self._get_nodes(list_Terminals, uuid_power_transformer)
start_node = nodes[0]
end_node = nodes[1]

# base voltage = high voltage side (=primaryConnection)
primary_connection = self._get_primary_connection(list_PowerTransformerEnds, uuid_power_transformer)
primary_connection = self._get_PowerTransformerEnd(list_PowerTransformerEnds, uuid_power_transformer)
base_voltage = primary_connection.BaseVoltage.nominalVoltage
self.branches.append(Branch(uuid=uuid_power_transformer, r=primary_connection.r, x=primary_connection.x,
start_node=start_node, end_node=end_node, base_voltage=base_voltage,
Expand Down Expand Up @@ -284,9 +284,9 @@ def _get_nodes(self, list_Terminals, elem_uuid):

return [start_node, end_node]

def _get_primary_connection(self, list_PowerTransformerEnds, elem_uuid):
def _get_PowerTransformerEnd(self, list_PowerTransformerEnds, elem_uuid):
"""
get primaryConnection of the powertransformer with uuid = elem_uuid
get PowerTransformerEnd with x>0, r>0 of the powertransformer with uuid = elem_uuid
:param list_PowerTransformerEnds: list of all elements of type PowerTransformerEnd
:param elem_uuid: uuid of the power transformer for which the primary connection is searched
:return: primary_connection
Expand All @@ -307,13 +307,16 @@ def _get_primary_connection(self, list_PowerTransformerEnds, elem_uuid):

if power_transformer.mRID == elem_uuid:
power_transformer_ends.append(power_transformer_end)

if power_transformer_ends[0].BaseVoltage.nominalVoltage >= \
power_transformer_ends[1].BaseVoltage.nominalVoltage:
primary_connection=power_transformer_ends[0]
elif power_transformer_ends[1].BaseVoltage.nominalVoltage >= \
power_transformer_ends[0].BaseVoltage.nominalVoltage:
primary_connection=power_transformer_ends[1]

if (len(power_transformer_ends)==0):
raise Exception('ERROR: No PowerTransformerEnd connected to the PowerTransformer UUID={} could be found!'.format(elem_uuid))

if (power_transformer_ends[0].r>0 or power_transformer_ends[0].x>0):
primary_connection = power_transformer_ends[0]
elif (power_transformer_ends[1].r>0 or power_transformer_ends[1].x>0):
primary_connection = power_transformer_ends[1]
else:
raise Exception('ERROR: The impedances of the PT UUID={} are equal to zero!'.format(elem_uuid))

return primary_connection

Expand Down

0 comments on commit 302b45e

Please sign in to comment.