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

Made some node entries more global than just in pipe #602

Merged
merged 1 commit into from
Apr 4, 2024
Merged
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
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,11 @@
import numpy as np

from pandapipes.component_models.abstract_models.branch_models import BranchComponent
from pandapipes.component_models.component_toolbox import set_entry_check_repeat
from pandapipes.component_models.component_toolbox import set_entry_check_repeat, vinterp, \
p_correction_height_air
from pandapipes.idx_branch import ACTIVE, FROM_NODE, TO_NODE, RHO, ETA, CP, ELEMENT_IDX, TOUTINIT
from pandapipes.idx_node import L, node_cols, TINIT as TINIT_NODE
from pandapipes.idx_node import (L, node_cols, TINIT as TINIT_NODE, HEIGHT, PINIT, PAMB,
ACTIVE as ACTIVE_ND)
from pandapipes.pf.pipeflow_setup import add_table_lookup, get_lookup, get_table_number
from pandapipes.properties.fluids import get_fluid

Expand Down Expand Up @@ -158,6 +160,17 @@ def create_pit_node_entries(cls, net, node_pit):
junction_indices = get_lookup(net, "node", "index")[junction_table_name]
fj_nodes = junction_indices[from_junctions]
tj_nodes = junction_indices[to_junctions]

int_node_pit[:, HEIGHT] = vinterp(junction_pit[fj_nodes, HEIGHT],
junction_pit[tj_nodes, HEIGHT], int_node_number)
int_node_pit[:, PINIT] = vinterp(junction_pit[fj_nodes, PINIT],
junction_pit[tj_nodes, PINIT], int_node_number)
int_node_pit[:, TINIT_NODE] = vinterp(junction_pit[fj_nodes, TINIT_NODE],
junction_pit[tj_nodes, TINIT_NODE],
int_node_number)
int_node_pit[:, PAMB] = p_correction_height_air(int_node_pit[:, HEIGHT])
int_node_pit[:, ACTIVE_ND] = \
np.repeat(net[cls.table_name()][cls.active_identifier()].values, int_node_number)
return table_nr, int_node_number, int_node_pit, junction_pit, fj_nodes, tj_nodes

@classmethod
Expand Down
43 changes: 7 additions & 36 deletions src/pandapipes/component_models/pipe_component.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,18 +5,17 @@
import matplotlib.pyplot as plt
import numpy as np
from numpy import dtype

from pandapipes.component_models.abstract_models import BranchWInternalsComponent
from pandapipes.component_models.component_toolbox import p_correction_height_air, \
vinterp, set_entry_check_repeat
from pandapipes.component_models.component_toolbox import set_entry_check_repeat
from pandapipes.component_models.junction_component import Junction
from pandapipes.constants import NORMAL_TEMPERATURE, NORMAL_PRESSURE
from pandapipes.idx_branch import FROM_NODE, TO_NODE, LENGTH, D, AREA, K, \
VINIT, ALPHA, QEXT, TEXT, LOSS_COEFFICIENT as LC
from pandapipes.idx_node import PINIT, HEIGHT, TINIT as TINIT_NODE, \
RHO as RHO_NODES, PAMB, ACTIVE as ACTIVE_ND
from pandapipes.idx_branch import (FROM_NODE, TO_NODE, LENGTH, D, AREA, K, VINIT,
ALPHA, QEXT, TEXT, LOSS_COEFFICIENT as LC)
from pandapipes.idx_node import PINIT, TINIT as TINIT_NODE, PAMB
from pandapipes.pf.pipeflow_setup import get_fluid, get_lookup
from pandapipes.pf.result_extraction import extract_branch_results_with_internals, \
extract_branch_results_without_internals
from pandapipes.pf.result_extraction import (extract_branch_results_with_internals,
extract_branch_results_without_internals)

try:
import pandaplan.core.pplog as logging
Expand Down Expand Up @@ -91,34 +90,6 @@ def create_node_lookups(cls, net, ft_lookups, table_lookup, idx_lookups, current

return end, current_table

@classmethod
def create_pit_node_entries(cls, net, node_pit):
"""
Function which creates pit node entries.

:param net: The pandapipes network
:type net: pandapipesNet
:param node_pit:
:type node_pit:
:return: No Output.
"""
table_nr, int_node_number, int_node_pit, junction_pit, fj_nodes, tj_nodes = \
super().create_pit_node_entries(net, node_pit)
if table_nr is None:
return
get_lookup(net, "node", "index")
int_node_pit[:, HEIGHT] = vinterp(junction_pit[fj_nodes, HEIGHT],
junction_pit[tj_nodes, HEIGHT], int_node_number)
int_node_pit[:, PINIT] = vinterp(junction_pit[fj_nodes, PINIT],
junction_pit[tj_nodes, PINIT], int_node_number)
int_node_pit[:, TINIT_NODE] = vinterp(junction_pit[fj_nodes, TINIT_NODE],
junction_pit[tj_nodes, TINIT_NODE],
int_node_number)
int_node_pit[:, PAMB] = p_correction_height_air(int_node_pit[:, HEIGHT])
int_node_pit[:, RHO_NODES] = get_fluid(net).get_density(int_node_pit[:, TINIT_NODE])
int_node_pit[:, ACTIVE_ND] = \
np.repeat(net[cls.table_name()][cls.active_identifier()].values, int_node_number)

@classmethod
def create_pit_branch_entries(cls, net, branch_pit):
"""
Expand Down
Loading