e2nIEE / pandapipes

@@ -120,3 +120,10 @@
Loading
120 120
            if isinstance(net[name + '_geodata'], list):
121 121
                net[name + '_geodata'] = pd.DataFrame(np.zeros(0, dtype=net[name + '_geodata']),
122 122
                                                      index=[])
123 +
124 +
125 +
def set_entry_check_repeat(pit, column, entry, repeat_number, repeated=True):
126 +
    if repeated:
127 +
        pit[:, column] = np.repeat(entry, repeat_number)
128 +
    else:
129 +
        pit[:, column] = entry

@@ -7,14 +7,14 @@
Loading
7 7
from numpy import dtype
8 8
from pandapipes.component_models.abstract_models import BranchWInternalsComponent
9 9
from pandapipes.component_models.auxiliaries.component_toolbox import p_correction_height_air, \
10 -
    vinterp
10 +
    vinterp, set_entry_check_repeat
11 11
from pandapipes.component_models.junction_component import Junction
12 12
from pandapipes.constants import NORMAL_TEMPERATURE, NORMAL_PRESSURE
13 -
from pandapipes.idx_branch import FROM_NODE, TO_NODE, LENGTH, D, AREA, K, \
14 -
    VINIT, ALPHA, QEXT, TEXT, LOSS_COEFFICIENT as LC, T_OUT, PL, TL
13 +
from pandapipes.idx_branch import FROM_NODE, TO_NODE, LENGTH, D, AREA, K, VINIT, ALPHA, QEXT, TEXT,\
14 +
    LOSS_COEFFICIENT as LC, T_OUT, PL, TL
15 15
from pandapipes.idx_node import PINIT, HEIGHT, TINIT as TINIT_NODE, \
16 16
    RHO as RHO_NODES, PAMB, ACTIVE as ACTIVE_ND
17 -
from pandapipes.pipeflow_setup import get_net_option, get_fluid, get_lookup
17 +
from pandapipes.pipeflow_setup import get_fluid, get_lookup
18 18
19 19
try:
20 20
    import pplog as logging
@@ -75,12 +75,12 @@
Loading
75 75
        if np.any(internal_nodes > 0):
76 76
            internal_nodes_lookup["TPINIT"] = np.empty((int_nodes_num, 2), dtype=np.int32)
77 77
            internal_nodes_lookup["TPINIT"][:, 0] = np.repeat(net[cls.table_name()].index,
78 -
                                                              internal_nodes)
78 +
                                                              internal_nodes.astype(np.int32))
79 79
            internal_nodes_lookup["TPINIT"][:, 1] = np.arange(current_start, end)
80 80
81 81
            internal_nodes_lookup["VINIT"] = np.empty((int_pipes_num, 2), dtype=np.int32)
82 82
            internal_nodes_lookup["VINIT"][:, 0] = np.repeat(net[cls.table_name()].index,
83 -
                                                             internal_pipes)
83 +
                                                             internal_pipes.astype(np.int32))
84 84
            internal_nodes_lookup["VINIT"][:, 1] = np.arange(int_pipes_num)
85 85
86 86
        return end, current_table
@@ -130,21 +130,26 @@
Loading
130 130
        pipe_pit, internal_pipe_number = \
131 131
            super().create_pit_branch_entries(net, pipe_pit, node_name)
132 132
133 -
        pipe_pit[:, LENGTH] = np.repeat(net[cls.table_name()].length_km.values * 1000 /
134 -
                                        internal_pipe_number, internal_pipe_number)
135 -
        pipe_pit[:, K] = np.repeat(net[cls.table_name()].k_mm.values / 1000,
136 -
                                   internal_pipe_number)
133 +
        has_internals = np.any(internal_pipe_number > 1)
134 +
        tbl = cls.table_name()
135 +
        set_entry_check_repeat(
136 +
            pipe_pit, LENGTH, net[tbl].length_km.values * 1000 / internal_pipe_number,
137 +
            internal_pipe_number, has_internals)
138 +
        set_entry_check_repeat(
139 +
            pipe_pit, K, net[tbl].k_mm.values / 1000, internal_pipe_number, has_internals)
140 +
        set_entry_check_repeat(
141 +
            pipe_pit, ALPHA, net[tbl].alpha_w_per_m2k.values, internal_pipe_number, has_internals)
142 +
        set_entry_check_repeat(
143 +
            pipe_pit, QEXT, net[tbl].qext_w.values, internal_pipe_number, has_internals)
144 +
        set_entry_check_repeat(
145 +
            pipe_pit, TEXT, net[tbl].text_k.values, internal_pipe_number, has_internals)
146 +
        set_entry_check_repeat(
147 +
            pipe_pit, D, net[tbl].diameter_m.values, internal_pipe_number, has_internals)
148 +
        set_entry_check_repeat(
149 +
            pipe_pit, LC, net[tbl].loss_coefficient.values, internal_pipe_number, has_internals)
150 +
137 151
        pipe_pit[:, T_OUT] = 293
138 -
        pipe_pit[:, ALPHA] = np.repeat(net[cls.table_name()].alpha_w_per_m2k.values,
139 -
                                       internal_pipe_number)
140 -
        pipe_pit[:, QEXT] = np.repeat(net[cls.table_name()].qext_w.values,
141 -
                                      internal_pipe_number)
142 -
        pipe_pit[:, TEXT] = np.repeat(net[cls.table_name()].text_k.values,
143 -
                                      internal_pipe_number)
144 -
        pipe_pit[:, D] = np.repeat(net[cls.table_name()].diameter_m.values, internal_pipe_number)
145 152
        pipe_pit[:, AREA] = pipe_pit[:, D] ** 2 * np.pi / 4
146 -
        pipe_pit[:, LC] = np.repeat(net[cls.table_name()].loss_coefficient.values,
147 -
                                    internal_pipe_number)
148 153
149 154
    @classmethod
150 155
    def calculate_pressure_lift(cls, net, pipe_pit, node_pit):
@@ -235,11 +240,11 @@
Loading
235 240
                                  2 / 3 * (p_from ** 3 - p_to ** 3) / (p_from ** 2 - p_to ** 2))
236 241
                numerator = NORMAL_PRESSURE * node_pit[v_nodes, TINIT_NODE]
237 242
                normfactor_mean = numerator * fluid.get_property("compressibility", p_mean) \
238 -
                                  / (p_mean * NORMAL_TEMPERATURE)
243 +
                    / (p_mean * NORMAL_TEMPERATURE)
239 244
                normfactor_from = numerator * fluid.get_property("compressibility", p_from) \
240 -
                                  / (p_from * NORMAL_TEMPERATURE)
245 +
                    / (p_from * NORMAL_TEMPERATURE)
241 246
                normfactor_to = numerator * fluid.get_property("compressibility", p_to) \
242 -
                                  / (p_to * NORMAL_TEMPERATURE)
247 +
                    / (p_to * NORMAL_TEMPERATURE)
243 248
244 249
                v_pipe_data_mean = v_pipe_data * normfactor_mean
245 250
                v_pipe_data_from = v_pipe_data * normfactor_from

@@ -3,8 +3,8 @@
Loading
3 3
# Use of this source code is governed by a BSD-style license that can be found in the LICENSE file.
4 4
5 5
import numpy as np
6 -
7 6
from pandapipes.component_models.abstract_models.branch_models import BranchComponent
7 +
from pandapipes.component_models.auxiliaries.component_toolbox import set_entry_check_repeat
8 8
from pandapipes.constants import NORMAL_PRESSURE, NORMAL_TEMPERATURE
9 9
from pandapipes.idx_branch import ACTIVE
10 10
from pandapipes.idx_branch import FROM_NODE, TO_NODE, TINIT, RHO, ETA, \
@@ -160,28 +160,35 @@
Loading
160 160
161 161
        :param net: The pandapipes network
162 162
        :type net: pandapipesNet
163 -
        :param branch_pit:
164 -
        :type branch_pit:
163 +
        :param branch_winternals_pit:
164 +
        :type branch_winternals_pit:
165 +
        :param node_name:
166 +
        :type node_name:
165 167
        :return: No Output.
166 168
        """
167 169
        branch_winternals_pit, node_pit, from_nodes, to_nodes \
168 170
            = super().create_pit_branch_entries(net, branch_winternals_pit, node_name)
169 171
170 172
        if not len(branch_winternals_pit):
171 -
            return branch_winternals_pit, []
173 +
            return branch_winternals_pit, np.array([], dtype=np.int32)
172 174
173 -
        internal_pipe_number = cls.get_internal_pipe_number(net)
175 +
        internal_pipe_number = cls.get_internal_pipe_number(net).astype(np.int32)
174 176
        node_ft_lookups = get_lookup(net, "node", "from_to")
175 177
176 -
        if cls.internal_node_name() in node_ft_lookups:
178 +
        has_internals = cls.internal_node_name() in node_ft_lookups
179 +
        if has_internals:
177 180
            pipe_nodes_from, pipe_nodes_to = node_ft_lookups[cls.internal_node_name()]
178 181
            pipe_nodes_idx = np.arange(pipe_nodes_from, pipe_nodes_to)
179 182
            insert_places = np.repeat(np.arange(len(from_nodes)), internal_pipe_number - 1)
180 183
            from_nodes = np.insert(from_nodes, insert_places + 1, pipe_nodes_idx)
181 184
            to_nodes = np.insert(to_nodes, insert_places, pipe_nodes_idx)
182 185
183 -
        branch_winternals_pit[:, ELEMENT_IDX] = np.repeat(net[cls.table_name()].index.values,
184 -
                                                          internal_pipe_number)
186 +
        set_entry_check_repeat(
187 +
            branch_winternals_pit, ELEMENT_IDX, net[cls.table_name()].index.values,
188 +
            internal_pipe_number, has_internals)
189 +
        set_entry_check_repeat(
190 +
            branch_winternals_pit, ACTIVE, net[cls.table_name()][cls.active_identifier()].values,
191 +
            internal_pipe_number, has_internals)
185 192
        branch_winternals_pit[:, FROM_NODE] = from_nodes
186 193
        branch_winternals_pit[:, TO_NODE] = to_nodes
187 194
        branch_winternals_pit[:, TINIT] = (node_pit[from_nodes, TINIT_NODE] + node_pit[
@@ -190,8 +197,6 @@
Loading
190 197
        branch_winternals_pit[:, RHO] = fluid.get_density(branch_winternals_pit[:, TINIT])
191 198
        branch_winternals_pit[:, ETA] = fluid.get_viscosity(branch_winternals_pit[:, TINIT])
192 199
        branch_winternals_pit[:, CP] = fluid.get_heat_capacity(branch_winternals_pit[:, TINIT])
193 -
        branch_winternals_pit[:, ACTIVE] = \
194 -
            np.repeat(net[cls.table_name()][cls.active_identifier()].values, internal_pipe_number)
195 200
196 201
        return branch_winternals_pit, internal_pipe_number
197 202
@@ -237,7 +242,7 @@
Loading
237 242
        :return:
238 243
        :rtype:
239 244
        """
240 -
        return net[cls.table_name()].sections.values
245 +
        return np.array(net[cls.table_name()].sections.values)
241 246
242 247
    @classmethod
243 248
    def get_internal_results(cls, net, branch):

@@ -9,6 +9,7 @@
Loading
9 9
from pandapower.control.util.diagnostic import control_diagnostic
10 10
from pandapower.timeseries.run_time_series import get_recycle_settings, init_time_steps, output_writer_routine, \
11 11
    print_progress_bar, cleanup, run_loop, init_default_outputwriter as init_default_ow_pp, init_output_writer
12 +
import tqdm
12 13
13 14
try:
14 15
    import pplog
@@ -91,7 +92,7 @@
Loading
91 92
92 93
    if logger.level != 10 and verbose:
93 94
        # simple progress bar
94 -
        print_progress_bar(0, len(time_steps), prefix='Progress:', suffix='Complete', length=50)
95 +
        ts_variables['progress_bar'] = tqdm.tqdm(total=len(time_steps))
95 96
96 97
    return ts_variables
97 98
Files Coverage
pandapipes 91.06%
setup.py 0.00%
Project Totals (76 files) 90.74%

No yaml found.

Create your codecov.yml to customize your Codecov experience

Sunburst
The inner-most circle is the entire project, moving away from the center are folders then, finally, a single file. The size and color of each slice is representing the number of statements and the coverage, respectively.
Icicle
The top section represents the entire project. Proceeding with folders and finally individual files. The size and color of each slice is representing the number of statements and the coverage, respectively.
Grid
Each block represents a single file in the project. The size and color of each block is represented by the number of statements and the coverage, respectively.
Loading