-
Notifications
You must be signed in to change notification settings - Fork 54
/
heat_exchanger_component.py
132 lines (111 loc) · 4.74 KB
/
heat_exchanger_component.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
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
# Copyright (c) 2020-2023 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.
import numpy as np
from numpy import dtype
from pandapipes.component_models.abstract_models.branch_wzerolength_models import \
BranchWZeroLengthComponent
from pandapipes.component_models.junction_component import Junction
from pandapipes.idx_branch import TL, ALPHA, TEXT, QEXT, T_OUT, D, AREA, LOSS_COEFFICIENT as LC
from pandapipes.pf.pipeflow_setup import get_fluid
from pandapipes.pf.result_extraction import extract_branch_results_without_internals
try:
import pandaplan.core.pplog as logging
except ImportError:
import logging
logger = logging.getLogger(__name__)
logger.setLevel(logging.DEBUG)
class HeatExchanger(BranchWZeroLengthComponent):
@classmethod
def from_to_node_cols(cls):
return "from_junction", "to_junction"
@classmethod
def table_name(cls):
return "heat_exchanger"
@classmethod
def active_identifier(cls):
return "in_service"
@classmethod
def get_connected_node_type(cls):
return Junction
@classmethod
def create_pit_branch_entries(cls, net, branch_pit):
"""
Function which creates pit branch entries with a specific table.
:param net: The pandapipes network
:type net: pandapipesNet
:param branch_pit:
:type branch_pit:
:return: No Output.
"""
heat_exchanger_pit = super().create_pit_branch_entries(net, branch_pit)
heat_exchanger_pit[:, D] = net[cls.table_name()].diameter_m.values
heat_exchanger_pit[:, AREA] = heat_exchanger_pit[:, D] ** 2 * np.pi / 4
heat_exchanger_pit[:, LC] = net[cls.table_name()].loss_coefficient.values
heat_exchanger_pit[:, ALPHA] = 0
heat_exchanger_pit[:, QEXT] = net[cls.table_name()].qext_w.values
heat_exchanger_pit[:, TEXT] = 293.15
heat_exchanger_pit[:, T_OUT] = 307
@classmethod
def extract_results(cls, net, options, branch_results, nodes_connected, branches_connected):
required_results = [
("p_from_bar", "p_from"), ("p_to_bar", "p_to"), ("t_from_k", "temp_from"),
("t_to_k", "temp_to"), ("mdot_to_kg_per_s", "mf_to"), ("mdot_from_kg_per_s", "mf_from"),
("vdot_norm_m3_per_s", "vf"), ("lambda", "lambda"), ("reynolds", "reynolds")
]
if get_fluid(net).is_gas:
required_results.extend([
("v_from_m_per_s", "v_gas_from"), ("v_to_m_per_s", "v_gas_to"),
("v_mean_m_per_s", "v_gas_mean"), ("normfactor_from", "normfactor_from"),
("normfactor_to", "normfactor_to")
])
else:
required_results.extend([("v_mean_m_per_s", "v_mps")])
extract_branch_results_without_internals(net, branch_results, required_results,
cls.table_name(), branches_connected)
@classmethod
def calculate_temperature_lift(cls, net, branch_component_pit, node_pit):
"""
:param net:
:type net:
:param branch_component_pit:
:type branch_component_pit:
:param node_pit:
:type node_pit:
:return:
:rtype:
"""
branch_component_pit[:, TL] = 0
@classmethod
def get_component_input(cls):
"""
:return:
:rtype:
"""
return [("name", dtype(object)),
("from_junction", "u4"),
("to_junction", "u4"),
("diameter_m", "f8"),
("qext_w", 'f8'),
("loss_coefficient", "f8"),
("in_service", 'bool'),
("type", dtype(object))]
@classmethod
def get_result_table(cls, net):
"""
:param net: The pandapipes network
:type net: pandapipesNet
:return: (columns, all_float) - the column names and whether they are all float type. Only
if False, returns columns as tuples also specifying the dtypes
: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"]
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"]
return output, True