Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Bugfix/bidirectional #628

Merged
merged 16 commits into from
Nov 7, 2024
Merged
Show file tree
Hide file tree
Changes from 12 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/pandapipes/component_models/flow_control_component.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
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 D, AREA, JAC_DERIV_DP, JAC_DERIV_DP1, JAC_DERIV_DM, MDOTINIT, LOAD_VEC_BRANCHES
from pandapipes.idx_branch import JAC_DERIV_DP, JAC_DERIV_DP1, JAC_DERIV_DM, MDOTINIT, LOAD_VEC_BRANCHES
from pandapipes.pf.result_extraction import extract_branch_results_without_internals


Expand Down
16 changes: 14 additions & 2 deletions src/pandapipes/component_models/heat_consumer_component.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,15 +8,21 @@
from pandapipes.component_models import (get_fluid, BranchWZeroLengthComponent, get_component_array,
standard_branch_wo_internals_result_lookup)
from pandapipes.component_models.junction_component import Junction
from pandapipes.idx_branch import (D, AREA, MDOTINIT, QEXT, JAC_DERIV_DP1, JAC_DERIV_DM,
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)
JAC_DERIV_DTOUT, LOAD_VEC_BRANCHES_T, ACTIVE)
from pandapipes.idx_node import TINIT
from pandapipes.pf.internals_toolbox import get_from_nodes_corrected
from pandapipes.pf.pipeflow_setup import get_lookup
from pandapipes.pf.result_extraction import extract_branch_results_without_internals
from pandapipes.properties.properties_toolbox import get_branch_cp

try:
import pandaplan.core.pplog as logging
except ImportError:
import logging

logger = logging.getLogger(__name__)

class HeatConsumer(BranchWZeroLengthComponent):
"""
Expand Down Expand Up @@ -71,6 +77,12 @@ 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)]
mask_q0 = hc_pit[:, QEXT] == 0 & np.isnan(hc_pit[:, MDOTINIT])
hc_pit[mask_q0, ACTIVE] = False
dlohmeier marked this conversation as resolved.
Show resolved Hide resolved
if any(mask_q0):
logger.warning(r'qext_w is equals to zero for heat consumers with index %s. '
r'Therefore, the defined temperature control cannot be maintained.' \
%net[cls.table_name()].index[mask_q0])
return hc_pit

@classmethod
Expand Down
1 change: 1 addition & 0 deletions src/pandapipes/pf/derivative_calculation.py
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,7 @@ def calculate_derivatives_hydraulic(net, branch_pit, node_pit, options):


def calculate_derivatives_thermal(net, branch_pit, node_pit, _):
node_pit[:, INFEED] = False
fluid = get_fluid(net)
cp = get_branch_cp(fluid, node_pit, branch_pit)
m_init_i = np.abs(branch_pit[:, MDOTINIT])
Expand Down
2 changes: 2 additions & 0 deletions src/pandapipes/pf/pipeflow_setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -775,6 +775,8 @@ 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:
node_pit[slack_nodes, INFEED] = True
infeed_nodes = node_pit[:, INFEED]
if sum(infeed_nodes) != sum(slack_nodes):
dlohmeier marked this conversation as resolved.
Show resolved Hide resolved
raise PipeflowNotConverged(r'The number of infeeding nodes and slacks do not match')
Expand Down
2 changes: 1 addition & 1 deletion src/pandapipes/pipeflow.py
Original file line number Diff line number Diff line change
Expand Up @@ -251,7 +251,7 @@ def solve_hydraulics(net):

x = spsolve(jacobian, epsilon)

branch_pit[:, MDOTINIT] -= x[len(node_pit):len(node_pit) + len(branch_pit)]
branch_pit[:, MDOTINIT] -= x[len(node_pit):len(node_pit) + len(branch_pit)] * options["alpha"]
node_pit[:, PINIT] -= x[:len(node_pit)] * options["alpha"]
node_pit[slack_nodes, MDOTSLACKINIT] -= x[len(node_pit) + len(branch_pit):]

Expand Down
Loading