Skip to content

Commit

Permalink
Merge pull request #668 from retoflow/connectivity_VLRL
Browse files Browse the repository at this point in the history
Connectivity vlrl
  • Loading branch information
SimonRubenDrauz authored Nov 28, 2024
2 parents 27c8c8e + be79a17 commit ab7ecf9
Show file tree
Hide file tree
Showing 5 changed files with 24 additions and 24 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
import numpy as np

from pandapipes.component_models.abstract_models.base_component import Component
from pandapipes.idx_branch import MDOTINIT, branch_cols, TEXT, VLRLCONNECT
from pandapipes.idx_branch import MDOTINIT, branch_cols, TEXT, FLOW_RETURN_CONNECT
from pandapipes.pf.pipeflow_setup import get_table_number, get_lookup, get_net_option

try:
Expand Down Expand Up @@ -90,7 +90,7 @@ def create_pit_branch_entries(cls, net, branch_pit):
branch_component_pit[:, :] = np.array([branch_table_nr] + [0] * (branch_cols - 1))
branch_component_pit[:, MDOTINIT] = 0.1
branch_component_pit[:, TEXT] = get_net_option(net, 'ambient_temperature')
branch_component_pit[:, VLRLCONNECT] = False
branch_component_pit[:, FLOW_RETURN_CONNECT] = False
return branch_component_pit, node_pit, from_nodes, to_nodes

@classmethod
Expand Down
5 changes: 3 additions & 2 deletions src/pandapipes/component_models/flow_control_component.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,8 @@
from pandapipes.component_models.component_toolbox import \
standard_branch_wo_internals_result_lookup, get_component_array
from pandapipes.component_models.junction_component import Junction
from pandapipes.idx_branch import JAC_DERIV_DP, JAC_DERIV_DP1, JAC_DERIV_DM, MDOTINIT, LOAD_VEC_BRANCHES, VLRLCONNECT
from pandapipes.idx_branch import (JAC_DERIV_DP, JAC_DERIV_DP1, JAC_DERIV_DM, MDOTINIT, LOAD_VEC_BRANCHES,
FLOW_RETURN_CONNECT)
from pandapipes.pf.result_extraction import extract_branch_results_without_internals


Expand Down Expand Up @@ -50,7 +51,7 @@ def create_pit_branch_entries(cls, net, branch_pit):
"""
fc_branch_pit = super().create_pit_branch_entries(net, branch_pit)
fc_branch_pit[:, MDOTINIT] = net[cls.table_name()].controlled_mdot_kg_per_s.values
fc_branch_pit[net[cls.table_name()].control_active, VLRLCONNECT] = True
fc_branch_pit[net[cls.table_name()].control_active, FLOW_RETURN_CONNECT] = True

@classmethod
def create_component_array(cls, net, component_pits):
Expand Down
4 changes: 2 additions & 2 deletions src/pandapipes/component_models/heat_consumer_component.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
from pandapipes.component_models.junction_component import Junction
from pandapipes.idx_branch import (MDOTINIT, QEXT, JAC_DERIV_DP1, JAC_DERIV_DM,
JAC_DERIV_DP, LOAD_VEC_BRANCHES, TOUTINIT, JAC_DERIV_DT,
JAC_DERIV_DTOUT, LOAD_VEC_BRANCHES_T, ACTIVE, VLRLCONNECT)
JAC_DERIV_DTOUT, LOAD_VEC_BRANCHES_T, ACTIVE, FLOW_RETURN_CONNECT)
from pandapipes.idx_node import TINIT
from pandapipes.pf.internals_toolbox import get_from_nodes_corrected
from pandapipes.pf.pipeflow_setup import get_lookup
Expand Down Expand Up @@ -77,7 +77,7 @@ def create_pit_branch_entries(cls, net, branch_pit):
hc_pit[~np.isnan(mdot), MDOTINIT] = mdot[~np.isnan(mdot)]
treturn = net[cls.table_name()].treturn_k.values
hc_pit[~np.isnan(treturn), TOUTINIT] = treturn[~np.isnan(treturn)]
hc_pit[:, VLRLCONNECT] = True
hc_pit[:, FLOW_RETURN_CONNECT] = True
mask_q0 = qext == 0 & np.isnan(mdot)
if np.any(mask_q0):
hc_pit[mask_q0, ACTIVE] = False
Expand Down
31 changes: 15 additions & 16 deletions src/pandapipes/idx_branch.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,23 +30,22 @@
MDOTINIT_T = 19
FROM_NODE_T_SWITCHED = 20 # flag to indicate if the from and to node are switched in the thermal calculation
TOUTINIT = 21 # Internal slot for outlet pipe temperature
FLOW_RETURN_CONNECT = 22 # Make sure that return and flow side are connected to the central pump, respectively

JAC_DERIV_DM = 22 # Slot for the derivative by mass
JAC_DERIV_DP = 23 # Slot for the derivative by pressure from_node
JAC_DERIV_DP1 = 24 # Slot for the derivative by pressure to_node
JAC_DERIV_DM_NODE = 25 # Slot for the derivative by mass for the nodes connected to branch
LOAD_VEC_BRANCHES = 26 # Slot for the load vector for the branches
LOAD_VEC_NODES_FROM = 27 # Slot for the load vector of the from nodes connected to branch
LOAD_VEC_NODES_TO = 28 # Slot for the load vector of the to nodes connected to branch
JAC_DERIV_DM = 23 # Slot for the derivative by mass
JAC_DERIV_DP = 24 # Slot for the derivative by pressure from_node
JAC_DERIV_DP1 = 25 # Slot for the derivative by pressure to_node
JAC_DERIV_DM_NODE = 26 # Slot for the derivative by mass for the nodes connected to branch
LOAD_VEC_BRANCHES = 27 # Slot for the load vector for the branches
LOAD_VEC_NODES_FROM = 28 # Slot for the load vector of the from nodes connected to branch
LOAD_VEC_NODES_TO = 29 # Slot for the load vector of the to nodes connected to branch

JAC_DERIV_DT = 29
JAC_DERIV_DTOUT = 30
JAC_DERIV_DT_NODE = 31 # Slot for the node equation derivative of T for the nodes branch is connected to
JAC_DERIV_DTOUT_NODE = 32 # Slot for the node equation derivative of T for the corresponding branch
LOAD_VEC_BRANCHES_T = 33
LOAD_VEC_NODES_FROM_T = 34 # Slot for the load vector of the from nodes connected to branch
LOAD_VEC_NODES_TO_T = 35 # Slot for the load vector of the to nodes connected to branch

VLRLCONNECT = 36
JAC_DERIV_DT = 30
JAC_DERIV_DTOUT = 31
JAC_DERIV_DT_NODE = 32 # Slot for the node equation derivative of T for the nodes branch is connected to
JAC_DERIV_DTOUT_NODE = 33 # Slot for the node equation derivative of T for the corresponding branch
LOAD_VEC_BRANCHES_T = 34
LOAD_VEC_NODES_FROM_T = 35 # Slot for the load vector of the from nodes connected to branch
LOAD_VEC_NODES_TO_T = 36 # Slot for the load vector of the to nodes connected to branch

branch_cols = 37
4 changes: 2 additions & 2 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, VLRLCONNECT, ACTIVE, BRANCH_TYPE, CIRC
ACTIVE as ACTIVE_BR, FLOW_RETURN_CONNECT, 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 @@ -619,7 +619,7 @@ 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"):
connect = branch_pit[:, VLRLCONNECT].astype(bool)
connect = branch_pit[:, FLOW_RETURN_CONNECT].astype(bool)
circ = branch_pit[:, BRANCH_TYPE] == CIRC
if np.any(circ) and mode == 'hydraulics':
active_branch_lookup = active_branch_lookup & ~connect
Expand Down

0 comments on commit ab7ecf9

Please sign in to comment.