1
# Copyright (c) 2020 by Fraunhofer Institute for Energy Economics
2
# and Energy System Technology (IEE), Kassel. All rights reserved.
3
# Use of this source code is governed by a BSD-style license that can be found in the LICENSE file.
4

5 1
from pandapipes.component_models.abstract_models.branch_models import BranchComponent
6

7 1
from pandapipes.idx_branch import FROM_NODE, TO_NODE, TINIT, ELEMENT_IDX, RHO, ETA, CP, ACTIVE
8 1
from pandapipes.idx_node import TINIT as TINIT_NODE
9

10 1
from pandapipes.pipeflow_setup import add_table_lookup
11 1
from pandapipes.properties.fluids import get_fluid
12

13 1
try:
14 1
    import pplog as logging
15 1
except ImportError:
16 1
    import logging
17

18 1
logger = logging.getLogger(__name__)
19

20

21 1
class BranchWOInternalsComponent(BranchComponent):
22

23 1
    @classmethod
24
    def create_branch_lookups(cls, net, ft_lookups, table_lookup, idx_lookups, current_table,
25
                              current_start):
26
        """
27
        Function which creates branch lookups.
28

29
        :param net: The pandapipes network
30
        :type net: pandapipesNet
31
        :param ft_lookups:
32
        :type ft_lookups:
33
        :param table_lookup:
34
        :type table_lookup:
35
        :param idx_lookups:
36
        :type idx_lookups:
37
        :param current_table:
38
        :type current_table:
39
        :param current_start:
40
        :type current_start:
41
        :return:
42
        :rtype:
43
        """
44 1
        end = current_start + len(net[cls.table_name()])
45 1
        ft_lookups[cls.table_name()] = (current_start, end)
46 1
        add_table_lookup(table_lookup, cls.table_name(), current_table)
47 1
        return end, current_table + 1
48

49 1
    @classmethod
50
    def create_pit_branch_entries(cls, net, branch_wo_internals_pit, node_name):
51
        """
52
        Function which creates pit branch entries with a specific table.
53

54
        :param net: The pandapipes network
55
        :type net: pandapipesNet
56
        :param branch_wo_internals_pit:
57
        :type branch_wo_internals_pit:
58
        :param node_name:
59
        :type node_name:
60
        :return: No Output.
61
        """
62 1
        branch_wo_internals_pit, node_pit, from_nodes, to_nodes \
63
            = super().create_pit_branch_entries(net, branch_wo_internals_pit, node_name)
64 1
        branch_wo_internals_pit[:, ELEMENT_IDX] = net[cls.table_name()].index.values
65 1
        branch_wo_internals_pit[:, FROM_NODE] = from_nodes
66 1
        branch_wo_internals_pit[:, TO_NODE] = to_nodes
67 1
        branch_wo_internals_pit[:, TINIT] = (node_pit[from_nodes, TINIT_NODE]
68
                                             + node_pit[to_nodes, TINIT_NODE]) / 2
69 1
        fluid = get_fluid(net)
70 1
        branch_wo_internals_pit[:, RHO] = fluid.get_density(branch_wo_internals_pit[:, TINIT])
71 1
        branch_wo_internals_pit[:, ETA] = fluid.get_viscosity(branch_wo_internals_pit[:, TINIT])
72 1
        branch_wo_internals_pit[:, CP] = fluid.get_heat_capacity(branch_wo_internals_pit[:, TINIT])
73 1
        branch_wo_internals_pit[:, ACTIVE] = net[cls.table_name()][cls.active_identifier()].values
74 1
        return branch_wo_internals_pit

Read our documentation on viewing source code .

Loading