/
branch_wo_internals_models.py
101 lines (83 loc) · 3.56 KB
/
branch_wo_internals_models.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
# Copyright (c) 2020-2021 by Fraunhofer Institute for Energy Economics
# and Energy System Technology (IEE), Kassel, and University of Kassel. All rights reserved.
# Use of this source code is governed by a BSD-style license that can be found in the LICENSE file.
from pandapipes.component_models.abstract_models.branch_models import BranchComponent
from pandapipes.idx_branch import FROM_NODE, TO_NODE, TINIT, ELEMENT_IDX, RHO, ETA, CP, ACTIVE
from pandapipes.idx_node import TINIT as TINIT_NODE
from pandapipes.pipeflow_setup import add_table_lookup
from pandapipes.properties.fluids import get_fluid
try:
import pplog as logging
except ImportError:
import logging
logger = logging.getLogger(__name__)
class BranchWOInternalsComponent(BranchComponent):
@classmethod
def table_name(cls):
raise NotImplementedError
@classmethod
def get_component_input(cls):
raise NotImplementedError
@classmethod
def get_result_table(cls, net):
raise NotImplementedError
@classmethod
def active_identifier(cls):
raise NotImplementedError
@classmethod
def from_to_node_cols(cls):
raise NotImplementedError
@classmethod
def calculate_pressure_lift(cls, net, pipe_pit, node_pit):
raise NotImplementedError
@classmethod
def calculate_temperature_lift(cls, net, pipe_pit, node_pit):
raise NotImplementedError
@classmethod
def create_branch_lookups(cls, net, ft_lookups, table_lookup, idx_lookups, current_table, current_start):
"""
Function which creates branch lookups.
:param net: The pandapipes network
:type net: pandapipesNet
:param ft_lookups:
:type ft_lookups:
:param table_lookup:
:type table_lookup:
:param idx_lookups:
:type idx_lookups:
:param current_table:
:type current_table:
:param current_start:
:type current_start:
:return:
:rtype:
"""
end = current_start + len(net[cls.table_name()])
ft_lookups[cls.table_name()] = (current_start, end)
add_table_lookup(table_lookup, cls.table_name(), current_table)
return end, current_table + 1
@classmethod
def create_pit_branch_entries(cls, net, branch_wo_internals_pit, node_name):
"""
Function which creates pit branch entries with a specific table.
:param net: The pandapipes network
:type net: pandapipesNet
:param branch_wo_internals_pit:
:type branch_wo_internals_pit:
:param node_name:
:type node_name:
:return: No Output.
"""
branch_wo_internals_pit, node_pit, from_nodes, to_nodes \
= super().create_pit_branch_entries(net, branch_wo_internals_pit, node_name)
branch_wo_internals_pit[:, ELEMENT_IDX] = net[cls.table_name()].index.values
branch_wo_internals_pit[:, FROM_NODE] = from_nodes
branch_wo_internals_pit[:, TO_NODE] = to_nodes
branch_wo_internals_pit[:, TINIT] = (node_pit[from_nodes, TINIT_NODE]
+ node_pit[to_nodes, TINIT_NODE]) / 2
fluid = get_fluid(net)
branch_wo_internals_pit[:, RHO] = fluid.get_density(branch_wo_internals_pit[:, TINIT])
branch_wo_internals_pit[:, ETA] = fluid.get_viscosity(branch_wo_internals_pit[:, TINIT])
branch_wo_internals_pit[:, CP] = fluid.get_heat_capacity(branch_wo_internals_pit[:, TINIT])
branch_wo_internals_pit[:, ACTIVE] = net[cls.table_name()][cls.active_identifier()].values
return branch_wo_internals_pit