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
import copy
6

7 1
import pandas as pd
8 1
from numpy import dtype
9 1
from pandapipes import __version__
10 1
from pandapower.auxiliary import ADict
11

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

17 1
logger = logging.getLogger(__name__)
18

19

20 1
class pandapipesNet(ADict):
21 1
    def __init__(self, *args, **kwargs):
22 1
        super().__init__(*args, **kwargs)
23 1
        if isinstance(args[0], self.__class__):
24 0
            net = args[0]
25 0
            self.clear()
26 0
            self.update(**net.deepcopy())
27

28 1
    def deepcopy(self):
29 0
        return copy.deepcopy(self)
30

31
    def __repr__(self):  # pragma: no cover
32
        r = "This pandapipes network includes the following parameter tables:"
33
        par = []
34
        res = []
35
        for tb in list(self.keys()):
36
            if isinstance(self[tb], pd.DataFrame) and len(self[tb]) > 0:
37
                if 'res_' in tb:
38
                    res.append(tb)
39
                else:
40
                    par.append(tb)
41
            elif tb == 'std_type':
42
                par.append(tb)
43
        for tb in par:
44
            r += "\n   - %s (%s elements)" % (tb, len(self[tb]))
45
        if res:
46
            r += "\nand the following results tables:"
47
            for tb in res:
48
                r += "\n   - %s (%s elements)" % (tb, len(self[tb]))
49
        r += "."
50
        if "fluid" in self and self["fluid"] is not None:
51
            r += "\nIt contains the following fluid: \n%s" % self["fluid"]
52
        else:
53
            r += "\nIt does not contain any defined fluid"
54
        if "component_list" in self:
55
            r += "\nand uses the following component models:"
56
            for component in self.component_list:
57
                r += "\n   - %s" %component.__name__
58
        return r
59

60

61 1
def get_default_pandapipes_structure():
62
    """
63

64
    :return:
65
    :rtype:
66
    """
67 1
    default_pandapipes_structure = {
68
        # structure data
69
        # f8, u4 etc. are probably referencing numba or numpy data types
70
        "fluid": None,
71
        "converged": False,
72
        "name": "",
73
        "version": __version__,
74
        "controller": [('object', dtype(object)),
75
                       ('in_service', "bool"),
76
                       ('order', "float64"),
77
                       ('level', dtype(object)),
78
                       ("recycle", "bool")],
79
        "component_list": []}
80 1
    return default_pandapipes_structure

Read our documentation on viewing source code .

Loading