e2nIEE / pandapipes
Showing 16 of 46 files from the diff.
Other files ignored by Codecov

@@ -4,9 +4,12 @@
Loading
4 4
5 5
import copy
6 6
7 +
import numpy as np
7 8
import pandas as pd
8 9
from numpy import dtype
9 10
from pandapipes import __version__
11 +
from pandapipes.component_models import Junction, Pipe, ExtGrid
12 +
from pandapipes.component_models.auxiliaries.component_toolbox import add_new_component
10 13
from pandapower.auxiliary import ADict
11 14
12 15
try:
@@ -58,24 +61,27 @@
Loading
58 61
        return r
59 62
60 63
61 -
def get_default_pandapipes_structure():
62 -
    """
63 -
64 -
    :return:
65 -
    :rtype:
66 -
    """
67 -
    default_pandapipes_structure = {
68 -
        # structure data
69 -
        # f8, u4 etc. are probably referencing numba or numpy data types
64 +
def get_basic_net_entries():
65 +
    return {
70 66
        "fluid": None,
71 67
        "converged": False,
72 68
        "name": "",
73 69
        "version": __version__,
74 -
        "controller": [('object', dtype(object)),
70 +
        "component_list": []}
71 +
72 +
73 +
def get_basic_components():
74 +
    return Junction, Pipe, ExtGrid
75 +
76 +
77 +
def add_default_components(net, overwrite=False):
78 +
    for comp in get_basic_components():
79 +
        add_new_component(net, comp, overwrite)
80 +
    if "controller" not in net or overwrite:
81 +
        ctrl_dtypes = [('object', dtype(object)),
75 82
                       ('in_service', "bool"),
76 83
                       ('order', "float64"),
77 84
                       ('level', dtype(object)),
78 85
                       ('initial_run', "bool"),
79 -
                       ("recycle", "bool")],
80 -
        "component_list": []}
81 -
    return default_pandapipes_structure
86 +
                       ("recycle", "bool")]
87 +
        net['controller'] = pd.DataFrame(np.zeros(0, dtype=ctrl_dtypes), index=pd.Int64Index([]))

@@ -3,6 +3,7 @@
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 +
import pandas as pd
6 7
from pandapower.plotting.collections import _create_node_collection, \
7 8
    _create_node_element_collection, _create_line2d_collection, _create_complex_branch_collection, \
8 9
    add_cmap_to_collection, coords_from_node_geodata
@@ -159,6 +160,8 @@
Loading
159 160
    if cmap is not None:
160 161
        if z is None:
161 162
            z = net.res_pipe.v_mean_m_per_s.loc[pipes_with_geo]
163 +
        elif isinstance(z, pd.Series):
164 +
            z = z.loc[pipes_with_geo]
162 165
        add_cmap_to_collection(lc, cmap, norm, z, cbar_title, clim=clim)
163 166
164 167
    return lc

@@ -343,9 +343,8 @@
Loading
343 343
        node_pit = net["_pit"]["node"]
344 344
345 345
        junction_idx_lookup = get_lookup(net, "node", "index")[Junction.table_name()]
346 -
        from_junction_nodes = junction_idx_lookup[net[cls.table_name]["from_junction"].values]
347 -
        to_junction_nodes = junction_idx_lookup[net[cls.table_name]["to_junction"].values]
348 -
346 +
        from_junction_nodes = junction_idx_lookup[net[cls.table_name()]["from_junction"].values]
347 +
        to_junction_nodes = junction_idx_lookup[net[cls.table_name()]["to_junction"].values]
349 348
        p_values = np.zeros(len(pipe_p_data[0]) + 2)
350 349
        p_values[0] = node_pit[from_junction_nodes[pipe], PINIT]
351 350
        p_values[1:-1] = pipe_p_data[:]

@@ -0,0 +1,81 @@
Loading
1 +
# Copyright (c) 2020-2021 by Fraunhofer Institute for Energy Economics
2 +
# and Energy System Technology (IEE), Kassel, and University of 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 +
import networkx as nx
6 +
import pandas as pd
7 +
from pandapipes.topology.create_graph import create_nxgraph
8 +
9 +
10 +
def calc_distance_to_junction(net, junction, notravjunctions=None,
11 +
                              nogojunctions= None, weight="weight"):
12 +
    """
13 +
    Calculates the shortest distance between a source junction and all junctions connected to it.
14 +
15 +
     INPUT:
16 +
        **net** (pandapipesNet) - Variable that contains a pandapipes network.
17 +
18 +
        **junction** (integer) - Index of the source junction.
19 +
20 +
21 +
     OPTIONAL:
22 +
        **nogojunctions** (integer/list, None) - nogojunctions are not being considered
23 +
24 +
        **notravjunctions** (integer/list, None) - lines connected to these junctions are not being
25 +
                                              considered
26 +
        **weight** (string, None) – Edge data key corresponding to the edge weight
27 +
28 +
     OUTPUT:
29 +
        **dist** - Returns a pandas series with containing all distances to the source junction
30 +
                   in km. If weight=None dist is the topological distance (int).
31 +
32 +
     EXAMPLE:
33 +
         import pandapipes.topology as top
34 +
35 +
         dist = top.calc_distance_to_junction(net, 5)
36 +
37 +
    """
38 +
    g = create_nxgraph(net, nogojunctions=nogojunctions,
39 +
                       notravjunctions=notravjunctions)
40 +
    dist = nx.single_source_dijkstra_path_length(g, junction, weight=weight)
41 +
    return pd.Series(dist)
42 +
43 +
def calc_minimum_distance_to_junctions(net, junctions, notravjunctions=None,
44 +
                              nogojunctions=None, weight="weight"):
45 +
    """
46 +
    Calculates the shortest distance between multiple source junctions and all junctions connected to it.
47 +
48 +
     INPUT:
49 +
        **net** (pandapipesNet) - Variable that contains a pandapipes network.
50 +
51 +
        **junction** (integer) - Index of the source junction.
52 +
53 +
54 +
     OPTIONAL:
55 +
        **nogojunctions** (integer/list, None) - nogojunctions are not being considered
56 +
57 +
        **notravjunctions** (integer/list, None) - lines connected to these junctions are not being
58 +
                                              considered
59 +
        **weight** (string, None) – Edge data key corresponding to the edge weight
60 +
61 +
     OUTPUT:
62 +
        **dist** - Returns a pandas series with containing all distances to the source junction
63 +
                   in km. If weight=None dist is the topological distance (int).
64 +
65 +
     EXAMPLE:
66 +
         import pandapipes.topology as top
67 +
68 +
         dist = top.calc_distance_to_junction(net, 5)
69 +
70 +
    """
71 +
    mg = create_nxgraph(net, notravjunctions=notravjunctions,
72 +
                        nogojunctions=nogojunctions, weight=weight)
73 +
    junctions = set(junctions)
74 +
    junction = junctions.pop()
75 +
    mg.add_edges_from([(junction, y, {"weight": 0}) for y in junctions])
76 +
    return pd.Series(nx.single_source_dijkstra_path_length(mg, junction))
77 +
78 +
if __name__ == '__main__':
79 +
    import pandapipes.networks as nw
80 +
    net = nw.gas_meshed_delta()
81 +
    dist = calc_minimum_distance_to_junctions(net, net.ext_grid.junction.values)

@@ -10,7 +10,7 @@
Loading
10 10
from pandapipes.component_models import Junction, Sink, Source, Pump, Pipe, ExtGrid, \
11 11
    HeatExchanger, Valve, CirculationPumpPressure, CirculationPumpMass, PressureControlComponent
12 12
from pandapipes.component_models.auxiliaries.component_toolbox import add_new_component
13 -
from pandapipes.pandapipes_net import pandapipesNet, get_default_pandapipes_structure
13 +
from pandapipes.pandapipes_net import pandapipesNet, get_basic_net_entries, add_default_components
14 14
from pandapipes.properties import call_lib
15 15
from pandapipes.properties.fluids import Fluid, _add_fluid_to_net
16 16
from pandapipes.std_types.std_type import PumpStdType, add_basic_std_types, add_pump_std_type, \
@@ -49,11 +49,8 @@
Loading
49 49
        >>> net2 = create_empty_network()
50 50
51 51
    """
52 -
    net = pandapipesNet(get_default_pandapipes_structure())
53 -
    add_new_component(net, Junction, True)
54 -
    add_new_component(net, Pipe, True)
55 -
    add_new_component(net, ExtGrid, True)
56 -
    net['controller'] = pd.DataFrame(np.zeros(0, dtype=net['controller']), index=[])
52 +
    net = pandapipesNet(get_basic_net_entries())
53 +
    add_default_components(net, True)
57 54
    net['name'] = name
58 55
    if add_stdtypes:
59 56
        add_basic_std_types(net)
@@ -277,7 +274,8 @@
Loading
277 274
    :type to_junction: int
278 275
    :param diameter_m: The heat exchanger inner diameter in [m]
279 276
    :type diameter_m: float
280 -
    :param qext_w: External heat feed-in through the heat exchanger in [W]
277 +
    :param qext_w: External heat flux in [W]. If positive, heat is derived from the network. If
278 +
            negative, heat is being fed into the network from a heat source.
281 279
    :type qext_w: float, default 0.0
282 280
    :param loss_coefficient: An additional pressure loss coefficient, introduced by e.g. bends
283 281
    :type loss_coefficient: float

@@ -0,0 +1,36 @@
Loading
1 +
# Copyright (c) 2020-2021 by Fraunhofer Institute for Energy Economics
2 +
# and Energy System Technology (IEE), Kassel, and University of 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 +
6 +
import pandapipes.topology as top
7 +
import pandas as pd
8 +
9 +
def pressure_profile_to_junction_geodata(net):
10 +
    """
11 +
    Calculates pressure profile for a pandapipes network.
12 +
13 +
     INPUT:
14 +
        **net** (pandapipesNet) - Variable that contains a pandapipes network.
15 +
16 +
     OUTPUT:
17 +
        **bgd** - Returns a pandas DataFrame containing distance to the closest ext_grid as x coordinate and pressure level as y coordinate for each junction.
18 +
19 +
     EXAMPLE:
20 +
        import pandapipes.networks as nw
21 +
        import pandapipes.plotting as plotting
22 +
        import pandapipes as pp
23 +
24 +
        net = nw.schutterwald()
25 +
        pp.pipeflow(net)
26 +
        bgd = plotting.pressure_profile_to_junction_geodata(net)
27 +
28 +
    """
29 +
    if not "res_junction" in net:
30 +
        raise ValueError("no results in this pandapipes network")
31 +
32 +
    dist = top.calc_minimum_distance_to_junctions(net, net.ext_grid.junction.values)
33 +
    junctions = net.junction.index.values
34 +
    return pd.DataFrame({"x": dist.loc[junctions].values,
35 +
                        "y": net.res_junction.p_bar.loc[junctions].values},
36 +
                       index=junctions)

@@ -56,7 +56,7 @@
Loading
56 56
57 57
        r = "Fluid %s (%s) with properties:" % (self.name, self.fluid_type)
58 58
        for key in self.all_properties.keys():
59 -
            r += "\n   - %s (%s)" %(key, self.all_properties[key].__class__.__name__[13:])
59 +
            r += "\n   - %s (%s)" % (key, self.all_properties[key].__class__.__name__[13:])
60 60
        return r
61 61
62 62
    def add_property(self, property_name, prop, overwrite=True, warn_on_duplicates=True):
@@ -74,7 +74,8 @@
Loading
74 74
        :type warn_on_duplicates: bool
75 75
76 76
        :Example:
77 -
            >>> fluid.add_property('water_density', pandapipes.FluidPropertyConstant(998.2061), overwrite=True, warn_on_duplicates=False)
77 +
            >>> fluid.add_property('water_density', pandapipes.FluidPropertyConstant(998.2061),
78 +
                                   overwrite=True, warn_on_duplicates=False)
78 79
79 80
        """
80 81
        if property_name in self.all_properties:
@@ -100,7 +101,7 @@
Loading
100 101
        if property_name not in self.all_properties:
101 102
            raise UserWarning("The property %s was not defined for the fluid %s"
102 103
                              % (property_name, self.name))
103 -
        return self.all_properties[property_name].get_property(*at_values)
104 +
        return self.all_properties[property_name].get_at_value(*at_values)
104 105
105 106
    def get_density(self, temperature):
106 107
        """
@@ -182,11 +183,11 @@
Loading
182 183
        """
183 184
        super().__init__()
184 185
185 -
    def get_property(self, *args):
186 +
    def get_at_value(self, *args):
186 187
        """
187 188
188 -
        :param arg:
189 -
        :type arg:
189 +
        :param args:
190 +
        :type args:
190 191
        :return:
191 192
        :rtype:
192 193
        """
@@ -216,10 +217,11 @@
Loading
216 217
        else:
217 218
            self.prop_getter = interp1d(x_values, y_values)
218 219
219 -
    def get_property(self, arg):
220 +
    def get_at_value(self, arg):
220 221
        """
221 222
222 -
        :param arg: Name of the property and one or more values (x-values) for which the y-values of the property are to be displayed
223 +
        :param arg: Name of the property and one or more values (x-values) for which the y-values \
224 +
            of the property are to be displayed
223 225
        :type arg: str, float or array
224 226
        :return: y-value/s
225 227
        :rtype: float, array
@@ -266,7 +268,7 @@
Loading
266 268
    Creates Property with a constant value.
267 269
    """
268 270
269 -
    def __init__(self, value):
271 +
    def __init__(self, value, warn_dependent_variables=False):
270 272
        """
271 273
272 274
        :param value:
@@ -274,27 +276,29 @@
Loading
274 276
        """
275 277
        super(FluidPropertyConstant, self).__init__()
276 278
        self.value = value
279 +
        self.warn_dependent_variables = warn_dependent_variables
277 280
278 -
    def get_property(self, *args):
281 +
    def get_at_value(self, *args):
279 282
        """
280 283
281 -
        :param arg: Name of the property
282 -
        :type arg: str
284 +
        :param args: Name of the property
285 +
        :type args: str
283 286
        :return: Value of the property
284 287
        :rtype: float
285 288
286 289
        :Example:
287 -
            >>> heat_capacity = get_fluid(net).get_property("heat_capacity")
290 +
            >>> heat_capacity = get_fluid(net).all_properties["heat_capacity"].get_at_value(293.15)
288 291
        """
289 292
        if len(args) > 1:
290 -
            raise(UserWarning('Please define either none or an array-like argument'))
293 +
            raise UserWarning('Please define either none or an array-like argument')
291 294
        elif len(args) == 1:
292 -
            logger.warning('One constant property has several input variables even though it is '
293 -
                           'independent of these')
295 +
            if self.warn_dependent_variables:
296 +
                logger.warning('Constant property received several input variables, although it is'
297 +
                               'independent of these')
294 298
            output = np.array([self.value]) * np.ones(len(args[0]))
295 299
        else:
296 300
            output = np.array([self.value])
297 -
        return  output
301 +
        return output
298 302
299 303
    @classmethod
300 304
    def from_path(cls, path):
@@ -312,6 +316,13 @@
Loading
312 316
        value = np.loadtxt(path).item()
313 317
        return cls(value)
314 318
319 +
    @classmethod
320 +
    def from_dict(cls, d):
321 +
        obj = super().from_dict(d)
322 +
        if "warn_dependent_variables" not in obj.__dict__.keys():
323 +
            obj.__dict__["warn_dependent_variables"] = False
324 +
        return obj
325 +
315 326
316 327
class FluidPropertyLinear(FluidProperty):
317 328
    """
@@ -331,16 +342,17 @@
Loading
331 342
        self.slope = slope
332 343
        self.offset = offset
333 344
334 -
    def get_property(self, arg):
345 +
    def get_at_value(self, arg):
335 346
        """
336 347
337 -
        :param arg: Name of the property and one or more values (x-values) for which the function of the property should be calculated
348 +
        :param arg: Name of the property and one or more values (x-values) for which the function \
349 +
            of the property should be calculated
338 350
        :type arg: str, float or array
339 351
        :return: y-value or function values
340 352
        :rtype: float, array
341 353
342 354
        :Example:
343 -
            >>> comp_fact = get_fluid(net).get_property("compressibility", p_bar)
355 +
            >>> comp_fact = get_fluid(net).all_properties["compressibility"].get_at_value(p_bar)
344 356
345 357
        """
346 358
        if isinstance(arg, pd.Series):
@@ -356,8 +368,6 @@
Loading
356 368
357 369
        :param path:
358 370
        :type path:
359 -
        :param method:
360 -
        :type method:
361 371
        :return:
362 372
        :rtype:
363 373
        """
@@ -484,6 +494,7 @@
Loading
484 494
                     heat_capacity=heat_capacity, molar_mass=molar_mass, compressibility=compr,
485 495
                     der_compressibility=der_compr)
486 496
497 +
487 498
def get_fluid(net):
488 499
    """
489 500
    This function shows which fluid is used in the net.
@@ -494,7 +505,7 @@
Loading
494 505
    :rtype: Fluid
495 506
    """
496 507
    if "fluid" not in net or net["fluid"] is None:
497 -
        raise UserWarning("There is no fluid defined for the given net!")
508 +
        raise AttributeError("There is no fluid defined for the given net!")
498 509
    fluid = net["fluid"]
499 510
    if not isinstance(fluid, Fluid):
500 511
        logger.warning("The fluid in this net is not of the pandapipes Fluid type. This could lead"
@@ -526,6 +537,6 @@
Loading
526 537
    if isinstance(fluid, str):
527 538
        logger.warning("Instead of a pandapipes.Fluid, a string ('%s') was passed to the fluid "
528 539
                       "argument. Internally, it will be passed to call_lib(fluid) to get the "
529 -
                       "respective pandapipes.Fluid." %fluid)
540 +
                       "respective pandapipes.Fluid." % fluid)
530 541
        fluid = call_lib(fluid)
531 542
    net["fluid"] = fluid

@@ -10,7 +10,7 @@
Loading
10 10
from pandapipes.multinet.create_multinet import MultiNet, create_empty_multinet
11 11
from pandapipes.component_models.abstract_models import Component
12 12
from pandapipes.create import create_empty_network
13 -
from pandapipes.pandapipes_net import pandapipesNet
13 +
from pandapipes.pandapipes_net import pandapipesNet, get_basic_net_entries
14 14
from pandapower.io_utils import pp_hook
15 15
from pandapower.io_utils import with_signature, to_serializable, JSONSerializableClass, \
16 16
    isinstance_partial as ppow_isinstance, FromSerializableRegistry, PPJSONDecoder
@@ -61,7 +61,7 @@
Loading
61 61
            from pandapipes import from_json_string
62 62
            return from_json_string(self.obj)
63 63
        else:
64 -
            net = create_empty_network()
64 +
            net = pandapipesNet(get_basic_net_entries())
65 65
            net.update(self.obj)
66 66
            return net
67 67

@@ -8,6 +8,7 @@
Loading
8 8
from pandapipes.plotting.geo import *
9 9
from pandapower.plotting.collections import add_collections_to_axes, add_cmap_to_collection, \
10 10
    add_single_collection
11 +
from pandapipes.plotting.pipeflow_results import *
11 12
12 13
import types
13 14
from matplotlib.backend_bases import GraphicsContextBase, RendererBase

@@ -58,16 +58,17 @@
Loading
58 58
59 59
def add_nets_to_multinet(multinet, overwrite=False, **networks):
60 60
    """
61 -
    Add multiple nets to a multinet. 'networks' has to be a dictionary.
61 +
    Add multiple nets to a multinet. 'networks' is one or more keyword arguments with nets.
62 62
63 63
    :param multinet: multinet to which several pandapipes/pandapower nets are added
64 64
    :type multinet: pandapipes.MultiNet
65 65
    :param overwrite: whether a net should be overwritten if it has the same net_name
66 66
    :type overwrite: bool
67 -
    :param networks: a dictionary with different pandapipes/pandapower nets as values. The keys
68 -
                     will be set in multinet.nets as net names for the different networks.
69 -
    :type networks: dict
70 -
    :return: net is added to multinet
67 +
    :param networks: one or more keyword arguments with pandapipes/pandapower nets as values. 
68 +
                     The keyword of each net will be set in multinet.nets as the name for the
69 +
                     network in the respective argument.
70 +
    :type networks: kwarg (name=net)
71 +
    :return: nets are added to multinet
71 72
    :rtype: None
72 73
    """
73 74
    for name, net in networks.items():

@@ -140,7 +140,8 @@
Loading
140 140
141 141
        height_difference = node_pit[from_nodes, HEIGHT] - node_pit[to_nodes, HEIGHT]
142 142
        dummy = length != 0
143 -
        lambda_pipe, re = calc_lambda(v_init, eta, rho, d, k, gas_mode, friction_model, dummy)
143 +
        lambda_pipe, re = calc_lambda(v_init, eta, rho, d, k, gas_mode, friction_model, dummy,
144 +
                                      options)
144 145
        der_lambda_pipe = calc_der_lambda(v_init, eta, rho, d, k, friction_model, lambda_pipe)
145 146
        branch_component_pit[:, RE] = re
146 147
        branch_component_pit[:, LAMBDA] = lambda_pipe

@@ -5,6 +5,7 @@
Loading
5 5
from packaging import version
6 6
7 7
from pandapipes import __version__
8 +
from pandapipes.pandapipes_net import add_default_components
8 9
9 10
try:
10 11
    import pplog as logging
@@ -18,6 +19,7 @@
Loading
18 19
    """
19 20
    Converts old nets to new format to ensure consistency. The converted net is returned.
20 21
    """
22 +
    add_default_components(net, overwrite=False)
21 23
    if isinstance(net.version, str) and version.parse(net.version) >= version.parse(__version__):
22 24
        return net
23 25
    _rename_columns(net)

@@ -25,7 +25,7 @@
Loading
25 25
                   "tol_T": 1e-3, "tol_res": 1e-3, "iter": 10, "error_flag": False, "alpha": 1,
26 26
                   "nonlinear_method": "constant", "p_scale": 1, "mode": "hydraulics",
27 27
                   "ambient_temperature": 293, "check_connectivity": True,
28 -
                   "only_update_hydraulic_matrix": False,
28 +
                   "max_iter_colebrook": 100, "only_update_hydraulic_matrix": False,
29 29
                   "reuse_internal_data": False,
30 30
                   "quit_on_inconsistency_connectivity": False}
31 31

@@ -6,7 +6,7 @@
Loading
6 6
import numpy as np
7 7
8 8
9 -
def calc_lambda(v, eta, rho, d, k, gas_mode, friction_model, dummy):
9 +
def calc_lambda(v, eta, rho, d, k, gas_mode, friction_model, dummy, options):
10 10
    """
11 11
    Function calculates the friction factor of a pipe. Turbulence is calculated based on
12 12
    Nikuradse. If v equals 0, a value of 0.001 is used in order to avoid division by zero.
@@ -28,6 +28,8 @@
Loading
28 28
    :type friction_model:
29 29
    :param dummy:
30 30
    :type dummy:
31 +
    :param options:
32 +
    :type options:
31 33
    :return:
32 34
    :rtype:
33 35
    """
@@ -43,7 +45,15 @@
Loading
43 45
        lambda_nikuradse = 1 / (-2 * np.log10(k / (3.71 * d))) ** 2
44 46
45 47
    if friction_model == "colebrook":
46 -
        lambda_colebrook = colebrook(re, d, k, lambda_nikuradse, dummy)
48 +
        # TODO: move this import to top level if possible
49 +
        from pandapipes.pipeflow import PipeflowNotConverged
50 +
        max_iter = options.get("max_iter_colebrook", 100)
51 +
        converged, lambda_colebrook = colebrook(re, d, k, lambda_nikuradse, dummy, max_iter)
52 +
        if not converged:
53 +
            raise PipeflowNotConverged(
54 +
                "The Colebrook-White algorithm did not converge. There might be model "
55 +
                "inconsistencies. The maximum iterations can be given as 'max_iter_colebrook' "
56 +
                "argument to the pipeflow.")
47 57
        return lambda_colebrook, re
48 58
    elif friction_model == "swamee-jain":
49 59
        lambda_swamee_jain = 0.25 / ((np.log10(k/(3.7*d) + 5.74/(re**0.9)))**2)
@@ -103,7 +113,7 @@
Loading
103 113
        return lambda_laminar_der
104 114
105 115
106 -
def colebrook(re, d, k, lambda_nikuradse, dummy):
116 +
def colebrook(re, d, k, lambda_nikuradse, dummy, max_iter):
107 117
    """
108 118
109 119
    :param re:
@@ -116,6 +126,8 @@
Loading
116 126
    :type lambda_nikuradse:
117 127
    :param dummy:
118 128
    :type dummy:
129 +
    :param max_iter:
130 +
    :type max_iter:
119 131
    :return: lambda_cb
120 132
    :rtype:
121 133
    """
@@ -125,7 +137,7 @@
Loading
125 137
    niter = 0
126 138
127 139
    # Inner Newton-loop for calculation of lambda
128 -
    while not converged:
140 +
    while not converged and niter < max_iter:
129 141
        f = lambda_cb ** (-1 / 2) + 2 * np.log10(2.51 / (re * np.sqrt(lambda_cb)) + k / (3.71 * d))
130 142
131 143
        df_dlambda_cb = (-1 / 2 * lambda_cb ** (-3 / 2)) - (2.51 / re) * lambda_cb ** (-3 / 2) \
@@ -144,4 +156,4 @@
Loading
144 156
145 157
        niter += 1
146 158
147 -
    return lambda_cb
159 +
    return converged, lambda_cb

@@ -22,17 +22,25 @@
Loading
22 22
23 23
    """
24 24
25 -
    def __init__(self, name, type):
25 +
    def __init__(self, name, component):
26 26
        """
27 27
28 28
        :param name: name of the standard type object
29 29
        :type name: str
30 -
        :param type: the specific standard type
31 -
        :type type: str
30 +
        :param component: the specific standard type
31 +
        :type component: str
32 32
        """
33 33
        super(StdType, self).__init__()
34 34
        self.name = name
35 -
        self.type = type
35 +
        self.component = component
36 +
37 +
    @classmethod
38 +
    def from_dict(cls, d):
39 +
        obj = super().from_dict(d)
40 +
        if hasattr(obj, "type") and not hasattr(obj, "component"):
41 +
            setattr(obj, "component", getattr(obj, "type"))
42 +
            delattr(obj, "type")
43 +
        return obj
36 44
37 45
38 46
class PumpStdType(StdType):

@@ -3,4 +3,5 @@
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
from pandapipes.topology.create_graph import *
6 -
from pandapower.topology.graph_searches import connected_component, connected_components
Files Coverage
pandapipes 91.34%
setup.py 0.00%
Project Totals (75 files) 91.01%

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