Skip to content

Commit

Permalink
disconnect flow and return system in connectivity check
Browse files Browse the repository at this point in the history
  • Loading branch information
SimonRubenDrauz committed Nov 8, 2024
1 parent 63036f2 commit 61511bc
Showing 1 changed file with 8 additions and 6 deletions.
14 changes: 8 additions & 6 deletions src/pandapipes/pf/pipeflow_setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
from scipy.sparse import coo_matrix, csgraph

from pandapipes.idx_branch import FROM_NODE, TO_NODE, branch_cols, MDOTINIT, \
ACTIVE as ACTIVE_BR, IGN, ACTIVE
ACTIVE as ACTIVE_BR, IGN, ACTIVE, BRANCH_TYPE, CIRC
from pandapipes.idx_node import NODE_TYPE, P, NODE_TYPE_T, node_cols, T, ACTIVE as ACTIVE_ND, \
TABLE_IDX as TABLE_IDX_ND, ELEMENT_IDX as ELEMENT_IDX_ND, INFEED
from pandapipes.pf.internals_toolbox import _sum_by_group
Expand Down Expand Up @@ -620,15 +620,17 @@ def check_connectivity(net, branch_pit, node_pit, mode="hydraulics"):
def perform_connectivity_search(net, node_pit, branch_pit, slack_nodes, active_node_lookup, active_branch_lookup,
mode="hydraulics"):
ign = branch_pit[:, IGN].astype(bool)
active_branch_lookup = active_branch_lookup & ~ign
circ = branch_pit[:, BRANCH_TYPE] == CIRC
if np.any(circ) and mode == 'hydraulics':
active_branch_lookup = active_branch_lookup & ~ign
nodes_connected, branches_connected = (
_connectivity(net, branch_pit, node_pit, active_branch_lookup, active_node_lookup, slack_nodes, mode))
if any(ign) and mode == 'hydraulics':
if np.any(ign) and mode == 'hydraulics':
from_nodes = branch_pit[:, FROM_NODE].astype(np.int32)
to_nodes = branch_pit[:, TO_NODE].astype(np.int32)
branch_active = branch_pit[:, ACTIVE].astype(bool)
active = nodes_connected[from_nodes] & nodes_connected[to_nodes] & branch_active
branches_connected[ign & ~active] = False
branches_connected[ign & active] = True
return nodes_connected, branches_connected


Expand Down Expand Up @@ -789,11 +791,11 @@ def reduce_pit(net, mode="hydraulics"):

def check_infeed_number(node_pit):
slack_nodes = node_pit[:, NODE_TYPE_T] == T
if len(node_pit) == 1:
if len(node_pit) == np.sum(slack_nodes):
node_pit[slack_nodes, INFEED] = True
infeed_nodes = node_pit[:, INFEED]
if np.sum(infeed_nodes) != np.sum(slack_nodes):
raise PipeflowNotConverged(r'The number of infeeding nodes and slacks do not match')
logger.warning(r'The number of infeeding nodes and slacks do not match. This might cause problems.')


class PipeflowNotConverged(ppException):
Expand Down

0 comments on commit 61511bc

Please sign in to comment.