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

Connectivity vlrl #616

Open
wants to merge 2 commits into
base: develop
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all 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
6 changes: 3 additions & 3 deletions doc/source/pipeflow/calculation_modes.rst
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ variations are very small.
The user has to decide if these assumptions are suitable for his purposes. In future, pandapipes
will be extended in order to make sure that calculated temperatures also effect hydraulic fluid
properties. To activate temperature calculation, the pipe flow option "mode" has to be set
to "all" or "heat". If heat is chosen, the user has to provide a solution vector of the hydraulics calculation manually.
to "sequential", "bidirectional" or "heat". If heat is chosen, the user has to provide a solution vector of the hydraulics calculation manually.


Hydraulic calculations for incompressible media
Expand Down Expand Up @@ -92,8 +92,8 @@ In gas flows, the velocity is typically not constant along a pipeline. For this
tables for pipes show more entries in comparison with the result tables for incompressible media.


Temperature calculations (pipeflow option: mode = "all" or mode = "heat")
=========================================================================
Temperature calculations (pipeflow option: mode = "sequential", mode = "bidrectional" or mode = "heat")
=======================================================================================================

Important parameters of the network main components (junctions and pipes) needed for the calculation
are listed in the following table. The :ref:`component section <components>` of this manual contains
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@
import numpy as np

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

try:
import pandaplan.core.pplog as logging
Expand Down Expand Up @@ -89,6 +89,8 @@ def create_pit_branch_entries(cls, net, branch_pit):
to_nodes = junction_idx_lookup[net[cls.table_name()][tn_col].values]
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[:, IGN] = False
return branch_component_pit, node_pit, from_nodes, to_nodes

@classmethod
Expand Down
8 changes: 4 additions & 4 deletions src/pandapipes/component_models/component_toolbox.py
Original file line number Diff line number Diff line change
Expand Up @@ -137,10 +137,10 @@ def set_entry_check_repeat(pit, column, entry, repeat_number, repeated=True):


def set_fixed_node_entries(net, node_pit, junctions, eg_types, p_values, t_values, node_comp,
mode="all"):
mode="sequential"):
junction_idx_lookups = get_lookup(net, "node", "index")[node_comp.table_name()]
for eg_type in ("p", "t"):
if eg_type not in mode and mode != "all":
if eg_type not in mode and mode != "sequential" and mode!= "bidrectional":
continue
if eg_type == "p":
val_col, type_col, eg_count_col, typ, valid_types, values = \
Expand Down Expand Up @@ -200,7 +200,7 @@ def standard_branch_wo_internals_result_lookup(net):
return required_results_hyd, required_results_ht


def get_component_array(net, component_name, component_type="branch", only_active=True):
def get_component_array(net, component_name, component_type="branch", mode='hydraulics', only_active=True):
"""
Returns the internal array of a component.

Expand All @@ -218,5 +218,5 @@ def get_component_array(net, component_name, component_type="branch", only_activ
f_all, t_all = get_lookup(net, component_type, "from_to")[component_name]
if not only_active:
return net["_pit"]["components"][component_name]
in_service_elm = get_lookup(net, component_type, "active_hydraulics")[f_all:t_all]
in_service_elm = get_lookup(net, component_type, "active_%s"%mode)[f_all:t_all]
return net["_pit"]["components"][component_name][in_service_elm]
54 changes: 32 additions & 22 deletions src/pandapipes/component_models/flow_control_component.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,12 +6,15 @@
from numpy import dtype

from pandapipes.component_models.abstract_models import BranchWZeroLengthComponent
from pandapipes.properties import get_fluid
from pandapipes.component_models.component_toolbox import \
standard_branch_wo_internals_result_lookup, get_component_array
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 D, AREA, JAC_DERIV_DP, JAC_DERIV_DP1, JAC_DERIV_DM, MDOTINIT, LOAD_VEC_BRANCHES, IGN, \
FROM_NODE_T, TO_NODE_T
from pandapipes.idx_node import PINIT
from pandapipes.pf.pipeflow_setup import get_lookup
from pandapipes.pf.result_extraction import extract_branch_results_without_internals
from pandapipes.properties import get_fluid


class FlowControlComponent(BranchWZeroLengthComponent):
Expand Down Expand Up @@ -52,6 +55,7 @@ def create_pit_branch_entries(cls, net, branch_pit):
fc_branch_pit[:, D] = net[cls.table_name()].diameter_m.values
fc_branch_pit[:, AREA] = fc_branch_pit[:, D] ** 2 * np.pi / 4
fc_branch_pit[:, MDOTINIT] = net[cls.table_name()].controlled_mdot_kg_per_s.values
fc_branch_pit[net[cls.table_name()].control_active, IGN] = True

@classmethod
def create_component_array(cls, net, component_pits):
Expand All @@ -71,7 +75,6 @@ def create_component_array(cls, net, component_pits):
fc_pit[:, cls.CONTROL_ACTIVE] = tbl.control_active.values
component_pits[cls.table_name()] = fc_pit


@classmethod
def adaption_after_derivatives_hydraulic(cls, net, branch_pit, node_pit, idx_lookups, options):
# set all pressure derivatives to 0 and velocity to 1; load vector must be 0, as no change
Expand All @@ -85,12 +88,26 @@ def adaption_after_derivatives_hydraulic(cls, net, branch_pit, node_pit, idx_loo
fc_branch_pit[active, JAC_DERIV_DM] = 1
fc_branch_pit[active, LOAD_VEC_BRANCHES] = 0

active_ign = get_lookup(net, "node", "active_ign_hydraulics")
active_hyd = get_lookup(net, "node", "active_hydraulics")
mask_ign = False if active_ign is None else active_ign != active_hyd

if np.any(mask_ign):
from_nodes = fc_branch_pit[:, FROM_NODE_T].astype(int)
to_nodes = fc_branch_pit[:, TO_NODE_T].astype(int)
mask = ~active_ign[from_nodes] | ~active_ign[to_nodes]
fc_branch_pit[mask, JAC_DERIV_DP] = 1
fc_branch_pit[mask, JAC_DERIV_DP1] = -1
fc_branch_pit[mask, JAC_DERIV_DM] = 0
fc_branch_pit[mask, LOAD_VEC_BRANCHES] = (
node_pit[from_nodes[mask], PINIT] - node_pit[to_nodes[mask], PINIT])

@classmethod
def extract_results(cls, net, options, branch_results, mode):
required_results_hyd, required_results_ht = standard_branch_wo_internals_result_lookup(net)

extract_branch_results_without_internals(net, branch_results, required_results_hyd,
required_results_ht, cls.table_name(), mode)
extract_branch_results_without_internals(net, branch_results, required_results_hyd, required_results_ht,
cls.table_name(), mode)

@classmethod
def get_component_input(cls):
Expand All @@ -101,14 +118,9 @@ def get_component_input(cls):
:return:
:rtype:
"""
return [("name", dtype(object)),
("from_junction", "u4"),
("to_junction", "u4"),
("controlled_mdot_kg_per_s", "f8"),
("diameter_m", "f8"),
("control_active", "bool"),
("in_service", 'bool'),
("type", dtype(object))]
return [("name", dtype(object)), ("from_junction", "u4"), ("to_junction", "u4"),
("controlled_mdot_kg_per_s", "f8"), ("diameter_m", "f8"), ("control_active", "bool"),
("in_service", 'bool'), ("type", dtype(object))]

@classmethod
def get_result_table(cls, net):
Expand All @@ -123,12 +135,10 @@ def get_result_table(cls, net):
:rtype: (list, bool)
"""
if get_fluid(net).is_gas:
output = ["v_from_m_per_s", "v_to_m_per_s", "v_mean_m_per_s", "p_from_bar", "p_to_bar",
"t_from_k", "t_to_k", "mdot_from_kg_per_s", "mdot_to_kg_per_s",
"vdot_norm_m3_per_s", "reynolds", "lambda", "normfactor_from",
"normfactor_to"]
output = ["v_from_m_per_s", "v_to_m_per_s", "v_mean_m_per_s", "p_from_bar", "p_to_bar", "t_from_k",
"t_to_k", "mdot_from_kg_per_s", "mdot_to_kg_per_s", "vdot_norm_m3_per_s", "reynolds", "lambda",
"normfactor_from", "normfactor_to"]
else:
output = ["v_mean_m_per_s", "p_from_bar", "p_to_bar", "t_from_k", "t_to_k",
"mdot_from_kg_per_s", "mdot_to_kg_per_s", "vdot_norm_m3_per_s", "reynolds",
"lambda"]
output = ["v_mean_m_per_s", "p_from_bar", "p_to_bar", "t_from_k", "t_to_k", "mdot_from_kg_per_s",
"mdot_to_kg_per_s", "vdot_norm_m3_per_s", "reynolds", "lambda"]
return output, True
Loading
Loading